Package org.apache.shale.test.mock

Examples of org.apache.shale.test.mock.MockHttpServletResponse


     *
     * @throws IOException If something goes wrong.
     */
    public void testForceInclude() throws IOException {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new CommitSupportMockHttpServletResponse();
        MockServletTilesRequestContext context = new MockServletTilesRequestContext(
                applicationContext, request, response);
        context.dispatch(TEST_PATH);
        assertEquals("Forward has not been called", 1, context.getForwardCount());
        assertEquals("Include has been called", 0, context.getIncludeCount());
View Full Code Here


        config = new MockServletConfig(servletContext);
        session = new MockHttpSession();
        session.setServletContext(servletContext);
        request = new MockHttpServletRequest(session);
        request.setServletContext(servletContext);
        response = new MockHttpServletResponse();

        setupFactories();
       
        externalContext =
            new MockExternalContext(servletContext, request, response);
View Full Code Here

      super();
      this.data = data;
    }

    public void runTestCase(FacesContext context) throws Throwable {
      MockHttpServletResponse response = new MockHttpServletResponse() {
        /* (non-Javadoc)
         * @see org.apache.shale.test.mock.MockHttpServletResponse#addDateHeader(java.lang.String, long)
         * Default shale implementation is not thread-safe.
         */
        public void addDateHeader(String name, long value) {
          SimpleDateFormat format = new SimpleDateFormat(
              "EEE, dd MMM yyyy HH:mm:ss zzz");
          format.setTimeZone(TimeZone.getTimeZone("GMT"));
          addHeader(name, format.format(new Date(value)));
        }
       
        //TODO fix when setContentLength in shale-test will start function
        //     https://issues.apache.org/struts/browse/SHALE-495
        public int getContentLength() {
          return Integer.parseInt(getHeader("Content-Length"));
        }
       
        public void setContentLength(int length) {
          addIntHeader("Content-Length", length);
        }

      };
      MockHttpServletRequest req = new MockHttpServletRequest(session);
      req.setServletContext(servletContext);
      req.setPathElements(request.getContextPath(), request
          .getServletPath(), request.getPathInfo(), data);
      MockResourceRequest resourceRequest = new MockResourceRequest(req);
      service.serviceResource(key, resourceRequest, response);
      byte[] content = ((MockServletOutputStream) response
          .getOutputStream()).content();
      String strContent = new String(content);
      assertEquals(strContent, "test");

    }
View Full Code Here

  public void setUp() throws Exception {
    super.setUp();
 
    //TODO fix when setContentLength in shale-test will start function
    //     https://issues.apache.org/struts/browse/SHALE-495
    this.response = new MockHttpServletResponse() {
     
      public int getContentLength() {
        return Integer.parseInt(getHeader("Content-Length"));
      }
     
View Full Code Here

     */
    protected FacesContext createFacesContext() {
        MockHttpSession tsession = new MockHttpSession();
        MockHttpServletRequest trequest = new MockHttpServletRequest(tsession);
        trequest.setAttribute(AjaxContext.AJAX_CONTEXT_KEY, new AjaxContextImpl());
        MockHttpServletResponse tresponse = new MockHttpServletResponse();
        MockFacesContext tfacesContext = (MockFacesContext)
        facesContextFactory.getFacesContext(servletContext,
                                            trequest,
                                            tresponse,
                                            lifecycle);
View Full Code Here

        MockServletContext servletContext = new MockServletContext();
        servletContext
                .addInitParameter("initParameter1", "initParameterValue1");
        MockHttpSession session = new MockHttpSession(servletContext);
        MockHttpServletRequest request = new MockHttpServletRequest(session);
        MockHttpServletResponse response = new MockHttpServletResponse();
        request.addHeader("Content-Type", "text/html");
        request.addParameter("myParam", "value1");
        request.addParameter("myParam", "value2");

        context = new ServletTilesRequestContext(servletContext, request,
View Full Code Here

        initParams.put("initParameter1", "initParameterValue1");
        EasyMock.expect(applicationContext.getInitParams()).andReturn(
                initParams);
        MockHttpSession session = new MockHttpSession(servletContext);
        MockHttpServletRequest request = new MockHttpServletRequest(session);
        MockHttpServletResponse response = new MockHttpServletResponse();
        request.addHeader("Content-Type", "text/html");
        request.addParameter("myParam", "value1");
        request.addParameter("myParam", "value2");

        context = new ServletTilesRequestContext(applicationContext, request,
View Full Code Here

     *
     * @throws IOException If something goes wrong.
     */
    public void testForceInclude() throws IOException {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new CommitSupportMockHttpServletResponse();
        MockServletTilesRequestContext context = new MockServletTilesRequestContext(
                applicationContext, request, response);
        context.dispatch(TEST_PATH);
        assertEquals("Forward has not been called", 1, context.getForwardCount());
        assertEquals("Include has been called", 0, context.getIncludeCount());
View Full Code Here

     * exception.
     */
    public void testObjectAttribute() throws IOException {
        Attribute attribute = new Attribute();
        HttpServletRequest request = new MockHttpServletRequest();
        HttpServletResponse response = new MockHttpServletResponse();
        boolean exceptionFound = false;

        attribute.setValue(new Integer(SAMPLE_INT)); // A simple object
        try {
            container.render(attribute, null, request, response);
View Full Code Here

    config = new MockServletConfig(servletContext);
    session = request.getSession();// new MockHttpSession();
    // session.setServletContext(servletContext);
    this.request = request;// new MockHttpServletRequest(session);
    // request.setServletContext(servletContext);
    response = new MockHttpServletResponse();

    // Set up JSF API Objects
    FactoryFinder.releaseFactories();
    FactoryFinder
        .setFactory(FactoryFinder.APPLICATION_FACTORY, "org.apache.shale.test.mock.MockApplicationFactory");
View Full Code Here

TOP

Related Classes of org.apache.shale.test.mock.MockHttpServletResponse

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.