axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidills...@apache.org
Subject svn commit: r427636 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/handlers/addressing/ core/src/org/apache/axis2/addressing/ core/test/org/apache/axis2/addressing/
Date Tue, 01 Aug 2006 16:21:52 GMT
Author: davidillsley
Date: Tue Aug  1 09:21:51 2006
New Revision: 427636

URL: http://svn.apache.org/viewvc?rev=427636&view=rev
Log:
Further initial work on implementation of AXIS2-948
Refactored generation of WS-Addressing faults and added some tests

Added:
    webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java
Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java?rev=427636&r1=427635&r2=427636&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingFinalInHandler.java
Tue Aug  1 09:21:51 2006
@@ -7,6 +7,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.AddressingHelper.FinalFaults;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
@@ -96,7 +97,7 @@
     
     protected void checkForMandatoryHeaders(ArrayList alreadyFoundAddrHeader, MessageContext
messageContext) throws AxisFault {
         if (!alreadyFoundAddrHeader.contains(WSA_ACTION)) {
-            throwFault(messageContext, WSA_ACTION, Final.FAULT_ADDRESSING_HEADER_REQUIRED,
null);
+            FinalFaults.triggerMessageAddressingRequiredFault(messageContext, WSA_ACTION);
         } 
     }
     

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=427636&r1=427635&r2=427636&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 Aug  1 09:21:51 2006
@@ -27,6 +27,7 @@
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.addressing.AddressingHelper.FinalFaults;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.util.Utils;
@@ -154,7 +155,7 @@
         // This means that if for example there are multiple MessageIDs and a FaultTo, the
FaultTo will be respected.
         if(!duplicateHeaderNames.isEmpty()){
         	// Simply choose the first problem header we came across as we can only fault for
one of them.
-        	throwFault(messageContext,(String)duplicateHeaderNames.get(0),Final.FAULT_INVALID_HEADER,
Final.FAULT_INVALID_CARDINALITY);
+            FinalFaults.triggerInvalidCardinalityFault(messageContext, (String)duplicateHeaderNames.get(0));
         }
         
         // check for the presence of madatory addressing headers
@@ -183,25 +184,6 @@
     	return shouldIgnore;
     }
 
-    protected void throwFault(MessageContext messageContext, String addressingHeaderName,
String faultCode, String faultSubCode) throws AxisFault {
-        Map faultInformation = (Map) messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
-        if (faultInformation == null) {
-            faultInformation = new HashMap();
-            messageContext.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS, faultInformation);
-        }
-
-        if(messageContext.getMessageID() != null) {
-            faultInformation.put(AddressingConstants.WSA_RELATES_TO,messageContext.getMessageID());
-        }
-        
-        faultInformation.put(Final.FAULT_HEADER_PROB_HEADER_QNAME, WSA_DEFAULT_PREFIX + ":"
+ addressingHeaderName);
-        faultInformation.put(Final.WSA_FAULT_ACTION, Final.WSA_FAULT_ACTION);
-        if (!messageContext.isSOAP11()) {
-            Utils.setFaultCode(messageContext, faultCode, faultSubCode);
-        }
-        throw new AxisFault("A header representing a Message Addressing Property is not valid
and the message cannot be processed", WSA_DEFAULT_PREFIX + ":" + faultCode);
-    }
-
     protected abstract void extractToEprReferenceParameters(EndpointReference toEPR, SOAPHeader
header, String namespace);
 
 
@@ -279,7 +261,7 @@
         
         if (soapAction != null && !"".equals(soapAction)) {
             if (!soapAction.equals(soapHeaderBlock.getText())) {
-                throwFault(messageContext, WSA_ACTION, Final.FAULT_INVALID_HEADER, null);
+                FinalFaults.triggerActionMismatchFault(messageContext);
             }
         }
         else {

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java?rev=427636&r1=427635&r2=427636&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingSubmissionInHandler.java
Tue Aug  1 09:21:51 2006
@@ -8,6 +8,7 @@
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.addressing.AddressingHelper.FinalFaults;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
 import org.apache.commons.logging.Log;
@@ -97,18 +98,19 @@
     
     protected void checkForMandatoryHeaders(ArrayList alreadyFoundAddrHeader, MessageContext
messageContext) throws AxisFault {
         if (!alreadyFoundAddrHeader.contains(WSA_TO)) {
-            throwFault(messageContext, WSA_TO, Final.FAULT_ADDRESSING_HEADER_REQUIRED, null);
+            // Should write a new SubmissionFaults class but for the moment use the FinalFaults
+            FinalFaults.triggerMessageAddressingRequiredFault(messageContext, WSA_TO);
         }
         
         if (!alreadyFoundAddrHeader.contains(WSA_ACTION)) {
-            throwFault(messageContext, WSA_ACTION, Final.FAULT_ADDRESSING_HEADER_REQUIRED,
null);
+            FinalFaults.triggerMessageAddressingRequiredFault(messageContext, WSA_ACTION);
         }
         
         if (alreadyFoundAddrHeader.contains(WSA_REPLY_TO) ||
             alreadyFoundAddrHeader.contains(WSA_FAULT_TO)) {
             
             if (!alreadyFoundAddrHeader.contains(WSA_MESSAGE_ID)) {
-                throwFault(messageContext, WSA_MESSAGE_ID, Final.FAULT_ADDRESSING_HEADER_REQUIRED,
null);
+                FinalFaults.triggerMessageAddressingRequiredFault(messageContext, WSA_MESSAGE_ID);
             }
         }
     }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java?rev=427636&r1=427635&r2=427636&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
Tue Aug  1 09:21:51 2006
@@ -46,6 +46,7 @@
 
     // ====================== WSDL Binding Constants ========================
     public static final String USING_ADDRESSING = "UsingAddressing";
+    public static final String ANONYMOUS = "Anonymous";
     
     // ====================== Addressing Requirement Levels ==================
     // These are used to represent the requirement level on WS-Addressing indicated
@@ -97,10 +98,17 @@
         public static final String FAULT_HEADER_PROB_HEADER = "ProblemHeader";
         public static final String FAULT_HEADER_DETAIL = "FaultDetail";
         public static final String FAULT_INVALID_HEADER = "InvalidAddressingHeader";
+        public static final String FAULT_INVALID_HEADER_REASON = "A header representing a
Message Addressing Property is not valid and the message cannot be processed";
         public static final String FAULT_ADDRESSING_HEADER_REQUIRED = "MessageAddressingHeaderRequired";
+        public static final String FAULT_ADDRESSING_HEADER_REQUIRED_REASON = "A required
header representing a Message Addressing Property is not present";
         public static final String FAULT_INVALID_CARDINALITY = "InvalidCardinality";
+        public static final String FAULT_ONLY_ANONYMOUS_ADDRESS_SUPPORTED = "OnlyAnonymousAddressSupported";
+        public static final String FAULT_ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED = "OnlyNonAnonymousAddressSupported";
+        public static final String FAULT_ACTION_NOT_SUPPORTED = "ActionNotSupported";
+        public static final String FAULT_ACTION_NOT_SUPPORTED_REASON = "The [action] cannot
be processed at the receiver.";
 
         public static final QName WSAW_USING_ADDRESSING = new QName(WSAW_NAMESPACE,USING_ADDRESSING);
+        public static final QName WSAW_ANONYMOUS = new QName(WSAW_NAMESPACE,USING_ADDRESSING);
     }
 
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java?rev=427636&r1=427635&r2=427636&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java
Tue Aug  1 09:21:51 2006
@@ -15,6 +15,20 @@
 */
 package org.apache.axis2.addressing;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPFaultSubCode;
+import org.apache.axiom.soap.SOAPFaultValue;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants.Final;
 import org.apache.axis2.context.MessageContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -27,7 +41,7 @@
      * Returns true if the ReplyTo address does not match one of the supported
      * anonymous urls. If the ReplyTo is not set, anonymous is assumed, per the Final
      * spec. The AddressingInHandler should have set the ReplyTo to non-null in the 
-     * 2004/08 case to ensure the different semantics. (per AXIS2-xxxx)
+     * 2004/08 case to ensure the different semantics. (per AXIS2-885)
      * 
      * @param messageContext
      * @return
@@ -61,6 +75,104 @@
             return isReplyRedirected(messageContext);
         }else{
             return !faultTo.hasAnonymousAddress(); 
+        }
+    }
+    
+    public static class FinalFaults{
+        
+        private static final Log log = LogFactory.getLog(FinalFaults.class);
+        
+        //    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
+        //      wsa:InvalidCardinality
+        public static void triggerInvalidCardinalityFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
+            if(log.isDebugEnabled()){
+                log.debug("triggerInvalidCardinalityFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
+            }
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
"InvalidCardinality", Final.FAULT_INVALID_HEADER_REASON);
+        }
+
+        //      wsa:MissingAddressInEPR
+        //      wsa:DuplicateMessageID
+        //      wsa:ActionMismatch
+        public static void triggerActionMismatchFault(MessageContext messageContext) throws
AxisFault {
+            if(log.isDebugEnabled()){
+                log.debug("triggerActionMismatchFault: messageContext: "+messageContext);
+            }
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":"+"Action", Final.FAULT_INVALID_HEADER, "ActionMismatch",
Final.FAULT_INVALID_HEADER_REASON);
+        }
+
+        //      wsa:OnlyAnonymousAddressSupported
+        public static void triggerOnlyAnonymousAddressSupportedFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
+            if(log.isDebugEnabled()){
+                log.debug("triggerOnlyAnonymousAddressSupportedFault: messageContext: "+messageContext+"
incorrectHeaderName: "+incorrectHeaderName);
+            }
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
Final.FAULT_ONLY_ANONYMOUS_ADDRESS_SUPPORTED, Final.FAULT_INVALID_HEADER_REASON);
+        }
+
+        //      wsa:OnlyNonAnonymousAddressSupported
+        public static void triggerOnlyNonAnonymousAddressSupportedFault(MessageContext messageContext,
String incorrectHeaderName) throws AxisFault {
+            if(log.isDebugEnabled()){
+                log.debug("triggerOnlyNonAnonymousAddressSupportedFault: messageContext:
"+messageContext+" incorrectHeaderName: "+incorrectHeaderName);
+            }
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + incorrectHeaderName, Final.FAULT_INVALID_HEADER,
Final.FAULT_ONLY_NON_ANONYMOUS_ADDRESS_SUPPORTED, Final.FAULT_INVALID_HEADER_REASON);
+        }
+
+        //    wsa:MessageAddressingHeaderRequired [Reason] the string: "A required header
representing a Message Addressing Property is not present"
+        public static void triggerMessageAddressingRequiredFault(MessageContext messageContext,
String missingHeaderName) throws AxisFault {
+            if(log.isDebugEnabled()){
+                log.debug("triggerMessageAddressingRequiredFault: messageContext: "+messageContext+"
missingHeaderName: "+missingHeaderName);
+            }
+            triggerAddressingFault(messageContext, Final.FAULT_HEADER_PROB_HEADER_QNAME,
AddressingConstants.WSA_DEFAULT_PREFIX + ":" + missingHeaderName, Final.FAULT_ADDRESSING_HEADER_REQUIRED,
null, Final.FAULT_ADDRESSING_HEADER_REQUIRED_REASON);
+        }
+
+        //    wsa:ActionNotSupported [Reason] the string: "The [action] cannot be processed
at the receiver"
+        public static void triggerActionNotSupportedFault(MessageContext messageContext,
String problemAction) throws AxisFault {
+            if(log.isDebugEnabled()){
+                log.debug("triggerActionNotSupportedFault: messageContext: "+messageContext+"
problemAction: "+problemAction);
+            }
+            triggerAddressingFault(messageContext, "PROBLEM_ACTION", problemAction, Final.FAULT_ACTION_NOT_SUPPORTED,
null, Final.FAULT_ACTION_NOT_SUPPORTED_REASON);
+        }
+        //    wsa:EndpointUnavailable [Reason] the string "The endpoint is unable to process
the message at this time"
+
+        private static void triggerAddressingFault(MessageContext messageContext, String
faultInformationKey, Object faultInformationValue, String faultcode, String faultSubcode,
String faultReason) throws AxisFault{
+            Map faultInformation = (Map) messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
+            if (faultInformation == null) {
+                faultInformation = new HashMap();
+                messageContext.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS, faultInformation);
+            }
+
+            if(messageContext.getMessageID() != null) {
+                faultInformation.put(AddressingConstants.WSA_RELATES_TO,messageContext.getMessageID());
+            }
+
+            faultInformation.put(Final.WSA_FAULT_ACTION, Final.WSA_FAULT_ACTION);
+            faultInformation.put(faultInformationKey, faultInformationValue);
+
+            if (!messageContext.isSOAP11()) {
+                setFaultCode(messageContext, faultcode, faultSubcode);
+            }
+
+            messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
Boolean.FALSE);
+            AxisFault fault = new AxisFault(faultReason, new QName(AddressingConstants.Final.WSA_NAMESPACE,faultcode));
+            throw fault;
+        }
+
+        private static void setFaultCode(MessageContext messageContext, String faultCode,
String faultSubCode) {
+            SOAPFactory soapFac = OMAbstractFactory.getSOAP12Factory();
+            SOAPFaultCode soapFaultCode = soapFac.createSOAPFaultCode();
+            SOAPFaultValue soapFaultValue = soapFac.createSOAPFaultValue(soapFaultCode);
+            soapFaultValue.setText(SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX + ":" +
SOAP12Constants.FAULT_CODE_SENDER);
+            SOAPFaultSubCode soapFaultSubCode = soapFac.createSOAPFaultSubCode(soapFaultCode);
+            SOAPFaultValue soapFaultSubcodeValue = soapFac.createSOAPFaultValue(soapFaultSubCode);
+            soapFaultSubcodeValue.setText(AddressingConstants.WSA_DEFAULT_PREFIX + ":" +
faultCode);
+            if (faultSubCode != null) {
+                SOAPFaultSubCode soapFaultSubCode2 = soapFac.createSOAPFaultSubCode(soapFaultSubCode);
+                SOAPFaultValue soapFaultSubcodeValue2 = soapFac.createSOAPFaultValue(soapFaultSubCode2);
+                soapFaultSubcodeValue2.setText(AddressingConstants.WSA_DEFAULT_PREFIX + ":"
+ faultSubCode);
+            }
+            messageContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
         }
     }
 }

Added: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java?rev=427636&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java
(added)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/FinalFaultsTest.java
Tue Aug  1 09:21:51 2006
@@ -0,0 +1,133 @@
+/*
+* Copyright 2006 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.addressing;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.context.MessageContext;
+
+import junit.framework.TestCase;
+
+public class FinalFaultsTest extends TestCase {
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerInvalidCardinalityFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerInvalidCardinalityFault() {
+        MessageContext messageContext = new MessageContext();
+        try{
+            AddressingHelper.FinalFaults.triggerInvalidCardinalityFault(messageContext, "Action");
+            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:Action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerActionMismatchFault(org.apache.axis2.context.MessageContext)}.
+     */
+    public void testTriggerActionMismatchFault() {
+        MessageContext messageContext = new MessageContext();
+        try{
+            AddressingHelper.FinalFaults.triggerActionMismatchFault(messageContext);
+            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:Action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerOnlyAnonymousAddressSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerOnlyAnonymousAddressSupportedFault() {
+        MessageContext messageContext = new MessageContext();
+        try{
+            AddressingHelper.FinalFaults.triggerOnlyAnonymousAddressSupportedFault(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(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerOnlyNonAnonymousAddressSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerOnlyNonAnonymousAddressSupportedFault() {
+        MessageContext messageContext = new MessageContext();
+        try{
+            AddressingHelper.FinalFaults.triggerOnlyNonAnonymousAddressSupportedFault(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(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerMessageAddressingRequiredFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerMessageAddressingRequiredFault() {
+        MessageContext messageContext = new MessageContext();
+        try{
+            AddressingHelper.FinalFaults.triggerMessageAddressingRequiredFault(messageContext,
"Action");
+            fail("Should have thrown exception");
+        }catch(AxisFault af){
+            // Expected
+            assertEquals(Final.FAULT_ADDRESSING_HEADER_REQUIRED_REASON, af.getMessage());
+            assertEquals(new QName(Final.WSA_NAMESPACE,Final.FAULT_ADDRESSING_HEADER_REQUIRED),
af.getFaultCode());
+            assertEquals("wsa:Action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get(Final.FAULT_HEADER_PROB_HEADER_QNAME));
+            assertEquals(Boolean.FALSE, messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));
+        }
+    }
+
+    /**
+     * Test method for {@link org.apache.axis2.addressing.AddressingHelper.FinalFaults#triggerActionNotSupportedFault(org.apache.axis2.context.MessageContext,
java.lang.String)}.
+     */
+    public void testTriggerActionNotSupportedFault() {
+        MessageContext messageContext = new MessageContext();
+        try{
+            AddressingHelper.FinalFaults.triggerActionNotSupportedFault(messageContext, "http://incorrect/action");
+            fail("Should have thrown exception");
+        }catch(AxisFault af){
+            // Expected
+            assertEquals(Final.FAULT_ACTION_NOT_SUPPORTED_REASON, af.getMessage());
+            assertEquals(new QName(Final.WSA_NAMESPACE,Final.FAULT_ACTION_NOT_SUPPORTED),
af.getFaultCode());
+            assertEquals("http://incorrect/action", ((Map)messageContext.getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS)).get("PROBLEM_ACTION"));
+            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