本文整理汇总了Java中com.meterware.servletunit.ServletRunner类的典型用法代码示例。如果您正苦于以下问题:Java ServletRunner类的具体用法?Java ServletRunner怎么用?Java ServletRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServletRunner类属于com.meterware.servletunit包,在下文中一共展示了ServletRunner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: testCreateNewResourceInstance
import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
/**
* Test of createNewResource method, of class ResourceFactory.
*/
public void testCreateNewResourceInstance() throws IOException, SAXException {
System.out.println("createNewResourceInstance");
//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 );
HttpServletRequest request = ic.getRequest();
HttpServletResponse response = ic.getResponse();
ProxymaResourceFactory factory = new ProxymaResourceFactory();
ProxymaResource instance = factory.createNewResource(request, response, context);
//Test resource creation
assertNotNull(instance);
assertSame(context, instance.getContext());
assertTrue(instance.getRequest() instanceof ProxymaServletRequest);
assertTrue(instance.getResponse() instanceof ProxymaServletResponse);
//Cleanup the pool
try {
proxyma.destroyContext(context);
} catch (Exception x) {
fail("Unable to unregister the context");
}
}
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:35,代码来源:ProxymaResourceFactoryTest.java
示例17: testGetContextRequestResponse
import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
/**
* Test of get Context/Request/Response method, of class ProxymaResource.
*/
public void testGetContextRequestResponse() throws IOException, SAXException {
System.out.println("getContext");
//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 );
HttpServletRequest request = ic.getRequest();
HttpServletResponse response = ic.getResponse();
ProxymaServletRequest proxumaReq = new ProxymaServletRequest(request, context);
ProxymaServletResponse proxymaRes = new ProxymaServletResponse(response, context);
ProxymaResource instance = new ProxymaResource(proxumaReq, proxymaRes, context);
assertSame(context, instance.getContext());
assertSame(proxumaReq, instance.getRequest());
assertSame(proxymaRes, instance.getResponse());
//Cleanup the pool
try {
proxyma.destroyContext(context);
} catch (Exception x) {
fail("Unable to unregister the context");
}
}
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:35,代码来源:ProxymaResourceTest.java
示例18: testDoProxy
import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
/**
* Test of doProxy method, of class ProxyEngine.
*/
public void testDoProxy() throws IOException, SAXException, IllegalAccessException, Exception {
System.out.println("doProxy");
//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();
System.out.println(" --->test contextroot (expected redirect)");
WebRequest wreq = new GetMethodWebRequest( "http://localhost:0/myServlet");
WebResponse wres = sc.getResponse( wreq );
InvocationContext ic = sc.newInvocation( wreq );
HttpServletRequest request = ic.getRequest();
HttpServletResponse response = ic.getResponse();
ProxymaResource aResource = proxyma.createNewResource(request, response, context);
ProxyEngine instance = proxyma.createNewProxyEngine(context);
ProxyFolderBean folder = proxyma.createNewProxyFolder("google", "http://www.google.com", context);
folder = proxyma.createNewProxyFolder("apple", "http://www.apple.com", context);
folder.setEnabled(false);
int retval = instance.doProxy(aResource);
assertEquals(302, retval);
assertEquals(context.getProxymaVersion(), aResource.getResponse().getResponseData().getHeader("Server").getValue());
//Cleanup the pool
try {
proxyma.removeProxyFolder(proxyma.getProxyFolderByURLEncodedName("google", context), context);
proxyma.removeProxyFolder(proxyma.getProxyFolderByURLEncodedName("apple", context), context);
proxyma.destroyContext(context);
} catch (Exception x) {
fail("Unable to unregister the context");
}
}
开发者ID:dpoldrugo,项目名称:proxyma,代码行数:41,代码来源:ProxyEngineTest.java
示例19: testInit
import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
/**
*
* @throws IOException
* @throws ServletException
*/
@Test
public void testInit() throws IOException, ServletException {
ServletRunner sr = new ServletRunner();
sr.registerServlet("Uploader", "Uploader");
ServletUnitClient sc = sr.newClient();
PostMethodWebRequest postRequest = new PostMethodWebRequest("http://zoeey.org/", true);
postRequest.selectFile("bugFile", new File(TestUtil.getBugPng()));
postRequest.setParameter("name", "MoXie");
postRequest.setParameter("email", "[email protected]");
postRequest.setParameter("multiLine", "1\n2\n3\n");
InvocationContext ic = sc.newInvocation(postRequest);
UploadConfig config = new UploadConfig();
config.setFilesizeMax(888);
Uploader up = new Uploader(ic.getRequest(), config);
assertEquals("MoXie", up.getParamenter("name"));
assertEquals("[email protected]", up.getParamenter("email"));
/**
* 多行httpunit bug!?
*/
assertEquals(JsonHelper.encode("1\r\n2\r\n3\r\n"), JsonHelper.encode(up.getParamenter("multiLine")));
FileItem fileItem = up.getFileItem("bugFile");
assertEquals(FileError.OK, fileItem.getError());
assertEquals("bugFile", fileItem.getFieldName());
assertEquals("bug.png", fileItem.getOriginalName());
assertEquals(774, fileItem.getSize());
assertTrue(fileItem.getTempFile().isFile());
assertEquals(774, fileItem.getTempFile().length());
assertEquals("image/png", fileItem.getType());
}
开发者ID:eixom,项目名称:zoeey,代码行数:37,代码来源:UploaderTest.java
示例20: testCreate
import com.meterware.servletunit.ServletRunner; //导入依赖的package包/类
/**
* Test of create method, of class PostTicket.
*/
@Test
public void testCreate() {
System.out.println("create");
ServletRunner sr = new ServletRunner();
sr.registerServlet("Uploader", "Uploader");
ServletUnitClient sc = sr.newClient();
/**
* 创建ticket -> 放入表单中 -> 提交后检验
*/
/**
* 第一次提交验证成功
*/
String ticket = PostTicket.create("tokenKey", sc.getSession(true));
Boolean isVali = PostTicket.vali(ticket, "tokenKey", sc.getSession(true));
assertTrue(isVali);
/**
* 未获取新的ticket,第二次提交验证失败
*/
isVali = PostTicket.vali(ticket, "tokenKey", sc.getSession(true));
assertFalse(isVali);
/**
* ticket是模拟出来的,验证失败
*/
ticket = PostTicket.create("tokenKey", sc.getSession(true));
ticket += "abc";
isVali = PostTicket.vali(ticket, "tokenKey", sc.getSession(true));
assertFalse(isVali);
}
开发者ID:eixom,项目名称:zoeey,代码行数:32,代码来源:PostTicketTest.java
注:本文中的com.meterware.servletunit.ServletRunner类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论