Examples of HttpDataReceiverMockup


Examples of org.apache.http.mockup.HttpDataReceiverMockup

    // Missing \r\n at the end of the first chunk
    public void testCorruptChunkedInputStreamMissingCRLF() throws IOException {
        String s = "5\r\n012345\r\n56789\r\n0\r\n";
        InputStream in = new ChunkedInputStream(
                new HttpDataReceiverMockup(
                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
        byte[] buffer = new byte[300];
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        int len;
        try {
View Full Code Here

Examples of org.apache.http.mockup.HttpDataReceiverMockup

    // Missing LF
    public void testCorruptChunkedInputStreamMissingLF() throws IOException {
        String s = "5\r01234\r\n5\r\n56789\r\n0\r\n";
        InputStream in = new ChunkedInputStream(
                new HttpDataReceiverMockup(
                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
        try {
            in.read();
            fail("MalformedChunkCodingException should have been thrown");
        } catch(MalformedChunkCodingException e) {
View Full Code Here

Examples of org.apache.http.mockup.HttpDataReceiverMockup

    }

    // Missing closing chunk
    public void testCorruptChunkedInputStreamNoClosingChunk() throws IOException {
        InputStream in = new ChunkedInputStream(
                new HttpDataReceiverMockup(new byte[] {}));
        try {
            in.read();
            fail("MalformedChunkCodingException should have been thrown");
        } catch(MalformedChunkCodingException e) {
            /* expected exception */
 
View Full Code Here

Examples of org.apache.http.mockup.HttpDataReceiverMockup

    // Invalid chunk size
    public void testCorruptChunkedInputStreamInvalidSize() throws IOException {
        String s = "whatever\r\n01234\r\n5\r\n56789\r\n0\r\n";
        InputStream in = new ChunkedInputStream(
                new HttpDataReceiverMockup(
                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
        try {
            in.read();
            fail("MalformedChunkCodingException should have been thrown");
        } catch(MalformedChunkCodingException e) {
View Full Code Here

Examples of org.apache.http.mockup.HttpDataReceiverMockup

    // Negative chunk size
    public void testCorruptChunkedInputStreamNegativeSize() throws IOException {
        String s = "-5\r\n01234\r\n5\r\n56789\r\n0\r\n";
        InputStream in = new ChunkedInputStream(
                new HttpDataReceiverMockup(
                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
        try {
            in.read();
            fail("MalformedChunkCodingException should have been thrown");
        } catch(MalformedChunkCodingException e) {
View Full Code Here

Examples of org.apache.http.mockup.HttpDataReceiverMockup

    // Invalid footer
    public void testCorruptChunkedInputStreamInvalidFooter() throws IOException {
        String s = "1\r\n0\r\n0\r\nstuff\r\n";
        InputStream in = new ChunkedInputStream(
                new HttpDataReceiverMockup(
                        EncodingUtils.getBytes(s, CONTENT_CHARSET)));
        try {
            in.read();
            in.read();
            fail("MalformedChunkCodingException should have been thrown");
View Full Code Here

Examples of org.apache.http.mockup.HttpDataReceiverMockup

    }

    public void testEmptyChunkedInputStream() throws IOException {
        String input = "0\r\n";
        InputStream in = new ChunkedInputStream(
                new HttpDataReceiverMockup(
                        EncodingUtils.getBytes(input, CONTENT_CHARSET)));
        byte[] buffer = new byte[300];
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        int len;
        while ((len = in.read(buffer)) > 0) {
View Full Code Here

Examples of org.apache.http.mockup.HttpDataReceiverMockup

        out.flush();
        out.close();
        out.close();
        buffer.close();
        InputStream in = new ChunkedInputStream(
                new HttpDataReceiverMockup(
                        buffer.toByteArray()));

        byte[] d = new byte[10];
        ByteArrayOutputStream result = new ByteArrayOutputStream();
        int len = 0;
View Full Code Here

Examples of org.apache.http.mockup.HttpDataReceiverMockup

            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            //expected
        }
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        new HttpDataReceiverMockup(in, 10);
        try {
            new HttpDataReceiverMockup(in, -10);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            //expected
        }
        try {
            new HttpDataTransmitterMockup(out, -10);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            //expected
        }
        try {
            new HttpDataReceiverMockup((InputStream)null, 1024);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            //expected
        }
    }
View Full Code Here

Examples of org.apache.http.mockup.HttpDataReceiverMockup

        //these write operations should have no effect
        transmitter.writeLine((String)null);
        transmitter.writeLine((CharArrayBuffer)null);
        transmitter.flush();
       
        HttpDataReceiverMockup receiver = new HttpDataReceiverMockup(
            transmitter.getData());

        for (int i = 0; i < teststrs.length; i++) {
            assertEquals(teststrs[i], receiver.readLine());
        }
        assertNull(receiver.readLine());
        assertNull(receiver.readLine());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.