Package org.apache.http.io

Examples of org.apache.http.io.CharArrayBuffer


            fail();
        } catch (HttpException e) { /* expected */ }
    }

    public void testParseInvalidInput() throws Exception {
        CharArrayBuffer buffer = new CharArrayBuffer(32);
        buffer.append("HTTP/1.1 200 OK");
        try {
            StatusLine.parse(null, 0, 0);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
View Full Code Here


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

      buffer.append(" and more stuff");
      assertEquals("stuff and more stuff", buffer.toString());
    }
   
    public void testAppendNullString() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(8);
      buffer.append((String)null);
      assertEquals("null", buffer.toString());
    }
View Full Code Here

     * Return the host uri.
     *
     * @return The host uri.
     */
    public String toURI() {
      CharArrayBuffer buffer = new CharArrayBuffer(32);       
        buffer.append(this.scheme.getName());
        buffer.append("://");
        buffer.append(this.hostname);
        if (this.port != this.scheme.getDefaultPort()) {
            buffer.append(':');
            buffer.append(Integer.toString(this.port));
        }
        return buffer.toString();
    }
View Full Code Here

      buffer.append((String)null);
      assertEquals("null", buffer.toString());
    }
   
    public void testAppendCharArrayBuffer() throws Exception {
        CharArrayBuffer buffer1 = new CharArrayBuffer(8);
        buffer1.append(" and more stuff");
        CharArrayBuffer buffer2 = new CharArrayBuffer(8);
        buffer2.append("stuff");
        buffer2.append(buffer1);
        assertEquals("stuff and more stuff", buffer2.toString());
    }
View Full Code Here

        buffer2.append(buffer1);
        assertEquals("stuff and more stuff", buffer2.toString());
    }
   
    public void testAppendNullCharArrayBuffer() throws Exception {
        CharArrayBuffer buffer = new CharArrayBuffer(8);
        buffer.append((CharArrayBuffer)null);
        buffer.append((CharArrayBuffer)null, 0, 0);
        assertEquals("", buffer.toString());
    }
View Full Code Here

        }
        return buffer.toString();
    }

    public String toHostString() {
      CharArrayBuffer buffer = new CharArrayBuffer(32);       
        buffer.append(this.hostname);
        if (this.port != this.scheme.getDefaultPort()) {
            buffer.append(':');
            buffer.append(Integer.toString(this.port));
        }
        return buffer.toString();
    }
View Full Code Here

        buffer.append((CharArrayBuffer)null, 0, 0);
        assertEquals("", buffer.toString());
    }
   
    public void testAppendSingleChar() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(4);
      buffer.append('1');
      buffer.append('2');
      buffer.append('3');
      buffer.append('4');
      buffer.append('5');
      buffer.append('6');
      assertEquals("123456", buffer.toString());
    }
View Full Code Here

      buffer.append('6');
      assertEquals("123456", buffer.toString());
    }
   
    public void testInvalidCharArrayAppend() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(4);
      buffer.append((char[])null, 0, 0);

      char[] tmp = new char[] { '1', '2', '3', '4'};
      try {
          buffer.append(tmp, -1, 0);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
      try {
          buffer.append(tmp, 0, -1);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
      try {
          buffer.append(tmp, 0, 8);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
      try {
          buffer.append(tmp, 10, Integer.MAX_VALUE);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
      try {
          buffer.append(tmp, 2, 4);
        fail("IndexOutOfBoundsException should have been thrown");
      } catch (IndexOutOfBoundsException ex) {
        // expected
      }
    }
View Full Code Here

        // expected
      }
    }

    public void testSetLength() throws Exception {
      CharArrayBuffer buffer = new CharArrayBuffer(4);
      buffer.setLength(2);
      assertEquals(2, buffer.length());
    }
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.