cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1070799 - in /cxf/trunk/tools/corba/src: main/java/org/apache/cxf/tools/corba/processors/idl/ConstVisitor.java test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java test/resources/idl/ReferUndefinedType.idl
Date Tue, 15 Feb 2011 08:04:04 GMT
Author: ffang
Date: Tue Feb 15 08:04:04 2011
New Revision: 1070799

URL: http://svn.apache.org/viewvc?rev=1070799&view=rev
Log:
[CXF-3303]idl2wsdl fails with NPE if a type cannot be resolved

Added:
    cxf/trunk/tools/corba/src/test/resources/idl/ReferUndefinedType.idl
Modified:
    cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ConstVisitor.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/processors/idl/ConstVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ConstVisitor.java?rev=1070799&r1=1070798&r2=1070799&view=diff
==============================================================================
--- cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ConstVisitor.java
(original)
+++ cxf/trunk/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ConstVisitor.java
Tue Feb 15 08:04:04 2011
@@ -93,7 +93,9 @@ public class ConstVisitor extends Visito
         } else if (ScopedNameVisitor.accept(getScope(), definition, schema, constTypeNode,
wsdlVisitor)) {
             visitor = new ScopedNameVisitor(getScope(), definition, schema, wsdlVisitor);
           
         }
-        
+        if (visitor == null) {
+            throw new RuntimeException("can't resolve type for const " + constNameNode.getText());
+        }
         visitor.visit(constTypeNode);                
         XmlSchemaType constSchemaType = visitor.getSchemaType();
         CorbaTypeImpl constCorbaType = visitor.getCorbaType();        

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=1070799&r1=1070798&r2=1070799&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
Feb 15 08:04:04 2011
@@ -378,4 +378,21 @@ public class IDLToWSDLTest extends ToolT
         doTestGeneratedWsdl(expected, actual);
     }
 
+    public void testUndefinedTypeRef() throws Exception {
+        File input = new File(getClass().getResource("/idl/ReferUndefinedType.idl").toURI());
+        File include1Dir = new File(getClass().getResource("/idl").toURI());
+               
+        String[] args = new String[] {"-ow", "ExternalInterfaceRef.wsdl",
+                                      "-o", output.toString(),
+                                      "-I", include1Dir.toString(),
+                                      "-verbose",
+                                      input.toString()
+        };
+        try {
+            IDLToWSDL.run(args);
+            fail("should throw a RuntimeException");
+        } catch (Exception e) {
+            assertTrue(e.getMessage().indexOf("can't resolve type for const myConst") >=
0);
+        }
+    }
 }

Added: cxf/trunk/tools/corba/src/test/resources/idl/ReferUndefinedType.idl
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/corba/src/test/resources/idl/ReferUndefinedType.idl?rev=1070799&view=auto
==============================================================================
--- cxf/trunk/tools/corba/src/test/resources/idl/ReferUndefinedType.idl (added)
+++ cxf/trunk/tools/corba/src/test/resources/idl/ReferUndefinedType.idl Tue Feb 15 08:04:04
2011
@@ -0,0 +1,30 @@
+/*
+ * 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 EXTERNAL_INTTERFACE_REF_IDL
+#define EXTERNAL_INTTERFACE_REF_IDL
+
+#include "PragmaPrefix.idl"
+
+module ReferUndefinedType {
+
+  
+  const Test2::NoThisType myConst = 1;
+};
+#endif



Mime
View raw message