HeaderGroup implements MessageHeaders, Serializable { public void setHeaders(final Header... headers) { clear(); if (headers == null) { return; } Collections.addAll(this.headers, headers); } HeaderGroup(); void clear(); void addHeader(final Header header); boolean removeHeader(final Header header); boolean removeHeaders(final Header header); void setHeader(final Header header); void setHeaders(final Header... headers); Header getCondensedHeader(final String name); @Override Header[] getHeaders(final String name); @Override Header getFirstHeader(final String name); @Override Header getHeader(final String name); @Override Header getLastHeader(final String name); @Override Header[] getHeaders(); @Override boolean containsHeader(final String name); @Override int countHeaders(final String name); @Override Iterator<Header> headerIterator(); @Override Iterator<Header> headerIterator(final String name); boolean removeHeaders(final String name); @Override String toString();  }
@Test public void testSetHeaders() { 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.setHeaders(header2, header3); Assert.assertEquals(2, headergroup.getHeaders().length); Assert.assertEquals(0, headergroup.getHeaders("name1").length); Assert.assertFalse(headergroup.containsHeader("name1")); Assert.assertEquals(1, headergroup.getHeaders("name2").length); Assert.assertTrue(headergroup.containsHeader("name2")); Assert.assertEquals(1, headergroup.getHeaders("name3").length); Assert.assertTrue(headergroup.containsHeader("name3")); headergroup.setHeaders(); Assert.assertEquals(0, headergroup.getHeaders().length); }