Package org.apache.http.mockup

Examples of org.apache.http.mockup.HttpMessageMockup.addHeader()


        assertNotNull(headers);
        assertEquals(2, headers.length);
        assertEquals("3", headers[0].getValue());
        assertEquals("2", headers[1].getValue());

        message.addHeader("name", "4");
       
        headers[1] = new BasicHeader("name", "5");
        message.setHeaders(headers);
       
        headers = message.getHeaders("name");
View Full Code Here


            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            message.addHeader(null, null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
View Full Code Here

    }

    public void testEntityWithChunkTransferEncoding() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "Chunked");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
        assertNotNull(outstream);
View Full Code Here

    }

    public void testEntityWithIdentityTransferEncoding() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "Identity");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
        assertNotNull(outstream);
View Full Code Here

    }
   
    public void testEntityWithInvalidTransferEncoding() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Transfer-Encoding", "whatever");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        try {
            entitywriter.doSerialize(datatransmitter, message);
View Full Code Here

    public void testEntityWithInvalidChunkEncodingAndHTTP10() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
                HttpVersion.HTTP_1_0);
        message.addHeader("Transfer-Encoding", "chunked");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        try {
            entitywriter.doSerialize(datatransmitter, message);
View Full Code Here

    }
   
    public void testEntityWithContentLength() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Content-Length", "100");
        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
        assertNotNull(outstream);
        assertTrue(outstream instanceof ContentLengthOutputStream);
View Full Code Here

    }
   
    public void testEntityWithInvalidContentLength() throws Exception {
        SessionOutputBuffer datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Content-Length", "whatever");

        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        try {
            entitywriter.doSerialize(datatransmitter, message);
View Full Code Here

        byte[] content = new byte[] {1, 2, 3, 4, 5};
        ByteArrayEntity entity = new ByteArrayEntity(content);
       
        SessionOutputBufferMockup datatransmitter = new SessionOutputBufferMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader("Content-Length", Integer.toString(content.length));
       
        EntitySerializer entitywriter = new EntitySerializer(
                new StrictContentLengthStrategy());
        entitywriter.serialize(datatransmitter, message, entity);
       
View Full Code Here

        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");
        message.addHeader("Transfer-Encoding", "identity, chunked");
        message.addHeader("Content-Length", "plain wrong");
        EntityDeserializer entitygen = new EntityDeserializer(
                new LaxContentLengthStrategy());
        HttpEntity entity = entitygen.deserialize(datareceiver, message);
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.