use of org.apache.hc.core5.http.message.HeaderGroup in project httpcomponents-core by apache.
the class TestHeaderGroup method testUpdateHeader.
@Test
public void testUpdateHeader() {
final HeaderGroup headergroup = new HeaderGroup();
final Header header1 = new BasicHeader("name1", "value1");
final Header header2 = new BasicHeader("name2", "value2");
final Header header3 = new BasicHeader("name3", "value3");
headergroup.addHeader(header1);
headergroup.addHeader(header2);
headergroup.addHeader(header3);
headergroup.setHeader(new BasicHeader("name2", "newvalue"));
headergroup.setHeader(new BasicHeader("name4", "value4"));
headergroup.setHeader(null);
Assertions.assertEquals(4, headergroup.getHeaders().length);
Assertions.assertEquals("newvalue", headergroup.getFirstHeader("name2").getValue());
}
use of org.apache.hc.core5.http.message.HeaderGroup in project httpcomponents-core by apache.
the class TestHeaderGroup method testAddRemoveHeaders.
@Test
public void testAddRemoveHeaders() {
final HeaderGroup headergroup = new HeaderGroup();
final Header header = new BasicHeader("name", "value");
headergroup.addHeader(header);
headergroup.addHeader(header);
Assertions.assertEquals(2, headergroup.getHeaders().length);
Assertions.assertFalse(headergroup.removeHeaders((Header) null));
Assertions.assertTrue(headergroup.removeHeaders(header));
Assertions.assertFalse(headergroup.removeHeaders((Header) null));
Assertions.assertEquals(0, headergroup.getHeaders().length);
}
Aggregations