Package net.sourceforge.javautil.developer.web.unit.mockserver.http

Examples of net.sourceforge.javautil.developer.web.unit.mockserver.http.MockHttpServletContext


      String path = request.getUrl().getPath();
      WebApplicationDeploymentContext deployment = this.getContext(path);
      if (deployment == null)
        throw new MockBrowserException(request, "No context could be found to handle request", null);
     
      MockHttpServletContext ctx = (MockHttpServletContext) deployment.getServletContext();
      path = path.length() == ctx.getContextPath().length() ? "/" : path.substring(ctx.getContextPath().length());
      if (!path.startsWith("/")) path = "/" + path;
       
      Thread.currentThread().setContextClassLoader(ctx.getParentClassLoader());
     
      MockServletSetup servlet = ctx.findServlet(path);
      List<Filter> filters = ctx.getFilters(servlet, path);
     
      WebApplicationServletContext wrapper = new WebApplicationServletContext(ctx, ctx.application);
     
      MockHttpServletRequest httpRequest = new MockHttpServletRequest(wrapper, ctx.getSessionManager(), path);
      for (String name : request.getCookies().keySet()) {
        httpRequest.addCookie(request.getCookies().get(name));
      }
     
      if (request.getUrl().getQuery() != null) {
View Full Code Here


  }

  public List<HttpSession> getSessions(WebApplicationDeploymentContext ctx) {
    MockServletContext msc = (MockServletContext) ctx.getServletContext();
    if (msc instanceof MockHttpServletContext) {
      MockHttpServletContext mhc = (MockHttpServletContext) msc;
      List<HttpSession> sessions = new ArrayList<HttpSession>();
      for (String id : mhc.getSessionManager().findSessionIds()) {
        sessions.add( mhc.getSessionManager().getSession(id) );
      }
      return sessions;
    }
    return null;
  }
View Full Code Here

  public boolean deploy(WebApplication application) {
    if (this.deployed.containsKey(name))
      throw new WebServerException(server, "An application is already deployed by this name: " + name);
   
    try {
      MockHttpServletContext context = new MockHttpServletContext(this, application);
      WebApplicationDeploymentContext deployment = new WebApplicationDeploymentContext(this, application, context);
      application.preDeploySetup(deployment, false);
      context.initialize();
      this.deployed.put(application.getName(), deployment);
      server.getHandler().applicationDeployed(new WebServerApplicationEvent(server, this, application));
      return true;
    } catch (Exception e) {
      server.getHandler().applicationError(new WebServerApplicationErrorEvent(this, server, application, e, e.getMessage()));
View Full Code Here

TOP

Related Classes of net.sourceforge.javautil.developer.web.unit.mockserver.http.MockHttpServletContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.