addressinginhandlertestbase.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 388 行 · 第 1/2 页
JAVA
388 行
testExtractAddressingInformationFromHeadersInvalidCardinality(
AddressingConstants.WSA_MESSAGE_ID);
}
public void testExtractAddressingInformationFromHeadersInvalidCardinalityFrom() {
testExtractAddressingInformationFromHeadersInvalidCardinality(AddressingConstants.WSA_FROM);
}
public void testExtractAddressingInformationFromHeadersInvalidCardinalityTo() {
testExtractAddressingInformationFromHeadersInvalidCardinality(AddressingConstants.WSA_TO);
}
private void assertFromEPR(EndpointReference fromEPR) {
assertEquals("Address in From EPR is not valid",
fromEPR.getAddress().trim(),
fromAddress.trim());
}
private void assertFaultEPR(EndpointReference faultEPR) {
assertEquals("Address in FaultTo EPR is not valid",
faultEPR.getAddress().trim(),
faultAddress.trim());
}
private void assertReplyToEPR(EndpointReference replyEPR) {
assertEquals("Address in ReplytTo EPR is not valid",
replyEPR.getAddress().trim(),
replyAddress.trim());
}
private void assertToEPR(EndpointReference toEPR) {
System.out.println(toEPR);
assertEquals("Address in To EPR is not valid",
toEPR.getAddress().trim(),
toAddress.trim());
assertEPRAddressHasExtensibilityAttribute(toEPR);
}
private void assertFullFromEPR(EndpointReference fromEPR) {
assertEquals("Address in From EPR is not valid",
fromEPR.getAddress().trim(),
fromAddress.trim());
assertEPRHasExtensibilityAttribute(fromEPR);
assertEPRHasCorrectReferenceParameters(fromEPR);
assertEPRHasCorrectExtensibilityElements(fromEPR);
}
private void assertFullFaultEPR(EndpointReference faultEPR) {
assertEquals("Address in FaultTo EPR is not valid",
faultEPR.getAddress().trim(),
faultAddress.trim());
assertEPRHasExtensibilityAttribute(faultEPR);
assertEPRHasCorrectReferenceParameters(faultEPR);
assertEPRHasCorrectExtensibilityElements(faultEPR);
}
private void assertFullReplyToEPR(EndpointReference replyEPR) {
assertEquals("Address in ReplytTo EPR is not valid",
replyEPR.getAddress().trim(),
replyAddress.trim());
assertEPRHasExtensibilityAttribute(replyEPR);
assertEPRHasCorrectReferenceParameters(replyEPR);
assertEPRHasCorrectExtensibilityElements(replyEPR);
}
private void assertEPRHasCorrectReferenceParameters(EndpointReference epr) {
//<wsa:ReferenceParameters>
// <fabrikam:CustomerKey>123456789</fabrikam:CustomerKey>
// <fabrikam:ShoppingCart>ABCDEFG</fabrikam:ShoppingCart>
//</wsa:ReferenceParameters>
Map referenceParameters = epr.getAllReferenceParameters();
if (referenceParameters != null) {
OMElement refparm1 = (OMElement)referenceParameters
.get(new QName("http://example.com/fabrikam", "CustomerKey"));
assertNotNull(refparm1);
assertEquals("ReferenceParameter value incorrect.", refparm1.getText(), "123456789");
OMElement refparm2 = (OMElement)referenceParameters
.get(new QName("http://example.com/fabrikam", "ShoppingCart"));
assertNotNull(refparm2);
assertEquals("ReferenceParameter value incorrect.", refparm2.getText(), "ABCDEFG");
} else {
fail("No ReferenceParameters found in EPR");
}
}
private void assertActionHasExtensibilityAttribute(MessageContext mc) {
boolean attributeFound = false;
ArrayList attributes = (ArrayList)mc.getProperty(AddressingConstants.ACTION_ATTRIBUTES);
if (attributes != null) {
Iterator iter = attributes.iterator();
while (iter.hasNext()) {
OMAttribute oa = (OMAttribute)iter.next();
if (oa.getLocalName().equals("AttrExt")) {
attributeFound = true;
assertEquals("Attribute value incorrectly deserialised", oa.getAttributeValue(),
"123456789");
}
}
}
assertTrue("Extensibility attribute not found on Action", attributeFound);
}
private void assertMessageIDHasExtensibilityAttribute(MessageContext mc) {
boolean attributeFound = false;
ArrayList attributes = (ArrayList)mc.getProperty(AddressingConstants.MESSAGEID_ATTRIBUTES);
if (attributes != null) {
Iterator iter = attributes.iterator();
while (iter.hasNext()) {
OMAttribute oa = (OMAttribute)iter.next();
if (oa.getLocalName().equals("AttrExt")) {
attributeFound = true;
assertEquals("Attribute value incorrectly deserialised", oa.getAttributeValue(),
"123456789");
}
}
}
assertTrue("Extensibility attribute not found on MessageID", attributeFound);
}
private void assertRelatesToHasExtensibilityAttribute(RelatesTo rt) {
boolean attributeFound = false;
ArrayList attributes = rt.getExtensibilityAttributes();
if (attributes != null) {
Iterator iter = attributes.iterator();
while (iter.hasNext()) {
OMAttribute oa = (OMAttribute)iter.next();
if (oa.getLocalName().equals("AttrExt")) {
attributeFound = true;
assertEquals("Attribute value incorrectly deserialised", oa.getAttributeValue(),
"123456789");
}
}
}
assertTrue("Extensibility attribute not found on RelatesTo", attributeFound);
}
private void assertEPRAddressHasExtensibilityAttribute(EndpointReference epr) {
boolean attributeFound = false;
ArrayList attributes = epr.getAddressAttributes();
if (attributes != null) {
Iterator iter = attributes.iterator();
while (iter.hasNext()) {
OMAttribute oa = (OMAttribute)iter.next();
if (oa.getLocalName().equals("AttrExt")) {
attributeFound = true;
assertEquals("Attribute value incorrectly deserialised", oa.getAttributeValue(),
"123456789");
}
}
}
assertTrue("Extensibility attribute not found on EPR Address", attributeFound);
}
private void assertEPRHasExtensibilityAttribute(EndpointReference epr) {
boolean attributeFound = false;
ArrayList attributes = epr.getAttributes();
if (attributes != null) {
Iterator iter = attributes.iterator();
while (iter.hasNext()) {
OMAttribute oa = (OMAttribute)iter.next();
if (oa.getLocalName().equals("AttrExt")) {
attributeFound = true;
assertEquals("Attribute value incorrectly deserialised", oa.getAttributeValue(),
"123456789");
}
}
}
assertTrue("Extensibility attribute not found on EPR", attributeFound);
}
private void assertEPRHasCorrectExtensibilityElements(EndpointReference epr) {
ArrayList eelements = epr.getExtensibleElements();
if (eelements != null) {
OMElement ee = (OMElement)eelements.get(0);
assertEquals(ee.getQName(),
new QName("http://ws.apache.org/namespaces/axis2", "EPRExt"));
assertEquals(ee.getText(), "123456789");
assertEquals(ee.getAttributeValue(
new QName("http://ws.apache.org/namespaces/axis2", "AttrExt")), "123456789");
} else {
fail("No Extensibility Elements found in EPR");
}
}
private void assertRelationships(Options options) {
assertNotNull(options.getRelatesTo());
assertRelatesToHasExtensibilityAttribute(options.getRelatesTo());
assertEquals(options.getRelatesTo().getValue(), "http://some.previous.message");
assertEquals(options.getRelatesTo(secondRelationshipType).getValue(),
"http://identifier.of.other.message/");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?