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 br...@apache.org on 2006/06/16 19:24:52 UTC

svn commit: r414890 - /incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java

Author: bravi
Date: Fri Jun 16 12:24:51 2006
New Revision: 414890

URL: http://svn.apache.org/viewvc?rev=414890&view=rev
Log:
Fixing the wsdltoidl unit tests which failed when run from trunk.
JIRA:http://issues.apache.org/jira/browse/YOKO-64

Modified:
    incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java

Modified: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java?rev=414890&r1=414889&r2=414890&view=diff
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java (original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java Fri Jun 16 12:24:51 2006
@@ -27,6 +27,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStreamReader;
+import java.io.IOException;
 import java.io.PrintStream;
 import java.net.URL;
 import java.security.Permission;
@@ -62,20 +63,35 @@
         }
         
         try {
-            URL url = WSDLToIDLTest.class.getResource(".");
-            output = new File(url.getFile());
-            output = new File(output, "/resources");
-
+            File file = File.createTempFile("WSDLToIDLTest", "");
+            output = new File(file.getAbsolutePath() + ".dir");
+            file.delete();
+            
             if (!output.exists()) {
                 output.mkdir();
-            }
+            }            
         } catch (Exception e) {
             // complete
         }
     }
 
+    private void deleteDir(File dir) throws IOException {
+        for (File f : dir.listFiles()) {
+            if (f.isDirectory()) {
+                deleteDir(f);
+            } else {
+                f.delete();
+            }
+        }
+        dir.delete();
+    }
+
     public void tearDown() {
-        output.deleteOnExit();
+        try {
+            deleteDir(output);
+        } catch (IOException ex) {
+            //ignore
+        }
         output = null;
     }
 
@@ -126,11 +142,12 @@
 
     public void testBindingGenDefault() throws Exception {
         String[] cmdArgs = {"-corba", "-i", "BasePortType",
+                            "-d", output.getCanonicalPath(),
                             getClass().getResource("/wsdl/simpleList.wsdl").toString()};
         int exc = execute(cmdArgs);
         assertEquals("WSDLToIDL Failed", noError, exc);
 
-        File f = new File("simpleList-corba.wsdl");
+        File f = new File(output, "simpleList-corba.wsdl");
         assertTrue("simpleList-corba.wsdl should be generated", f.exists());
 
         WSDLToProcessor proc = new WSDLToProcessor();
@@ -147,15 +164,16 @@
         }
     }
     
-    
     public void testBindingGenSpecifiedFile() throws Exception {
 
-        String[] cmdArgs = {"-corba", "-i", "BasePortType", "-o", "simpleList-corba_gen.wsdl",
+        String[] cmdArgs = {"-corba", "-i", "BasePortType",
+                            "-o", "simpleList-corba_gen.wsdl",
+                            "-d", output.getCanonicalPath(),
                             getClass().getResource("/wsdl/simpleList.wsdl").toString()};
         int exc = execute(cmdArgs);
         assertEquals("WSDLToIDL Failed", noError, exc);
 
-        File f = new File("simpleList-corba_gen.wsdl");
+        File f = new File(output, "simpleList-corba_gen.wsdl");
         assertTrue("simpleList-corba_gen.wsdl should be generated", f.exists());
 
         WSDLToProcessor proc = new WSDLToProcessor();
@@ -174,12 +192,13 @@
     
     
     public void testIDLGenDefault() throws Exception {        
-        String[] cmdArgs = {"-idl", "-b", "BaseCORBABinding", "-verbose",
+        String[] cmdArgs = {"-idl", "-b", "BaseCORBABinding",
+                            "-d", output.getCanonicalPath(),
                             getClass().getResource("/wsdl/simple-Binding.wsdl").toString()};        
         int exc = execute(cmdArgs);
         assertEquals("WSDLToIDL Failed", noError, exc);
 
-        File f = new File("simple-Binding.idl");
+        File f = new File(output, "simple-Binding.idl");
         assertTrue("simple-Binding.idl should be generated", f.exists());
         try {
             FileInputStream stream = new FileInputStream(f);            
@@ -190,38 +209,17 @@
         } finally {
             f.deleteOnExit();
         }
-    }
-
-    
-    public void testIDLGenSpecifiedDirectory() throws Exception {
-        String[] cmdArgs = {"-idl", "-b", "BaseCORBABinding", "-d", "classes-tests", 
-                            getClass().getResource("/wsdl/simple-Binding.wsdl").toString()};
-        int exc = execute(cmdArgs);
-        assertEquals("WSDLToIDL Failed in Idl Generation", noError, exc);
-
-        File f = new File("classes-tests/simple-binding.idl");
-        assertTrue("simple-binding.idl should be generated into classes-tests directory", f.exists());
-
-        try {
-            FileInputStream stream = new FileInputStream(f);            
-            BufferedInputStream bis = new BufferedInputStream(stream); 
-            DataInputStream dis = new DataInputStream(bis);
-            String line = dis.toString();
-            assertTrue("Invalid Idl File Generated", line.length() > 0);
-        } finally {
-            f.deleteOnExit();
-        }
-    }
-
+    }   
     
     public void testIDLGenSpecifiedFile() throws Exception {
         String[] cmdArgs = {"-idl", "-b", "BaseCORBABinding",
                             "-o", "simple-binding_gen.idl",
+                            "-d", output.getCanonicalPath(),
                             getClass().getResource("/wsdl/simple-Binding.wsdl").toString()};
         int exc = execute(cmdArgs);
         assertEquals("WSDLToIDL Failed in Idl Generation", noError, exc);
 
-        File f = new File("simple-binding_gen.idl");
+        File f = new File(output, "simple-binding_gen.idl");
         assertTrue("simple-binding_gen.idl should be generated", f.exists());
 
         try {
@@ -236,16 +234,18 @@
     }
 
     // tests generating corba and idl in default wsdl and idl files
+    // pass the temp directory to create the wsdl files.
     public void testBindAndIDLGen() throws Exception {        
         String[] cmdArgs = {"-i", "BasePortType",
                             "-b", "BaseOneCORBABinding",
+                            "-d", output.getCanonicalPath(),
                             getClass().getResource("/wsdl/simple-Binding.wsdl").toString()};
         int exc = execute(cmdArgs);
         assertEquals("WSDLToIDL Failed", noError, exc);
 
-        File f1 = new File("simple-Binding-corba.wsdl");
+        File f1 = new File(output, "simple-Binding-corba.wsdl");
         assertTrue("simple-Binding-corba.wsdl should be generated", f1.exists());
-        File f2 = new File("simple-binding.idl");
+        File f2 = new File(output, "simple-binding.idl");
         assertTrue("simple-binding.idl should be generated", f2.exists());
 
         WSDLToProcessor proc = new WSDLToProcessor();
@@ -355,6 +355,5 @@
         String[] args = new String[] {"-help"};
         WSDLToIDL.main(args);
         assertNotNull(getStdOut());
-    }
-    
+    }   
 }