public ServletTestContainer() { servletRunner = new PatchedServletRunner(); servletRunner.registerServlet("/noop/*", NoopServlet.class.getName()); init(servletRunner); client = servletRunner.newClient(); }
public ServletTestContainer() { servletRunner = new PatchedServletRunner(); servletRunner.registerServlet("/noop/*", NoopServlet.class.getName()); init(servletRunner); client = servletRunner.newClient(); }
private ServletUnitClient getClient() { if (_client == null) _client = newClient(); return _client; }
protected ServletUnitClient newClient() { return sr.newClient(); }
private ServletUnitClient getClient() { if (_client == null) _client = newClient(); return _client; }
private ServletUnitClient getClient() { if (_client == null) _client = newClient(); return _client; }
protected ServletUnitClient newClient() { return sr.newClient(); }
protected ServletUnitClient newClient() { return sr.newClient(); }
/** * Sets up the GAE simulation. */ public void setup() { synchronized (this) { 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.setEnvAttributes(getEnvironmentAttributesWithApplicationHostname()); helper.setUp(); sc = new ServletRunner().newClient(); } }
public void testDynamicReport() throws Exception { ServletRunner sr = new ServletRunner( getClass().getResourceAsStream("/struts2/web.xml") ); // (1) use the web.xml file to define mappings ServletUnitClient client = sr.newClient(); // (2) create a client to invoke the application WebResponse r = client.getResponse( "http://localhost/example/generateReport.action" ); // (3) invoke the servlet w/o authorization String fname=r.getHeaderField("CONTENT-DISPOSITION"); fname = fname.substring(fname.indexOf("=")+1); FileOutputStream fos = new FileOutputStream( new File(System.getProperty("user.dir")+ "/target/" + fname)); InputStream is = r.getInputStream(); StreamUtils.copy(is, fos); is.close(); fos.close(); }
public void testDynamicReportWithTemplate() throws Exception { ServletRunner sr = new ServletRunner( getClass().getResourceAsStream("/struts2/web.xml") ); // (1) use the web.xml file to define mappings ServletUnitClient client = sr.newClient(); // (2) create a client to invoke the application WebResponse r = client.getResponse( "http://localhost/generateReportTemplate.action" ); // (3) invoke the servlet w/o authorization String fname=r.getHeaderField("CONTENT-DISPOSITION"); fname = fname.substring(fname.indexOf("=")+1); FileOutputStream fos = new FileOutputStream( new File(System.getProperty("user.dir")+ "/target/" + fname)); InputStream is = r.getInputStream(); StreamUtils.copy(is, fos); is.close(); fos.close(); }
public void testDynamicReport() throws Exception { ServletRunner sr = new ServletRunner( getClass().getResourceAsStream("/webwork/web.xml") ); // (1) use the web.xml file to define mappings ServletUnitClient client = sr.newClient(); // (2) create a client to invoke the application WebResponse r = client.getResponse( "http://localhost/generateReport.action" ); // (3) invoke the servlet w/o authorization String fname=r.getHeaderField("CONTENT-DISPOSITION"); fname = fname.substring(fname.indexOf("=")+1); FileOutputStream fos = new FileOutputStream( new File(System.getProperty("user.dir")+ "/target/" + fname)); InputStream is = r.getInputStream(); StreamUtils.copy(is, fos); is.close(); fos.close(); }
public void testDynamicReportWithTemplate() throws Exception { ServletRunner sr = new ServletRunner( getClass().getResourceAsStream("/webwork/web.xml") ); // (1) use the web.xml file to define mappings ServletUnitClient client = sr.newClient(); // (2) create a client to invoke the application WebResponse r = client.getResponse( "http://localhost/generateReportTemplate.action" ); // (3) invoke the servlet w/o authorization String fname=r.getHeaderField("CONTENT-DISPOSITION"); fname = fname.substring(fname.indexOf("=")+1); FileOutputStream fos = new FileOutputStream( new File(System.getProperty("user.dir")+ "/target/" + fname)); InputStream is = r.getInputStream(); StreamUtils.copy(is, fos); is.close(); fos.close(); }
@Before public void setUp() throws Exception { InputStream configurationStream = getResourceAsStream(getConfiguration()); sr = new ServletRunner(configurationStream, CONTEXT); try { sr.newClient().getResponse(CONTEXT_URL + "/services"); } catch (HttpNotFoundException e) { // ignore, we just want to boot up the servlet } HttpUnitOptions.setExceptionsThrownOnErrorStatus(true); }
m_client = m_runner.newClient(); m_client.getClientProperties().setUserAgent(m_userAgent);
@Before public void setUp() throws Exception { InputStream configurationStream = getResourceAsStream(getConfiguration()); sr = new ServletRunner(configurationStream, CONTEXT); try { sr.newClient().getResponse(CONTEXT_URL + "/services"); } catch (HttpNotFoundException e) { // ignore, we just want to boot up the servlet } HttpUnitOptions.setExceptionsThrownOnErrorStatus(true); configurationStream.close(); } @After
@Test public void testInvoke() { try { sr = new ServletRunner(getResourceAsStream(getConfiguration()), CONTEXT); sr.newClient().getResponse(CONTEXT_URL + "/services"); // there expect a spring bean exception fail("we expect a spring bean Exception here"); } catch (Exception ex) { // supprot spring 2.0.x and sping 2.5 assertTrue("we expect a Bean Exception here", ex instanceof org.springframework.beans.FatalBeanException); } }