public void testDuplicateHeadersWithOverridingOn() throws Exception {
// this will check whether we can add to epr, if there is one already.
EndpointReference eprOne = new EndpointReference("http://whatever.org");
RelatesTo custom = new RelatesTo("urn:id", "customRelationship");
ConfigurationContext cfgCtx =
ConfigurationContextFactory.createEmptyConfigurationContext();
msgCtxt = cfgCtx.createMessageContext();
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope defaultEnvelope = factory.getDefaultEnvelope();
OMNamespace addressingNamespace =
factory.createOMNamespace(Final.WSA_NAMESPACE, WSA_DEFAULT_PREFIX);
SOAPHeaderBlock soapHeaderBlock =
defaultEnvelope.getHeader().addHeaderBlock(WSA_TO, addressingNamespace);
soapHeaderBlock.setText("http://oldEPR.org");
soapHeaderBlock =
defaultEnvelope.getHeader().addHeaderBlock(WSA_RELATES_TO, addressingNamespace);
soapHeaderBlock.setText("urn:id");
soapHeaderBlock =
defaultEnvelope.getHeader().addHeaderBlock(WSA_RELATES_TO, addressingNamespace);
soapHeaderBlock.setText("urn:id");
soapHeaderBlock
.addAttribute(WSA_RELATES_TO_RELATIONSHIP_TYPE, custom.getRelationshipType(), null);
msgCtxt.setEnvelope(defaultEnvelope);
msgCtxt.setProperty(REPLACE_ADDRESSING_HEADERS, Boolean.TRUE);
msgCtxt.addRelatesTo(custom);
msgCtxt.setTo(eprOne);