MetadataRequestHeaders implements RequestHeaderProvider<HttpURLConnection> { @Override public HttpURLConnection addHeaders(AdaptrisMessage msg, HttpURLConnection target) { MetadataCollection metadataSubset = getFilter().filter(msg); for (MetadataElement me : metadataSubset) { String value = unfold(me.getValue()); log.trace("Adding Request Property [{}: {}]", me.getKey(), value); target.addRequestProperty(me.getKey(), value); } return target; } MetadataRequestHeaders();  MetadataRequestHeaders(MetadataFilter mf); @Override HttpURLConnection addHeaders(AdaptrisMessage msg, HttpURLConnection target); MetadataFilter getFilter(); void setFilter(MetadataFilter mf); Boolean getUnfold(); void setUnfold(Boolean b);  }
@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(); MetadataRequestHeaders headers = new MetadataRequestHeaders(); headers.setFilter(new RegexMetadataFilter()); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(""); String name = testName.getMethodName(); msg.addMetadata(name, name); urlC = headers.addHeaders(msg, urlC); assertTrue(contains(urlC, name, name)); } finally { HttpHelper.stopChannelAndRelease(c); } }