axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prad...@apache.org
Subject svn commit: r635880 - in /webservices/axis2/trunk/java/modules/addressing: src/org/apache/axis2/addressing/ src/org/apache/axis2/handlers/addressing/ test/org/apache/axis2/addressing/
Date Tue, 11 Mar 2008 10:58:48 GMT
Author: pradine
Date: Tue Mar 11 03:58:34 2008
New Revision: 635880

URL: http://svn.apache.org/viewvc?rev=635880&view=rev
Log:
Done some work to the AddressingInHandler to add support for another
WS-Addressing spec defined fault. Also removed some redundant code to
do with roles.

Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
    webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java?rev=635880&r1=635879&r2=635880&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingFaultsHelper.java
Tue Mar 11 03:58:34 2008
@@ -135,6 +135,29 @@
     //    wsa:InvalidAddressingHeader [Reason] the string: "A header representing a Message
Addressing Property is not valid and the message cannot be processed"
     //      wsa:InvalidAddress
     //      wsa:InvalidEPR
+    public static void triggerInvalidEPRFault(MessageContext messageContext,
+            String incorrectHeaderName)
+    throws AxisFault {
+        log.warn("triggerInvalidEPRFault: messageContext: " + messageContext +
+                " incorrectHeaderName: " + incorrectHeaderName);
+        String namespace =
+            (String)messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+        if (Submission.WSA_NAMESPACE.equals(namespace)) {
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
+                    AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
+                    incorrectHeaderName, Submission.FAULT_INVALID_HEADER,
+                    null, AddressingMessages.getMessage(
+                    "spec.submission.FAULT_INVALID_HEADER_REASON"));
+        } else {
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
+                    AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
+                    incorrectHeaderName, Final.FAULT_INVALID_HEADER,
+                    "InvalidEPR",
+                    AddressingMessages.getMessage(
+                    "spec.final.FAULT_INVALID_HEADER_REASON"));
+        }
+    }
+
     //      wsa:InvalidCardinality
     public static void triggerInvalidCardinalityFault(MessageContext messageContext,
                                                       String incorrectHeaderName) throws
AxisFault {

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java?rev=635880&r1=635879&r2=635880&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
Tue Mar 11 03:58:34 2008
@@ -136,21 +136,20 @@
                 log.debug(namespace +
                           " headers present in the SOAP message. Starting to process ...");
             }
+
+            //Need to set these properties here, before we extract the WS-Addressing
+            //information, in case we throw a fault.
+            msgContext.setProperty(WS_ADDRESSING_VERSION, namespace);
+            msgContext.setProperty(DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.FALSE);
             
-            if (extractAddressingInformation(msgContext, iterator, namespace)) {
-                // check for reference parameters
-                if (!disableRefparamExtract) {
-                    extractToEprReferenceParameters(msgContext.getTo(), header, namespace);
-                }
-                
-                msgContext.setProperty(WS_ADDRESSING_VERSION, namespace);
-                msgContext.setProperty(DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.FALSE);
-                msgContext.setProperty(IS_ADDR_INFO_ALREADY_PROCESSED, Boolean.TRUE);
-            }
-            else {
-                msgContext.setProperty(DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
-                msgContext.setProperty(IS_ADDR_INFO_ALREADY_PROCESSED, Boolean.FALSE);  
             
+            extractAddressingInformation(msgContext, iterator, namespace);
+            
+            // check for reference parameters
+            if (!disableRefparamExtract) {
+                extractToEprReferenceParameters(msgContext.getTo(), header, namespace);
             }
+            
+            msgContext.setProperty(IS_ADDR_INFO_ALREADY_PROCESSED, Boolean.TRUE);
         }
         else {
             msgContext.setProperty(DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
@@ -170,10 +169,9 @@
      * @param messageContext the active MessageContext
      * @param headers an Iterator over the addressing headers targeted to me
      * @param namespace the addressing namespace
-     * @return true if addressing information was found
      * @throws AxisFault if an error occurs
      */
-    private boolean extractAddressingInformation(MessageContext messageContext, Iterator
headers,
+    private void extractAddressingInformation(MessageContext messageContext, Iterator headers,
                                          String namespace)
             throws AxisFault {
         Options messageContextOptions = messageContext.getOptions();
@@ -230,14 +228,6 @@
             }
         }
 
-        if (actionBlock == null && toBlock == null && messageIDBlock == null
-            && replyToBlock == null && faultToBlock == null
-            && fromBlock == null && relatesToHeaders == null) {
-            // All of the headers must have had the non local roles so further
-            // processing should be skipped.
-            return false;
-        }
-
         if (actionBlock != null && !ignoreHeaders[ACTION_FLAG]) {
             extractActionInformation(actionBlock, messageContext);
         }
@@ -279,8 +269,6 @@
 
         // provide default values for headers that have not been found.
         setDefaults(checkedHeaderNames, messageContext, namespace);
-
-        return true;
     }
 
     private void checkForMandatoryHeaders(boolean[] alreadyFoundAddrHeader,
@@ -324,7 +312,7 @@
             //used instead, such as the transport URL. Therefore, we only apply the default
             //on the inbound response side of a synchronous request-response exchange.
             if (!alreadyFoundAddrHeader[TO_FLAG] && !messageContext.isServerSide())
{
-                if (log.isTraceEnabled()) {
+                if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                     log.trace(messageContext.getLogIDString() +
                     " setDefaults: Setting WS-Addressing default value for the To property.");
                 }
@@ -333,7 +321,7 @@
             
             if (!alreadyFoundAddrHeader[REPLYTO_FLAG]) {
                 messageContext.setReplyTo(new EndpointReference(Final.WSA_ANONYMOUS_URL));
-                if (log.isTraceEnabled()) {
+                if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                     log.trace(messageContext.getLogIDString() +
                     " setDefaults: Setting WS-Addressing default value for the ReplyTo property.");
                 }
@@ -345,7 +333,7 @@
             //the absence of a ReplyTo header indicates that a response is NOT required.
             if (!alreadyFoundAddrHeader[REPLYTO_FLAG]) {
                 messageContext.setReplyTo(new EndpointReference(Final.WSA_NONE_URI));
-                if (log.isTraceEnabled()) {
+                if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                     log.trace(
                             "setDefaults: Setting WS-Addressing default value for the ReplyTo
property.");
                 }
@@ -384,7 +372,7 @@
         String relationshipTypeString =
                 relationshipType == null ? null : relationshipType.getAttributeValue();
 
-        if (log.isTraceEnabled()) {
+        if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
             log.trace("extractRelatesToInformation: Extracted Relationship. Value=" + address
+
                       " RelationshipType=" + relationshipTypeString);
         }
@@ -410,7 +398,7 @@
             messageContextOptions.setFaultTo(epr);
         }
         extractEPRInformation(soapHeaderBlock, epr, addressingNamespace, messageContext);
-        if (log.isTraceEnabled()) {
+        if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
             log.trace("extractFaultToEPRInformation: Extracted FaultTo EPR: " + epr);
         }
         soapHeaderBlock.setProcessed();
@@ -426,7 +414,7 @@
             messageContextOptions.setReplyTo(epr);
         }
         extractEPRInformation(soapHeaderBlock, epr, addressingNamespace, messageContext);
-        if (log.isTraceEnabled()) {
+        if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
             log.trace("extractReplyToEPRInformation: Extracted ReplyTo EPR: " + epr);
         }
         soapHeaderBlock.setProcessed();
@@ -444,7 +432,7 @@
             messageContextOptions.setFrom(epr);
         }
         extractEPRInformation(soapHeaderBlock, epr, addressingNamespace, messageContext);
-        if (log.isTraceEnabled()) {
+        if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
             log.trace("extractFromEPRInformation: Extracted From EPR: " + epr);
         }
         soapHeaderBlock.setProcessed();
@@ -471,7 +459,7 @@
 
         soapHeaderBlock.setProcessed();
 
-        if (log.isTraceEnabled()) {
+        if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
             log.trace("extractToEPRInformation: Extracted To EPR: " + epr);
         }
     }
@@ -484,13 +472,13 @@
                 OMElement headerElement = (OMElement)headerBlocks.next();
                 OMAttribute isRefParamAttr =
                     headerElement.getAttribute(new QName(namespace, "IsReferenceParameter"));
-                if (log.isTraceEnabled()) {
+                if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                     log.trace("extractToEprReferenceParameters: Checking header: " +
                             headerElement.getQName());
                 }
                 if (isRefParamAttr != null && "true".equals(isRefParamAttr.getAttributeValue()))
{
                     toEPR.addReferenceParameter(headerElement);
-                    if (log.isTraceEnabled()) {
+                    if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled())
{
                         log.trace("extractToEprReferenceParameters: Header: " +
                                 headerElement.getQName() +
                         " has IsReferenceParameter attribute. Adding to toEPR.");
@@ -517,7 +505,7 @@
         String soapAction = messageContextOptions.getAction();
         String wsaAction = soapHeaderBlock.getText();
 
-        if (log.isTraceEnabled()) {
+        if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
             log.trace("extractActionInformation: soapAction='" + soapAction + "' wsa:Action='"
+
                       wsaAction + "'");
         }
@@ -573,16 +561,29 @@
     private void extractEPRInformation(SOAPHeaderBlock headerBlock, EndpointReference epr,
                                        String addressingNamespace, MessageContext messageContext)
             throws AxisFault {
+        String namespace = null;
+        
         try {
-            EndpointReferenceHelper.fromOM(epr, headerBlock, addressingNamespace);
+            namespace = EndpointReferenceHelper.fromOM(epr, headerBlock);            
         } catch (AxisFault af) {
-            if (log.isTraceEnabled()) {
+            if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                 log.trace(
                         "extractEPRInformation: Exception occurred deserialising an EndpointReference.",
                         af);
             }
             AddressingFaultsHelper
                     .triggerMissingAddressInEPRFault(messageContext, headerBlock.getLocalName());
+        }
+        
+        //Check that the EPR has the correct namespace.
+        if (!namespace.equals(addressingNamespace)) {
+            if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
+                log.trace(
+                        "extractEPRInformation: Addressing namespace = " + addressingNamespace
+
+                        ", EPR namespace = " + namespace);
+            }
+            AddressingFaultsHelper
+                    .triggerInvalidEPRFault(messageContext, headerBlock.getLocalName());
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java?rev=635880&r1=635879&r2=635880&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/test/org/apache/axis2/addressing/AddressingFaultsTest.java
Tue Mar 11 03:58:34 2008
@@ -22,6 +22,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.addressing.AddressingConstants.Submission;
 import org.apache.axis2.context.MessageContext;
 
 import javax.xml.namespace.QName;
@@ -34,6 +35,7 @@
      * String)}.
      */
     public void testTriggerInvalidCardinalityFault() {
+        //Final namespace
         MessageContext messageContext = new MessageContext();
         messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                                    AddressingConstants.Final.WSA_NAMESPACE);
@@ -51,10 +53,27 @@
             assertEquals(Boolean.FALSE, messageContext.getProperty(
                     AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
         }
+        
+        //Submission namespace
+        messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Submission.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper.triggerInvalidCardinalityFault(messageContext, "Action");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Submission.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(new QName(Submission.WSA_NAMESPACE, Submission.FAULT_INVALID_HEADER),
+                         af.getFaultCode());
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
     }
 
     /** Test method for {@link AddressingFaultsHelper#triggerActionMismatchFault(org.apache.axis2.context.MessageContext)}.
*/
     public void testTriggerActionMismatchFault() {
+        //Final namespace
         MessageContext messageContext = new MessageContext();
         messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                                    AddressingConstants.Final.WSA_NAMESPACE);
@@ -72,6 +91,22 @@
             assertEquals(Boolean.FALSE, messageContext.getProperty(
                     AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
         }
+
+        //Submission namespace
+        messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Submission.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper.triggerActionMismatchFault(messageContext, "soapAction",
"wsaAction");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Submission.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(new QName(Submission.WSA_NAMESPACE, Submission.FAULT_INVALID_HEADER),
+                         af.getFaultCode());
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
     }
 
     /**
@@ -79,6 +114,7 @@
      * String)}.
      */
     public void testTriggerOnlyAnonymousAddressSupportedFault() {
+        //Final namespace
         MessageContext messageContext = new MessageContext();
         messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                                    AddressingConstants.Final.WSA_NAMESPACE);
@@ -97,6 +133,23 @@
             assertEquals(Boolean.FALSE, messageContext.getProperty(
                     AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
         }
+
+        //Submission namespace
+        messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Submission.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper
+                    .triggerOnlyAnonymousAddressSupportedFault(messageContext, "ReplyTo");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Submission.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(new QName(Submission.WSA_NAMESPACE, Submission.FAULT_INVALID_HEADER),
+                         af.getFaultCode());
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
     }
 
     /**
@@ -104,6 +157,7 @@
      * String)}.
      */
     public void testTriggerOnlyNonAnonymousAddressSupportedFault() {
+        //Final namespace
         MessageContext messageContext = new MessageContext();
         messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                                    AddressingConstants.Final.WSA_NAMESPACE);
@@ -122,6 +176,23 @@
             assertEquals(Boolean.FALSE, messageContext.getProperty(
                     AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
         }
+        
+        //Submission namespace
+        messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Submission.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper
+                    .triggerOnlyNonAnonymousAddressSupportedFault(messageContext, "ReplyTo");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Submission.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(new QName(Submission.WSA_NAMESPACE, Submission.FAULT_INVALID_HEADER),
+                         af.getFaultCode());
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
     }
 
     /**
@@ -129,6 +200,7 @@
      * String)}.
      */
     public void testTriggerMessageAddressingRequiredFault() {
+        //Final namespace
         MessageContext messageContext = new MessageContext();
         messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                                    AddressingConstants.Final.WSA_NAMESPACE);
@@ -146,6 +218,22 @@
             assertEquals(Boolean.FALSE, messageContext.getProperty(
                     AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
         }
+
+        //Submission namespace
+        messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Submission.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper.triggerMessageAddressingRequiredFault(messageContext,
"Action");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Submission.FAULT_ADDRESSING_HEADER_REQUIRED_REASON, af.getMessage());
+            assertEquals(new QName(Submission.WSA_NAMESPACE, Submission.FAULT_ADDRESSING_HEADER_REQUIRED),
+                         af.getFaultCode());
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
     }
 
     /**
@@ -153,6 +241,7 @@
      * String)}.
      */
     public void testTriggerActionNotSupportedFault() {
+        //Final namespace
         MessageContext messageContext = new MessageContext();
         messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                                    AddressingConstants.Final.WSA_NAMESPACE);
@@ -169,6 +258,153 @@
             assertEquals("http://incorrect/action", ((Map)messageContext
                     .getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(
                     AddressingConstants.Final.FAULT_PROBLEM_ACTION_NAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+
+        //Submission namespace
+        messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Submission.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper
+                    .triggerActionNotSupportedFault(messageContext, "http://incorrect/action");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(AddressingConstants.FAULT_ACTION_NOT_SUPPORTED_REASON, af.getMessage());
+            assertEquals(
+                    new QName(Submission.WSA_NAMESPACE, AddressingConstants.FAULT_ACTION_NOT_SUPPORTED),
+                    af.getFaultCode());
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link AddressingFaultsHelper#triggerDestinationUnreachableFault(MessageContext,
String)}.
+     */
+    public void testTriggerDestinationUnreachableFault() {
+        //Final namespace
+        MessageContext messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Final.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper.triggerDestinationUnreachableFault(messageContext, "http://somewhere.com/somehow");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Final.FAULT_ADDRESSING_DESTINATION_UNREACHABLE_REASON, af.getMessage());
+            assertEquals(
+                    new QName(Final.WSA_NAMESPACE, AddressingConstants.FAULT_ADDRESSING_DESTINATION_UNREACHABLE),
+                    af.getFaultCode());
+            assertEquals("http://somewhere.com/somehow", ((Map)messageContext
+                    .getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(
+                    AddressingConstants.Final.FAULT_HEADER_PROB_IRI));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+        
+        //Submission namespace
+        messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Submission.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper.triggerDestinationUnreachableFault(messageContext, "http://somewhere.com/somehow");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Submission.FAULT_ADDRESSING_DESTINATION_UNREACHABLE_REASON, af.getMessage());
+            assertEquals(
+                    new QName(Submission.WSA_NAMESPACE, AddressingConstants.FAULT_ADDRESSING_DESTINATION_UNREACHABLE),
+                    af.getFaultCode());
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link AddressingFaultsHelper#triggerInvalidEPRFault(MessageContext,
String)}.
+     */
+    public void testTriggerInvalidEPRFault() {
+        //Final namespace
+        MessageContext messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Final.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper.triggerInvalidEPRFault(messageContext, "ReplyTo");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Final.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(
+                    new QName(Final.WSA_NAMESPACE, Final.FAULT_INVALID_HEADER),
+                    af.getFaultCode());
+            assertEquals("wsa:ReplyTo", ((Map)messageContext
+                    .getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(
+                    AddressingConstants.Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+
+        //Submission namespace
+        messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Submission.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper.triggerInvalidEPRFault(messageContext, "ReplyTo");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Submission.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(
+                    new QName(Submission.WSA_NAMESPACE, Submission.FAULT_INVALID_HEADER),
+                    af.getFaultCode());
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link AddressingFaultsHelper#triggerMissingAddressInEPRFault(MessageContext,
String)}.
+     */
+    public void testTriggerMissingAddressInEPRFault() {
+        //Final namespace
+        MessageContext messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Final.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper.triggerMissingAddressInEPRFault(messageContext, "ReplyTo");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Final.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(
+                    new QName(Final.WSA_NAMESPACE, Final.FAULT_INVALID_HEADER),
+                    af.getFaultCode());
+            assertEquals("wsa:ReplyTo", ((Map)messageContext
+                    .getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(
+                    AddressingConstants.Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(
+                    AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+        
+        //Submission namespace
+        messageContext = new MessageContext();
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
+                                   AddressingConstants.Submission.WSA_NAMESPACE);
+        try {
+            AddressingFaultsHelper.triggerMissingAddressInEPRFault(messageContext, "ReplyTo");
+            fail("Should have thrown exception");
+        } catch (AxisFault af) {
+            // Expected
+            assertEquals(Submission.FAULT_INVALID_HEADER_REASON, af.getMessage());
+            assertEquals(
+                    new QName(Submission.WSA_NAMESPACE, Submission.FAULT_INVALID_HEADER),
+                    af.getFaultCode());
+            assertEquals("wsa:ReplyTo", ((Map)messageContext
+                    .getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(
+                    AddressingConstants.Final.FAULT_HEADER_PROB_HEADER_QNAME));
             assertEquals(Boolean.FALSE, messageContext.getProperty(
                     AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message