cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r531847 - in /incubator/cxf/trunk/tools: common/src/main/java/org/apache/cxf/tools/common/ wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/ wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/ wsdlto/tes...
Date Tue, 24 Apr 2007 09:25:56 GMT
Author: ema
Date: Tue Apr 24 02:25:56 2007
New Revision: 531847

URL: http://svn.apache.org/viewvc?view=rev&rev=531847
Log:
[CXF-595] Get nexclude flag to work 

Modified:
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
    incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
    incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java?view=diff&rev=531847&r1=531846&r2=531847
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
Tue Apr 24 02:25:56 2007
@@ -98,7 +98,7 @@
         assertTrue(!st1.hasMoreTokens());
     }
 
-    private String getStringFromFile(File location) {
+    public String getStringFromFile(File location) {
         InputStream is = null;
         String result = null;
 

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java?view=diff&rev=531847&r1=531846&r2=531847
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
Tue Apr 24 02:25:56 2007
@@ -62,6 +62,7 @@
         try {
             PropertyUtil properties = new PropertyUtil();
             properties.load(ins);
+            namespacePackageMap.putAll(properties.getMaps());
             excludeNamespacePackageMap.putAll(properties.getMaps());
         } catch (IOException e) {
             e.printStackTrace();
@@ -161,11 +162,12 @@
     }
 
     public void addExcludeNamespacePackageMap(String namespace, String pn) {
-        this.excludeNamespacePackageMap.put(namespace, pn);
+        excludeNamespacePackageMap.put(namespace, pn);
+        excludePkgList.add(pn);
     }
 
     public boolean hasExcludeNamespace(String ns) {
-        return this.excludeNamespacePackageMap.containsKey(ns);
+        return excludeNamespacePackageMap.containsKey(ns);
     }
 
     public String getExcludePackageName(String ns) {

Modified: incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?view=diff&rev=531847&r1=531846&r2=531847
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Tue Apr 24 02:25:56 2007
@@ -258,7 +258,14 @@
 
     public void setExcludePackageAndNamespaces(ToolContext env) {
         if (env.get(ToolConstants.CFG_NEXCLUDE) != null) {
-            String[] pns = (String[])env.get(ToolConstants.CFG_NEXCLUDE);
+            String[] pns = null;
+            try {
+                pns = (String[])env.get(ToolConstants.CFG_NEXCLUDE);
+            } catch (ClassCastException e) {
+                pns = new String[1];
+                pns[0] = (String)env.get(ToolConstants.CFG_NEXCLUDE);
+            }
+
             for (int j = 0; j < pns.length; j++) {
                 int pos = pns[j].indexOf("=");
                 String excludePackagename = pns[j];
@@ -266,8 +273,9 @@
                     String ns = pns[j].substring(0, pos);
                     excludePackagename = pns[j].substring(pos + 1);
                     env.addExcludeNamespacePackageMap(ns, excludePackagename);
+                    env.addNamespacePackageMap(ns, excludePackagename);
                 } else {
-                    env.addExcludeNamespacePackageMap(pns[j], null);
+                    env.addExcludeNamespacePackageMap(pns[j], env.mapPackageName(pns[j]));
                 }
             }
         }
@@ -387,10 +395,10 @@
         if (!context.containsKey(ToolConstants.CFG_WSDL_VERSION)) {
             context.put(ToolConstants.CFG_WSDL_VERSION, WSDLConstants.WSDL11);
         }
-
-        setExcludePackageAndNamespaces(context);
+        
         loadDefaultNSPackageMapping(context);
         setPackageAndNamespaces(context);
+        setExcludePackageAndNamespaces(context);
     }
 
     protected static InputStream getResourceAsStream(String file) {

Modified: incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?view=diff&rev=531847&r1=531846&r2=531847
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Tue Apr 24 02:25:56 2007
@@ -55,7 +55,6 @@
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.util.ClassCollector;
-import org.apache.cxf.tools.util.URIParserUtil;
 import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
 
 public class JAXBDataBinding implements DataBindingProfile {
@@ -88,25 +87,15 @@
             if (StringUtils.isEmpty(tns)) {
                 continue;
             }
-            String excludePkg = null;
-            if (context.hasExcludeNamespace(tns)) {
-                excludePkg = context.getExcludePackageName(tns);
-                if (excludePkg != null) {
-                    context.getExcludePkgList().add(excludePkg);
-                } else {
-                    context.getExcludePkgList().add(URIParserUtil.getPackageName(tns));
-                }
-            }
+
             schemaCompiler.parseSchema(key, ele);
 
         }
-       
-        
+
         for (InputSource binding : jaxbBindings) {
             schemaCompiler.parseSchema(binding);
         }
-        
-        
+
         if (context.getPackageName() != null) {
             schemaCompiler.forcePackageName(context.getPackageName());
         } else {
@@ -118,7 +107,6 @@
                 FileUtils.delete(file);
             }
         }
-        
 
         rawJaxbModelGenCode = schemaCompiler.bind();
 
@@ -128,7 +116,7 @@
     // JAXB bug. JAXB ClassNameCollector may not be invoked when generated
     // class is an enum. We need to use this method to add the missed file
     // to classCollector.
-    private void addedEnumClassToCollector(Map<String, Element> schemaList,
+    private void addedEnumClassToCollector(Map<String, Element> schemaList, 
                                            ClassNameAllocatorImpl allocator) {
         for (Element schemaElement : schemaList.values()) {
             String targetNamespace = schemaElement.getAttribute("targetNamespace");
@@ -158,7 +146,7 @@
     private boolean isSuppressCodeGen() {
         return context.optionSet(ToolConstants.CFG_SUPPRESS_GEN);
     }
-    
+
     public void generate(ToolContext c) throws ToolException {
         initialize(c);
         if (rawJaxbModelGenCode == null) {
@@ -199,7 +187,7 @@
                 typeAnno = mapping.getType();
             }
         }
-                
+
         if (typeAnno != null && typeAnno.getTypeClass() != null) {
             return typeAnno.getTypeClass().fullName();
         }
@@ -287,7 +275,6 @@
      * @param namespace
      * @param pkgName
      * @return file
-     *         
      */
     public File getCustomizedSchemaElement(String namespace, String pkgName) {
         Document doc = DOMUtils.createDocument();
@@ -314,7 +301,7 @@
         } catch (Exception e) {
             Message msg = new Message("FAIL_TO_CREATE_JAXBBINIDNG_FILE", LOG);
             throw new ToolException(msg, e);
-        } 
+        }
         return tmpFile;
     }
 

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?view=diff&rev=531847&r1=531846&r2=531847
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Tue Apr 24 02:25:56 2007
@@ -175,6 +175,9 @@
         Class clz = classLoader.loadClass("org.cxf.Greeter");
         assertTrue("Generate " + clz.getName() + "error", clz.isInterface());
     }
+    
+    
+    
 
     @Test
     public void testBug305772() throws Exception {
@@ -201,7 +204,8 @@
 
         String[] args = new String[] {"-d", output.getCanonicalPath(), "-nexclude",
                                       "http://apache.org/test/types=com.iona", "-nexclude",
-                                      "http://apache.org/Invoice",
+                                      "http://apache.org/Invoice", "-compile",
+                                      "-classdir", output.getCanonicalPath() + "/classes",
                                       getLocation("/wsdl2java_wsdl/hello_world_exclude.wsdl")};
         WSDLToJava.main(args);
 
@@ -210,7 +214,11 @@
         assertFalse("Generated file has been excluded", com.exists());
         File iona = new File(com, "iona");
         assertFalse("Generated file has been excluded", iona.exists());
-
+        
+        File implFile = new File(output, "org/apache/hello_world_soap_http/Greeter.java");
+        String str = getStringFromFile(implFile);
+        assertTrue(str.indexOf("com.iona.BareDocumentResponse") > 0);
+        
         File org = new File(output, "org");
         File apache = new File(org, "apache");
         File invoice = new File(apache, "Invoice");
@@ -218,6 +226,7 @@
 
     }
 
+
     @Test
     public void testExcludeNSWithoutPackageName() throws Exception {
 
@@ -231,7 +240,7 @@
         assertFalse("Generated file has been excluded", com.exists());
 
     }
-
+     
     @Test
     public void testCommandLine() throws Exception {
         String[] args = new String[] {"-compile", "-d", output.getCanonicalPath(), "-classdir",
@@ -414,6 +423,27 @@
         assertTrue(ws.exists());
         File address = new File(ws, "addressing");
         assertTrue(address.exists());
+    }
+    
+    
+    @Test
+    public void testDefatultNsMapExclude() throws Exception {
+        env.put(ToolConstants.CFG_ALL, ToolConstants.CFG_ALL);
+        env.put(ToolConstants.CFG_NEXCLUDE, 
+                "http://www.w3.org/2005/08/addressing=org.apache.cxf.ws.addressing");
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/cxf492/locator.wsdl"));
+        processor.setContext(env);
+        processor.execute();
+        
+        File org = new File(output, "org");
+        assertTrue("org directory is not exist", org.exists());
+        File apache = new File(org, "apache");
+        assertTrue(apache.exists());
+        File ws = new File(output, "org/apache/cxf/ws/addressing");
+        assertFalse(ws.exists());
+        
+        File orginal = new File(output, "org.w3._2005._08.addressing");
+        assertFalse(orginal.exists());
     }
     
     @Test



Mime
View raw message