incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mvesc...@apache.org
Subject svn commit: r518666 - in /incubator/yoko/trunk/tools/src: main/java/org/apache/yoko/tools/processors/idl/ test/java/org/apache/yoko/tools/ test/resources/idl/
Date Thu, 15 Mar 2007 15:35:22 GMT
Author: mvescovi
Date: Thu Mar 15 08:35:21 2007
New Revision: 518666

URL: http://svn.apache.org/viewvc?view=rev&rev=518666
Log:
[YOKO-308] Implemented '-t <corba-type-map target-namespace>' idltowsdl option and added
test

Added:
    incubator/yoko/trunk/tools/src/test/resources/idl/expected_sequence_octet_corba_typemap_tns.wsdl
  (with props)
Modified:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
    incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java?view=diff&rev=518666&r1=518665&r2=518666
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
Thu Mar 15 08:35:21 2007
@@ -94,13 +94,12 @@
         }
         // XmlSchema namespace
         String schemans = (String) env.get(ToolCorbaConstants.CFG_SCHEMA_NAMESPACE);
-        if (schemans == null) {
-            schemans = tns;
-        }
-
+        
+        // corba typemap namespace
+        String corbatypemaptns = (String) env.get(ToolCorbaConstants.CFG_CORBATYPEMAP_NAMESPACE);
         
         try {
-            WSDLASTVisitor visitor = new WSDLASTVisitor(tns, schemans);
+            WSDLASTVisitor visitor = new WSDLASTVisitor(tns, schemans, corbatypemaptns);
             if (env.optionSet(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE)) {
                 visitor.setSequenceOctetType((String) env.get(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE));
             }

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java?view=diff&rev=518666&r1=518665&r2=518666
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/WSDLASTVisitor.java
Thu Mar 15 08:35:21 2007
@@ -73,7 +73,7 @@
 
     XmlSchemaType sequenceOctetType;
     
-    public WSDLASTVisitor(String tns, String schemans)
+    public WSDLASTVisitor(String tns, String schemans, String corbatypemaptns)
         throws WSDLException, JAXBException {
         
         definition = createWsdlDefinition(tns);
@@ -83,7 +83,7 @@
         
         addAnyType();
         
-        createCorbaTypeMap();
+        createCorbaTypeMap(corbatypemaptns);
         
         // idl:sequence<octet> maps to xsd:base64Binary by default
         sequenceOctetType = schemas.getTypeByQName(Constants.XSD_BASE64);
@@ -181,17 +181,26 @@
     }
     
     private XmlSchema createSchema(String schemans) {
+        // if no XmlSchema target namespace was specified, default to the 
+        // definition target namespace
+        if (schemans == null) {
+            schemans = definition.getTargetNamespace();
+        }
         XmlSchema xmlSchema = new XmlSchema(schemans, schemas);
         return xmlSchema;
     }
     
-    private void createCorbaTypeMap() throws WSDLException { 
+    private void createCorbaTypeMap(String corbatypemaptns) throws WSDLException { 
         typeMap = (TypeMappingType)
             definition.getExtensionRegistry().createExtension(Definition.class,
                                                               CorbaConstants.NE_CORBA_TYPEMAPPING);
-        typeMap.setTargetNamespace(definition.getTargetNamespace()
-                                   + "/"
-                                   + CorbaConstants.NS_CORBA_TYPEMAP);
+        if (corbatypemaptns == null) {
+            typeMap.setTargetNamespace(definition.getTargetNamespace()
+                + "/"
+                + CorbaConstants.NS_CORBA_TYPEMAP);
+        } else {
+            typeMap.setTargetNamespace(corbatypemaptns);
+        }
         definition.addExtensibilityElement(typeMap);
     }
 

Modified: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java?view=diff&rev=518666&r1=518665&r2=518666
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java (original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java Thu
Mar 15 08:35:21 2007
@@ -237,5 +237,19 @@
         IDLToWSDL.main(args);
         testGeneratedWsdl(expected, actual);
     }
-    
+
+    // test "-t <corba-type-map target-namespace>"
+    public void testCorbaTypeMapTargetNamespace() throws Exception {
+        File input = new File(getClass().getResource("/idl/sequence_octet.idl").getFile());
+        File actual = new File(output, "sequence_octet.wsdl");
+        File expected = new File(getClass().getResource("/idl/expected_sequence_octet_corba_typemap_tns.wsdl").getFile());
+        
+        String[] args = new String[] {"-t", "http://yoko.org/foobar/typemap",
+                                      "-o", output.toString(),
+                                      input.toString()
+                                      };
+        IDLToWSDL.main(args);
+        testGeneratedWsdl(expected, actual);
+    }
+
 }

Added: incubator/yoko/trunk/tools/src/test/resources/idl/expected_sequence_octet_corba_typemap_tns.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_sequence_octet_corba_typemap_tns.wsdl?view=auto&rev=518666
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_sequence_octet_corba_typemap_tns.wsdl
(added)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_sequence_octet_corba_typemap_tns.wsdl
Thu Mar 15 08:35:21 2007
@@ -0,0 +1,36 @@
+<?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://schemas.apache.org/yoko/idl/sequence_octet"
xmlns:tns="http://schemas.apache.org/yoko/idl/sequence_octet" xmlns:corba="http://schemas.apache.org/yoko/bindings/corba"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+  <corba:typeMapping targetNamespace="http://yoko.org/foobar/typemap">
+    <corba:sequence xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://yoko.org/foobar/typemap"
elemtype="corba:octet" bound="0" repositoryID="IDL:mySequenceOctet:1.0" name="mySequenceOctet"
type="xs:base64Binary" />
+    <corba:anonsequence xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://yoko.org/foobar/typemap"
elemtype="corba:octet" bound="0" name="_1_mySequenceSequenceOctet" type="xs:base64Binary"
/>
+    <corba:sequence xmlns:ns4="http://schemas.apache.org/yoko/idl/sequence_octet" xmlns="http://yoko.org/foobar/typemap"
elemtype="_1_mySequenceSequenceOctet" bound="0" repositoryID="IDL:mySequenceSequenceOctet:1.0"
name="mySequenceSequenceOctet" type="ns4:mySequenceSequenceOctet" />
+  </corba:typeMapping>
+  <wsdl:types>
+    <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/sequence_octet"
xmlns="http://schemas.apache.org/yoko/idl/sequence_octet" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+      <xs:complexType name="mySequenceSequenceOctet">
+        <xs:sequence>
+          <xs:element maxOccurs="unbounded" minOccurs="0" name="item" type="xs:base64Binary">
+          </xs:element>
+        </xs:sequence>
+      </xs:complexType>
+    </xs:schema>
+  </wsdl:types>
+</wsdl:definitions>

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_sequence_octet_corba_typemap_tns.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_sequence_octet_corba_typemap_tns.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/yoko/trunk/tools/src/test/resources/idl/expected_sequence_octet_corba_typemap_tns.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message