cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [05/16] git commit: Update the javato tests to pass with MOXy
Date Fri, 04 Apr 2014 15:01:41 GMT
Update the javato tests to pass with MOXy


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/0940d45d
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/0940d45d
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/0940d45d

Branch: refs/heads/2.7.x-fixes
Commit: 0940d45d27aee71138870d2895195feafcccf5d0
Parents: 8001e89
Author: Daniel Kulp <dkulp@apache.org>
Authored: Thu Mar 27 10:31:18 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Apr 4 09:57:09 2014 -0400

----------------------------------------------------------------------
 .../cxf/tools/common/ProcessorTestBase.java     | 12 ++++++
 .../org/apache/cxf/tools/fortest/MyImage.java   |  3 ++
 .../apache/cxf/tools/java2ws/JavaToWSTest.java  | 40 +++++++++++++++-----
 .../processor/JavaToProcessorTest.java          |  2 +-
 .../jaxws/JaxwsServiceBuilderRPCTest.java       | 10 ++++-
 .../internal/jaxws/JaxwsServiceBuilderTest.java |  7 ++++
 6 files changed, 63 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0940d45d/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
----------------------------------------------------------------------
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
b/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
index 3930d4d..fc21ed9 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
@@ -40,6 +40,8 @@ import java.util.StringTokenizer;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.util.StringUtils;
@@ -94,6 +96,16 @@ public class ProcessorTestBase extends Assert {
     public void tearDown() {
         env = null;
     }
+    
+
+    protected boolean isMOXy() {
+        try {
+            JAXBContext c = JAXBContext.newInstance(String.class);
+            return c.getClass().getName().contains(".eclipse");
+        } catch (JAXBException e) {
+            return false;
+        }
+    }
 
     protected String getClassPath() throws URISyntaxException, IOException {
         ClassLoader loader = getClass().getClassLoader();

http://git-wip-us.apache.org/repos/asf/cxf/blob/0940d45d/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java
----------------------------------------------------------------------
diff --git a/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java b/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java
index 53f30c7..ed07f59 100644
--- a/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java
+++ b/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java
@@ -19,8 +19,11 @@
 package org.apache.cxf.tools.fortest;
 
 import java.awt.Image;
+
 import javax.xml.bind.annotation.XmlMimeType;
+import javax.xml.bind.annotation.XmlType;
 
+@XmlType(name = "myImage", namespace = "http://fortest.tools.cxf.apache.org/")
 public class MyImage {
     @XmlMimeType("image/png")
     protected Image myPhoto;

http://git-wip-us.apache.org/repos/asf/cxf/blob/0940d45d/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
----------------------------------------------------------------------
diff --git a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
index 0788134..ba12120 100644
--- a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
+++ b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
@@ -22,11 +22,19 @@ import java.io.File;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 import org.apache.cxf.common.util.Compiler;
 import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.helpers.XPathUtils;
+import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolTestBase;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -337,10 +345,17 @@ public class JavaToWSTest extends ToolTestBase {
         JavaToWS.main(args);
 
         File file = new File(output.getPath() + "/xml-list.wsdl");
-        String str = FileUtils.getStringFromFile(file);
-        assertTrue("Java2wsdl did not generate xsd:list element",
-                   str.indexOf("xs:list") > -1);
-
+        
+        Document doc = StaxUtils.read(file);
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("xsd", "http://www.w3.org/2001/XMLSchema");
+        map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
+        map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+        XPathUtils util = new XPathUtils(map);
+        Element node = (Element)util.getValueNode("//xsd:list", doc);
+        assertNotNull(node);
+
+        assertTrue(node.getAttribute("itemType").contains("string"));
     }
 
     @Test
@@ -365,11 +380,18 @@ public class JavaToWSTest extends ToolTestBase {
        
         JavaToWS.main(args);
         File file = new File(output.getPath() + "/xmladapter.wsdl");
-        String str = FileUtils.getStringFromFile(file);
-        String expected = "<xs:element  minOccurs=\"0\"  name=\"arg0\"  type=\"xs:string\"/>";
-        assertTrue("@XmlJavaTypeAdapter in SEI dose not take effect",
-                   str.indexOf(expected) > -1);
-            
+        
+        Document doc = StaxUtils.read(file);
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("xsd", "http://www.w3.org/2001/XMLSchema");
+        map.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
+        map.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+        XPathUtils util = new XPathUtils(map);
+        Element node = (Element)util.getValueNode("//xsd:element[@name='arg0']", doc);
+        assertNotNull(node);
+
+        assertEquals("0", node.getAttribute("minOccurs"));
+        assertTrue(node.getAttribute("type").contains("string"));
     }
 
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/0940d45d/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
----------------------------------------------------------------------
diff --git a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
index 7751893..bc0212f 100644
--- a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
+++ b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
@@ -480,7 +480,7 @@ public class JavaToProcessorTest extends ProcessorTestBase {
     @Test
     public void testMimeTypeInBean() throws Exception {
         env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/send_image2.wsdl");
-        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.ImageSender2");
+        env.put(ToolConstants.CFG_CLASSNAME, org.apache.cxf.tools.fortest.ImageSender2.class.getName());
         env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
         try {
             processor.setEnvironment(env);

http://git-wip-us.apache.org/repos/asf/cxf/blob/0940d45d/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java
----------------------------------------------------------------------
diff --git a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java
b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java
index 6b9e64a..9080260 100644
--- a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java
+++ b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderRPCTest.java
@@ -20,6 +20,8 @@
 package org.apache.cxf.tools.java2wsdl.processor.internal.jaxws;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.jaxb.JAXBContextCache;
@@ -27,6 +29,7 @@ import org.apache.cxf.jaxws.JaxwsServiceBuilder;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.java2wsdl.generator.wsdl11.WSDL11Generator;
+
 import org.junit.Before;
 import org.junit.Test;
 
@@ -59,7 +62,12 @@ public class JaxwsServiceBuilderRPCTest extends ProcessorTestBase {
 
         File expectedFile = new File(this.getClass()
             .getResource("expected/rpc_greeter.wsdl").toURI());
-        assertWsdlEquals(expectedFile, output);
+        
+        //MOXy doesn't put a final attribute on the array types, we can ignore that
+        //for the purpose of this test
+        List<String> ignores = new ArrayList<String>(DEFAULT_IGNORE_ATTR);
+        ignores.add("final");
+        assertWsdlEquals(expectedFile, output, ignores, DEFAULT_IGNORE_TAG);
     }
 
     private File getOutputFile(String fileName) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/0940d45d/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
----------------------------------------------------------------------
diff --git a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
index d587deb..f49aaae 100644
--- a/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
+++ b/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
@@ -68,6 +68,13 @@ public class JaxwsServiceBuilderTest extends ProcessorTestBase {
 
     @Test
     public void testDocLitWrappedWithWrapperClass() throws Exception {
+        if (isMOXy()) {
+            //This test is testing to see if the lack of namespace declarations on the wrapper
classes
+            //can still map into the targetnamespace of the service.   MOXy always looks
for the
+            //namespace on the annotation or in package-info and thus cannot support this.
 This
+            //is fairly bad practice anyway.
+            return;
+        }
         builder.setServiceClass(org.apache.cxf.tools.fortest.withannotation.doc.StockWrapped.class);
         ServiceInfo service = builder.createService();
         generator.setServiceModel(service);


Mime
View raw message