axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidills...@apache.org
Subject svn commit: r417509 - in /webservices/axis2/trunk/java/modules/core: src/org/apache/axis2/addressing/EndpointReference.java test/org/apache/axis2/addressing/EndpointReferenceTypeTest.java
Date Tue, 27 Jun 2006 16:48:25 GMT
Author: davidillsley
Date: Tue Jun 27 09:48:24 2006
New Revision: 417509

URL: http://svn.apache.org/viewvc?rev=417509&view=rev
Log:
Changes to EndpointReference.java
Adding to toOM: serialisation of attributes and extensibility elements
Adding to fromOM: deserialisation of attributes and extensibility elements
Fixing toOM and fromOM to use "Metadata" rather than "MetaData"

Added unit test to check for regressions

Passes unit tests locally

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

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=417509&r1=417508&r2=417509&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
Tue Jun 27 09:48:24 2006
@@ -24,6 +24,9 @@
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 import java.io.Serializable;
@@ -42,6 +45,8 @@
 
     private static final long serialVersionUID = 5278892171162372439L;
 
+    private static final Log log = LogFactory.getLog(EndpointReference.class);
+    
     /**
      * <EndpointReference>
      * <Address>xs:anyURI</Address>
@@ -209,7 +214,7 @@
         }
 
 
-        OMElement metaDataElement = eprOMElement.getFirstChildWithName(new QName("MetaData"));
+        OMElement metaDataElement = eprOMElement.getFirstChildWithName(new QName(AddressingConstants.Final.WSA_METADATA));
         if (metaDataElement != null) {
             Iterator children = metaDataElement.getChildren();
             while (children.hasNext()) {
@@ -229,6 +234,17 @@
             OMAttribute attribute = (OMAttribute) allAttributes.next();
             attributes.add(attribute);
         }
+        
+        Iterator childElements = eprOMElement.getChildElements();
+        while (childElements.hasNext()) {
+            OMElement eprChildElement = (OMElement) childElements.next();
+            String localName = eprChildElement.getLocalName();
+            if(!localName.equals("Address") &&
+               !localName.equals(AddressingConstants.EPR_REFERENCE_PARAMETERS) &&
+               !localName.equals(AddressingConstants.Final.WSA_METADATA)){
+                addExtensibleElement(eprChildElement);
+            }
+        }
     }
 
     public OMElement toOM(String nsurl, String localName, String prefix) throws AxisFault
{
@@ -255,6 +271,23 @@
                     refParameterElement.addChild((OMNode) refParms.next());
                 }
             }
+            
+            if (attributes != null) {
+                Iterator attrIter = attributes.iterator();
+                while (attrIter.hasNext()) {
+                    OMAttribute omAttributes = (OMAttribute) attrIter.next();
+                    epr.addAttribute(omAttributes);
+                }
+            }
+            
+            // add xs:any
+            ArrayList omElements = extensibleElements;
+            if (omElements != null) {
+                for (int i = 0; i < omElements.size(); i++) {
+                    epr.addChild((OMElement) omElements.get(i));
+                }
+            }
+            
             return epr;
         } else {
             throw new AxisFault("prefix must be specified");

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=417509&r1=417508&r2=417509&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
Tue Jun 27 09:48:24 2006
@@ -18,9 +18,16 @@
 
 import junit.framework.TestCase;
 import junit.textui.TestRunner;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
 
 import javax.xml.namespace.QName;
+
+import java.util.ArrayList;
 import java.util.Map;
 
 
@@ -69,5 +76,49 @@
                     referenceParameter.getText(),
                     "value " + i * 50);
         }
+    }
+    
+    public void testToAndFromOM() throws Exception{
+        OMFactory omf = OMAbstractFactory.getOMFactory();
+        OMNamespace ns1 = omf.createOMNamespace("http://uri1","prefix1");
+        OMAttribute attr1 = omf.createOMAttribute("attr1",ns1,"attr1value");
+        OMNamespace ns2 = omf.createOMNamespace("http://uri2","prefix2");
+        OMAttribute attr2 = omf.createOMAttribute("attr2",ns2,"attr2value");
+        endpointReference.addAttribute(attr1);
+        endpointReference.addAttribute(attr2);
+        OMElement md1 = omf.createOMElement("md1", "http://mduri1", "md1prefix"); 
+        OMElement md2 = omf.createOMElement("md2", "http://mduri2", "md2prefix");
+        endpointReference.addMetaData(md1);
+        endpointReference.addMetaData(md2);
+        OMElement ext1 = omf.createOMElement("ext1", "http://exturi1", "ext1prefix"); 
+        OMElement ext2 = omf.createOMElement("ext2", "http://exturi2", "ext2prefix");
+        endpointReference.addExtensibleElement(ext1);
+        endpointReference.addExtensibleElement(ext2);
+        QName rp1Qname = new QName("http://rp1uri","refParm1","rp1prefix");
+        QName rp2Qname = new QName("http://rp2uri","refParm2","rp2prefix");
+        endpointReference.addReferenceParameter(rp1Qname,"rp1");
+        endpointReference.addReferenceParameter(rp2Qname,"rp2");
+        
+        OMElement om = endpointReference.toOM("http://nsurl","localName","prefix");
+        
+        EndpointReference deser = new EndpointReference("");
+        deser.fromOM(om);
+        
+        assertEquals(endpointReference.getAddress(),deser.getAddress());
+        ArrayList attrs = deser.getAttributes();
+        assertEquals(attr1,attrs.get(0));
+        assertEquals(attr2,attrs.get(1));
+        
+        ArrayList metadata = deser.getMetaData();
+        assertEquals(md1, metadata.get(0));
+        assertEquals(md2, metadata.get(1));
+        
+        ArrayList extelts = deser.getExtensibleElements();
+        assertEquals(ext1,extelts.get(0));
+        assertEquals(ext2,extelts.get(1));
+        
+        Map m = deser.getAllReferenceParameters();
+        assertEquals("rp1", ((OMElement)m.get(rp1Qname)).getText());
+        assertEquals("rp2", ((OMElement)m.get(rp2Qname)).getText());
     }
 }



---------------------------------------------------------------------
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