Package org.apache.http.io

Examples of org.apache.http.io.CharArrayBuffer


        HttpProtocolParams.setHttpElementCharset(params, HTTP.ISO_8859_1);
       
        HttpDataTransmitterMockup transmitter = new HttpDataTransmitterMockup();
        transmitter.reset(params);

        CharArrayBuffer chbuffer = new CharArrayBuffer(16);
        for (int i = 0; i < 10; i++) {
            chbuffer.clear();
            chbuffer.append(s1);
            transmitter.writeLine(chbuffer);
        }
        transmitter.flush();
       
        HttpDataReceiverMockup receiver = new HttpDataReceiverMockup(
View Full Code Here


    public static final StatusLine parse(final String s)
            throws ProtocolException {
        if (s == null) {
            throw new IllegalArgumentException("String may not be null");
        }
        CharArrayBuffer buffer = new CharArrayBuffer(s.length());
        buffer.append(s);
        return parse(buffer, 0, buffer.length());
    }
View Full Code Here

    public final String getReasonPhrase() {
        return this.reasonPhrase;
    }

    public final String toString() {
      CharArrayBuffer buffer = new CharArrayBuffer(64);       
        buffer.append(this.httpVersion);
        buffer.append(' ');
        buffer.append(Integer.toString(this.statusCode));
        if (this.reasonPhrase != null && !this.reasonPhrase.equals("")) {
            buffer.append(' ');
            buffer.append(this.reasonPhrase);
        }
        return buffer.toString();
    }
View Full Code Here

        assertEquals("value", buffer.substringTrimmed(6, buffer.length()));
        assertEquals("", buffer.substringTrimmed(13, buffer.length()));
    }
   
    public void testSubstringIndexOfOutBound() {
        CharArrayBuffer buffer = new CharArrayBuffer(16);
        buffer.append("stuff");
        try {
            buffer.substring(-2, 10);
            fail("IndexOutOfBoundsException should have been thrown");
        } catch (IndexOutOfBoundsException ex) {
            // expected
        }
        try {
            buffer.substringTrimmed(-2, 10);
            fail("IndexOutOfBoundsException should have been thrown");
        } catch (IndexOutOfBoundsException ex) {
            // expected
        }
        try {
            buffer.substring(12, 10);
            fail("IndexOutOfBoundsException should have been thrown");
        } catch (IndexOutOfBoundsException ex) {
            // expected
        }
        try {
            buffer.substringTrimmed(12, 10);
            fail("IndexOutOfBoundsException should have been thrown");
        } catch (IndexOutOfBoundsException ex) {
            // expected
        }
        try {
            buffer.substring(2, 1);
            fail("IndexOutOfBoundsException should have been thrown");
        } catch (IndexOutOfBoundsException ex) {
            // expected
        }
        try {
            buffer.substringTrimmed(2, 1);
            fail("IndexOutOfBoundsException should have been thrown");
        } catch (IndexOutOfBoundsException ex) {
            // expected
        }
    }   
View Full Code Here

            buffer.append(statusline.getReasonPhrase());
        }
    }
    public static String format(final StatusLine statusline) {
        CharArrayBuffer buffer = new CharArrayBuffer(32);
        format(buffer, statusline);
        return buffer.toString();
    }
View Full Code Here

        HeaderElement[] elements = HeaderElement.parseAll(headerValue);
        assertEquals("Number of elements", 0, elements.length);
    }

    public void testInvalidInput() throws Exception {
        CharArrayBuffer buffer = new CharArrayBuffer(32);
        buffer.append("name = value");
        try {
            HeaderElement.parseAll(null, 0, 0);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
View Full Code Here

        String s1 = "stuff";
        String s2 = " and more stuff";
        byte[] b1 = s1.getBytes("US-ASCII");
        byte[] b2 = s2.getBytes("US-ASCII");
       
        CharArrayBuffer buffer = new CharArrayBuffer(8);
        buffer.append(b1, 0, b1.length);
        buffer.append(b2, 0, b2.length);
       
        assertEquals("stuff and more stuff", buffer.toString());
    }
View Full Code Here

            fail("IllegalArgumentException should habe been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            HeaderElement.format(new CharArrayBuffer(10), (HeaderElement) null);
            fail("IllegalArgumentException should habe been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            HeaderElement.formatAll(null, new HeaderElement[] {new HeaderElement("name1", "value1")});
            fail("IllegalArgumentException should habe been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            HeaderElement.formatAll(new CharArrayBuffer(10), (HeaderElement[]) null);
            fail("IllegalArgumentException should habe been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

    }
   
    public void testAppendISOByteArray() throws Exception {
        byte[] b = new byte[] {0x00, 0x20, 0x7F, -0x80, -0x01};
       
        CharArrayBuffer buffer = new CharArrayBuffer(8);
        buffer.append(b, 0, b.length);
        char[] ch = buffer.toCharArray();
        assertNotNull(ch);
        assertEquals(5, ch.length);
        assertEquals(0x00, ch[0]);
        assertEquals(0x20, ch[1]);
        assertEquals(0x7F, ch[2]);
View Full Code Here

        assertEquals(0x80, ch[3]);
        assertEquals(0xFF, ch[4]);
    }
   
    public void testAppendNullByteArray() throws Exception {
        CharArrayBuffer buffer = new CharArrayBuffer(8);
        buffer.append((byte[])null, 0, 0);
        assertEquals("", buffer.toString());
    }
View Full Code Here

TOP

Related Classes of org.apache.http.io.CharArrayBuffer

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.