cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r700726 - in /cxf/branches/2.1.x-fixes: api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
Date Wed, 01 Oct 2008 10:09:22 GMT
Author: sergeyb
Date: Wed Oct  1 03:09:22 2008
New Revision: 700726

URL: http://svn.apache.org/viewvc?rev=700726&view=rev
Log:
Updating EndpointReferenceUtils.setPortName to recognize DOM Elements and getServiceName to
accept the older ServiceName namespace 

Modified:
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
    cxf/branches/2.1.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?rev=700726&r1=700725&r2=700726&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
(original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Wed Oct  1 03:09:22 2008
@@ -177,6 +177,7 @@
 
     private static final Logger LOG = LogUtils.getL7dLogger(EndpointReferenceUtils.class);
 
+    private static final String NS_WSAW_2005 = "http://www.w3.org/2005/02/addressing/wsdl";
     private static final String WSDL_INSTANCE_NAMESPACE = 
         "http://www.w3.org/2006/01/wsdl-instance";
     
@@ -268,7 +269,8 @@
         for (Object obj : metadata.getAny()) {
             if (obj instanceof Element) {
                 Node node = (Element)obj;
-                if (node.getNamespaceURI().equals(JAXWSAConstants.NS_WSAW) 
+                if ((node.getNamespaceURI().equals(JAXWSAConstants.NS_WSAW)
+                    || node.getNamespaceURI().equals(NS_WSAW_2005))
                     && node.getLocalName().equals("ServiceName")) {
                     String content = node.getTextContent();
                     String namespaceURI = node.getFirstChild().getNamespaceURI();
@@ -309,9 +311,11 @@
             for (Object obj : metadata.getAny()) {
                 if (obj instanceof Element) {
                     Node node = (Element)obj;
-                    if (node.getNamespaceURI().equals(JAXWSAConstants.NS_WSAW)
+                    if ((node.getNamespaceURI().equals(JAXWSAConstants.NS_WSAW)
+                        || node.getNamespaceURI().equals(NS_WSAW_2005))
                         && node.getNodeName().contains("ServiceName")) {
-                        return node.getAttributes().getNamedItem("EndpointName").getTextContent();
+                        Node item = node.getAttributes().getNamedItem("EndpointName");
+                        return item != null ? item.getTextContent() : null;
                     }
                 } else if (obj instanceof JAXBElement) {
                     Object val = ((JAXBElement)obj).getValue();
@@ -335,7 +339,14 @@
         MetadataType metadata = ref.getMetadata();
         if (metadata != null) {
             for (Object obj : metadata.getAny()) {
-                if (obj instanceof JAXBElement) {
+                if (obj instanceof Element) {
+                    Element node = (Element)obj;
+                    if (node.getNodeName().contains("ServiceName")
+                        && (node.getNamespaceURI().equals(JAXWSAConstants.NS_WSAW)
+                        || node.getNamespaceURI().equals(NS_WSAW_2005))) {
+                        node.setAttribute(JAXWSAConstants.WSAW_ENDPOINT_NAME, portName);
+                    }
+                } else if (obj instanceof JAXBElement) {
                     Object val = ((JAXBElement)obj).getValue();
                     if (val instanceof ServiceNameType) {
                         ((ServiceNameType)val).setEndpointName(portName);

Modified: cxf/branches/2.1.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java?rev=700726&r1=700725&r2=700726&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/VersionTransformerTest.java
Wed Oct  1 03:09:22 2008
@@ -20,6 +20,7 @@
 package org.apache.cxf.ws.addressing;
 
 import java.io.InputStream;
+import java.util.List;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
@@ -31,6 +32,7 @@
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.wsdl.EndpointReferenceUtils;
@@ -54,6 +56,18 @@
         assertEquals("http://localhost:8080/test", ert.getAddress().getValue());
         assertEquals(new QName("http://apache.org/hello_world_soap_http", "SOAPService"),

                                EndpointReferenceUtils.getServiceName(ert, null));
+        
+        // VersionTransformer.convertToInternal produces metadata extensions of type 
+        // DOM Element hence we're testing the relevant EndpointReferenceUtils.setPortName
+        // code path here
+        
+        List<Object> metadata = ert.getMetadata().getAny();
+        assertEquals("Single metadata extension expected", 1, metadata.size());
+        assertTrue("Metadata extension of type DOM Element expected", 
+                   metadata.get(0) instanceof Element);
+        assertNull("No portName has been set yet", EndpointReferenceUtils.getPortName(ert));
+        EndpointReferenceUtils.setPortName(ert, "Greeter");
+        assertEquals("No portName has been set", "Greeter", EndpointReferenceUtils.getPortName(ert));
     }
     
     private EndpointReference readEndpointReference(Source eprInfoset) {



Mime
View raw message