本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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");
}
示例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");
}
示例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\"]|");
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}