ConfiguredRequestHeaders implements RequestHeaderProvider<HttpURLConnection> { @Override public HttpURLConnection addHeaders(AdaptrisMessage msg, HttpURLConnection target) { for (KeyValuePair k : getHeaders()) { log.trace("Adding Request Property [{}: {}]", k.getKey(), k.getValue()); target.addRequestProperty(k.getKey(), k.getValue()); } return target; } ConfiguredRequestHeaders(); @Override HttpURLConnection addHeaders(AdaptrisMessage msg, HttpURLConnection target); KeyValuePairSet getHeaders(); void setHeaders(KeyValuePairSet headers); ConfiguredRequestHeaders withHeaders(KeyValuePair... keyValuePairs);  }
@Test public void testAddHeaders() throws Exception { Channel c = null; HttpURLConnection urlC = null; try { c = HttpHelper.createAndStartChannel(); URL url = new URL(HttpHelper.createProduceDestination(c).getDestination()); urlC = (HttpURLConnection) url.openConnection(); String name = testName.getMethodName(); ConfiguredRequestHeaders headers = new ConfiguredRequestHeaders(); headers.getHeaders().add(new KeyValuePair(name, name)); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(""); msg.addMetadata(name, name); urlC = headers.addHeaders(msg, urlC); assertTrue(contains(urlC, name, name)); } finally { HttpHelper.stopChannelAndRelease(c); } }