Package org.apache.shale.test.mock

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


    // Test a valid resource
    public void testValidResource() throws Exception {

        processor.process(facesContext, VALID_RESOURCE_ID);
        assertEquals("text/x-plain", response.getContentType());
        MockServletOutputStream stream =
          (MockServletOutputStream) response.getOutputStream();
        assertNotNull(stream);
        assertTrue(stream.size() > VALID_RESOURCE_CONTENT.length());
        byte content[] = stream.content();
        for (int i = 0; i < VALID_RESOURCE_CONTENT.length(); i++) {
            byte b = (byte) ((int) VALID_RESOURCE_CONTENT.charAt(i));
            assertEquals("Byte at position " + i, b, content[i]);
        }
       
View Full Code Here


          final MockFacesResourceContext resourceContext = new MockFacesResourceContext(facesContext);
          resourceContext.setResourceData(resourceData);

          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          response.setOutputStream(new MockServletOutputStream(baos));
         
          resource.sendHeaders(resourceContext);
          resource.send(resourceContext);
         
          return new WebResponseImpl(
View Full Code Here

          final MockFacesResourceContext resourceContext = new MockFacesResourceContext(facesContext);
          resourceContext.setResourceData(resourceData);

          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          response.setOutputStream(new MockServletOutputStream(baos));
         
          resource.sendHeaders(resourceContext);
          resource.send(resourceContext);
         
          return new WebResponseImpl(
View Full Code Here

    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    content.send(this.response);
    MockServletOutputStream mockStream = (MockServletOutputStream) response.getOutputStream();
    byte[] bs = mockStream.content();
    assertEquals("Test", new String(bs));
  }
View Full Code Here

    // Test output sent directly to the servlet response ServletOutputStream
    public void testDirectStream() throws Exception {

        processor.process(facesContext, "/business/directStream");
        assertEquals("application/x-binary", response.getContentType());
        MockServletOutputStream stream =
          (MockServletOutputStream) response.getOutputStream();
        assertNotNull(stream);
        assertEquals(10, stream.size());
        byte content[] = stream.content();
        for (int i = 0; i < 10; i++) {
            assertEquals("Byte at position " + i, (byte) i, content[i]);
        }
        assertTrue(facesContext.getResponseComplete());
View Full Code Here

    // Test output sent indirectly to the servlet or portlet response stream
    public void testIndirectStream() throws Exception {

        processor.process(facesContext, "/business/indirectStream");
        assertEquals("application/x-binary", response.getContentType());
        MockServletOutputStream stream =
          (MockServletOutputStream) response.getOutputStream();
        assertNotNull(stream);
        assertEquals(10, stream.size());
        byte content[] = stream.content();
        for (int i = 0; i < 10; i++) {
            assertEquals("Byte at position " + i, (byte) i, content[i]);
        }
        assertTrue(facesContext.getResponseComplete());
View Full Code Here

TOP

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

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.