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 mv...@apache.org on 2007/03/15 13:54:26 UTC

svn commit: r518630 - in /incubator/yoko/trunk/tools/src: main/java/org/apache/yoko/tools/ main/java/org/apache/yoko/tools/common/ main/java/org/apache/yoko/tools/processors/idl/ test/java/org/apache/yoko/tools/ test/resources/idl/

Author: mvescovi
Date: Thu Mar 15 06:54:24 2007
New Revision: 518630

URL: http://svn.apache.org/viewvc?view=rev&rev=518630
Log:
[YOKO-309] Implemented '-f <corba-address-file>' idltowsdl option and added test

Added:
    incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld_corba_address_file.wsdl   (with props)
Modified:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.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/IDLToWSDL.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java?view=diff&rev=518630&r1=518629&r2=518630
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java Thu Mar 15 06:54:24 2007
@@ -169,6 +169,15 @@
                 }
             }
         }
+        if (doc.hasParameter(ToolCorbaConstants.CFG_ADDRESSFILE)) {
+            String addressFileName = doc.getParameter(ToolCorbaConstants.CFG_ADDRESSFILE);
+            File addressFile = new File(addressFileName);
+            if (!addressFile.canRead()
+                || !addressFile.isFile()) {
+                errors.add(new ErrorVisitor.UserError("Invalid value specified for -f option\n"
+                                                      + "\"" + addressFileName + "\" cannot be read"));
+            }
+        }
 
         if (errors.getErrors().size() > 0) {
             Message msg = new Message("PARAMETER_MISSING", LOG);

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java?view=diff&rev=518630&r1=518629&r2=518630
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java Thu Mar 15 06:54:24 2007
@@ -37,4 +37,6 @@
     public static final String CFG_SEQUENCE_OCTET_TYPE_HEXBINARY = "hexBinary";
     public static final String CFG_SCHEMA_NAMESPACE = "schemans";
     public static final String CFG_SCHEMA_NAMESPACE_PREFIX = "xsd1";
+    public static final String CFG_ADDRESSFILE = "addressfile";
+    public static final String CFG_CORBATYPEMAP_NAMESPACE = "corbatypemapns";
 }

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=518630&r1=518629&r2=518630
==============================================================================
--- 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 06:54:24 2007
@@ -19,7 +19,10 @@
 
 package org.apache.yoko.tools.processors.idl;
 
+import java.io.BufferedReader;
+import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileReader;
 import java.io.InputStream;
 import java.io.Writer;
 import java.util.StringTokenizer;
@@ -153,7 +156,21 @@
             AddressType address =
                 (AddressType) def.getExtensionRegistry().createExtension(Port.class,
                                                                          CorbaConstants.NE_CORBA_ADDRESS);
-            String addr = (String) env.get(ToolCorbaConstants.CFG_ADDRESS);
+            
+            String addr = null;
+            String addrFileName = (String) env.get(ToolCorbaConstants.CFG_ADDRESSFILE); 
+            if (addrFileName != null) {
+                try {
+                    File addrFile = new File(addrFileName);
+                    FileReader fileReader = new FileReader(addrFile);
+                    BufferedReader bufferedReader = new BufferedReader(fileReader);
+                    addr = bufferedReader.readLine();
+                } catch (Exception ex) {
+                    throw new ToolException(ex.getMessage(), ex);
+                }
+            } else {
+                addr = (String) env.get(ToolCorbaConstants.CFG_ADDRESS);
+            }
             if (addr == null) {
                 addr = "IOR:";
             }

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=518630&r1=518629&r2=518630
==============================================================================
--- 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 06:54:24 2007
@@ -25,6 +25,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.FileWriter;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
@@ -209,4 +210,32 @@
         IDLToWSDL.main(args);
         testGeneratedWsdl(expected, actual);
     }
+    
+    // test "-f <corba-address-file>"
+    public void testCorbaAddressFile() throws Exception {
+        File input = new File(getClass().getResource("/idl/HelloWorld.idl").getFile());
+        File actual = new File(output, "HelloWorld.wsdl");
+        File expected = new File(getClass().getResource("/idl/expected_HelloWorld_corba_address_file.wsdl").getFile());
+        
+        // create temporary file containing ior
+        File addressFile = new File(output, "HelloWorld.idl");
+        FileWriter addressFileWriter = new FileWriter(addressFile);
+        addressFileWriter.write(
+           "IOR:010000001400000049444c3a48656c6c6f576f726c64493a312e3000020000000000000080000000010101001e0000"
+           + "006d766573636f76692e6475626c696e2e656d65612e696f6e612e636f6d0022064d0000003a5c6d766573636f76692e64"
+           + "75626c696e2e656d65612e696f6e612e636f6d3a48656c6c6f576f726c642f48656c6c6f576f726c643a6d61726b65723a" 
+           + "3a49523a48656c6c6f576f726c644900000000000000000100000018000000010000000100000000000000080000000100"
+           + "0000305f5449"
+        );
+        addressFileWriter.close();
+        addressFile.deleteOnExit();
+        
+        String[] args = new String[] {"-f", addressFile.toString(),
+                                      "-o", output.toString(),
+                                      input.toString()
+                                      };
+        IDLToWSDL.main(args);
+        testGeneratedWsdl(expected, actual);
+    }
+    
 }

Added: incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld_corba_address_file.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld_corba_address_file.wsdl?view=auto&rev=518630
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld_corba_address_file.wsdl (added)
+++ incubator/yoko/trunk/tools/src/test/resources/idl/expected_HelloWorld_corba_address_file.wsdl Thu Mar 15 06:54:24 2007
@@ -0,0 +1,76 @@
+<?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/HelloWorld" xmlns:tns="http://schemas.apache.org/yoko/idl/HelloWorld" 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://schemas.apache.org/yoko/idl/HelloWorld/typemap" />
+  <wsdl:types>
+    <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://schemas.apache.org/yoko/idl/HelloWorld" xmlns="http://schemas.apache.org/yoko/idl/HelloWorld" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+      <xs:element name="greetMe">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="return_message" type="xs:string">
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="greetMeResponse">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="return" type="xs:string">
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:schema>
+  </wsdl:types>
+  <wsdl:message name="greetMeResponse">
+    <wsdl:part name="outparameter" element="tns:greetMeResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="greetMe">
+    <wsdl:part name="inparameter" element="tns:greetMe">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="HelloWorld">
+    <wsdl:operation name="greetMe">
+      <wsdl:input name="greetMeRequest" message="tns:greetMe">
+    </wsdl:input>
+      <wsdl:output name="greetMeResponse" message="tns:greetMeResponse">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="HelloWorldCORBABinding" type="tns:HelloWorld">
+    <corba:binding repositoryID="IDL:HelloWorld:1.0" />
+    <wsdl:operation name="greetMe">
+      <corba:operation name="greetMe">
+        <corba:param mode="in" name="return_message" idltype="corba:string" />
+        <corba:return name="return" idltype="corba:string" />
+      </corba:operation>
+      <wsdl:input name="greetMeRequest">
+      </wsdl:input>
+      <wsdl:output name="greetMeResponse">
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="HelloWorldCORBAService">
+    <wsdl:port name="HelloWorldCORBAPort" binding="tns:HelloWorldCORBABinding">
+      <corba:address location="IOR:010000001400000049444c3a48656c6c6f576f726c64493a312e3000020000000000000080000000010101001e0000006d766573636f76692e6475626c696e2e656d65612e696f6e612e636f6d0022064d0000003a5c6d766573636f76692e6475626c696e2e656d65612e696f6e612e636f6d3a48656c6c6f576f726c642f48656c6c6f576f726c643a6d61726b65723a3a49523a48656c6c6f576f726c6449000000000000000001000000180000000100000001000000000000000800000001000000305f5449" />
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

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

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

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