当前位置: 首页>>代码示例>>Java>>正文


Java ServletRunner类代码示例

本文整理汇总了Java中com.meterware.servletunit.ServletRunner的典型用法代码示例。如果您正苦于以下问题:Java ServletRunner类的具体用法?Java ServletRunner怎么用?Java ServletRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ServletRunner类属于com.meterware.servletunit包,在下文中一共展示了ServletRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    //Prepare the environment..
    ProxymaFacade proxyma = new ProxymaFacade();
    ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
    ServletRunner sr = new ServletRunner();
    sr.registerServlet( "myServlet", TestServlet.class.getName() );
    ServletUnitClient sc = sr.newClient();
    WebRequest wreq   = new GetMethodWebRequest( "http://test.meterware.com/myServlet?a=1&b=2" );
    wreq.setParameter( "color", "red" );
    WebResponse wres = sc.getResponse( wreq );
    InvocationContext ic = sc.newInvocation( wreq );
    request = ic.getRequest();
    response = ic.getResponse();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:18,代码来源:CookieRewriteEngineTest.java

示例2: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    //Prepare the environment..
    ProxymaFacade proxyma = new ProxymaFacade();
    ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
    ServletRunner sr = new ServletRunner();
    sr.registerServlet( "myServlet", TestServlet.class.getName() );
    ServletUnitClient sc = sr.newClient();
    WebRequest wreq   = new GetMethodWebRequest( "http://test.meterware.com/myServlet?a=1&b=2" );
    wreq.setParameter( "color", "red" );
    WebResponse wres = sc.getResponse( wreq );
    InvocationContext ic = sc.newInvocation( wreq );
    request = ic.getRequest();
    response = ic.getResponse();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:17,代码来源:ProxymaServletResponseTest.java

示例3: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
     //Prepare the environment..
    ProxymaFacade proxyma = new ProxymaFacade();
    ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
    ServletRunner sr = new ServletRunner();
    sr.registerServlet( "myServlet", TestServlet.class.getName() );
    ServletUnitClient sc = sr.newClient();
    WebRequest wreq   = new GetMethodWebRequest( "http://test.meterware.com/myServlet?a=1&b=2" );
    wreq.setParameter( "color", "red" );
    WebResponse wres = sc.getResponse( wreq );
    InvocationContext ic = sc.newInvocation( wreq );
    request = ic.getRequest();
    response = ic.getResponse();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:17,代码来源:ProxymaServletRequestTest.java

示例4: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    //Prepare the environment..
    ProxymaFacade proxyma = new ProxymaFacade();
    ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
    ServletRunner sr = new ServletRunner();
    sr.registerServlet( "myServlet", TestServlet.class.getName() );
    ServletUnitClient sc = sr.newClient();
    WebRequest wreq   = new GetMethodWebRequest( "http://test.meterware.com/myServlet" );
    wreq.setParameter( "color", "red" );
    WebResponse wres = sc.getResponse( wreq );
    InvocationContext ic = sc.newInvocation( wreq );
    request = ic.getRequest();
    response = ic.getResponse();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:18,代码来源:SimpleHttpRetriverTest.java

示例5: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    //Prepare the environment..
    ProxymaFacade proxyma = new ProxymaFacade();
    ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
    ServletRunner sr = new ServletRunner();
    sr.registerServlet( "myServlet/library.js", TestServlet.class.getName() );
    ServletUnitClient sc = sr.newClient();
    WebRequest wreq   = new GetMethodWebRequest( "http://test.meterware.com/myServlet/library.js" );
    wreq.setParameter( "color", "red" );
    WebResponse wres = sc.getResponse( wreq );
    InvocationContext ic = sc.newInvocation( wreq );
    request = ic.getRequest();
    response = ic.getResponse();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:18,代码来源:JSRewriteTransformerTest.java

示例6: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    //Prepare the environment..
    ProxymaFacade proxyma = new ProxymaFacade();
    ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
    ServletRunner sr = new ServletRunner();
    sr.registerServlet( "myServlet", TestServlet.class.getName() );
    ServletUnitClient sc = sr.newClient();
    WebRequest wreq   = new GetMethodWebRequest( "http://test.meterware.com/myServlet?a=1&b=2" );
    wreq.setParameter( "color", "red" );
    wreq.setHeaderField("Cookie", "rewritten=value1");
    WebResponse wres = sc.getResponse( wreq );
    InvocationContext ic = sc.newInvocation( wreq );
    request = ic.getRequest();
    response = ic.getResponse();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:19,代码来源:HttpRedirectsRewriteTransformerTest.java

示例7: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    //Prepare the environment..
    ProxymaFacade proxyma = new ProxymaFacade();
    ProxymaContext context = proxyma.createNewContext("default", "/", "src/test/resources/test-config.xml", "/tmp/");
    ServletRunner sr = new ServletRunner();
    sr.registerServlet( "myServlet/style.css", TestServlet.class.getName() );
    ServletUnitClient sc = sr.newClient();
    WebRequest wreq   = new GetMethodWebRequest( "http://test.meterware.com/myServlet/style.css" );
    wreq.setParameter( "color", "red" );
    WebResponse wres = sc.getResponse( wreq );
    InvocationContext ic = sc.newInvocation( wreq );
    request = ic.getRequest();
    response = ic.getResponse();
}
 
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:18,代码来源:CharsetInspectorTransformerTest.java

示例8: setup

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
/**
 * Sets up the GAE simulation.
 */
public synchronized void setup() {
    System.out.println("Setting up GAE simulation");

    LocalTaskQueueTestConfig localTasks = new LocalTaskQueueTestConfig();
    localTasks.setQueueXmlPath(QUEUE_XML_PATH);

    LocalUserServiceTestConfig localUserServices = new LocalUserServiceTestConfig();
    LocalDatastoreServiceTestConfig localDatastore = new LocalDatastoreServiceTestConfig();
    LocalMailServiceTestConfig localMail = new LocalMailServiceTestConfig();
    LocalSearchServiceTestConfig localSearch = new LocalSearchServiceTestConfig();
    localSearch.setPersistent(false);
    LocalModulesServiceTestConfig localModules = new LocalModulesServiceTestConfig();
    LocalLogServiceTestConfig localLog = new LocalLogServiceTestConfig();
    helper = new LocalServiceTestHelper(localDatastore, localMail, localUserServices,
                                        localTasks, localSearch, localModules, localLog);
    helper.setUp();

    sc = new ServletRunner().newClient();
    localLogService = LocalLogServiceTestConfig.getLocalLogService();
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:24,代码来源:GaeSimulation.java

示例9: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
/**
 * @see junit.framework.TestCase#setUp()
 */
@Before
public void setUp() throws Exception
{
    // need to pass a web.xml file to setup servletunit working directory
    ClassLoader classLoader = getClass().getClassLoader();
    URL webXmlUrl = classLoader.getResource("WEB-INF/web.xml");
    String path = URLDecoder.decode(webXmlUrl.getFile(), "UTF-8");

    HttpUnitOptions.setDefaultCharacterSet("utf-8");
    System.setProperty("file.encoding", "utf-8");

    // start servletRunner
    runner = new ServletRunner(new File(path), CONTEXT);

    Hashtable<String, String> params = new Hashtable<String, String>();
    params.put("javaEncoding", "utf-8");
    runner.registerServlet("*.jsp", "org.apache.jasper.servlet.JspServlet", params);

    log.debug("ServletRunner setup OK");

}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:25,代码来源:DisplaytagCase.java

示例10: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
/**
 * @see junit.framework.TestCase#setUp()
 * @throws Exception e
 */
@Before
public void setUp() throws Exception
{
    // need to pass a web.xml file to setup servletunit working directory
    Properties p = new Properties();
    p.setProperty("export.pdf.class", "org.displaytag.export.FopExportView");
    TableProperties.setUserProperties(p);

    ClassLoader classLoader = getClass().getClassLoader();
    URL webXmlUrl = classLoader.getResource("WEB-INF/web.xml");
    String path = URLDecoder.decode(webXmlUrl.getFile(), "UTF-8");

    HttpUnitOptions.setDefaultCharacterSet("utf-8");
    System.setProperty("file.encoding", "utf-8");

    // start servletRunner
    runner = new ServletRunner(new File(path), CONTEXT);

    Hashtable<String, String> params = new Hashtable<String, String>();
    params.put("javaEncoding", "utf-8");
    runner.registerServlet("*.jsp", "org.apache.jasper.servlet.JspServlet", params);

    log.debug("ServletRunner setup OK");

}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:30,代码来源:ExportExcelTest.java

示例11: testLog

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
/**
 * Test of log method, of class FireJavaSimple.
 * @throws IOException
 */
@Test
public void testLog() throws IOException {
    System.out.println("log");
    ServletRunner sr = new ServletRunner();
    sr.registerServlet("FireJavaSimple", "FireJavaSimple");
    ServletUnitClient sc = sr.newClient();
    PostMethodWebRequest postRequest = new PostMethodWebRequest("http://zoeey.org/", true);
    postRequest.setParameter("name", "MoXie");
    postRequest.setParameter("email", "[email protected]");
    InvocationContext ic = sc.newInvocation(postRequest);
    HttpServletResponse response = ic.getResponse();
    FireJavaSimple.log(response, "LOG MESSAGE");
    FireJavaSimple.info(response, "INFO MESSAGE");
    FireJavaSimple.warn(response, "WARN MESSAGE");
    FireJavaSimple.error(response, "ERROR MESSAGE");
    WebResponse wresponse = ic.getServletResponse();
    assertEquals(wresponse.getHeaderField("X-WF-1-INDEX"), "4");
    assertEquals(wresponse.getHeaderField("X-WF-1-1-1-1"), "30|[{\"Type\":\"LOG\"},\"LOG MESSAGE\"]|");
    assertEquals(wresponse.getHeaderField("X-WF-1-1-1-2"), "32|[{\"Type\":\"INFO\"},\"INFO MESSAGE\"]|");
    assertEquals(wresponse.getHeaderField("X-WF-1-1-1-3"), "32|[{\"Type\":\"WARN\"},\"WARN MESSAGE\"]|");
    assertEquals(wresponse.getHeaderField("X-WF-1-1-1-4"), "34|[{\"Type\":\"ERROR\"},\"ERROR MESSAGE\"]|");
}
 
开发者ID:eixom,项目名称:zoeey,代码行数:27,代码来源:FireJavaSimpleTest.java

示例12: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    String configuration = getConfiguration();
    InputStream is = this.getClass().getResourceAsStream(configuration);
    sr = new ServletRunner(is, CONTEXT);

    HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:9,代码来源:ServletUnitTest.java

示例13: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    InputStream is = this.getClass().getResourceAsStream(getConfiguration());
    assertNotNull("The configuration input stream should not be null", is);
    sr = new ServletRunner(is, CONTEXT);
    
    HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
    if (startCamelContext) {        
        super.setUp();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:ServletCamelRouterTestSupport.java

示例14: setUp

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    InputStream is =  this.getClass().getResourceAsStream(getConfiguration());
    assertNotNull("The configuration input stream should not be null", is);
    sr = new ServletRunner(is, CONTEXT);

    HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:ServletCamelTestSupport.java

示例15: prepareWebClient

import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
protected final void prepareWebClient(String xmlName, String contextPath) throws Exception {
    // Servlet container
    File webInf = new File(TestUtils.srcdir, "WEB-INF");
    File xml = new File(webInf, StringUtils.defaultIfEmpty(xmlName, "web.xml"));

    ServletRunner servletRunner = new PatchedServletRunner(xml, contextPath);

    // Servlet client
    client = servletRunner.newClient();
    client.setExceptionsThrownOnErrorStatus(false);
    client.getClientProperties().setAutoRedirect(false);

    // Ignore script error
    JavaScript.setThrowExceptionsOnError(false);
}
 
开发者ID:solmix,项目名称:wmix,代码行数:16,代码来源:AbstractTests.java


注:本文中的com.meterware.servletunit.ServletRunner类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。