You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2006/07/03 14:31:49 UTC
svn commit: r418754 [2/2] - in
/webservices/axis2/trunk/java/modules/addressing:
src/org/apache/axis2/handlers/addressing/
test-resources/omitted-header-messages/
test-resources/omitted-header-messages/final/
test-resources/omitted-header-messages/subm...
Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTestBase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTestBase.java?rev=418754&r1=418753&r2=418754&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTestBase.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingInHandlerTestBase.java Mon Jul 3 05:31:48 2006
@@ -1,288 +1,295 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.axis2.handlers.addressing;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.TestCase;
-
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.RelatesTo;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.handlers.util.TestUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public abstract class AddressingInHandlerTestBase extends TestCase {
- private Log log = LogFactory.getLog(getClass());
- AddressingInHandler inHandler;
- String addressingNamespace;
- TestUtil testUtil = new TestUtil();
- private String testFileName = "soapmessage.xml";
-
- String versionDirectory;
-
- private String action = "http://ws.apache.org/tests/action";
- private String messageID = "uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5";
- String fromAddress;
- String secondRelationshipType;
- private String faultAddress = "http://example.com/fabrikam/fault";
- private String replyAddress = "http://example.com/fabrikam/acct";
- private String toAddress = "http://localhost:8081/axis/services/BankPort";
-
- /**
- * @param testName
- */
- public AddressingInHandlerTestBase(String testName) {
- super(testName);
- }
-
- protected void basicExtractAddressingInformationFromHeaders(String testMessagePath, MessageContext mc) throws Exception{
- StAXSOAPModelBuilder omBuilder = testUtil.getOMBuilder(testMessagePath);
- SOAPHeader header = ((SOAPEnvelope) omBuilder.getDocumentElement()).getHeader();
- ArrayList addressingHeaderBlocks = header.getHeaderBlocksWithNSURI(addressingNamespace);
- inHandler.extractAddressingInformation(header, mc, addressingHeaderBlocks, addressingNamespace);
- }
-
- protected Options extractAddressingInformationFromHeaders(){
- try {
- String testfile = "valid-messages/"+versionDirectory+"/"+testFileName;
-
- MessageContext mc = new MessageContext();
-
- basicExtractAddressingInformationFromHeaders(testfile, mc);
-
- Options options = mc.getOptions();
-
- if (options == null) {
- fail("Addressing Information Headers have not been retrieved properly");
- }
- assertEquals("action header is not correct",
- options.getAction(),
- action);
- assertEquals("message id header is not correct",
- options.getMessageId().trim(),
- messageID.trim());
-
- assertFullFromEPR(options.getFrom());
- assertFullFaultEPR(options.getFaultTo());
- assertFullReplyToEPR(options.getReplyTo());
-
- assertRelationships(options);
-
- return options;
-
- } catch (Exception e) {
- e.printStackTrace();
- log.info(e.getMessage());
- fail(" An Exception has occured " + e.getMessage());
- }
-
- return null;
- }
-
- private void testExtractAddressingInformationFromHeadersInvalidCardinality(String headerName) {
- String testfile = "invalid-cardinality-messages/"+versionDirectory+"/invalidCardinality"+headerName+"Message.xml";
- try {
- MessageContext mc = new MessageContext();
- try{
- basicExtractAddressingInformationFromHeaders(testfile, mc);
- fail("An AxisFault should have been thrown due to 2 wsa:"+headerName+" headers.");
- }catch(AxisFault af){
- if(headerName.equals(AddressingConstants.WSA_REPLY_TO)){
- assertNull("No ReplyTo should be set on the MessageContext", mc.getReplyTo());
- }else{
- assertReplyToEPR(mc.getReplyTo());
- }
-
- if(headerName.equals(AddressingConstants.WSA_FAULT_TO)){
- assertNull("No FaultTo should be set on the MessageContext", mc.getFaultTo());
- }else{
- assertFaultEPR(mc.getFaultTo());
- }
-
- if(headerName.equals(AddressingConstants.WSA_ACTION)){
- assertNull("No Action should be set on the MessageContext", mc.getWSAAction());
- }else{
- assertEquals("WSAAction property is not correct", mc.getWSAAction(), action);
- }
-
- if(headerName.equals(AddressingConstants.WSA_MESSAGE_ID)){
- assertNull("No MessageID should be set on the MessageContext", mc.getMessageID());
- }else{
- assertEquals("MessageID property is not correct", mc.getMessageID().trim(), messageID.trim());
- }
-
- if(headerName.equals(AddressingConstants.WSA_FROM)){
- assertNull("No From should be set on the MessageContext", mc.getFrom());
- }else{
- assertFromEPR(mc.getFrom());
- }
-
- if(headerName.equals(AddressingConstants.WSA_TO)){
- assertNull("No To should be set on the MessageContext", mc.getTo());
- }else{
- assertToEPR(mc.getTo());
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- log.info(e.getMessage());
- fail(" An Exception has occured " + e.getMessage());
- }
- }
-
- public void testExtractAddressingInformationFromHeadersInvalidCardinalityReplyTo() {
- testExtractAddressingInformationFromHeadersInvalidCardinality(AddressingConstants.WSA_REPLY_TO);
- }
-
- public void testExtractAddressingInformationFromHeadersInvalidCardinalityFaultTo() {
- testExtractAddressingInformationFromHeadersInvalidCardinality(AddressingConstants.WSA_FAULT_TO);
- }
-
- public void testExtractAddressingInformationFromHeadersInvalidCardinalityAction() {
- testExtractAddressingInformationFromHeadersInvalidCardinality(AddressingConstants.WSA_ACTION);
- }
-
- public void testExtractAddressingInformationFromHeadersInvalidCardinalityMessageID() {
- 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) {
- assertEquals("Address in To EPR is not valid",
- toEPR.getAddress().trim(),
- toAddress.trim());
- }
-
- 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 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());
- assertEquals(options.getRelatesTo().getValue(),"http://some.previous.message");
- assertEquals(options.getRelatesTo(secondRelationshipType).getValue(),"http://identifier.of.other.message/");
- }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.handlers.addressing;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.util.TestUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class AddressingInHandlerTestBase extends TestCase {
+ private Log log = LogFactory.getLog(getClass());
+ AddressingInHandler inHandler;
+ String addressingNamespace;
+ TestUtil testUtil = new TestUtil();
+ private String testFileName = "soapmessage.xml";
+
+ String versionDirectory;
+
+ private String action = "http://ws.apache.org/tests/action";
+ private String messageID = "uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5";
+ String fromAddress;
+ String secondRelationshipType;
+ private String faultAddress = "http://example.com/fabrikam/fault";
+ private String replyAddress = "http://example.com/fabrikam/acct";
+ private String toAddress = "http://localhost:8081/axis/services/BankPort";
+
+ /**
+ * @param testName
+ */
+ public AddressingInHandlerTestBase(String testName) {
+ super(testName);
+ }
+
+ protected void basicExtractAddressingInformationFromHeaders(String testMessagePath, MessageContext mc) throws Exception{
+ StAXSOAPModelBuilder omBuilder = testUtil.getOMBuilder(testMessagePath);
+ SOAPHeader header = ((SOAPEnvelope) omBuilder.getDocumentElement()).getHeader();
+ ArrayList addressingHeaderBlocks = header.getHeaderBlocksWithNSURI(addressingNamespace);
+ inHandler.extractAddressingInformation(header, mc, addressingHeaderBlocks, addressingNamespace);
+ }
+
+ protected Options extractAddressingInformationFromHeaders(){
+ try {
+ String testfile = "valid-messages/"+versionDirectory+"/"+testFileName;
+
+ MessageContext mc = new MessageContext();
+
+ basicExtractAddressingInformationFromHeaders(testfile, mc);
+
+ Options options = mc.getOptions();
+
+ if (options == null) {
+ fail("Addressing Information Headers have not been retrieved properly");
+ }
+ assertEquals("action header is not correct",
+ options.getAction(),
+ action);
+ assertEquals("message id header is not correct",
+ options.getMessageId().trim(),
+ messageID.trim());
+
+ assertFullFromEPR(options.getFrom());
+ assertFullFaultEPR(options.getFaultTo());
+ assertFullReplyToEPR(options.getReplyTo());
+
+ assertRelationships(options);
+
+ return options;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.info(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+
+ return null;
+ }
+
+ private void testExtractAddressingInformationFromHeadersInvalidCardinality(String headerName) {
+ String testfile = "invalid-cardinality-messages/"+versionDirectory+"/invalidCardinality"+headerName+"Message.xml";
+ try {
+ MessageContext mc = new MessageContext();
+ try{
+ basicExtractAddressingInformationFromHeaders(testfile, mc);
+ fail("An AxisFault should have been thrown due to 2 wsa:"+headerName+" headers.");
+ }catch(AxisFault af){
+ if(headerName.equals(AddressingConstants.WSA_REPLY_TO)){
+ assertNull("No ReplyTo should be set on the MessageContext", mc.getReplyTo());
+ }else{
+ assertReplyToEPR(mc.getReplyTo());
+ }
+
+ if(headerName.equals(AddressingConstants.WSA_FAULT_TO)){
+ assertNull("No FaultTo should be set on the MessageContext", mc.getFaultTo());
+ }else{
+ assertFaultEPR(mc.getFaultTo());
+ }
+
+ if(headerName.equals(AddressingConstants.WSA_ACTION)){
+ assertNull("No Action should be set on the MessageContext", mc.getWSAAction());
+ }else{
+ assertEquals("WSAAction property is not correct", mc.getWSAAction(), action);
+ }
+
+ if(headerName.equals(AddressingConstants.WSA_MESSAGE_ID)){
+ assertNull("No MessageID should be set on the MessageContext", mc.getMessageID());
+ }else{
+ assertEquals("MessageID property is not correct", mc.getMessageID().trim(), messageID.trim());
+ }
+
+ if(headerName.equals(AddressingConstants.WSA_FROM)){
+ assertNull("No From should be set on the MessageContext", mc.getFrom());
+ }else{
+ assertFromEPR(mc.getFrom());
+ }
+
+ if(headerName.equals(AddressingConstants.WSA_TO)){
+ assertNull("No To should be set on the MessageContext", mc.getTo());
+ }else{
+ assertToEPR(mc.getTo());
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.info(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+ }
+
+ protected void testMessageWithOmittedHeaders(String testName) throws Exception {
+ String testfile = "omitted-header-messages/"+versionDirectory+"/"+testName+"Message.xml";
+
+ MessageContext mc = new MessageContext();
+ basicExtractAddressingInformationFromHeaders(testfile, mc);
+ }
+
+ public void testExtractAddressingInformationFromHeadersInvalidCardinalityReplyTo() {
+ testExtractAddressingInformationFromHeadersInvalidCardinality(AddressingConstants.WSA_REPLY_TO);
+ }
+
+ public void testExtractAddressingInformationFromHeadersInvalidCardinalityFaultTo() {
+ testExtractAddressingInformationFromHeadersInvalidCardinality(AddressingConstants.WSA_FAULT_TO);
+ }
+
+ public void testExtractAddressingInformationFromHeadersInvalidCardinalityAction() {
+ testExtractAddressingInformationFromHeadersInvalidCardinality(AddressingConstants.WSA_ACTION);
+ }
+
+ public void testExtractAddressingInformationFromHeadersInvalidCardinalityMessageID() {
+ 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) {
+ assertEquals("Address in To EPR is not valid",
+ toEPR.getAddress().trim(),
+ toAddress.trim());
+ }
+
+ 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 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());
+ assertEquals(options.getRelatesTo().getValue(),"http://some.previous.message");
+ assertEquals(options.getRelatesTo(secondRelationshipType).getValue(),"http://identifier.of.other.message/");
+ }
+}
Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandlerTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandlerTest.java?rev=418754&r1=418753&r2=418754&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandlerTest.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandlerTest.java Mon Jul 3 05:31:48 2006
@@ -1,54 +1,164 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.axis2.handlers.addressing;
-
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.client.Options;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class AddressingSubmissionInHandlerTest extends AddressingInHandlerTestBase {
-
- private Log log = LogFactory.getLog(getClass());
-
- /**
- * @param testName
- */
- public AddressingSubmissionInHandlerTest(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- inHandler = new AddressingSubmissionInHandler();
- addressingNamespace = AddressingConstants.Submission.WSA_NAMESPACE;
- versionDirectory = "submission";
- fromAddress = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";
- secondRelationshipType = "axis2:some.custom.relationship";
- }
-
- public void testExtractAddressingInformationFromHeaders() {
- try {
- Options options = extractAddressingInformationFromHeaders();
- // Cannot check refparams in 2004/08 case as they can't be extracted until later
- } catch (Exception e) {
- e.printStackTrace();
- log.error(e.getMessage());
- fail(" An Exception has occured " + e.getMessage());
- }
- }
-}
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.handlers.addressing;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.client.Options;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class AddressingSubmissionInHandlerTest extends AddressingInHandlerTestBase {
+
+ private Log log = LogFactory.getLog(getClass());
+
+ /**
+ * @param testName
+ */
+ public AddressingSubmissionInHandlerTest(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ inHandler = new AddressingSubmissionInHandler();
+ addressingNamespace = AddressingConstants.Submission.WSA_NAMESPACE;
+ versionDirectory = "submission";
+ fromAddress = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";
+ secondRelationshipType = "axis2:some.custom.relationship";
+ }
+
+ public void testExtractAddressingInformationFromHeaders() {
+ try {
+ Options options = extractAddressingInformationFromHeaders();
+ // Cannot check refparams in 2004/08 case as they can't be extracted until later
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.error(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+ }
+
+ public void testMessageWithOmittedAction() {
+ try {
+ testMessageWithOmittedHeaders("noAction");
+ fail("An AxisFault should have been thrown due to a missing Action header.");
+ }
+ catch (AxisFault af) {
+ //test passed
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ log.error(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+ }
+
+ public void testMessageWithOmittedFaultTo() {
+ try {
+ testMessageWithOmittedHeaders("noFaultTo");
+ }
+ catch (AxisFault af) {
+ af.printStackTrace();
+ log.error(af.getMessage());
+ fail("An unexpected AxisFault was thrown due to a missing FaultTo header.");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ log.error(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+ }
+
+ public void testMessageWithOmittedFrom() {
+ try {
+ testMessageWithOmittedHeaders("noFrom");
+ }
+ catch (AxisFault af) {
+ af.printStackTrace();
+ log.error(af.getMessage());
+ fail("An unexpected AxisFault was thrown due to a missing From header.");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ log.error(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+ }
+
+ public void testMessageWithOmittedMessageID() {
+ try {
+ testMessageWithOmittedHeaders("noMessageID");
+ fail("An AxisFault should have been thrown due to a missing MessageID header.");
+ }
+ catch (AxisFault af) {
+ //test passed
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ log.error(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+ }
+
+ public void testMessageWithOmittedMessageIDReplyToAndFaultTo() {
+ try {
+ testMessageWithOmittedHeaders("noMessageIDNoReplyToNoFaultTo");
+ }
+ catch (AxisFault af) {
+ af.printStackTrace();
+ log.error(af.getMessage());
+ fail("An unexpected AxisFault was thrown due to missing MessageID, ReplyTo, and FaultTo headers.");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ log.error(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+ }
+
+ public void testMessageWithOmittedReplyTo() {
+ try {
+ testMessageWithOmittedHeaders("noReplyTo");
+ }
+ catch (AxisFault af) {
+ af.printStackTrace();
+ log.error(af.getMessage());
+ fail("An unexpected AxisFault was thrown due to a missing ReplyTo header.");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ log.error(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+ }
+
+ public void testMessageWithOmittedTo() {
+ try {
+ testMessageWithOmittedHeaders("noTo");
+ fail("An AxisFault should have been thrown due to a missing To header.");
+ }
+ catch (AxisFault af) {
+ //test passed
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ log.error(e.getMessage());
+ fail(" An Exception has occured " + e.getMessage());
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org