cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r687067 - in /cxf/branches/2.0.x-fixes: api/ common/schemas/src/main/resources/schemas/wsdl/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/ rt/ws/addr/src/test/java/org/apa...
Date Tue, 19 Aug 2008 14:48:58 GMT
Author: dkulp
Date: Tue Aug 19 07:48:57 2008
New Revision: 687067

URL: http://svn.apache.org/viewvc?rev=687067&view=rev
Log:
[CXF-1747] Backport support for older ws-addressing spec to 2.0.x branch

Added:
    cxf/branches/2.0.x-fixes/common/schemas/src/main/resources/schemas/wsdl/addressing200403.xjb
      - copied unchanged from r685947, cxf/trunk/common/schemas/src/main/resources/schemas/wsdl/addressing200403.xjb
    cxf/branches/2.0.x-fixes/common/schemas/src/main/resources/schemas/wsdl/addressing200403.xsd
      - copied unchanged from r685947, cxf/trunk/common/schemas/src/main/resources/schemas/wsdl/addressing200403.xsd
Modified:
    cxf/branches/2.0.x-fixes/api/pom.xml
    cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
    cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/VersionTransformer.java
    cxf/branches/2.0.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java

Modified: cxf/branches/2.0.x-fixes/api/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/api/pom.xml?rev=687067&r1=687066&r2=687067&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/api/pom.xml (original)
+++ cxf/branches/2.0.x-fixes/api/pom.xml Tue Aug 19 07:48:57 2008
@@ -155,6 +155,10 @@
                                     <bindingFile>${basedir}/target/schemas/schemas/wsdl/ws-addr-wsdl.xjb</bindingFile>
                                     <extension>true</extension>
                                 </xsdOption>
+                                   <xsdOption>
+                                    <xsd>${basedir}/target/schemas/schemas/wsdl/addressing200403.xsd</xsd>
+                                    <bindingFile>${basedir}/target/schemas/schemas/wsdl/addressing200403.xjb</bindingFile>
+                                </xsdOption>
                             </xsdOptions>
                         </configuration>
                         <goals>

Modified: cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java?rev=687067&r1=687066&r2=687067&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java (original)
+++ cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/VersionTransformer.java Tue Aug 19 07:48:57 2008
@@ -27,6 +27,7 @@
 import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
 
+
 // importation convention: if the same class name is used for 
 // 2005/08 and 2004/08, then the former version is imported
 // and the latter is fully qualified when used
@@ -77,7 +78,8 @@
      */
     public boolean isSupported(String namespace) {
         return NATIVE_VERSION.equals(namespace) 
-               || Names200408.WSA_NAMESPACE_NAME.equals(namespace);
+               || Names200408.WSA_NAMESPACE_NAME.equals(namespace)
+               || Names200403.WSA_NAMESPACE_NAME.equals(namespace);
     }
     
     /**
@@ -101,6 +103,23 @@
     }
 
     /**
+     * Convert from 2005/08 AttributedURI to 2004/03 AttributedURI.
+     * 
+     * @param internal the 2005/08 AttributedURIType
+     * @return an equivalent 2004/08 or 2004/03 AttributedURI
+     */
+    public static org.apache.cxf.ws.addressing.v200403.AttributedURI 
+    convertTo200403(AttributedURIType internal) {
+        org.apache.cxf.ws.addressing.v200403.AttributedURI exposed = Names200403.WSA_OBJECT_FACTORY
+            .createAttributedURI();
+        String exposedValue = Names.WSA_ANONYMOUS_ADDRESS.equals(internal.getValue())
+            ? Names200403.WSA_ANONYMOUS_ADDRESS : Names.WSA_NONE_ADDRESS.equals(internal.getValue())
+                ? Names200403.WSA_NONE_ADDRESS : internal.getValue();
+        exposed.setValue(exposedValue);
+        putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
+        return exposed;
+    }
+    /**
      * Convert from 2004/08 AttributedURI to 2005/08 AttributedURI.
      * 
      * @param exposed the 2004/08 AttributedURI
@@ -121,6 +140,22 @@
     }
     
     /**
+     * Convert from 2004/03 AttributedURI to 2005/08 AttributedURI.
+     * 
+     * @param exposed the 2004/03 AttributedURI
+     * @return an equivalent 2005/08 AttributedURIType
+     */
+    public static AttributedURIType convert(org.apache.cxf.ws.addressing.v200403.AttributedURI exposed) {
+        AttributedURIType internal = ContextUtils.WSA_OBJECT_FACTORY.createAttributedURIType();
+        String internalValue = Names200403.WSA_ANONYMOUS_ADDRESS.equals(exposed.getValue())
+            ? Names.WSA_ANONYMOUS_ADDRESS : Names200403.WSA_NONE_ADDRESS.equals(exposed.getValue())
+                ? Names.WSA_NONE_ADDRESS : exposed.getValue();
+        internal.setValue(internalValue);
+        putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
+        return internal;
+    }    
+
+    /**
      * Convert from 2005/08 EndpointReferenceType to 2004/08 
      * EndpointReferenceType.
      * 
@@ -160,6 +195,40 @@
     }
     
     /**
+     * Convert from 2005/08 EndpointReferenceType to 2004/03 EndpointReferenceType.
+     * 
+     * @param internal the 2005/08 EndpointReferenceType
+     * @return an equivalent 2004/03 EndpointReferenceType
+     */
+    public static org.apache.cxf.ws.addressing.v200403.EndpointReferenceType 
+    convertTo200403(EndpointReferenceType internal) {
+        org.apache.cxf.ws.addressing.v200403.EndpointReferenceType exposed = Names200403.WSA_OBJECT_FACTORY
+            .createEndpointReferenceType();
+        exposed.setAddress(convertTo200403(internal.getAddress()));
+
+        QName serviceQName = EndpointReferenceUtils.getServiceName(internal);
+        if (serviceQName != null) {
+            org.apache.cxf.ws.addressing.v200403.ServiceNameType serviceName = Names200403.WSA_OBJECT_FACTORY
+                .createServiceNameType();
+            serviceName.setValue(serviceQName);
+            exposed.setServiceName(serviceName);
+        }
+        String portLocalName = EndpointReferenceUtils.getPortName(internal);
+        if (portLocalName != null) {
+            String namespace = serviceQName.getNamespaceURI() != null
+                ? serviceQName.getNamespaceURI() : Names.WSDL_INSTANCE_NAMESPACE_NAME;
+            QName portQName = new QName(namespace, portLocalName);
+            org.apache.cxf.ws.addressing.v200403.AttributedQName portType = Names200403.WSA_OBJECT_FACTORY
+                .createAttributedQName();
+            portType.setValue(portQName);
+            exposed.setPortType(portType);
+        }
+        // no direct analogue for Metadata
+        addAll(exposed.getAny(), internal.getAny());
+        putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
+        return exposed;
+    }
+    /**
      * Convert from 2004/08 EndpointReferenceType to 2005/08 
      * EndpointReferenceType.
      * 
@@ -188,6 +257,32 @@
     }
 
     /**
+     * Convert from 2004/03 EndpointReferenceType to 2005/08 EndpointReferenceType.
+     * 
+     * @param exposed the 2004/03 EndpointReferenceType
+     * @return an equivalent 2005/08 EndpointReferenceType
+     */
+    public static EndpointReferenceType 
+    convert(org.apache.cxf.ws.addressing.v200403.EndpointReferenceType exposed) {
+        EndpointReferenceType internal = ContextUtils.WSA_OBJECT_FACTORY.createEndpointReferenceType();
+        internal.setAddress(convert(exposed.getAddress()));
+        // TODO ref parameters not present in 2004/03
+        // internal.setReferenceParameters(convert(exposed
+        // .getReferenceParameters()));
+        org.apache.cxf.ws.addressing.v200403.ServiceNameType serviceName = exposed.getServiceName();
+        org.apache.cxf.ws.addressing.v200403.AttributedQName portName = exposed.getPortType();
+        if (serviceName != null && portName != null) {
+            EndpointReferenceUtils.setServiceAndPortName(internal, serviceName.getValue(), portName
+                .getValue().getLocalPart());
+        }
+
+        // no direct analogue for ReferenceProperties
+        addAll(internal.getAny(), exposed.getAny());
+        putAll(internal.getOtherAttributes(), exposed.getOtherAttributes());
+        return internal;
+    }    
+    
+    /**
      * Convert from 2005/08 ReferenceParametersType to 2004/08
      * ReferenceParametersType.
      * 
@@ -223,6 +318,7 @@
         }
         return internal; 
     }
+     // THERE IS NO ReferenceParametersType for 2004/03
 
     /**
      * Convert from 2005/08 RelatesToType to 2004/08 Relationship.
@@ -249,7 +345,30 @@
     }
 
     /**
-     * Convert from 2004/08 Relationship to 2005/08 RelatesToType.
+     * Convert from 2005/08 RelatesToType to 2004/03 Relationship.
+     * 
+     * @param internal the 2005/08 RelatesToType
+     * @return an equivalent 2004/03 Relationship
+     */
+    public static org.apache.cxf.ws.addressing.v200403.Relationship convertTo200403(RelatesToType internal) {
+        org.apache.cxf.ws.addressing.v200403.Relationship exposed = null;
+        if (internal != null) {
+            exposed = Names200403.WSA_OBJECT_FACTORY.createRelationship();
+            exposed.setValue(internal.getValue());
+            String internalRelationshipType = internal.getRelationshipType();
+            if (internalRelationshipType != null) {
+                QName exposedRelationshipType = null;
+                if (!Names.WSA_RELATIONSHIP_REPLY.equals(internalRelationshipType)) {
+                    exposedRelationshipType = new QName(internalRelationshipType);
+                }
+                exposed.setRelationshipType(exposedRelationshipType);
+            }
+            putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
+        }
+        return exposed;
+    }
+    
+    /** Convert from 2004/08 Relationship to 2005/08 RelatesToType.
      * 
      * @param exposed the 2004/08 Relationship
      * @return an equivalent 2005/08 RelatesToType
@@ -273,15 +392,38 @@
         return internal; 
     }
     
-    /** 
+    /**
+     * Convert from 2004/03 Relationship to 2005/08 RelatesToType.
+     * 
+     * @param exposed the 2004/03 Relationship
+     * @return an equivalent 2005/08 RelatesToType
+     */
+    public static RelatesToType convert(org.apache.cxf.ws.addressing.v200403.Relationship exposed) {
+        RelatesToType internal = null;
+        if (exposed != null) {
+            internal = ContextUtils.WSA_OBJECT_FACTORY.createRelatesToType();
+            internal.setValue(exposed.getValue());
+            QName exposedRelationshipType = exposed.getRelationshipType();
+            if (exposedRelationshipType != null) {
+                String internalRelationshipType = Names.WSA_REPLY_NAME.equals(exposedRelationshipType
+                    .getLocalPart()) ? Names.WSA_RELATIONSHIP_REPLY : exposedRelationshipType.toString();
+                internal.setRelationshipType(internalRelationshipType);
+            }
+            internal.getOtherAttributes().putAll(exposed.getOtherAttributes());
+        }
+        return internal;
+    }
+
+    /**
      * @param exposedURI specifies the version WS-Addressing
      * @return JABXContext for the exposed namespace URI
      */
-    public static JAXBContext getExposedJAXBContext(String exposedURI) 
-        throws JAXBException {
+    public static JAXBContext getExposedJAXBContext(String exposedURI) throws JAXBException {
+
         return NATIVE_VERSION.equals(exposedURI)
-               ? ContextUtils.getJAXBContext()
-               : Names200408.getJAXBContext();
+            ? ContextUtils.getJAXBContext() : Names200408.WSA_NAMESPACE_NAME.equals(exposedURI) ? Names200408
+                .getJAXBContext() : Names200403.WSA_NAMESPACE_NAME.equals(exposedURI) ? Names200403
+                .getJAXBContext() : null;
     }
 
     /**
@@ -358,4 +500,49 @@
             }
         }        
     }
+    /**
+     * Holder for 2004/03 Names
+     */
+    public static class Names200403 {
+        public static final String WSA_NAMESPACE_NAME = "http://schemas.xmlsoap.org/ws/2004/03/addressing";
+        public static final String WSA_ANONYMOUS_ADDRESS = WSA_NAMESPACE_NAME + "/role/anonymous";
+        public static final String WSA_NONE_ADDRESS = WSA_NAMESPACE_NAME + "/role/none";
+        public static final org.apache.cxf.ws.addressing.v200403.ObjectFactory WSA_OBJECT_FACTORY = 
+            new org.apache.cxf.ws.addressing.v200403.ObjectFactory();
+        public static final Class<org.apache.cxf.ws.addressing.v200403.EndpointReferenceType> EPR_TYPE = 
+            org.apache.cxf.ws.addressing.v200403.EndpointReferenceType.class;
+
+        private static JAXBContext jaxbContext;
+
+        protected Names200403() {
+        }
+
+        /**
+         * Retrieve a JAXBContext for marshalling and unmarshalling JAXB generated types for the 2004/08
+         * version.
+         * 
+         * @return a JAXBContext
+         */
+        public static JAXBContext getJAXBContext() throws JAXBException {
+            synchronized (Names200403.class) {
+                if (jaxbContext == null) {
+                    Class clz = org.apache.cxf.ws.addressing.v200403.ObjectFactory.class;
+                    jaxbContext = JAXBContext.newInstance(clz.getPackage().getName(), clz.getClassLoader());
+                }
+            }
+            return jaxbContext;
+        }
+
+        /**
+         * Set the encapsulated JAXBContext (used by unit tests).
+         * 
+         * @param ctx JAXBContext
+         */
+        public static void setJAXBContext(JAXBContext ctx) throws JAXBException {
+            synchronized (Names200403.class) {
+                jaxbContext = ctx;
+            }
+        }
+    }
+
 }

Modified: cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/VersionTransformer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/VersionTransformer.java?rev=687067&r1=687066&r2=687067&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/VersionTransformer.java (original)
+++ cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/VersionTransformer.java Tue Aug 19 07:48:57 2008
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.ws.addressing.soap;
 
-
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -31,12 +30,7 @@
 import javax.xml.namespace.QName;
 
 import org.w3c.dom.Element;
-
 import org.apache.cxf.common.logging.LogUtils;
-
-// importation convention: if the same class name is used for 
-// 2005/08 and 2004/08, then the former version is imported
-// and the latter is fully qualified when used
 import org.apache.cxf.ws.addressing.AttributedURIType;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.apache.cxf.ws.addressing.Names;
@@ -44,36 +38,27 @@
 import org.apache.cxf.ws.addressing.v200408.AttributedURI;
 import org.apache.cxf.ws.addressing.v200408.Relationship;
 
-
 /**
- * This class is responsible for transforming between the native 
- * WS-Addressing schema version (i.e. 2005/08) and exposed
- * version (currently may be 2005/08 or 2004/08).
+ * This class is responsible for transforming between the native WS-Addressing schema version (i.e. 2005/08)
+ * and exposed version (currently may be 2005/08 or 2004/08).
  * <p>
- * The native version is that used throughout the stack, were the
- * WS-A types are represented via the JAXB generated types for the
- * 2005/08 schema.
+ * The native version is that used throughout the stack, were the WS-A types are represented via the JAXB
+ * generated types for the 2005/08 schema.
  * <p>
- * The exposed version is that used when the WS-A types are 
- * externalized, i.e. are encoded in the headers of outgoing 
- * messages. For outgoing requests, the exposed version is 
- * determined from configuration. For outgoing responses, the
- * exposed version is determined by the exposed version of
- * the corresponding request.
+ * The exposed version is that used when the WS-A types are externalized, i.e. are encoded in the headers of
+ * outgoing messages. For outgoing requests, the exposed version is determined from configuration. For
+ * outgoing responses, the exposed version is determined by the exposed version of the corresponding request.
  * <p>
- * The motivation for using different native and exposed types
- * is usually to facilitate a WS-* standard based on an earlier 
- * version of WS-Adressing (for example WS-RM depends on the
- * 2004/08 version).
+ * The motivation for using different native and exposed types is usually to facilitate a WS-* standard based
+ * on an earlier version of WS-Adressing (for example WS-RM depends on the 2004/08 version).
  */
-public class VersionTransformer 
-    extends org.apache.cxf.ws.addressing.VersionTransformer {
+public class VersionTransformer extends org.apache.cxf.ws.addressing.VersionTransformer {
 
     public static final Set<QName> HEADERS;
     private static final Logger LOG = LogUtils.getL7dLogger(VersionTransformer.class);
-    
+
     protected MAPCodec codec;
-    
+
     /**
      * Constructor.
      * 
@@ -82,69 +67,63 @@
     public VersionTransformer(MAPCodec mapCodec) {
         codec = mapCodec;
     }
-    
+
     /**
      * Encode message in exposed version.
      * 
      * @param exposeAs specifies the WS-Addressing version to expose
      * @param value the value to encode
-     * @param localName the localName for the header 
+     * @param localName the localName for the header
      * @param clz the class
      * @param header the SOAP header element
      * @param marshaller the JAXB marshaller to use
      */
-    public <T> void encodeAsExposed(String exposeAs,
-                                    T value,
-                                    String localName,
-                                    Class<T> clz,
-                                    Element header,
-                                    Marshaller marshaller) 
-        throws JAXBException {
+    public <T> void encodeAsExposed(String exposeAs, T value, String localName, Class<T> clz, Element header,
+                                    Marshaller marshaller) throws JAXBException {
         if (value != null) {
             if (NATIVE_VERSION.equals(exposeAs)) {
-                codec.encodeMAP(value,
-                                new QName(exposeAs, localName),
-                                clz,
-                                header,
-                                marshaller);
+                codec.encodeMAP(value, new QName(exposeAs, localName), clz, header, marshaller);
             } else if (Names200408.WSA_NAMESPACE_NAME.equals(exposeAs)) {
                 if (AttributedURIType.class.equals(clz)) {
-                    codec.encodeMAP(convert((AttributedURIType)value),
-                                    new QName(exposeAs, localName),
-                                    AttributedURI.class,
-                                    header,
-                                    marshaller);
+                    codec.encodeMAP(convert((AttributedURIType)value), new QName(exposeAs, localName),
+                                    AttributedURI.class, header, marshaller);
                 } else if (EndpointReferenceType.class.equals(clz)) {
-                    codec.encodeMAP(convert((EndpointReferenceType)value),
+                    codec.encodeMAP(convert((EndpointReferenceType)value), new QName(exposeAs, localName),
+                                    Names200408.EPR_TYPE, header, marshaller);
+                } else if (RelatesToType.class.equals(clz)) {
+                    codec.encodeMAP(convert((RelatesToType)value), new QName(exposeAs, localName),
+                                    Relationship.class, header, marshaller);
+                }
+            } else if (Names200403.WSA_NAMESPACE_NAME.equals(exposeAs)) {
+                if (AttributedURIType.class.equals(clz)) {
+                    codec.encodeMAP(convertTo200403((AttributedURIType)value),
                                     new QName(exposeAs, localName),
-                                    Names200408.EPR_TYPE,
-                                    header,
+                                    org.apache.cxf.ws.addressing.v200403.AttributedURI.class, header,
                                     marshaller);
+                } else if (EndpointReferenceType.class.equals(clz)) {
+                    codec.encodeMAP(convertTo200403((EndpointReferenceType)value), new QName(exposeAs,
+                                                                                             localName),
+                                    Names200403.EPR_TYPE, header, marshaller);
                 } else if (RelatesToType.class.equals(clz)) {
-                    codec.encodeMAP(convert((RelatesToType)value),
-                                    new QName(exposeAs, localName),
-                                    Relationship.class,
-                                    header,
+                    codec.encodeMAP(convertTo200403((RelatesToType)value), new QName(exposeAs, localName),
+                                    org.apache.cxf.ws.addressing.v200403.Relationship.class, header,
                                     marshaller);
                 }
-            } 
+            }
         }
     }
-    
+
     /**
      * Decodes a MAP from a exposed version.
-     *
+     * 
      * @param encodedAs specifies the encoded version
      * @param clz the class
      * @param headerElement the SOAP header element
      * @param marshaller the JAXB marshaller to use
      * @return the decoded value
      */
-    public <T> T decodeAsNative(String encodedAs,
-                                Class<T> clz,
-                                Element headerElement,
-                                Unmarshaller unmarshaller) 
-        throws JAXBException {
+    public <T> T decodeAsNative(String encodedAs, Class<T> clz, Element headerElement,
+                                Unmarshaller unmarshaller) throws JAXBException {
         T ret = null;
         LOG.fine("decodeAsNative: encodedAs: " + encodedAs);
         LOG.fine("                class: " + clz.getName());
@@ -153,60 +132,87 @@
             ret = codec.decodeMAP(clz, headerElement, unmarshaller);
         } else if (Names200408.WSA_NAMESPACE_NAME.equals(encodedAs)) {
             if (AttributedURIType.class.equals(clz)) {
-                return clz.cast(convert(codec.decodeMAP(AttributedURI.class, 
-                                                  headerElement, 
-                                                  unmarshaller)));
+                ret = clz.cast(convert(codec.decodeMAP(AttributedURI.class, headerElement, unmarshaller)));
+            } else if (EndpointReferenceType.class.equals(clz)) {
+                ret = clz.cast(convert(codec.decodeMAP(Names200408.EPR_TYPE, headerElement, unmarshaller)));
+            } else if (RelatesToType.class.equals(clz)) {
+                ret = clz.cast(convert(codec.decodeMAP(Relationship.class, headerElement, unmarshaller)));
+            }
+        } else if (Names200403.WSA_NAMESPACE_NAME.equals(encodedAs)) {
+            if (AttributedURIType.class.equals(clz)) {
+                ret = clz.cast(convert(codec
+                    .decodeMAP(org.apache.cxf.ws.addressing.v200403.AttributedURI.class, headerElement,
+                               unmarshaller)));
             } else if (EndpointReferenceType.class.equals(clz)) {
-                return clz.cast(convert(codec.decodeMAP(Names200408.EPR_TYPE, 
-                                                  headerElement, 
-                                                  unmarshaller)));
-            }  else if (RelatesToType.class.equals(clz)) {
-                return clz.cast(convert(codec.decodeMAP(Relationship.class, 
-                                                  headerElement, 
-                                                  unmarshaller)));
-            }           
+                ret = clz.cast(convert(codec.decodeMAP(Names200403.EPR_TYPE, headerElement, unmarshaller)));
+            } else if (RelatesToType.class.equals(clz)) {
+                ret = clz.cast(convert(codec
+                    .decodeMAP(org.apache.cxf.ws.addressing.v200403.Relationship.class, headerElement,
+                               unmarshaller)));
+            }
         }
         return ret;
     }
-           
+
     /**
-     * Augment the set of headers understood by the protocol binding
-     * with the 2004/08 header QNames.
+     * Augment the set of headers understood by the protocol binding with the 2004/08 header QNames.
      */
     static {
         Set<QName> headers = new HashSet<QName>();
         headers.addAll(Names.HEADERS);
         Names200408.addHeaders(headers);
+        Names200403.addHeaders(headers);
         HEADERS = Collections.unmodifiableSet(headers);
     }
-    
+
     /**
      * Holder for 2004/08 Names
      */
     public static final class Names200408 
         extends org.apache.cxf.ws.addressing.VersionTransformer.Names200408 {
-        
+
         protected Names200408() {
         }
-        
+
         /**
          * Adds 2004/08 headers to set.
          * 
          * @param headers set of headers
          */
         private static void addHeaders(Set<QName> headers) {
-            headers.add(new QName(WSA_NAMESPACE_NAME, 
-                                  Names.WSA_FROM_NAME));
-            headers.add(new QName(WSA_NAMESPACE_NAME, 
-                                  Names.WSA_TO_NAME));
-            headers.add(new QName(WSA_NAMESPACE_NAME, 
-                                  Names.WSA_REPLYTO_NAME));
-            headers.add(new QName(WSA_NAMESPACE_NAME, 
-                                  Names.WSA_FAULTTO_NAME));
-            headers.add(new QName(WSA_NAMESPACE_NAME, 
-                                  Names.WSA_ACTION_NAME));
-            headers.add(new QName(WSA_NAMESPACE_NAME, 
-                                  Names.WSA_MESSAGEID_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_FROM_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_TO_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_REPLYTO_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_FAULTTO_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_ACTION_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_MESSAGEID_NAME));
         }
     }
+
+    /**
+     * Adds 2004/03 headers to set.
+     * 
+     * @param headers set of headers
+     */
+    public static final class Names200403 
+        extends org.apache.cxf.ws.addressing.VersionTransformer.Names200403 {
+
+        protected Names200403() {
+        }
+
+        /**
+         * Adds 2004/08 headers to set.
+         * 
+         * @param headers set of headers
+         */
+        private static void addHeaders(Set<QName> headers) {
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_FROM_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_TO_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_REPLYTO_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_FAULTTO_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_ACTION_NAME));
+            headers.add(new QName(WSA_NAMESPACE_NAME, Names.WSA_MESSAGEID_NAME));
+        }
+    }
+
 }

Modified: cxf/branches/2.0.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java?rev=687067&r1=687066&r2=687067&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java (original)
+++ cxf/branches/2.0.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/soap/MAPCodecTest.java Tue Aug 19 07:48:57 2008
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.ws.addressing.soap;
 
-
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -35,7 +34,6 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 
-
 import org.apache.cxf.binding.soap.SoapConstants;
 import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -69,7 +67,6 @@
 import static org.apache.cxf.ws.addressing.JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND;
 import static org.apache.cxf.ws.addressing.JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND;
 
-
 public class MAPCodecTest extends Assert {
 
     private MAPCodec codec;
@@ -103,28 +100,57 @@
     @Test
     public void testGetHeaders() throws Exception {
         Set<QName> headers = codec.getUnderstoodHeaders();
-        assertTrue("expected From header", 
-                   headers.contains(Names.WSA_FROM_QNAME));
-        assertTrue("expected To header", 
-                   headers.contains(Names.WSA_TO_QNAME));
-        assertTrue("expected ReplyTo header", 
-                   headers.contains(Names.WSA_REPLYTO_QNAME));
-        assertTrue("expected FaultTo header", 
-                   headers.contains(Names.WSA_FAULTTO_QNAME));
-        assertTrue("expected Action header", 
-                   headers.contains(Names.WSA_ACTION_QNAME));
-        assertTrue("expected MessageID header", 
-                   headers.contains(Names.WSA_MESSAGEID_QNAME));
+        assertTrue("expected From header", headers.contains(Names.WSA_FROM_QNAME));
+        assertTrue("expected To header", headers.contains(Names.WSA_TO_QNAME));
+        assertTrue("expected ReplyTo header", headers.contains(Names.WSA_REPLYTO_QNAME));
+        assertTrue("expected FaultTo header", headers.contains(Names.WSA_FAULTTO_QNAME));
+        assertTrue("expected Action header", headers.contains(Names.WSA_ACTION_QNAME));
+        assertTrue("expected MessageID header", headers.contains(Names.WSA_MESSAGEID_QNAME));
+    }
+
+    @Test
+    public void testRequestorInboundNonNative200403() throws Exception {
+        String uri = VersionTransformer.Names200403.WSA_NAMESPACE_NAME;
+        SoapMessage message = setUpMessage(true, false, false, false, uri);
+        codec.handleMessage(message);
+        control.verify();
+        verifyMessage(message, true, false, false);
+    }
+
+    @Test
+    public void testResponderInboundNonNative200403() throws Exception {
+        String uri = VersionTransformer.Names200403.WSA_NAMESPACE_NAME;
+        SoapMessage message = setUpMessage(false, false, false, false, uri);
+        codec.handleMessage(message);
+        control.verify();
+        verifyMessage(message, false, false, false);
     }
 
     @Test
+    public void testRequestorOutboundNonNative200403() throws Exception {
+        String uri = VersionTransformer.Names200403.WSA_NAMESPACE_NAME;
+        SoapMessage message = setUpMessage(true, true, false, false, uri);
+        codec.handleMessage(message);
+        control.verify();
+        verifyMessage(message, true, true, false);
+    }
+
+    @Test
+    public void testResponderOutboundNonNative200403() throws Exception {
+        String uri = VersionTransformer.Names200403.WSA_NAMESPACE_NAME;
+        SoapMessage message = setUpMessage(false, true, false, false, uri);
+        codec.handleMessage(message);
+        control.verify();
+        verifyMessage(message, false, true, false);
+    }
+
     public void testRequestorOutbound() throws Exception {
         SoapMessage message = setUpMessage(true, true);
         codec.handleMessage(message);
         control.verify();
         verifyMessage(message, true, true, true);
     }
-    
+
     @Test
     public void testRequestorOutboundPreExistingSOAPAction() throws Exception {
         SoapMessage message = setUpMessage(true, true, false, true);
@@ -133,17 +159,16 @@
         control.verify();
         verifyMessage(message, true, true, true);
     }
-    
+
     @Test
     public void testRequestorOutboundNonNative() throws Exception {
         String uri = VersionTransformer.Names200408.WSA_NAMESPACE_NAME;
-        SoapMessage message = 
-            setUpMessage(true, true, false, false, uri);
+        SoapMessage message = setUpMessage(true, true, false, false, uri);
         codec.handleMessage(message);
         control.verify();
         verifyMessage(message, true, true, false);
     }
-    
+
     @Test
     public void testResponderInbound() throws Exception {
         SoapMessage message = setUpMessage(false, false);
@@ -159,17 +184,16 @@
         control.verify();
         verifyMessage(message, false, true, true);
     }
-    
+
     @Test
     public void testResponderInboundNonNative() throws Exception {
         String uri = VersionTransformer.Names200408.WSA_NAMESPACE_NAME;
-        SoapMessage message = 
-            setUpMessage(false, false, false, false, uri);
+        SoapMessage message = setUpMessage(false, false, false, false, uri);
         codec.handleMessage(message);
         control.verify();
         verifyMessage(message, false, false, false);
     }
-    
+
     @Test
     public void testResponderOutboundInvalidMAP() throws Exception {
         SoapMessage message = setUpMessage(false, true, true);
@@ -177,14 +201,12 @@
             codec.handleMessage(message);
             fail("expected SOAPFaultException on invalid MAP");
         } catch (SoapFault sfe) {
-            assertEquals("unexpected fault string",
-                         "Duplicate Message ID urn:uuid:12345", 
-                         sfe.getMessage());
+            assertEquals("unexpected fault string", "Duplicate Message ID urn:uuid:12345", sfe.getMessage());
         }
         control.verify();
         verifyMessage(message, false, true, true);
     }
-    
+
     @Test
     public void testResponderOutboundPreExistingSOAPAction() throws Exception {
         SoapMessage message = setUpMessage(false, true, false, true);
@@ -197,13 +219,12 @@
     @Test
     public void testResponderOutboundNonNative() throws Exception {
         String uri = VersionTransformer.Names200408.WSA_NAMESPACE_NAME;
-        SoapMessage message = 
-            setUpMessage(false, true, false, false, uri);
+        SoapMessage message = setUpMessage(false, true, false, false, uri);
         codec.handleMessage(message);
         control.verify();
         verifyMessage(message, false, true, false);
     }
-    
+
     @Test
     public void testRequestorInbound() throws Exception {
         SoapMessage message = setUpMessage(true, false);
@@ -211,51 +232,32 @@
         control.verify();
         verifyMessage(message, true, false, true);
     }
-    
+
     @Test
     public void testRequestorInboundNonNative() throws Exception {
         String uri = VersionTransformer.Names200408.WSA_NAMESPACE_NAME;
-        SoapMessage message = 
-            setUpMessage(true, false, false, false, uri);
+        SoapMessage message = setUpMessage(true, false, false, false, uri);
         codec.handleMessage(message);
         control.verify();
         verifyMessage(message, true, false, false);
     }
 
-    private SoapMessage setUpMessage(boolean requestor, 
-                                     boolean outbound)
-        throws Exception {
-        return setUpMessage(requestor, outbound, false); 
+    private SoapMessage setUpMessage(boolean requestor, boolean outbound) throws Exception {
+        return setUpMessage(requestor, outbound, false);
     }
 
-    private SoapMessage setUpMessage(boolean requestor, 
-                                     boolean outbound,
-                                     boolean invalidMAP) 
+    private SoapMessage setUpMessage(boolean requestor, boolean outbound, boolean invalidMAP)
         throws Exception {
-        return setUpMessage(requestor, 
-                            outbound,
-                            invalidMAP,
-                            false);
+        return setUpMessage(requestor, outbound, invalidMAP, false);
     }
 
-    private SoapMessage setUpMessage(boolean requestor, 
-                                     boolean outbound,
-                                     boolean invalidMAP,
-                                     boolean preExistingSOAPAction) 
-        throws Exception {
-        return setUpMessage(requestor, 
-                            outbound,
-                            invalidMAP,
-                            preExistingSOAPAction,
-                            Names.WSA_NAMESPACE_NAME);
+    private SoapMessage setUpMessage(boolean requestor, boolean outbound, boolean invalidMAP,
+                                     boolean preExistingSOAPAction) throws Exception {
+        return setUpMessage(requestor, outbound, invalidMAP, preExistingSOAPAction, Names.WSA_NAMESPACE_NAME);
     }
 
-    private SoapMessage setUpMessage(boolean requestor, 
-                                     boolean outbound,
-                                     boolean invalidMAP,
-                                     boolean preExistingSOAPAction,
-                                     String exposeAs) 
-        throws Exception {
+    private SoapMessage setUpMessage(boolean requestor, boolean outbound, boolean invalidMAP,
+                                     boolean preExistingSOAPAction, String exposeAs) throws Exception {
         SoapMessage message = new SoapMessage(new MessageImpl());
         setUpOutbound(message, outbound);
         expectRelatesTo = (requestor && !outbound) || (!requestor && outbound);
@@ -272,14 +274,9 @@
         JAXBContext jaxbContext = control.createMock(JAXBContext.class);
         ContextUtils.setJAXBContext(jaxbContext);
         VersionTransformer.Names200408.setJAXBContext(jaxbContext);
+        VersionTransformer.Names200403.setJAXBContext(jaxbContext);
         if (outbound) {
-            setUpEncode(requestor,
-                        message,
-                        header,
-                        maps,
-                        mapProperty,
-                        invalidMAP,
-                        preExistingSOAPAction);
+            setUpEncode(requestor, message, header, maps, mapProperty, invalidMAP, preExistingSOAPAction);
         } else {
             setUpDecode(message, headers, maps, mapProperty, requestor);
         }
@@ -287,13 +284,9 @@
         return message;
     }
 
-    private void setUpEncode(boolean requestor,
-                             SoapMessage message,
-                             Element header,
-                             AddressingPropertiesImpl maps,
-                             String mapProperty,
-                             boolean invalidMAP,
-                             boolean preExistingSOAPAction) throws Exception { 
+    private void setUpEncode(boolean requestor, SoapMessage message, Element header,
+                             AddressingPropertiesImpl maps, String mapProperty, boolean invalidMAP,
+                             boolean preExistingSOAPAction) throws Exception {
         message.put(mapProperty, maps);
         Marshaller marshaller = control.createMock(Marshaller.class);
         ContextUtils.getJAXBContext().createMarshaller();
@@ -301,16 +294,14 @@
         marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
         EasyMock.expectLastCall();
         IArgumentMatcher matcher = new JAXBEltMatcher();
-        int expectedMarshals = requestor 
-                               ? expectedValues.length - 1
-                               : expectedValues.length;
+        int expectedMarshals = requestor ? expectedValues.length - 1 : expectedValues.length;
         for (int i = 0; i < expectedMarshals; i++) {
             EasyMock.reportMatcher(matcher);
             EasyMock.eq(header);
             marshaller.marshal(null, header);
             EasyMock.expectLastCall();
         }
-        
+
         NodeList children = control.createMock(NodeList.class);
         header.getChildNodes();
         EasyMock.expectLastCall().andReturn(children);
@@ -321,17 +312,15 @@
             children.item(i);
             EasyMock.expectLastCall().andReturn(child);
             /*
-            child.setAttributeNS(EasyMock.eq("http://www.w3.org/2000/xmlns/"),
-                                 EasyMock.eq("xmlns:wsa"),
-                                 EasyMock.eq(maps.getNamespaceURI()));
-            EasyMock.expectLastCall();
-            */
+             * child.setAttributeNS(EasyMock.eq("http://www.w3.org/2000/xmlns/"), EasyMock.eq("xmlns:wsa"),
+             * EasyMock.eq(maps.getNamespaceURI())); EasyMock.expectLastCall();
+             */
             child.getNamespaceURI();
             EasyMock.expectLastCall().andReturn(expectedNames[i].getNamespaceURI());
             child.getLocalName();
             EasyMock.expectLastCall().andReturn(expectedNames[i].getLocalPart());
         }
-        
+
         mimeHeaders = new HashMap<String, List<String>>();
         message.put(MIME_HEADERS, mimeHeaders);
         if (preExistingSOAPAction) {
@@ -340,84 +329,46 @@
             mimeHeaders.put(SoapConstants.SOAP_ACTION, soapAction);
         }
         if (invalidMAP) {
-            message.put("org.apache.cxf.ws.addressing.map.fault.name",
-                        Names.DUPLICATE_MESSAGE_ID_NAME);
+            message.put("org.apache.cxf.ws.addressing.map.fault.name", Names.DUPLICATE_MESSAGE_ID_NAME);
             message.put("org.apache.cxf.ws.addressing.map.fault.reason",
                         "Duplicate Message ID urn:uuid:12345");
         }
     }
-    
-    private void setUpDecode(SoapMessage message, 
-                             List<Header> headers,
-                             AddressingPropertiesImpl maps,
-                             String mapProperty,
-                             boolean requestor) throws Exception {
+
+    private void setUpDecode(SoapMessage message, List<Header> headers, AddressingPropertiesImpl maps,
+                             String mapProperty, boolean requestor) throws Exception {
         Unmarshaller unmarshaller = control.createMock(Unmarshaller.class);
         ContextUtils.getJAXBContext().createUnmarshaller();
         EasyMock.expectLastCall().andReturn(unmarshaller);
         String uri = maps.getNamespaceURI();
         boolean exposedAsNative = Names.WSA_NAMESPACE_NAME.equals(uri);
-        boolean exposedAs200408 = 
-            VersionTransformer.Names200408.WSA_NAMESPACE_NAME.equals(uri);
-        assertTrue("unexpected namescape URI: " + uri, 
-                   exposedAsNative || exposedAs200408);
-        setUpHeaderDecode(headers,
-                          uri,
-                          Names.WSA_MESSAGEID_NAME,
-                          exposedAsNative
-                          ? AttributedURIType.class
-                          : AttributedURI.class,
-                          0,
-                          unmarshaller);
-        setUpHeaderDecode(headers,
-                          uri,
-                          Names.WSA_TO_NAME,
-                          exposedAsNative
-                          ? AttributedURIType.class
-                          : AttributedURI.class,
-                          1,
-                          unmarshaller);
-        setUpHeaderDecode(headers,
-                          uri,
-                          Names.WSA_REPLYTO_NAME,
-                          exposedAsNative
-                          ? EndpointReferenceType.class
-                          : VersionTransformer.Names200408.EPR_TYPE,
-                          2,
-                          unmarshaller);
-        setUpHeaderDecode(headers,
-                          uri,
-                          Names.WSA_FAULTTO_NAME,
-                          exposedAsNative
-                          ? EndpointReferenceType.class
-                          : VersionTransformer.Names200408.EPR_TYPE,
-                          3,
-                          unmarshaller);
-        setUpHeaderDecode(headers,
-                          uri,
-                          Names.WSA_RELATESTO_NAME,
-                          exposedAsNative
-                          ? RelatesToType.class
-                          : Relationship.class,
-                          4,
-                          unmarshaller);
-        setUpHeaderDecode(headers,
-                          uri,
-                          Names.WSA_ACTION_NAME,
-                          exposedAsNative
-                          ? AttributedURIType.class
-                          : AttributedURI.class,
-                          5,
-                          unmarshaller);
-    }
-
-    private <T> void setUpHeaderDecode(List<Header> headers,
-                                       String uri,
-                                       String name,
-                                       Class<T> clz,
-                                       int index,
-                                       Unmarshaller unmarshaller) 
-        throws Exception { 
+        boolean exposedAs200408 = VersionTransformer.Names200408.WSA_NAMESPACE_NAME.equals(uri);
+        boolean exposedAs200403 = VersionTransformer.Names200403.WSA_NAMESPACE_NAME.equals(uri);
+        assertTrue("unexpected namescape URI: " + uri, exposedAsNative || exposedAs200408 || exposedAs200403);
+        setUpHeaderDecode(headers, uri, Names.WSA_MESSAGEID_NAME, exposedAsNative
+            ? AttributedURIType.class : exposedAs200408 ? AttributedURI.class : exposedAs200403
+                ? org.apache.cxf.ws.addressing.v200403.AttributedURI.class : null, 0, unmarshaller);
+        setUpHeaderDecode(headers, uri, Names.WSA_TO_NAME, exposedAsNative
+            ? AttributedURIType.class : exposedAs200408 ? AttributedURI.class : exposedAs200403
+                ? org.apache.cxf.ws.addressing.v200403.AttributedURI.class : null, 1, unmarshaller);
+        setUpHeaderDecode(headers, uri, Names.WSA_REPLYTO_NAME, exposedAsNative
+            ? EndpointReferenceType.class : exposedAs200408
+                ? VersionTransformer.Names200408.EPR_TYPE : exposedAs200403
+                    ? VersionTransformer.Names200403.EPR_TYPE : null, 2, unmarshaller);
+        setUpHeaderDecode(headers, uri, Names.WSA_FAULTTO_NAME, exposedAsNative
+            ? EndpointReferenceType.class : exposedAs200408
+                ? VersionTransformer.Names200408.EPR_TYPE : exposedAs200403
+                    ? VersionTransformer.Names200403.EPR_TYPE : null, 3, unmarshaller);
+        setUpHeaderDecode(headers, uri, Names.WSA_RELATESTO_NAME, exposedAsNative
+            ? RelatesToType.class : exposedAs200408 ? Relationship.class : exposedAs200403
+                ? org.apache.cxf.ws.addressing.v200403.Relationship.class : null, 4, unmarshaller);
+        setUpHeaderDecode(headers, uri, Names.WSA_ACTION_NAME, exposedAsNative
+            ? AttributedURIType.class : exposedAs200408 ? AttributedURI.class : exposedAs200403
+                ? org.apache.cxf.ws.addressing.v200403.AttributedURI.class : null, 5, unmarshaller);
+    }
+
+    private <T> void setUpHeaderDecode(List<Header> headers, String uri, String name, Class<T> clz,
+                                       int index, Unmarshaller unmarshaller) throws Exception {
         Element headerElement = control.createMock(Element.class);
         headers.add(new Header(new QName(uri, name), headerElement));
         headerElement.getNamespaceURI();
@@ -425,117 +376,118 @@
         headerElement.getLocalName();
         EasyMock.expectLastCall().andReturn(name);
         Object v = expectedValues[index];
-        JAXBElement<?> jaxbElement = 
-            new JAXBElement<T>(new QName(uri, name), clz, clz.cast(v));
+        JAXBElement<?> jaxbElement = new JAXBElement<T>(new QName(uri, name), clz, clz.cast(v));
         unmarshaller.unmarshal(headerElement, clz);
         EasyMock.expectLastCall().andReturn(jaxbElement);
     }
-    
+
     private void setUpOutbound(Message message, boolean outbound) {
         Exchange exchange = new ExchangeImpl();
         exchange.setOutMessage(outbound ? message : new MessageImpl());
         message.setExchange(exchange);
     }
 
-    private String getMAPProperty(boolean requestor, boolean outbound) { 
-        return requestor
-               ? outbound
-                 ? CLIENT_ADDRESSING_PROPERTIES_OUTBOUND
-                 : CLIENT_ADDRESSING_PROPERTIES_INBOUND
-               : outbound
-                 ? SERVER_ADDRESSING_PROPERTIES_OUTBOUND
-                 : SERVER_ADDRESSING_PROPERTIES_INBOUND;
+    private String getMAPProperty(boolean requestor, boolean outbound) {
+        return requestor ? outbound
+            ? CLIENT_ADDRESSING_PROPERTIES_OUTBOUND : CLIENT_ADDRESSING_PROPERTIES_INBOUND : outbound
+            ? SERVER_ADDRESSING_PROPERTIES_OUTBOUND : SERVER_ADDRESSING_PROPERTIES_INBOUND;
     }
 
-    private AddressingPropertiesImpl getMAPs(boolean requestor,
-                                             boolean outbound,
-                                             String uri) {
+    private AddressingPropertiesImpl getMAPs(boolean requestor, boolean outbound, String uri) {
         AddressingPropertiesImpl maps = new AddressingPropertiesImpl();
         boolean exposeAsNative = Names.WSA_NAMESPACE_NAME.equals(uri);
-        boolean exposeAs200408 = 
-            VersionTransformer.Names200408.WSA_NAMESPACE_NAME.equals(uri);
-        AttributedURIType id = 
-            ContextUtils.getAttributedURI("urn:uuid:12345");
+        boolean exposeAs200408 = VersionTransformer.Names200408.WSA_NAMESPACE_NAME.equals(uri);
+        boolean exposeAs200403 = VersionTransformer.Names200403.WSA_NAMESPACE_NAME.equals(uri);
+
+        AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345");
         maps.setMessageID(id);
-        AttributedURIType to =
-            ContextUtils.getAttributedURI("foobar");
+        AttributedURIType to = ContextUtils.getAttributedURI("foobar");
         EndpointReferenceType toEpr = EndpointReferenceUtils.getEndpointReference(to);
         maps.setTo(toEpr);
         EndpointReferenceType replyTo = new EndpointReferenceType();
-        String anonymous = 
-            exposeAsNative
-            ? Names.WSA_ANONYMOUS_ADDRESS
-            : VersionTransformer.Names200408.WSA_ANONYMOUS_ADDRESS;
-        replyTo.setAddress(
-            ContextUtils.getAttributedURI(anonymous));
+        String anonymous = exposeAsNative ? Names.WSA_ANONYMOUS_ADDRESS : exposeAs200408
+            ? VersionTransformer.Names200408.WSA_ANONYMOUS_ADDRESS
+            : VersionTransformer.Names200403.WSA_ANONYMOUS_ADDRESS;
+        replyTo.setAddress(ContextUtils.getAttributedURI(anonymous));
         maps.setReplyTo(replyTo);
         EndpointReferenceType faultTo = new EndpointReferenceType();
-        anonymous = 
-            exposeAsNative
-            ? Names.WSA_ANONYMOUS_ADDRESS
-            : VersionTransformer.Names200408.WSA_ANONYMOUS_ADDRESS;
-        faultTo.setAddress(
-            ContextUtils.getAttributedURI(anonymous));
+        anonymous = exposeAsNative ? Names.WSA_ANONYMOUS_ADDRESS : exposeAs200408
+            ? VersionTransformer.Names200408.WSA_ANONYMOUS_ADDRESS
+            : VersionTransformer.Names200403.WSA_ANONYMOUS_ADDRESS;
+        faultTo.setAddress(ContextUtils.getAttributedURI(anonymous));
         maps.setFaultTo(faultTo);
         RelatesToType relatesTo = null;
         if (expectRelatesTo) {
             String correlationID = "urn:uuid:67890";
-            relatesTo = new RelatesToType(); 
+            relatesTo = new RelatesToType();
             relatesTo.setValue(correlationID);
             maps.setRelatesTo(relatesTo);
             correlatedExchange = new ExchangeImpl();
             codec.uncorrelatedExchanges.put(correlationID, correlatedExchange);
         }
-        AttributedURIType action = 
-            ContextUtils.getAttributedURI("http://foo/bar/SEI/opRequest");
+        AttributedURIType action = ContextUtils.getAttributedURI("http://foo/bar/SEI/opRequest");
         maps.setAction(action);
         maps.exposeAs(uri);
         expectedNamespaceURI = uri;
 
-        expectedNames = 
-            new QName[] {new QName(uri, Names.WSA_MESSAGEID_NAME), 
-                         new QName(uri, Names.WSA_TO_NAME), 
-                         new QName(uri, Names.WSA_REPLYTO_NAME),
-                         new QName(uri, Names.WSA_FAULTTO_NAME),
-                         new QName(uri, Names.WSA_RELATESTO_NAME),
-                         new QName(uri, Names.WSA_ACTION_NAME)};
+        expectedNames = new QName[] {
+            new QName(uri, Names.WSA_MESSAGEID_NAME), new QName(uri, Names.WSA_TO_NAME),
+            new QName(uri, Names.WSA_REPLYTO_NAME), new QName(uri, Names.WSA_FAULTTO_NAME),
+            new QName(uri, Names.WSA_RELATESTO_NAME), new QName(uri, Names.WSA_ACTION_NAME)
+        };
         if (exposeAsNative) {
-            expectedValues = new Object[] {id, to, replyTo, faultTo, relatesTo, action};
-            expectedDeclaredTypes = 
-                new Class<?>[] {AttributedURIType.class,
-                                AttributedURIType.class,
-                                EndpointReferenceType.class,
-                                EndpointReferenceType.class,
-                                RelatesToType.class, 
-                                AttributedURIType.class};
+            expectedValues = new Object[] {
+                id, to, replyTo, faultTo, relatesTo, action
+            };
+            expectedDeclaredTypes = new Class<?>[] {
+                AttributedURIType.class, AttributedURIType.class, EndpointReferenceType.class,
+                EndpointReferenceType.class, RelatesToType.class, AttributedURIType.class
+            };
         } else if (exposeAs200408) {
-            expectedValues = new Object[] {VersionTransformer.convert(id),
-                                           VersionTransformer.convert(to),
-                                           VersionTransformer.convert(replyTo),
-                                           VersionTransformer.convert(faultTo),
-                                           VersionTransformer.convert(relatesTo),
-                                           VersionTransformer.convert(action)};
+            expectedValues = new Object[] {
+                VersionTransformer.convert(id), VersionTransformer.convert(to),
+                VersionTransformer.convert(replyTo), VersionTransformer.convert(faultTo),
+                VersionTransformer.convert(relatesTo), VersionTransformer.convert(action)
+            };
             if (!outbound) {
                 // conversion from 2004/08 to 2005/08 anonymous address
                 // occurs transparently in VersionTransformer
-                VersionTransformer.Names200408.EPR_TYPE.cast(expectedValues[2]).
-                    getAddress().setValue(Names.WSA_ANONYMOUS_ADDRESS);
-                VersionTransformer.Names200408.EPR_TYPE.cast(expectedValues[3]).
-                    getAddress().setValue(Names.WSA_ANONYMOUS_ADDRESS);    
+                VersionTransformer.Names200408.EPR_TYPE.cast(expectedValues[2]).getAddress()
+                    .setValue(Names.WSA_ANONYMOUS_ADDRESS);
+                VersionTransformer.Names200408.EPR_TYPE.cast(expectedValues[3]).getAddress()
+                    .setValue(Names.WSA_ANONYMOUS_ADDRESS);
             }
-            expectedDeclaredTypes = 
-                new Class<?>[] {AttributedURI.class,
-                                AttributedURI.class,
-                                VersionTransformer.Names200408.EPR_TYPE,
-                                VersionTransformer.Names200408.EPR_TYPE,
-                                Relationship.class, 
-                                AttributedURI.class};
+            expectedDeclaredTypes = new Class<?>[] {
+                AttributedURI.class, AttributedURI.class, VersionTransformer.Names200408.EPR_TYPE,
+                VersionTransformer.Names200408.EPR_TYPE, Relationship.class, AttributedURI.class
+            };
+        } else if (exposeAs200403) {
+            expectedValues = new Object[] {
+                VersionTransformer.convertTo200403(id), VersionTransformer.convertTo200403(to),
+                VersionTransformer.convertTo200403(replyTo), VersionTransformer.convertTo200403(faultTo),
+                VersionTransformer.convertTo200403(relatesTo), VersionTransformer.convertTo200403(action)
+            };
+            if (!outbound) {
+                // conversion from 2004/03 to 2005/08 anonymous address
+                // occurs transparently in VersionTransformer
+                VersionTransformer.Names200403.EPR_TYPE.cast(expectedValues[2]).getAddress()
+                    .setValue(Names.WSA_ANONYMOUS_ADDRESS);
+                VersionTransformer.Names200403.EPR_TYPE.cast(expectedValues[3]).getAddress()
+                    .setValue(Names.WSA_ANONYMOUS_ADDRESS);
+            }
+            expectedDeclaredTypes = new Class<?>[] {
+                org.apache.cxf.ws.addressing.v200403.AttributedURI.class,
+                org.apache.cxf.ws.addressing.v200403.AttributedURI.class,
+                VersionTransformer.Names200403.EPR_TYPE, VersionTransformer.Names200403.EPR_TYPE,
+                org.apache.cxf.ws.addressing.v200403.Relationship.class,
+                org.apache.cxf.ws.addressing.v200403.AttributedURI.class
+            };
         } else {
             fail("unexpected namespace URI: " + uri);
         }
         return maps;
     }
-    
+
     private final class JAXBEltMatcher implements IArgumentMatcher {
         public boolean matches(Object obj) {
             QName name = expectedNames[expectedIndex];
@@ -548,8 +500,7 @@
             }
             if (obj instanceof JAXBElement) {
                 JAXBElement other = (JAXBElement)obj;
-                ret = name.equals(other.getName()) 
-                      && declaredType.isAssignableFrom(other.getDeclaredType())
+                ret = name.equals(other.getName()) && declaredType.isAssignableFrom(other.getDeclaredType())
                       && compare(value, other.getValue());
             }
             return ret;
@@ -558,30 +509,43 @@
         public void appendTo(StringBuffer buffer) {
             buffer.append("JAXBElements did not match[" + expectedIndex + "]");
         }
-        
+
         private boolean compare(Object a, Object b) {
             boolean ret = false;
             if (a instanceof AttributedURI && b instanceof AttributedURI) {
                 ret = ((AttributedURI)a).getValue().equals(((AttributedURI)b).getValue());
+            } else if (a instanceof org.apache.cxf.ws.addressing.v200403.AttributedURI
+                       && b instanceof org.apache.cxf.ws.addressing.v200403.AttributedURI) {
+                ret = ((org.apache.cxf.ws.addressing.v200403.AttributedURI)a).getValue()
+                    .equals(((org.apache.cxf.ws.addressing.v200403.AttributedURI)b).getValue());
             } else if (a instanceof AttributedURIType && b instanceof AttributedURIType) {
                 ret = ((AttributedURIType)a).getValue().equals(((AttributedURIType)b).getValue());
             } else if (a instanceof EndpointReferenceType && b instanceof EndpointReferenceType) {
                 EndpointReferenceType aEPR = (EndpointReferenceType)a;
                 EndpointReferenceType bEPR = (EndpointReferenceType)b;
-                ret = aEPR.getAddress() != null
-                      && bEPR.getAddress() != null
+                ret = aEPR.getAddress() != null && bEPR.getAddress() != null
                       && aEPR.getAddress().getValue().equals(bEPR.getAddress().getValue());
             } else if (VersionTransformer.Names200408.EPR_TYPE.isInstance(a)
                        && VersionTransformer.Names200408.EPR_TYPE.isInstance(b)) {
                 ret = VersionTransformer.Names200408.EPR_TYPE.cast(a).getAddress() != null
                       && VersionTransformer.Names200408.EPR_TYPE.cast(b).getAddress() != null
-                      && VersionTransformer.Names200408.EPR_TYPE.cast(a).getAddress().getValue().equals(
-                             VersionTransformer.Names200408.EPR_TYPE.cast(b).getAddress().getValue());
+                      && VersionTransformer.Names200408.EPR_TYPE.cast(a).getAddress().getValue()
+                          .equals(VersionTransformer.Names200408.EPR_TYPE.cast(b).getAddress().getValue());
+            } else if (VersionTransformer.Names200403.EPR_TYPE.isInstance(a)
+                       && VersionTransformer.Names200403.EPR_TYPE.isInstance(b)) {
+                ret = VersionTransformer.Names200403.EPR_TYPE.cast(a).getAddress() != null
+                      && VersionTransformer.Names200403.EPR_TYPE.cast(b).getAddress() != null
+                      && VersionTransformer.Names200403.EPR_TYPE.cast(a).getAddress().getValue()
+                          .equals(VersionTransformer.Names200403.EPR_TYPE.cast(b).getAddress().getValue());
             } else if (a instanceof Relationship && b instanceof Relationship) {
                 ret = ((Relationship)a).getValue().equals(((Relationship)b).getValue());
+            } else if (a instanceof org.apache.cxf.ws.addressing.v200403.Relationship
+                       && b instanceof org.apache.cxf.ws.addressing.v200403.Relationship) {
+                ret = ((org.apache.cxf.ws.addressing.v200403.Relationship)a).getValue()
+                    .equals(((org.apache.cxf.ws.addressing.v200403.Relationship)b).getValue());
             } else if (a instanceof RelatesToType && b instanceof RelatesToType) {
                 ret = ((RelatesToType)a).getValue().equals(((RelatesToType)b).getValue());
-            } 
+            }
             return ret;
         }
     }
@@ -590,100 +554,89 @@
         if (obj instanceof AddressingPropertiesImpl) {
             AddressingPropertiesImpl other = (AddressingPropertiesImpl)obj;
             return compareExpected(other);
-        } 
+        }
         return false;
-    }    
+    }
 
     private boolean compareExpected(AddressingPropertiesImpl other) {
         boolean ret = false;
         String uri = other.getNamespaceURI();
         boolean exposedAsNative = Names.WSA_NAMESPACE_NAME.equals(uri);
-        boolean exposedAs200408 = 
-            VersionTransformer.Names200408.WSA_NAMESPACE_NAME.equals(uri);
-        if (exposedAsNative || exposedAs200408) {
-            String expectedMessageID = 
-                exposedAsNative
-                ? ((AttributedURIType)expectedValues[0]).getValue()
-                : ((AttributedURI)expectedValues[0]).getValue();
-            String expectedTo =
-                exposedAsNative
-                ? ((AttributedURIType)expectedValues[1]).getValue()
-                : ((AttributedURI)expectedValues[1]).getValue();
-            String expectedReplyTo = 
-                exposedAsNative
-                ? ((EndpointReferenceType)expectedValues[2]).getAddress().getValue()
-                : (VersionTransformer.Names200408.EPR_TYPE.cast(expectedValues[2])).
-                    getAddress().getValue();
-            String expectedAction =                    
-                exposedAsNative
-                ? ((AttributedURIType)expectedValues[5]).getValue()
-                : ((AttributedURI)expectedValues[5]).getValue();
+        boolean exposedAs200408 = VersionTransformer.Names200408.WSA_NAMESPACE_NAME.equals(uri);
+        boolean exposedAs200403 = VersionTransformer.Names200403.WSA_NAMESPACE_NAME.equals(uri);
+
+        if (exposedAsNative || exposedAs200408 || exposedAs200403) {
+            String expectedMessageID = exposedAsNative
+                ? ((AttributedURIType)expectedValues[0]).getValue() : exposedAs200408
+                    ? ((AttributedURI)expectedValues[0]).getValue()
+                    : ((org.apache.cxf.ws.addressing.v200403.AttributedURI)expectedValues[0]).getValue();
+
+            String expectedTo = exposedAsNative
+                ? ((AttributedURIType)expectedValues[1]).getValue() : exposedAs200408
+                    ? ((AttributedURI)expectedValues[1]).getValue()
+                    : ((org.apache.cxf.ws.addressing.v200403.AttributedURI)expectedValues[1]).getValue();
+
+            String expectedReplyTo = exposedAsNative ? ((EndpointReferenceType)expectedValues[2])
+                .getAddress().getValue() : exposedAs200408 ? (VersionTransformer.Names200408.EPR_TYPE
+                .cast(expectedValues[2])).getAddress().getValue() : (VersionTransformer.Names200403.EPR_TYPE
+                .cast(expectedValues[2])).getAddress().getValue();
+            String expectedAction = exposedAsNative
+                ? ((AttributedURIType)expectedValues[5]).getValue() : exposedAs200408
+                    ? ((AttributedURI)expectedValues[5]).getValue()
+                    : ((org.apache.cxf.ws.addressing.v200403.AttributedURI)expectedValues[5]).getValue();
 
             ret = expectedMessageID.equals(other.getMessageID().getValue())
                   && expectedTo.equals(other.getTo().getValue())
-                  && expectedReplyTo.equals(
-                        other.getReplyTo().getAddress().getValue())
+                  && expectedReplyTo.equals(other.getReplyTo().getAddress().getValue())
                   && expectedAction.equals(other.getAction().getValue())
                   && expectedNamespaceURI.equals(other.getNamespaceURI());
             if (expectRelatesTo) {
-                String expectedRelatesTo = 
-                    exposedAsNative
-                    ? ((RelatesToType)expectedValues[4]).getValue()
-                    : ((Relationship)expectedValues[4]).getValue();
-                ret = ret
-                      && expectedRelatesTo.equals(other.getRelatesTo().getValue());
+                String expectedRelatesTo = exposedAsNative
+                    ? ((RelatesToType)expectedValues[4]).getValue() : exposedAs200408
+                        ? ((Relationship)expectedValues[4]).getValue()
+                        : ((org.apache.cxf.ws.addressing.v200403.Relationship)expectedValues[4]).getValue();
+                ret = ret && expectedRelatesTo.equals(other.getRelatesTo().getValue());
             }
-        } 
+        }
         return ret;
     }
-        
+
     private void verifyAction() {
         List<?> soapAction = (List<?>)mimeHeaders.get("SOAPAction");
         assertNotNull("expected propogated action", soapAction);
         assertEquals("expected single action", 1, soapAction.size());
-        String expectedAction =
-            "\"" + ((AttributedURIType)expectedValues[5]).getValue() + "\"";
-        assertEquals("expected propogated action", 
-                     expectedAction,
-                     soapAction.get(0));
+        String expectedAction = "\"" + ((AttributedURIType)expectedValues[5]).getValue() + "\"";
+        assertEquals("expected propogated action", expectedAction, soapAction.get(0));
     }
 
-    private void verifyMessage(SoapMessage message,
-                               boolean requestor,
-                               boolean outbound,
+    private void verifyMessage(SoapMessage message, boolean requestor, boolean outbound,
                                boolean exposedAsNative) {
         if (requestor) {
             if (outbound) {
                 String id = expectedValues[0] instanceof AttributedURIType
-                            ? ((AttributedURIType)expectedValues[0]).getValue()
-                            : ((AttributedURI)expectedValues[0]).getValue();
-                //assertTrue("expected correlationID : " + id + " in map: " + codec.uncorrelatedExchanges,
-                //           codec.uncorrelatedExchanges.containsKey(id));
-                assertSame("unexpected correlated exchange",
-                           codec.uncorrelatedExchanges.get(id),
-                           message.getExchange());
+                    ? ((AttributedURIType)expectedValues[0]).getValue()
+                    : expectedValues[0] instanceof AttributedURI ? ((AttributedURI)expectedValues[0])
+                        .getValue() : ((org.apache.cxf.ws.addressing.v200403.AttributedURI)expectedValues[0])
+                        .getValue();
+                // assertTrue("expected correlationID : " + id + " in map: " +
+                // codec.uncorrelatedExchanges,
+                // codec.uncorrelatedExchanges.containsKey(id));
+                assertSame("unexpected correlated exchange", codec.uncorrelatedExchanges.get(id), message
+                    .getExchange());
             } else {
-                assertSame("unexpected correlated exchange",
-                           correlatedExchange,
-                           message.getExchange());
+                assertSame("unexpected correlated exchange", correlatedExchange, message.getExchange());
             }
         }
         if (outbound) {
-            int expectedMarshals = requestor 
-                                   ? expectedValues.length - 1
-                                   : expectedValues.length;
+            int expectedMarshals = requestor ? expectedValues.length - 1 : expectedValues.length;
             List<Header> headers = message.getHeaders();
-            assertTrue("expected holders added to header list",
-                       headers.size() >= expectedMarshals);
+            assertTrue("expected holders added to header list", headers.size() >= expectedMarshals);
             for (int i = 0; i < expectedMarshals; i++) {
-                assertTrue("expected " + expectedNames[i] + " added to headers",
-                           message.hasHeader(expectedNames[i]));
+                assertTrue("expected " + expectedNames[i] + " added to headers", message
+                    .hasHeader(expectedNames[i]));
             }
         }
-        assertTrue("unexpected MAPs",
-                   verifyMAPs(message.get(getMAPProperty(requestor, outbound))));
-        
+        assertTrue("unexpected MAPs", verifyMAPs(message.get(getMAPProperty(requestor, outbound))));
+
     }
 }
-
-



Mime
View raw message