Package org.apache.http.mockup

Examples of org.apache.http.mockup.SessionInputBufferMockup


        String s =
            "header1: stuff\r\n" +
            " stuff \r\n" +
            " stuff\r\n" +
            "\r\n";
        SessionInputBuffer receiver = new SessionInputBufferMockup(s, "US-ASCII");
        try {
            AbstractMessageParser.parseHeaders(receiver, 2, 15, null);
            fail("IOException should have been thrown");
        } catch (IOException ex) {
            // expected
View Full Code Here


    public static Test suite() {
        return new TestSuite(TestIdentitynputStream.class);
    }

    public void testConstructor() throws Exception {
        SessionInputBuffer receiver = new SessionInputBufferMockup(new byte[] {});
        new IdentityInputStream(receiver);
        try {
            new IdentityInputStream(null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
View Full Code Here

        }
    }
   
    public void testBasicRead() throws Exception {
        byte[] input = new byte[] {'a', 'b', 'c'};
        SessionInputBufferMockup receiver = new SessionInputBufferMockup(input);
        IdentityInputStream instream = new IdentityInputStream(receiver);
        byte[] tmp = new byte[2];
        assertEquals(2, instream.read(tmp, 0, tmp.length));
        assertEquals('a', tmp[0]);
        assertEquals('b', tmp[1]);
View Full Code Here

        assertEquals(-1, instream.read());       
    }
   
    public void testClosedCondition() throws Exception {
        byte[] input = new byte[] {'a', 'b', 'c'};
        SessionInputBufferMockup receiver = new SessionInputBufferMockup(input);
        IdentityInputStream instream = new IdentityInputStream(receiver);

        instream.close();
        instream.close();
       
View Full Code Here

        assertEquals(-1, instream.read());       
    }

    public void testAvailable() throws Exception {
        byte[] input = new byte[] {'a', 'b', 'c'};
        SessionInputBufferMockup receiver = new SessionInputBufferMockup(input);
        IdentityInputStream instream = new IdentityInputStream(receiver);
        assertTrue(instream.available() > 0);       
    }
View Full Code Here

            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            entitygen.deserialize(new SessionInputBufferMockup(new byte[] {}) , null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

            // expected
        }
    }

    public void testEntityWithTransferEncoding() throws Exception {
        SessionInputBuffer datareceiver = new SessionInputBufferMockup("0\r\n", "US-ASCII");
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
View Full Code Here

        assertTrue(entity.getContent() instanceof ChunkedInputStream);
    }

    public void testEntityWithIdentityTransferEncoding() throws Exception {
        SessionInputBuffer datareceiver =
          new SessionInputBufferMockup(new byte[] {});
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
View Full Code Here

        assertEquals(-1, entity.getContentLength());
        assertFalse(entity.isChunked());
    }

    public void testEntityWithUnsupportedTransferEncoding() throws Exception {
        SessionInputBuffer datareceiver = new SessionInputBufferMockup("0\r\n", "US-ASCII");
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
View Full Code Here

            // expected
        }
    }

    public void testChunkedTransferEncodingMustBeLast() throws Exception {
        SessionInputBuffer datareceiver = new SessionInputBufferMockup("0\r\n", "US-ASCII");
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
View Full Code Here

TOP

Related Classes of org.apache.http.mockup.SessionInputBufferMockup

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.