cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1063236 - in /cxf/trunk/tools/corba/src: main/java/org/apache/cxf/tools/corba/ main/java/org/apache/cxf/tools/corba/idlpreprocessor/ main/java/org/apache/cxf/tools/corba/processors/idl/ test/java/org/apache/cxf/tools/corba/ test/resources/...
Date Tue, 25 Jan 2011 11:35:44 GMT
Author: ffang
Date: Tue Jan 25 11:35:43 2011
New Revision: 1063236

URL: http://svn.apache.org/viewvc?rev=1063236&view=rev
Log:
[CXF-3280]idl2wsdl does not process multiple include directories -I <dir> correctly.

Added:
    cxf/trunk/tools/corba/src/test/resources/idl/Parent.idl
    cxf/trunk/tools/corba/src/test/resources/idl/expected_Parent.wsdl
    cxf/trunk/tools/corba/src/test/resources/idl/subdir1/
    cxf/trunk/tools/corba/src/test/resources/idl/subdir1/Included1.idl
    cxf/trunk/tools/corba/src/test/resources/idl/subdir2/
    cxf/trunk/tools/corba/src/test/resources/idl/subdir2/Included2.idl
Modified:
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java
    cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java?rev=1063236&r1=1063235&r2=1063236&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java (original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java Tue Jan
25 11:35:43 2011
@@ -51,7 +51,9 @@ public class IDLToWSDL extends AbstractC
     }
 
     private Set getArrayKeys() {
-        return new HashSet<String>();
+        Set<String> arrayKeys = new HashSet<String>();
+        arrayKeys.add(ToolCorbaConstants.CFG_INCLUDEDIR);
+        return arrayKeys;
     }
 
     public void execute(boolean exitOnFinish) {
@@ -144,7 +146,7 @@ public class IDLToWSDL extends AbstractC
         
         if (env.optionSet(ToolCorbaConstants.CFG_INCLUDEDIR)) {
             env.put(ToolCorbaConstants.CFG_INCLUDEDIR,
-                    doc.getParameter(ToolCorbaConstants.CFG_INCLUDEDIR));
+                    doc.getParameters(ToolCorbaConstants.CFG_INCLUDEDIR));
         }
         if (env.optionSet(ToolCorbaConstants.CFG_WSDLOUTPUTFILE)) {
             env.put(ToolCorbaConstants.CFG_WSDLOUTPUTFILE,

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java?rev=1063236&r1=1063235&r2=1063236&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java
(original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java
Tue Jan 25 11:35:43 2011
@@ -20,10 +20,17 @@
 package org.apache.cxf.tools.corba.idlpreprocessor;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
 import java.util.Arrays;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+
 
 /**
  * @author lk
@@ -31,6 +38,7 @@ import java.util.Arrays;
  */
 public class DefaultIncludeResolver implements IncludeResolver {
 
+    private static final Logger LOG = LogUtils.getL7dLogger(DefaultIncludeResolver.class);
     private final File[] userIdlDirs;
 
     public DefaultIncludeResolver(File... idlDirs) {
@@ -61,8 +69,21 @@ public class DefaultIncludeResolver impl
                 // offload slash vs backslash to URL machinery
                 URL searchDirURL = searchDirURI.toURL();
                 final URL url = new URL(searchDirURL, spec);
-                // TODO: if "file in URL exists"
-                return url;
+                
+                // Check if file in URL exists, otherwise try next searchDir 
+                try {
+                    // If we can open a stream, the file exists 
+                    InputStream str = url.openStream();
+                    str.close();
+                    return url;
+                } catch (IOException ioe) {
+                    if (LOG.isLoggable(Level.WARNING)) {
+                        LOG.fine("Not able to resolve " 
+                                 + spec  
+                                 + "from  " 
+                                 + searchDirURL.toString());
+                    }
+                } 
             } catch (MalformedURLException e) {
                 final PreprocessingException preprocessingException = new PreprocessingException(
                     "Unable to resolve user include '" + spec + "' in '"

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java?rev=1063236&r1=1063235&r2=1063236&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java
(original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java
Tue Jan 25 11:35:43 2011
@@ -21,7 +21,6 @@ package org.apache.cxf.tools.corba.proce
 import java.io.File;
 import java.net.URL;
 import java.util.HashMap;
-import java.util.StringTokenizer;
 
 import antlr.TokenStreamHiddenTokenFilter;
 import antlr.collections.AST;
@@ -85,17 +84,13 @@ public class IDLProcessor implements Pro
 
     private DefaultIncludeResolver getDefaultIncludeResolver(File currentDir) {
         DefaultIncludeResolver includeResolver;
-        if (env.optionSet(ToolCorbaConstants.CFG_INCLUDEDIR)) {                        
-            String includedDirs = env.get(ToolCorbaConstants.CFG_INCLUDEDIR).toString();
-            StringTokenizer tok = new StringTokenizer(includedDirs, "");
-            File[] includeDirs = new File[tok.countTokens()];
-            int i = 0;
-            while (tok.hasMoreTokens()) {
-                String includeDir = tok.nextToken();
-                File infile = new File(includeDir);
-                includeDirs[i] = infile;
-                i++;
+        if (env.optionSet(ToolCorbaConstants.CFG_INCLUDEDIR)) {      
+            String[] includedDirs = (String[]) env.get(ToolCorbaConstants.CFG_INCLUDEDIR);
+            File[] includeDirs = new File[includedDirs.length];
+            for (int i = 0; i < includedDirs.length; i++) {
+                includeDirs[i] = new File(includedDirs[i]);
             }
+            
             includeResolver = new DefaultIncludeResolver(includeDirs);
         } else {
             includeResolver = new DefaultIncludeResolver(currentDir);

Modified: cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java?rev=1063236&r1=1063235&r2=1063236&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java
(original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java
Tue Jan 25 11:35:43 2011
@@ -89,7 +89,11 @@ public class OperationVisitor extends Vi
                                  WSDLASTVisitor wsdlVisitor) {
         boolean result = false;
         AST node2 = node.getFirstChild();
-        if (node2.getType() == IDLTokenTypes.LITERAL_oneway) {
+        
+        if (null == node2) {
+           // throw whatever appropriate error 
+           // or do nothing and return false
+        } else if (node2.getType() == IDLTokenTypes.LITERAL_oneway) {
             result = true;
         } else {
             int type = node2.getType();

Modified: cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java?rev=1063236&r1=1063235&r2=1063236&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java (original)
+++ cxf/trunk/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java Tue
Jan 25 11:35:43 2011
@@ -319,4 +319,24 @@ public class IDLToWSDLTest extends ToolT
         assertEquals("IDLToWSDL Failed", noError, exc);
         doTestGeneratedWsdl(expected, actual);
     }
+    
+    public void testMultipleIncludes() throws Exception {
+        File input = new File(getClass().getResource("/idl/Parent.idl").toURI());
+        File actual = new File(output, "Parent.wsdl");
+        File expected = 
+            new File(getClass().getResource("/idl/expected_Parent.wsdl").toURI());
+        
+        File include1Dir = new File(getClass().getResource("/idl/subdir1").toURI());
+        File include2Dir = new File(getClass().getResource("/idl/subdir2").toURI());
+        
+        String[] args = new String[] {"-ow", "Parent.wsdl",
+                                      "-o", output.toString(),
+                                      "-I", include1Dir.toString(),
+                                      "-I", include2Dir.toString(),
+                                      input.toString()
+        };
+        int exc = execute(args);
+        assertEquals("IDLToWSDL Failed", noError, exc);
+        doTestGeneratedWsdl(expected, actual);
+    }
 }

Added: cxf/trunk/tools/corba/src/test/resources/idl/Parent.idl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/resources/idl/Parent.idl?rev=1063236&view=auto
==============================================================================
--- cxf/trunk/tools/corba/src/test/resources/idl/Parent.idl (added)
+++ cxf/trunk/tools/corba/src/test/resources/idl/Parent.idl Tue Jan 25 11:35:43 2011
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef PARENT_IDL
+#define PARENT_IDL
+
+#include <Included1.idl>
+#include <Included2.idl>
+
+module Parent {
+  
+  interface TestForMultipleIncludes 
+  {
+      void testOperation(in Included1::MyType1 arg1, in Included2::MyType2 arg2); 
+  };
+};
+#endif

Added: cxf/trunk/tools/corba/src/test/resources/idl/expected_Parent.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/resources/idl/expected_Parent.wsdl?rev=1063236&view=auto
==============================================================================
--- cxf/trunk/tools/corba/src/test/resources/idl/expected_Parent.wsdl (added)
+++ cxf/trunk/tools/corba/src/test/resources/idl/expected_Parent.wsdl Tue Jan 25 11:35:43
2011
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<wsdl:definitions targetNamespace="http://cxf.apache.org/bindings/corba/idl/Parent" xmlns:corba="http://cxf.apache.org/bindings/corba"
xmlns:tns="http://cxf.apache.org/bindings/corba/idl/Parent" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+  <corba:typeMapping targetNamespace="http://cxf.apache.org/bindings/corba/idl/Parent/typemap">
+    <corba:alias xmlns:xs="http://www.w3.org/2001/XMLSchema" basetype="corba:string" repositoryID="IDL:Included1/MyType1:1.0"
name="Included1.MyType1" type="xs:string"/>
+    <corba:alias xmlns:xs="http://www.w3.org/2001/XMLSchema" basetype="corba:string" repositoryID="IDL:Included2/MyType2:1.0"
name="Included2.MyType2" type="xs:string"/>
+  </corba:typeMapping>
+  <wsdl:types>
+    <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://cxf.apache.org/bindings/corba/idl/Parent"
xmlns="http://cxf.apache.org/bindings/corba/idl/Parent" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+      <xs:element name="testOperation">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="arg1" type="xs:string">
+            </xs:element>
+            <xs:element name="arg2" type="xs:string">
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="testOperationResponse">
+        <xs:complexType>
+          <xs:sequence>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:schema>
+  </wsdl:types>
+  <wsdl:message name="testOperation">
+    <wsdl:part name="inparameter" element="tns:testOperation">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="testOperationResponse">
+    <wsdl:part name="outparameter" element="tns:testOperationResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="Parent.TestForMultipleIncludes">
+    <wsdl:operation name="testOperation">
+      <wsdl:input name="testOperationRequest" message="tns:testOperation">
+    </wsdl:input>
+      <wsdl:output name="testOperationResponse" message="tns:testOperationResponse">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="Parent.TestForMultipleIncludesCORBABinding" type="tns:Parent.TestForMultipleIncludes">
+    <corba:binding repositoryID="IDL:Parent/TestForMultipleIncludes:1.0"/>
+    <wsdl:operation name="testOperation">
+      <corba:operation name="testOperation">
+        <corba:param xmlns="http://cxf.apache.org/bindings/corba/idl/Parent/typemap" mode="in"
name="arg1" idltype="Included1.MyType1"/>
+        <corba:param xmlns="http://cxf.apache.org/bindings/corba/idl/Parent/typemap" mode="in"
name="arg2" idltype="Included2.MyType2"/>
+      </corba:operation>
+      <wsdl:input name="testOperationRequest">
+      </wsdl:input>
+      <wsdl:output name="testOperationResponse">
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="Parent.TestForMultipleIncludesCORBAService">
+    <wsdl:port name="Parent.TestForMultipleIncludesCORBAPort" binding="tns:Parent.TestForMultipleIncludesCORBABinding">
+      <corba:address location="IOR:"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

Added: cxf/trunk/tools/corba/src/test/resources/idl/subdir1/Included1.idl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/resources/idl/subdir1/Included1.idl?rev=1063236&view=auto
==============================================================================
--- cxf/trunk/tools/corba/src/test/resources/idl/subdir1/Included1.idl (added)
+++ cxf/trunk/tools/corba/src/test/resources/idl/subdir1/Included1.idl Tue Jan 25 11:35:43
2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef INCLUDED1_IDL
+#define INCLUDED1_IDL
+
+module Included1 {
+  
+  typedef string MyType1;
+  
+};
+#endif

Added: cxf/trunk/tools/corba/src/test/resources/idl/subdir2/Included2.idl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/resources/idl/subdir2/Included2.idl?rev=1063236&view=auto
==============================================================================
--- cxf/trunk/tools/corba/src/test/resources/idl/subdir2/Included2.idl (added)
+++ cxf/trunk/tools/corba/src/test/resources/idl/subdir2/Included2.idl Tue Jan 25 11:35:43
2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef INCLUDED2_IDL
+#define INCLUDED2_IDL
+
+module Included2 {
+  
+  typedef string MyType2;
+  
+};
+#endif



Mime
View raw message