Package org.apache.http.message

Examples of org.apache.http.message.HeaderGroup


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

    public void testConstructor() {
        HeaderGroup headergroup = new HeaderGroup();
        assertNotNull(headergroup.getAllHeaders());
        assertEquals(0, headergroup.getAllHeaders().length);
    }
View Full Code Here


        assertNotNull(headergroup.getAllHeaders());
        assertEquals(0, headergroup.getAllHeaders().length);
    }
   
    public void testClear() {
        HeaderGroup headergroup = new HeaderGroup();
        headergroup.addHeader(new BasicHeader("name", "value"));
        assertEquals(1, headergroup.getAllHeaders().length);
        headergroup.clear();
        assertEquals(0, headergroup.getAllHeaders().length);
    }
View Full Code Here

        headergroup.clear();
        assertEquals(0, headergroup.getAllHeaders().length);
    }
   
    public void testAddRemoveHeader() {
        HeaderGroup headergroup = new HeaderGroup();
        Header header = new BasicHeader("name", "value");
        headergroup.addHeader(header);
        headergroup.addHeader(null);
        assertEquals(1, headergroup.getAllHeaders().length);
        headergroup.removeHeader(header);
        headergroup.removeHeader(null);
        assertEquals(0, headergroup.getAllHeaders().length);
    }
View Full Code Here

        headergroup.removeHeader(null);
        assertEquals(0, headergroup.getAllHeaders().length);
    }

    public void testUpdateHeader() {
        HeaderGroup headergroup = new HeaderGroup();
        Header header1 = new BasicHeader("name1", "value1");
        Header header2 = new BasicHeader("name2", "value2");
        Header header3 = new BasicHeader("name3", "value3");
        headergroup.addHeader(header1);
        headergroup.addHeader(header2);
        headergroup.addHeader(header3);
        headergroup.updateHeader(new BasicHeader("name2", "newvalue"));
        headergroup.updateHeader(new BasicHeader("name4", "value4"));
        headergroup.updateHeader(null);
        assertEquals(4, headergroup.getAllHeaders().length);
        assertEquals("newvalue", headergroup.getFirstHeader("name2").getValue());
    }
View Full Code Here

        assertEquals(4, headergroup.getAllHeaders().length);
        assertEquals("newvalue", headergroup.getFirstHeader("name2").getValue());
    }

    public void testSetHeaders() {
        HeaderGroup headergroup = new HeaderGroup();
        Header header1 = new BasicHeader("name1", "value1");
        Header header2 = new BasicHeader("name2", "value2");
        Header header3 = new BasicHeader("name3", "value3");
        headergroup.addHeader(header1);
        headergroup.setHeaders(new Header[] { header2, header3 });
        assertEquals(2, headergroup.getAllHeaders().length);
        assertEquals(0, headergroup.getHeaders("name1").length);
        assertFalse(headergroup.containsHeader("name1"));
        assertEquals(1, headergroup.getHeaders("name2").length);
        assertTrue(headergroup.containsHeader("name2"));
        assertEquals(1, headergroup.getHeaders("name3").length);
        assertTrue(headergroup.containsHeader("name3"));
        headergroup.setHeaders(null);
        assertEquals(0, headergroup.getAllHeaders().length);
    }
View Full Code Here

        headergroup.setHeaders(null);
        assertEquals(0, headergroup.getAllHeaders().length);
    }

    public void testFirstLastHeaders() {
        HeaderGroup headergroup = new HeaderGroup();
        Header header1 = new BasicHeader("name", "value1");
        Header header2 = new BasicHeader("name", "value2");
        Header header3 = new BasicHeader("name", "value3");
        headergroup.setHeaders(new Header[] { header1, header2, header3 });
       
        assertNull(headergroup.getFirstHeader("whatever"));
        assertNull(headergroup.getLastHeader("whatever"));
       
        assertEquals("value1", headergroup.getFirstHeader("name").getValue());
        assertEquals("value3", headergroup.getLastHeader("name").getValue());
    }
View Full Code Here

        assertEquals("value1", headergroup.getFirstHeader("name").getValue());
        assertEquals("value3", headergroup.getLastHeader("name").getValue());
    }

    public void testCondensedHeader() {
        HeaderGroup headergroup = new HeaderGroup();
        assertNull(headergroup.getCondensedHeader("name"));
       
        Header header1 = new BasicHeader("name", "value1");
        Header header2 = new BasicHeader("name", "value2");
        Header header3 = new BasicHeader("name", "value3");
        headergroup.setHeaders(new Header[] { header1, header2, header3 });
       
        assertEquals("value1, value2, value3", headergroup.getCondensedHeader("name").getValue());

        headergroup.setHeaders(new Header[] { header1 });
        assertEquals(header1, headergroup.getCondensedHeader("name"));
    }
View Full Code Here

        headergroup.setHeaders(new Header[] { header1 });
        assertEquals(header1, headergroup.getCondensedHeader("name"));
    }

    public void testIterator() {
        HeaderGroup headergroup = new HeaderGroup();
        Iterator i = headergroup.iterator();
        assertNotNull(i);
        assertFalse(i.hasNext());
    }
View Full Code Here

        assertNotNull(i);
        assertFalse(i.hasNext());
    }
   
    public void testCloning() throws Exception {
        HeaderGroup orig = new HeaderGroup();
        Header header1 = new BasicHeader("name", "value1");
        Header header2 = new BasicHeader("name", "value2");
        Header header3 = new BasicHeader("name", "value3");
        orig.setHeaders(new Header[] { header1, header2, header3 });
        HeaderGroup clone = (HeaderGroup) orig.clone();
        Header[] headers1 = orig.getAllHeaders();
        Header[] headers2 = clone.getAllHeaders();
        assertNotNull(headers1);
        assertNotNull(headers2);
        assertEquals(headers1.length, headers2.length);
        for (int i = 0; i < headers1.length; i++) {
            assertEquals(headers1[i], headers2[i]);
View Full Code Here

            uri = ((HttpUriRequest) request).getURI();
        } else {
            uri = URI.create(request.getRequestLine().getUri());
        }
        if (headergroup == null) {
            headergroup = new HeaderGroup();
        }
        headergroup.clear();
        headergroup.setHeaders(request.getAllHeaders());
        if (request instanceof HttpEntityEnclosingRequest) {
            entity = ((HttpEntityEnclosingRequest) request).getEntity();
View Full Code Here

TOP

Related Classes of org.apache.http.message.HeaderGroup

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.