cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r702550 - in /cxf/branches/2.1.x-fixes: ./ api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
Date Tue, 07 Oct 2008 17:10:05 GMT
Author: dkulp
Date: Tue Oct  7 10:10:05 2008
New Revision: 702550

URL: http://svn.apache.org/viewvc?rev=702550&view=rev
Log:
Merged revisions 702547 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r702547 | dkulp | 2008-10-07 13:06:08 -0400 (Tue, 07 Oct 2008) | 2 lines
  
  [CXF-1834] Fix for writing extensor objects that have been namespace mapped
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
    cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Oct  7 10:10:05 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,702267
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,702267,702547

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java?rev=702550&r1=702549&r2=702550&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
(original)
+++ cxf/branches/2.1.x-fixes/api/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
Tue Oct  7 10:10:05 2008
@@ -87,7 +87,18 @@
                 .asSubclass(TExtensibilityElementImpl.class);
         addExtensions(registry, parentTypeClass, elementTypeClass, null);
     }
-    
+    public static void addExtensions(ExtensionRegistry registry,
+                                     String parentType, 
+                                     String elementType,
+                                     String namespace)
+        throws JAXBException, ClassNotFoundException {
+        Class<?> parentTypeClass = ClassLoaderUtils.loadClass(parentType, JAXBExtensionHelper.class);
+
+        Class<? extends TExtensibilityElementImpl> elementTypeClass = 
+            ClassLoaderUtils.loadClass(elementType, JAXBExtensionHelper.class)
+                .asSubclass(TExtensibilityElementImpl.class);
+        addExtensions(registry, parentTypeClass, elementTypeClass, namespace);
+    }
     public static void addExtensions(ExtensionRegistry registry,
                                      Class<?> parentType,
                                      Class<? extends TExtensibilityElementImpl> cls)
@@ -224,6 +235,10 @@
                 }
                                 
                 public String getPrefix(String arg) {
+                    if (arg.equals(jaxbNamespace)) {
+                        arg = namespace;
+                    }
+                    
                     for (Object ent : wsdl.getNamespaces().entrySet()) {
                         Map.Entry entry = (Map.Entry)ent;
                         if (arg.equals(entry.getValue())) {
@@ -234,6 +249,9 @@
                 }
                 
                 public Iterator getPrefixes(String arg) {
+                    if (arg.equals(jaxbNamespace)) {
+                        arg = namespace;
+                    }
                     return wsdl.getNamespaces().keySet().iterator();
                 }
             });

Modified: cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java?rev=702550&r1=702549&r2=702550&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
(original)
+++ cxf/branches/2.1.x-fixes/api/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
Tue Oct  7 10:10:05 2008
@@ -23,6 +23,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.PrintWriter;
 import java.io.StringReader;
+import java.io.StringWriter;
 import java.util.List;
 
 import javax.wsdl.Definition;
@@ -33,6 +34,8 @@
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
 
+import org.xml.sax.InputSource;
+
 import org.apache.cxf.abc.test.AnotherPolicyType;
 import org.apache.cxf.abc.test.NewServiceType;
 import org.apache.cxf.abc.test.TestPolicyType;
@@ -79,28 +82,7 @@
         wsdlReader.setExtensionRegistry(registry);
 
         wsdlDefinition = wsdlReader.readWSDL(file);
-        Service s = wsdlDefinition.getService(new QName("http://cxf.apache.org/test/hello_world",
-                        "HelloWorldService"));
-        Port p = s.getPort("HelloWorldPort");
-        List extPortList = p.getExtensibilityElements();
-
-        TestPolicyType tp = null;
-        AnotherPolicyType ap = null;
-        for (Object ext : extPortList) {
-            if (ext instanceof TestPolicyType) {
-                tp = (TestPolicyType) ext;
-            }
-            if (ext instanceof AnotherPolicyType) {
-                ap = (AnotherPolicyType) ext;
-            }
-        }
-        assertNotNull("Could not find extension element TestPolicyType", tp);
-        assertNotNull("Could not find extension element AnotherPolicyType", ap);
-
-        assertEquals("Unexpected value for TestPolicyType intAttr", 30, tp.getIntAttr());
-        assertEquals("Unexpected value for TestPolicyType stringAttr", "hello", tp.getStringAttr());
-        assertTrue("Unexpected value for AnotherPolicyType floatAttr",
-            Math.abs(0.1F - ap.getFloatAttr()) < 0.5E-5);
+        checkTestExt();
     }
 
     @Test
@@ -149,6 +131,57 @@
             actual = reader.readLine();
         }
     }
+    
+    @Test
+    public void testMappedNamespace() throws Exception {
+        JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.Port",
+            "org.apache.cxf.abc.test.TestPolicyType",
+            "http://cxf.apache.org/abc/test/remapped");
+
+        JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.Port",
+            "org.apache.cxf.abc.test.AnotherPolicyType",
+            "http://cxf.apache.org/abc/test/remapped");
+
+        JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.Definition",
+            "org.apache.cxf.abc.test.NewServiceType",
+            "http://cxf.apache.org/abc/test/remapped");
+
+        String file = this.getClass().getResource("/wsdl/test_ext_remapped.wsdl").toURI().toString();
+        wsdlReader.setExtensionRegistry(registry);
+
+        wsdlDefinition = wsdlReader.readWSDL(file);
+        checkTestExt();
+        StringWriter out = new StringWriter();
+        wsdlFactory.newWSDLWriter().writeWSDL(wsdlDefinition, out);
+        wsdlDefinition = wsdlReader.readWSDL(null,
+                                             new InputSource(new StringReader(out.toString())));
+        checkTestExt();
+    }
+    
+    private void checkTestExt() throws Exception {
+        Service s = wsdlDefinition.getService(new QName("http://cxf.apache.org/test/hello_world",
+            "HelloWorldService"));
+        Port p = s.getPort("HelloWorldPort");
+        List extPortList = p.getExtensibilityElements();
+    
+        TestPolicyType tp = null;
+        AnotherPolicyType ap = null;
+        for (Object ext : extPortList) {
+            if (ext instanceof TestPolicyType) {
+                tp = (TestPolicyType) ext;
+            }
+            if (ext instanceof AnotherPolicyType) {
+                ap = (AnotherPolicyType) ext;
+            }
+        }
+        assertNotNull("Could not find extension element TestPolicyType", tp);
+        assertNotNull("Could not find extension element AnotherPolicyType", ap);
+    
+        assertEquals("Unexpected value for TestPolicyType intAttr", 30, tp.getIntAttr());
+        assertEquals("Unexpected value for TestPolicyType stringAttr", "hello", tp.getStringAttr());
+        assertTrue("Unexpected value for AnotherPolicyType floatAttr",
+                   Math.abs(0.1F - ap.getFloatAttr()) < 0.5E-5);        
+    }
 
     private void checkSpaces(String actual, int spaces) {
         String space = "";



Mime
View raw message