Package org.jboss.seam.mock

Examples of org.jboss.seam.mock.MockHttpServletRequest


            return SEAM_ROLE.equals(role);
         }
        
      };
      session.setAttribute(Seam.getComponentName(Identity.class), identity);
      HttpServletRequest request = new MockHttpServletRequest(session, JAAS_USER, new HashSet<String>(Arrays.asList(JAAS_ROLE)), null, "GET");
      return new IdentityRequestWrapper(request);
   }
View Full Code Here


      assertEquals(expressions.createValueExpression(expr).getValue(), "bar");
   }
  
   protected FacesContext setupFacesContextToAccessRequestParams(Map<String, String> params)
   {
      MockHttpServletRequest request = new MockHttpServletRequest(new MockHttpSession());
      if (params != null)
      {
         for (Map.Entry<String, String> param : params.entrySet())
         {
            request.getParameterMap().put(param.getKey(), new String[] { param.getValue() });
         }
      }
      ExternalContext extContext = new MockExternalContext(request);
      Application application = new MockApplication();
      application.addELResolver(new ImplicitObjectELResolver());
View Full Code Here

      Contexts.getEventContext().remove(Component.getComponentName(TestActions.class));
   }

   private void simulatePostback(FacesContext facesContext)
   {
      MockHttpServletRequest request = (MockHttpServletRequest) facesContext.getExternalContext().getRequest();
      request.getParameters().put(ResponseStateManager.VIEW_STATE_PARAM, new String[] { "true" });
      assert facesContext.getRenderKit().getResponseStateManager().isPostback(facesContext) == true;
   }
View Full Code Here

    public void testMultipartRequest() throws IOException, ServletException
    {
        MultipartFilter filter = new MultipartFilter();
        ServletContext context = new MockServletContext();
        HttpSession session = new MockHttpSession(context);
        MockHttpServletRequest request = new MockHttpServletRequest(session, "Pete", new HashSet<String>(), new Cookie[0], "post")
        {
           
            private final InputStream is = Resources.getResourceAsStream("/META-INF/seam.properties", null);
           
            @Override
            public String getContentType()
            {
                return "multipart/test; boundary=foo";
            }
           
            @Override
            public ServletInputStream getInputStream() throws IOException
            {
                return new ServletInputStream() {

                    @Override
                    public int read() throws IOException
                    {
                        return is.read();
                    }
                   
                    @Override
                    public int read(byte[] b) throws IOException
                    {
                        return is.read(b);
                    }
                   
                };
            }
           
        };
        // Add some parameters to test passthrough
        String [] fooParams = {"bar"};
        request.getParameterMap().put("foo", fooParams);
        ServletResponse response = new MockHttpServletResponse();
        FilterChain chain = new FilterChain()
        {

            public void doFilter(ServletRequest request, ServletResponse response)
View Full Code Here

    @Test
    public void testContexts() {
        MockServletContext servletContext = new MockServletContext();
        ServletLifecycle.beginApplication(servletContext);
        MockHttpSession session = new MockHttpSession(servletContext);
        MockHttpServletRequest request = new MockHttpServletRequest(session);
        final ExternalContext externalContext = new MockExternalContext(
                servletContext, request);
        final Map sessionAdaptor = new ServletRequestSessionMap(request);
        Map requestAdaptor = new ServletRequestMap(request);
        Context appContext = new ApplicationContext(externalContext
View Full Code Here

   }

   private void init()
   {
      if (FacesContext.getCurrentInstance() != null) {
         request = new MockHttpServletRequest(HttpSessionManager.instance(), FacesContext.getCurrentInstance().getExternalContext())
      } else {
         request = new MockHttpServletRequest(HttpSessionManager.instance());
      }
      response = new MockHttpServletResponse();

      setContextClassLoader();
View Full Code Here

      this.viewId = viewId;
   }
  
   private void init()
   {
      request = new MockHttpServletRequest(HttpSessionManager.instance());
      response = new MockHttpServletResponse();
     
      // Generate the FacesContext from the JSF FacesContextFactory
      originalFacesContext = FacesContext.getCurrentInstance();
      facesContext = RendererFacesContextFactory.instance().getFacesContext(request, response);
View Full Code Here

   public void testContexts()
   {
      MockServletContext servletContext = new MockServletContext();
      ServletLifecycle.beginApplication(servletContext);
      MockHttpSession session = new MockHttpSession(servletContext);
      MockHttpServletRequest request = new MockHttpServletRequest(session);
      ExternalContext externalContext = new MockExternalContext(servletContext, request);
      Map sessionAdaptor = new ServletRequestSessionMap(request);
      Map requestAdaptor = new ServletRequestMap(request);
      Context appContext = new ApplicationContext( externalContext.getApplicationMap() );
      installComponent(appContext, ConversationEntries.class);
View Full Code Here

    public void testMultipartRequest() throws IOException, ServletException
    {
        MultipartFilter filter = new MultipartFilter();
        ServletContext context = new MockServletContext();
        HttpSession session = new MockHttpSession(context);
        MockHttpServletRequest request = new MockHttpServletRequest(session, "Pete", new HashSet<String>(), new Cookie[0], "post")
        {
           
            private final InputStream is = Resources.getResourceAsStream("/META-INF/seam.properties", null);
           
            @Override
            public String getContentType()
            {
                return "multipart/test; boundary=foo";
            }
           
            @Override
            public ServletInputStream getInputStream() throws IOException
            {
                return new ServletInputStream() {

                    @Override
                    public int read() throws IOException
                    {
                        return is.read();
                    }
                   
                    @Override
                    public int read(byte[] b) throws IOException
                    {
                        return is.read(b);
                    }
                   
                };
            }
           
        };
        // Add some parameters to test passthrough
        String [] fooParams = {"bar"};
        request.getParameterMap().put("foo", fooParams);
        ServletResponse response = new MockHttpServletResponse();
        FilterChain chain = new FilterChain()
        {

            public void doFilter(ServletRequest request, ServletResponse response)
View Full Code Here

   @Test
   public void testContexts()
   {
      MockServletContext servletContext = new MockServletContext();
      MockHttpSession session = new MockHttpSession(servletContext);
      MockHttpServletRequest request = new MockHttpServletRequest(session);
      ExternalContext externalContext = new MockExternalContext(servletContext, request);
      ContextAdaptor sessionAdaptor = new ServletSessionImpl(session);
      ContextAdaptor requestAdaptor = new ServletRequestImpl(request);
      Context appContext = new FacesApplicationContext(externalContext);
      appContext.set(
View Full Code Here

TOP

Related Classes of org.jboss.seam.mock.MockHttpServletRequest

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.