/** * 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 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; }
m_runner = new ServletRunner(file); m_client = m_runner.newClient(); m_client.getClientProperties().setUserAgent(m_userAgent); m_runner.shutDown();
/** * Default constructor, which defines no servlets. */ public ServletRunner() { _application = new WebApplication(); completeInitialization( null ); }
/** * Constructs a servlet invocation context for a specified servlet container, * request, and cookie headers. **/ InvocationContextImpl( ServletUnitClient client, ServletRunner runner, FrameSelector frame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { _client = client; _application = runner.getApplication(); _frame = frame; URL requestURL = request.getURL(); final ServletUnitHttpRequest suhr = new ServletUnitHttpRequest( _application.getServletRequest( requestURL ), request, runner.getContext(), clientHeaders, messageBody ); if (_application.usesBasicAuthentication()) suhr.readBasicAuthentication(); else if (_application.usesFormAuthentication()) suhr.readFormAuthentication(); HttpSession session = suhr.getSession( /* create */ false ); if (session != null) ((ServletUnitHttpSession) session).access(); _effectiveURL = computeEffectiveUrl( suhr, requestURL ); _contextStack.push( new ExecutionContext( suhr, new ServletUnitHttpResponse(), _application.getServletRequest( _effectiveURL ) ) ); }
/** * Returns the response from the specified servlet using GET. * @exception SAXException thrown if there is an error parsing the response **/ public WebResponse getResponse( String url ) throws MalformedURLException, IOException, SAXException { return getClient().getResponse( url ); }
public void setUp() throws Exception { super.setUp(); HttpUnitOptions.setExceptionsThrownOnErrorStatus(true); sr = new ServletRunner( getResourceAsStream(getConfiguration()) ); }
/** * Sets a application context parameter. * @param name - the name of the parameter to set * @param value - the value of the parameter to set * @deprecated - test case for this function deactivated wf 2007-12-30 */ public void setContextParameter(String name, Object value){ getApplication().getServletContext().setAttribute(name, value); }
private ServletUnitClient getClient() { if (_client == null) _client = newClient(); return _client; }
public ServletTestContainer() { servletRunner = new PatchedServletRunner(); servletRunner.registerServlet("/noop/*", NoopServlet.class.getName()); init(servletRunner); client = servletRunner.newClient(); }
/** * Default constructor, which defines no servlets. */ public ServletRunner() { _application = new WebApplication(); completeInitialization( null ); }
/** * Constructs a servlet invocation context for a specified servlet container, * request, and cookie headers. **/ InvocationContextImpl( ServletUnitClient client, ServletRunner runner, FrameSelector frame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { _client = client; _application = runner.getApplication(); _frame = frame; URL requestURL = request.getURL(); final ServletUnitHttpRequest suhr = new ServletUnitHttpRequest( _application.getServletRequest( requestURL ), request, runner.getContext(), clientHeaders, messageBody ); if (_application.usesBasicAuthentication()) suhr.readBasicAuthentication(); else if (_application.usesFormAuthentication()) suhr.readFormAuthentication(); HttpSession session = suhr.getSession( /* create */ false ); if (session != null) ((ServletUnitHttpSession) session).access(); _effectiveURL = computeEffectiveUrl( suhr, requestURL ); _contextStack.push( new ExecutionContext( suhr, new ServletUnitHttpResponse(), _application.getServletRequest( _effectiveURL ) ) ); }
/** * Returns the response from the specified servlet using GET. * @exception SAXException thrown if there is an error parsing the response **/ public WebResponse getResponse( String url ) throws MalformedURLException, IOException, SAXException { return getClient().getResponse( url ); }
/** * Sets a application context parameter. * @param name - the name of the parameter to set * @param value - the value of the parameter to set * @deprecated - test case for this function deactivated wf 2007-12-30 */ public void setContextParameter(String name, Object value){ getApplication().getServletContext().setAttribute(name, value); }
@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); }
protected ServletUnitClient newClient() { return sr.newClient(); }
/** * Default constructor, which defines no servlets. */ public ServletRunner() { _application = new WebApplication(); completeInitialization( null ); }
/** * Constructs a servlet invocation context for a specified servlet container, * request, and cookie headers. **/ InvocationContextImpl( ServletUnitClient client, ServletRunner runner, FrameSelector frame, WebRequest request, Dictionary clientHeaders, byte[] messageBody ) throws IOException, MalformedURLException { _client = client; _application = runner.getApplication(); _frame = frame; URL requestURL = request.getURL(); final ServletUnitHttpRequest suhr = new ServletUnitHttpRequest( _application.getServletRequest( requestURL ), request, runner.getContext(), clientHeaders, messageBody ); if (_application.usesBasicAuthentication()) suhr.readBasicAuthentication(); else if (_application.usesFormAuthentication()) suhr.readFormAuthentication(); HttpSession session = suhr.getSession( /* create */ false ); if (session != null) ((ServletUnitHttpSession) session).access(); _effectiveURL = computeEffectiveUrl( suhr, requestURL ); _contextStack.push( new ExecutionContext( suhr, new ServletUnitHttpResponse(), _application.getServletRequest( _effectiveURL ) ) ); }
/** * Returns the session to be used by the next request. * @param create if true, will create a new session if no valid session is defined. * @since 1.6 */ public HttpSession getSession( boolean create ) { return getClient().getSession( create ); }