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/31 18:23:10 UTC
svn commit: r427155 - in /webservices/axis2/trunk/java/modules/core:
src/org/apache/axis2/addressing/ test/org/apache/axis2/addressing/
Author: davidillsley
Date: Mon Jul 31 09:23:10 2006
New Revision: 427155
URL: http://svn.apache.org/viewvc?rev=427155&view=rev
Log:
New helper methods for implementation of AXIS2-948
Added:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java
webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/AddressingHelperTest.java
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java
webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java
Added: 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=427155&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingHelper.java Mon Jul 31 09:23:10 2006
@@ -0,0 +1,66 @@
+/*
+* 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 org.apache.axis2.context.MessageContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class AddressingHelper {
+
+ private static final Log log = LogFactory.getLog(AddressingHelper.class);
+
+ /**
+ * 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)
+ *
+ * @param messageContext
+ * @return
+ */
+ public static boolean isReplyRedirected(MessageContext messageContext){
+ EndpointReference replyTo = messageContext.getReplyTo();
+ if(replyTo == null){
+ if(log.isDebugEnabled()){
+ log.debug("isReplyRedirected: ReplyTo is null. Returning false");
+ }
+ return false;
+ }else{
+ return !replyTo.hasAnonymousAddress();
+ }
+ }
+
+ /**
+ * Returns true if the FaultTo address does not match one of the supported
+ * anonymous urls. If the FaultTo is not set, the ReplyTo is checked per the
+ * spec.
+ * @see isReplyRedirected
+ * @param messageContext
+ * @return
+ */
+ public static boolean isFaultRedirected(MessageContext messageContext){
+ EndpointReference faultTo = messageContext.getFaultTo();
+ if(faultTo == null){
+ if(log.isDebugEnabled()){
+ log.debug("isReplyRedirected: FaultTo is null. Returning isReplyRedirected");
+ }
+ return isReplyRedirected(messageContext);
+ }else{
+ return !faultTo.hasAnonymousAddress();
+ }
+ }
+}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java?rev=427155&r1=427154&r2=427155&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/EndpointReference.java Mon Jul 31 09:23:10 2006
@@ -120,6 +120,20 @@
}
/**
+ * hasAnonymousAddress
+ *
+ * @return true if address is 'Anonymous URI' from either supported addressing version
+ */
+ public boolean hasAnonymousAddress(){
+ boolean result = (AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(address) ||
+ AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(address));
+ if(log.isTraceEnabled()){
+ log.trace("hasAnonymousAddress: "+address+" is Anonymous: "+result);
+ }
+ return result;
+ }
+
+ /**
* @param localName
* @param ns
* @param value
Added: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/AddressingHelperTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/AddressingHelperTest.java?rev=427155&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/AddressingHelperTest.java (added)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/AddressingHelperTest.java Mon Jul 31 09:23:10 2006
@@ -0,0 +1,55 @@
+/*
+* 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 org.apache.axis2.context.MessageContext;
+
+import junit.framework.TestCase;
+
+public class AddressingHelperTest extends TestCase {
+
+ public void testIsReplyRedirectedNoReplyTo() {
+ MessageContext mc = new MessageContext();
+ assertFalse(AddressingHelper.isReplyRedirected(mc));
+ }
+ public void testIsReplyRedirectedAnonReplyTo() {
+ MessageContext mc = new MessageContext();
+ mc.setReplyTo(new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL));
+ assertFalse(AddressingHelper.isReplyRedirected(mc));
+ }
+ public void testIsReplyRedirectedNonAnonReplyTo() {
+ MessageContext mc = new MessageContext();
+ mc.setReplyTo(new EndpointReference("http://ws.apache.org/axis2"));
+ assertTrue(AddressingHelper.isReplyRedirected(mc));
+ }
+
+ public void testIsFaultRedirectedNoFaultToOrReplyTo() {
+ MessageContext mc = new MessageContext();
+ assertFalse(AddressingHelper.isFaultRedirected(mc));
+ }
+
+ public void testIsFaultRedirectedAnonFaultTo() {
+ MessageContext mc = new MessageContext();
+ mc.setFaultTo(new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL));
+ assertFalse(AddressingHelper.isFaultRedirected(mc));
+ }
+
+ public void testIsFaultRedirectedNonAnonFaultTo() {
+ MessageContext mc = new MessageContext();
+ mc.setFaultTo(new EndpointReference("http://ws.apache.org/axis2"));
+ assertTrue(AddressingHelper.isFaultRedirected(mc));
+ }
+}
Modified: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java?rev=427155&r1=427154&r2=427155&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java (original)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java Mon Jul 31 09:23:10 2006
@@ -78,6 +78,19 @@
}
}
+ public void testHasAnonymousAddress(){
+ // Default EndpointReference does not has 'anonymous address'
+ assertFalse(endpointReference.hasAnonymousAddress());
+
+ // EndpointReference with 2005/08 Anonymous address
+ EndpointReference epr200508anon = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+ assertTrue(epr200508anon.hasAnonymousAddress());
+
+ // EndpointReference with 2004/08 Anonymous address
+ EndpointReference epr200408anon = new EndpointReference(AddressingConstants.Submission.WSA_ANONYMOUS_URL);
+ assertTrue(epr200408anon.hasAnonymousAddress());
+ }
+
public void testToAndFromOM() throws Exception{
OMFactory omf = OMAbstractFactory.getOMFactory();
OMNamespace ns1 = omf.createOMNamespace("http://uri1","prefix1");
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org