cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1502886 - in /cxf/trunk/rt/wsdl/src: main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
Date Sat, 13 Jul 2013 21:29:33 GMT
Author: dkulp
Date: Sat Jul 13 21:29:32 2013
New Revision: 1502886

URL: http://svn.apache.org/r1502886
Log:
Use the output transformer to map the namespaces as other jaxb impls may not use the namespace
context the same way.

Modified:
    cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
    cxf/trunk/rt/wsdl/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java

Modified: cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java?rev=1502886&r1=1502885&r2=1502886&view=diff
==============================================================================
--- cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java (original)
+++ cxf/trunk/rt/wsdl/src/main/java/org/apache/cxf/wsdl/JAXBExtensionHelper.java Sat Jul 13
21:29:32 2013
@@ -21,6 +21,7 @@ package org.apache.cxf.wsdl;
 
 import java.io.PrintWriter;
 import java.lang.reflect.Method;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -76,6 +77,7 @@ import org.apache.cxf.common.util.String
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.staxutils.PrettyPrintXMLStreamWriter;
 import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.transform.OutTransformWriter;
 
 
 /**
@@ -327,6 +329,16 @@ public class JAXBExtensionHelper impleme
                     return ret;
                 }
             });
+            if (namespace != null && !namespace.equals(jaxbNamespace)) {
+                Map<String, String> outMap = new HashMap<String, String>();
+                outMap.put("{" + jaxbNamespace + "}*", "{" + namespace + "}*");
+                writer = new OutTransformWriter(writer,
+                                                outMap,
+                                                Collections.<String, String>emptyMap(),
+                                                Collections.<String>emptyList(),
+                                                false,
+                                                "");
+            }
             
             u.marshal(mObj, writer);
             writer.flush();            

Modified: cxf/trunk/rt/wsdl/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/wsdl/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java?rev=1502886&r1=1502885&r2=1502886&view=diff
==============================================================================
--- cxf/trunk/rt/wsdl/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java (original)
+++ cxf/trunk/rt/wsdl/src/test/java/org/apache/cxf/wsdl/JAXBExtensionHelperTest.java Sat Jul
13 21:29:32 2013
@@ -30,6 +30,7 @@ import javax.wsdl.Definition;
 import javax.wsdl.Port;
 import javax.wsdl.Service;
 import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
@@ -39,6 +40,7 @@ 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;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -134,16 +136,16 @@ public class JAXBExtensionHelperTest ext
     
     @Test
     public void testMappedNamespace() throws Exception {
-        JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.Port",
-            "org.apache.cxf.abc.test.TestPolicyType",
+        JAXBExtensionHelper.addExtensions(registry, javax.wsdl.Port.class,
+            org.apache.cxf.abc.test.TestPolicyType.class,
             "http://cxf.apache.org/abc/test/remapped");
 
-        JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.Port",
-            "org.apache.cxf.abc.test.AnotherPolicyType",
+        JAXBExtensionHelper.addExtensions(registry, javax.wsdl.Port.class,
+            org.apache.cxf.abc.test.AnotherPolicyType.class,
             "http://cxf.apache.org/abc/test/remapped");
 
-        JAXBExtensionHelper.addExtensions(registry, "javax.wsdl.Definition",
-            "org.apache.cxf.abc.test.NewServiceType",
+        JAXBExtensionHelper.addExtensions(registry, javax.wsdl.Definition.class,
+            org.apache.cxf.abc.test.NewServiceType.class,
             "http://cxf.apache.org/abc/test/remapped");
 
         String file = this.getClass().getResource("/wsdl/test_ext_remapped.wsdl").toURI().toString();
@@ -169,9 +171,11 @@ public class JAXBExtensionHelperTest ext
         for (Object ext : extPortList) {
             if (ext instanceof TestPolicyType) {
                 tp = (TestPolicyType) ext;
-            }
-            if (ext instanceof AnotherPolicyType) {
+            } else if (ext instanceof AnotherPolicyType) {
                 ap = (AnotherPolicyType) ext;
+            } else if (ext instanceof UnknownExtensibilityElement) {
+                UnknownExtensibilityElement e = (UnknownExtensibilityElement)ext;
+                System.out.println(e.getElementType());
             }
         }
         assertNotNull("Could not find extension element TestPolicyType", tp);



Mime
View raw message