You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by en...@apache.org on 2006/07/31 15:44:26 UTC

svn commit: r427146 [1/3] - in /incubator/yoko/trunk/tools/src: main/java/org/apache/yoko/tools/processors/wsdl/ test/java/org/apache/yoko/tools/processors/ test/resources/idlgen/

Author: enolan
Date: Mon Jul 31 08:44:25 2006
New Revision: 427146

URL: http://svn.apache.org/viewvc?rev=427146&view=rev
Log:
Jira issues Yoko 106 and 108 - fix for incorrect exceptions and added new tests for idl generation
for array/sequence support.

Added:
    incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_sequencetype.idl
    incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_struct.idl
    incubator/yoko/trunk/tools/src/test/resources/idlgen/sequencetype.wsdl   (with props)
    incubator/yoko/trunk/tools/src/test/resources/idlgen/struct.wsdl   (with props)
Modified:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
    incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTest.java
    incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java?rev=427146&r1=427145&r2=427146&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaBinding.java Mon Jul 31 08:44:25 2006
@@ -559,7 +559,13 @@
             CorbaTypeImpl corbaTypeImpl = (CorbaTypeImpl)corbaex;
             corbaTypeImpl.setQName(null);            
             if (!isDuplicate(corbaTypeImpl)) {
-                typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
+                CorbaTypeImpl dup = isDuplicateException(corbaTypeImpl);
+                if (dup != null) {
+                    typeMappingType.getStructOrExceptionOrUnion().remove(dup);
+                    typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
+                } else {
+                    typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
+                }
             }
         }
 
@@ -1085,7 +1091,7 @@
         } else if (isUnion(complex)) {
             corbatype = processRegularUnion(complex, defaultName);                                           
         } else if (complex.getQName() != null && isIDLObjectType(complex.getQName())) {
-            // process it.        
+            // process it.                
         } else {
             // Deal the ComplexType as Struct
             corbatype = processStruct(complex, defaultName);
@@ -1093,6 +1099,8 @@
 
         return corbatype;
     }
+    
+      
 
     private CorbaTypeImpl processStruct(XmlSchemaComplexType complex, QName defaultName)
         throws Exception {
@@ -1140,7 +1148,7 @@
 
         return corbaStruct;
     }
-    
+        
     protected Struct processSimpleContentStruct(XmlSchemaSimpleContent simpleContent, 
                                                 QName defaultName, Struct corbaStruct, QName schematypeName)
         throws Exception {        
@@ -1523,6 +1531,25 @@
             }
         }
         return false;
+    }
+    
+    private CorbaTypeImpl isDuplicateException(CorbaTypeImpl corbaTypeImpl) {
+        CorbaTypeImpl duplicate = null;
+        String corbaName = corbaTypeImpl.getName();
+        String corbaType = corbaTypeImpl.getType().getLocalPart();
+        if (!typeMappingType.getStructOrExceptionOrUnion().isEmpty()) {
+            Iterator i = typeMappingType.getStructOrExceptionOrUnion().iterator();
+            while (i.hasNext()) {
+                CorbaTypeImpl type = (CorbaTypeImpl)i.next();
+                if (corbaName.equals(type.getName())
+                                     && corbaType.equals(type.getType().getLocalPart())) {                    
+                    if (type instanceof Struct) {                        
+                        return type;
+                    }
+                }
+            }
+        }
+        return duplicate;
     }
     
     private QName checkPrefix(QName schematypeName) {

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java?rev=427146&r1=427145&r2=427146&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java Mon Jul 31 08:44:25 2006
@@ -139,16 +139,18 @@
         if (env.optionSet(ToolConstants.CFG_BINDING)) {
             idlAction.setBindingName(env.get("binding").toString());
         } else {
-            String portType = null;
-            if (env.optionSet(ToolConstants.CFG_PORTTYPE)) {
-                portType = env.get("porttype").toString();
-            } else {
-                portType = wsdlToCorbaBinding.getInterfaceNames().get(0).toString();
-            }
-            if (portType != null) {
-                String bindingName = wsdlToCorbaBinding.getMappedBindingName(portType);
-                if (bindingName != null) {
-                    idlAction.setBindingName(bindingName);
+            if (wsdlToCorbaBinding != null) {
+                String portType = null;
+                if (env.optionSet(ToolConstants.CFG_PORTTYPE)) {
+                    portType = env.get("porttype").toString();
+                } else {
+                    portType = wsdlToCorbaBinding.getInterfaceNames().get(0).toString();
+                }
+                if (portType != null) {
+                    String bindingName = wsdlToCorbaBinding.getMappedBindingName(portType);
+                    if (bindingName != null) {
+                        idlAction.setBindingName(bindingName);
+                    }
                 }
             }
         }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java?rev=427146&r1=427145&r2=427146&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java Mon Jul 31 08:44:25 2006
@@ -330,7 +330,7 @@
             Iterator i = typeMappingType.getStructOrExceptionOrUnion().iterator();
             while (i.hasNext()) {
                 CorbaTypeImpl corbaType = (CorbaTypeImpl)i.next();                
-                if (corbaType.getType().equals(qname)) {                
+                if (corbaType.getType().getLocalPart().equals(qname.getLocalPart())) {                
                     return corbaType;
                 }
             }
@@ -648,14 +648,22 @@
     }
 
     private Binding findBinding(Definition definition) {
+        Binding binding = null;
         Map bindings = definition.getBindings();
         Iterator i = bindings.values().iterator();
-        Binding binding = null;
-        while (i.hasNext()) {
-            binding = (Binding)i.next();
-            if (binding.getQName().getLocalPart().equals(bindingName)) {
-                return binding;
+        
+        if (bindingName != null) {                    
+            while (i.hasNext()) {
+                binding = (Binding)i.next();
+                if (binding.getQName().getLocalPart().equals(bindingName)) {
+                    return binding;
+                }
             }
+        } else {
+            if (bindings.size() >= 1) {
+                binding = (Binding)i.next();
+            }
+            
         }
         return binding;
     }
@@ -678,7 +686,7 @@
     public void setOutput(PrintWriter pw) {
         printWriter = pw;
     }
-
+ 
     public void setWsdlFile(String file) {
         wsdlFileName = new String(file);
     }

Modified: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTest.java?rev=427146&r1=427145&r2=427146&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTest.java (original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTest.java Mon Jul 31 08:44:25 2006
@@ -85,7 +85,7 @@
         assertNotNull(typemap);
         assertEquals(2, typemap.getElementsByTagName("corba:sequence").getLength());
         assertEquals(5, typemap.getElementsByTagName("corba:exception").getLength());
-        assertEquals(75, typemap.getElementsByTagName("corba:struct").getLength());
+        assertEquals(70, typemap.getElementsByTagName("corba:struct").getLength());
     }
     
     public void testUnionType() throws Exception {

Modified: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java?rev=427146&r1=427145&r2=427146&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java (original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java Mon Jul 31 08:44:25 2006
@@ -212,7 +212,52 @@
         }
     }
     
-   /*public void testEnumIdlgen() throws Exception {
+    public void testStructIdlgen() throws Exception {
+
+        try {
+            WSDLToIDLAction idlgen = new WSDLToIDLAction();
+            String fileName = getClass().getResource("/idlgen/struct.wsdl").toString();
+            idlgen.setWsdlFile(fileName);
+
+            idlgen.setBindingName("StructTestCORBABinding");
+            idlgen.setOutputFile("structtypes.idl");
+            ByteArrayOutputStream idloutput = new ByteArrayOutputStream();
+            idlgen.setOutput(new PrintWriter(idloutput));
+            idlgen.generateIDL(null);
+
+            InputStream origstream = getClass().getResourceAsStream("/idlgen/expected_struct.idl");
+            byte orig[] = inputStreamToBytes(origstream);
+
+            checkIDLStrings(orig, idloutput.toByteArray());
+        } finally {
+            new File("structtypes.idl").deleteOnExit();
+        }
+    }
+
+
+    public void testSequenceIdlgen() throws Exception {
+
+        try {
+            WSDLToIDLAction idlgen = new WSDLToIDLAction();
+            String fileName = getClass().getResource("/idlgen/sequencetype.wsdl").toString();
+            idlgen.setWsdlFile(fileName);
+
+            idlgen.setBindingName("IACC.ServerCORBABinding");
+            idlgen.setOutputFile("sequencetypes.idl");
+            ByteArrayOutputStream idloutput = new ByteArrayOutputStream();
+            idlgen.setOutput(new PrintWriter(idloutput));
+            idlgen.generateIDL(null);
+
+            InputStream origstream = getClass().getResourceAsStream("/idlgen/expected_sequencetype.idl");
+            byte orig[] = inputStreamToBytes(origstream);
+
+            checkIDLStrings(orig, idloutput.toByteArray());
+        } finally {
+            new File("sequencetypes.idl").deleteOnExit();
+        }
+    }
+
+    /*public void testEnumIdlgen() throws Exception {
         
         try {
             WSDLToIDLAction idlgen = new WSDLToIDLAction();

Added: incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_sequencetype.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_sequencetype.idl?rev=427146&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_sequencetype.idl (added)
+++ incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_sequencetype.idl Mon Jul 31 08:44:25 2006
@@ -0,0 +1,374 @@
+module IACC {
+    struct OneAttribute {
+        long level;
+        string name;
+        string value;
+    };
+    typedef sequence<OneAttribute> IACCList;
+    struct Subscriber {
+        IACCList info;
+        long request_id;
+    };
+    typedef sequence<Subscriber> IACCLists;
+    exception RemoteException {
+    };
+    exception IACCException {
+    };
+    exception ConnectionNotAvailableException {
+    };
+    exception ConnectionExhaustedException {
+    };
+    exception TimeoutException {
+    };
+    interface Server {
+        struct makeAllowanceResult {
+            ::IACC::IACCList return;
+        };
+        struct setSNParserClass {
+            string parserName;
+        };
+        struct cancelReservationResult {
+            ::IACC::IACCList return;
+        };
+        struct cancelReservation2 {
+            ::IACC::IACCLists attributes;
+        };
+        struct commitReservation2 {
+            ::IACC::IACCLists attributes;
+        };
+        struct getVersionResult {
+            string return;
+        };
+        struct makeTopUp {
+            ::IACC::IACCList attributes;
+        };
+        struct commitReservation2Result {
+            ::IACC::IACCLists return;
+        };
+        struct makeTopUpResult {
+            ::IACC::IACCList return;
+        };
+        struct hasCreditResult {
+            ::IACC::IACCList return;
+        };
+        struct setDatabaseHostPort {
+            string port;
+        };
+        struct setDatabaseHostName {
+            string hostname;
+        };
+        struct cancelReservation2Result {
+            ::IACC::IACCLists return;
+        };
+        struct hasCredit2 {
+            ::IACC::IACCLists attributes;
+            long operation;
+        };
+        struct setPassword {
+            string password;
+        };
+        struct refreshAllowance {
+            ::IACC::IACCList attributes;
+        };
+        struct commitReservation {
+            ::IACC::IACCList attributes;
+        };
+        struct isServerUp2Result {
+            ::IACC::IACCList return;
+        };
+        struct cancelAllowanceResult {
+            ::IACC::IACCList return;
+        };
+        struct setConnectionInstances {
+            string number;
+        };
+        struct makeAllowance {
+            ::IACC::IACCList attributes;
+        };
+        struct setServiceNameSelector {
+            string option;
+        };
+        struct commitAllowance {
+            ::IACC::IACCList attributes;
+        };
+        struct cancelAllowance {
+            ::IACC::IACCList attributes;
+        };
+        struct isServerUpResult {
+            string return;
+        };
+        struct cancelReservation {
+            ::IACC::IACCList attributes;
+        };
+        struct commitAllowanceResult {
+            ::IACC::IACCList return;
+        };
+        struct getUsernameResult {
+            string return;
+        };
+        struct getDatabaseHostPortResult {
+            string return;
+        };
+        struct getServiceNameSelectorResult {
+            string return;
+        };
+        struct hasCredit {
+            ::IACC::IACCList attributes;
+            long operation;
+        };
+        struct hasCredit2Result {
+            ::IACC::IACCLists return;
+        };
+        struct getSNParserClassResult {
+            string return;
+        };
+        struct setLoginType {
+            string logintype;
+        };
+        struct getPasswordResult {
+            string return;
+        };
+        struct getDatabaseHostNameResult {
+            string return;
+        };
+        struct isServerUp2 {
+            ::IACC::IACCList attributes;
+        };
+        struct getConnectionInstancesResult {
+            string return;
+        };
+        struct setUsername {
+            string username;
+        };
+        struct isProxyUpResult {
+            string return;
+        };
+        struct refreshAllowanceResult {
+            ::IACC::IACCList return;
+        };
+        struct getLoginTypeResult {
+            string return;
+        };
+        struct commitReservationResult {
+            ::IACC::IACCList return;
+        };
+        void
+        updateConfigParameters() raises(
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCList
+        hasCredit(
+            in ::IACC::IACCList attributes,
+            in long operation
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCLists
+        hasCredit2(
+            in ::IACC::IACCLists attributes,
+            in long operation
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCList
+        commitReservation(
+            in ::IACC::IACCList attributes
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCLists
+        commitReservation2(
+            in ::IACC::IACCLists attributes
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCList
+        cancelReservation(
+            in ::IACC::IACCList attributes
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCLists
+        cancelReservation2(
+            in ::IACC::IACCLists attributes
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCList
+        makeAllowance(
+            in ::IACC::IACCList attributes
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCList
+        refreshAllowance(
+            in ::IACC::IACCList attributes
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCList
+        commitAllowance(
+            in ::IACC::IACCList attributes
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCList
+        cancelAllowance(
+            in ::IACC::IACCList attributes
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCList
+        makeTopUp(
+            in ::IACC::IACCList attributes
+        ) raises(
+            ::IACC::IACCException,
+            ::IACC::ConnectionNotAvailableException,
+            ::IACC::ConnectionExhaustedException,
+            ::IACC::TimeoutException,
+            ::IACC::RemoteException
+        );
+        void
+        setConnectionInstances(
+            in string number
+        ) raises(
+            ::IACC::RemoteException
+        );
+        string
+        getConnectionInstances() raises(
+            ::IACC::RemoteException
+        );
+        void
+        setDatabaseHostName(
+            in string hostname
+        ) raises(
+            ::IACC::RemoteException
+        );
+        string
+        getDatabaseHostName() raises(
+            ::IACC::RemoteException
+        );
+        void
+        setDatabaseHostPort(
+            in string port
+        ) raises(
+            ::IACC::RemoteException
+        );
+        string
+        getDatabaseHostPort() raises(
+            ::IACC::RemoteException
+        );
+        void
+        setUsername(
+            in string username
+        ) raises(
+            ::IACC::RemoteException
+        );
+        string
+        getUsername() raises(
+            ::IACC::RemoteException
+        );
+        void
+        setPassword(
+            in string password
+        ) raises(
+            ::IACC::RemoteException
+        );
+        string
+        getPassword() raises(
+            ::IACC::RemoteException
+        );
+        void
+        setLoginType(
+            in string logintype
+        ) raises(
+            ::IACC::RemoteException
+        );
+        string
+        getLoginType() raises(
+            ::IACC::RemoteException
+        );
+        void
+        setSNParserClass(
+            in string parserName
+        ) raises(
+            ::IACC::RemoteException
+        );
+        string
+        getSNParserClass() raises(
+            ::IACC::RemoteException
+        );
+        void
+        setServiceNameSelector(
+            in string option
+        ) raises(
+            ::IACC::RemoteException
+        );
+        string
+        getServiceNameSelector() raises(
+            ::IACC::RemoteException
+        );
+        void
+        shutdown() raises(
+            ::IACC::RemoteException
+        );
+        string
+        isServerUp() raises(
+            ::IACC::RemoteException
+        );
+        string
+        isProxyUp() raises(
+            ::IACC::RemoteException
+        );
+        string
+        getVersion() raises(
+            ::IACC::RemoteException
+        );
+        ::IACC::IACCList
+        isServerUp2(
+            in ::IACC::IACCList attributes
+        ) raises(
+            ::IACC::IACCException
+        );
+    };
+};

Added: incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_struct.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_struct.idl?rev=427146&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_struct.idl (added)
+++ incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_struct.idl Mon Jul 31 08:44:25 2006
@@ -0,0 +1,10 @@
+struct OutsideStruct {
+    long number;
+    string word;
+};
+interface StructTest {
+    void
+    simple(
+        inout ::OutsideStruct outside
+    );
+};