geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r719284 - in /geronimo/server/trunk: plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java testsuite/commands-testsuite/jaxws/src/test/java/org/apache/geronimo/testsuite/jaxws/CXFToolsTest.java
Date Thu, 20 Nov 2008 17:01:07 GMT
Author: gawor
Date: Thu Nov 20 09:01:07 2008
New Revision: 719284

URL: http://svn.apache.org/viewvc?rev=719284&view=rev
Log:
a basic test for cxf jaxws tools and a fix to resolve java.io.tmpdir properly (part of GERONIMO-4351)

Added:
    geronimo/server/trunk/testsuite/commands-testsuite/jaxws/src/test/java/org/apache/geronimo/testsuite/jaxws/CXFToolsTest.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java

Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java?rev=719284&r1=719283&r2=719284&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java
(original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf-tools/src/main/java/org/apache/geronimo/cxf/tools/JAXWSToolsCLI.java
Thu Nov 20 09:01:07 2008
@@ -58,7 +58,7 @@
         }
         
         Command cmd = null;
-        if (args[0].equalsIgnoreCase("java2wsdl")) {
+        if (args[0].equalsIgnoreCase("java2ws")) {
             cmd = Command.JAVA2WS;
         } else if (args[0].equalsIgnoreCase("wsdl2java")) {
             cmd = Command.WSDL2JAVA;
@@ -69,13 +69,16 @@
             System.exit(1);
         }
 
-        String geroninoHome = getGeronimoHome();
+        String geronimoHome = getGeronimoHome();
+        
         String[] arguments = getCmdArguments(args); 
-        boolean rs = run(cmd, geroninoHome, arguments);
+        boolean rs = run(cmd, geronimoHome, arguments);
         System.exit( (rs) ? 0 : 1 );
     }
     
-    static boolean run(Command cmd, String geronimoHome, String[] args) throws Exception
{         
+    static boolean run(Command cmd, String geronimoHome, String[] args) throws Exception
{   
+        resolveTmpDir(geronimoHome);
+        
         String repository = System.getProperty("Xorg.apache.geronimo.repository.boot.path",
"repository");
         Maven2Repository bootRepository = new Maven2Repository(new File(geronimoHome, repository));
         Collection<Maven2Repository> repositories = Collections.singleton(bootRepository);
@@ -168,6 +171,21 @@
         return "..";        
     }
     
+    private static void resolveTmpDir(String geronimoHome) throws Exception {
+        String tmpDir = System.getProperty("java.io.tmpdir");
+        File tmpDirFile = new File(tmpDir);
+        if (!tmpDirFile.exists()) {
+            if (tmpDirFile.isAbsolute()) {
+                throw new Exception("The temporary directory set does not exist: " + tmpDir);
+            } 
+            File newTmpDirFile = new File(geronimoHome, tmpDir); 
+            if (!newTmpDirFile.exists()) {
+                throw new Exception("Unable to resolve temporary directory " + tmpDir + "
in " + geronimoHome);
+            }
+            System.setProperty("java.io.tmpdir", newTmpDirFile.getAbsolutePath());
+        }      
+    }
+    
     public static Set<URL> getClassLoaderClasspath(ClassLoader loader) {
         LinkedHashSet<URL> jars = new LinkedHashSet<URL>();
         getClassLoaderClasspath(loader, jars);

Added: geronimo/server/trunk/testsuite/commands-testsuite/jaxws/src/test/java/org/apache/geronimo/testsuite/jaxws/CXFToolsTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/commands-testsuite/jaxws/src/test/java/org/apache/geronimo/testsuite/jaxws/CXFToolsTest.java?rev=719284&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/commands-testsuite/jaxws/src/test/java/org/apache/geronimo/testsuite/jaxws/CXFToolsTest.java
(added)
+++ geronimo/server/trunk/testsuite/commands-testsuite/jaxws/src/test/java/org/apache/geronimo/testsuite/jaxws/CXFToolsTest.java
Thu Nov 20 09:01:07 2008
@@ -0,0 +1,109 @@
+/**
+ *  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.
+ */
+
+package org.apache.geronimo.testsuite.jaxws;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.geronimo.testsupport.commands.CommandTestSupport;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+@Test
+public class CXFToolsTest extends CommandTestSupport {
+
+    protected String executeJava2WS(String[] args) throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        List<String> cmd = new ArrayList<String>();
+        cmd.addAll(Arrays.asList("java2ws"));
+        if (args != null) {
+            cmd.addAll(Arrays.asList(args));
+        }
+        execute("cxf-tools", cmd, null, baos);
+        return baos.toString();
+    }
+    
+    protected String executeWSDL2Java(String[] args) throws Exception {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        List<String> cmd = new ArrayList<String>();
+        cmd.addAll(Arrays.asList("wsdl2java"));
+        if (args != null) {
+            cmd.addAll(Arrays.asList(args));
+        }
+        execute("cxf-tools", cmd, null, baos);
+        return baos.toString();
+    }
+    
+    @Test
+    public void testJava2WS() throws Exception {
+        String projectDir = System.getProperty("project.directory");
+        String targetDir = System.getProperty("project.build.directory");
+        
+        File outputDir = createUniqueDirectory(targetDir, "java2ws-");
+        File testClassesDir = new File(projectDir, "target/test-classes");
+        
+        String[] args = new String[]{ "-verbose", "-wrapperbean", "-s", outputDir.getAbsolutePath(),
"-cp", testClassesDir.getAbsolutePath(), "org.apache.geronimo.testsuite.jaxws.Greeter" };
+ 
+        String output = executeJava2WS(args);
+     
+        checkGeneratedFiles(outputDir, output);
+    }
+
+    @Test
+    public void testWSDL2Java() throws Exception {
+        String projectDir = System.getProperty("project.directory");
+        String targetDir = System.getProperty("project.build.directory");
+        
+        File outputDir = createUniqueDirectory(targetDir, "wsdl2java-");        
+        File wsdlFile = new File(projectDir, "src/test/java/org/apache/geronimo/testsuite/jaxws/greeter_control.wsdl");
+        
+        String[] args = new String[]{ "-verbose", "-keep", "-d", outputDir.getAbsolutePath(),
wsdlFile.getAbsolutePath() };
+        
+        String output = executeWSDL2Java(args);
+
+        checkGeneratedFiles(outputDir, output);
+    }
+
+    private void checkGeneratedFiles(File outputDir, String output) {
+        System.out.println(output);
+        
+        String packageName = "org.apache.greeter_control.types.";
+        packageName = packageName.replace('.', File.separatorChar);
+        List<String> expectedFiles = Arrays.asList("GreetMe.java",  "GreetMeOneWay.java",
"GreetMeResponse.java", "SayHi.java", "SayHiResponse.java");
+                                      
+        for (String file : expectedFiles) {
+            file = packageName + file;
+            File sourceFile = new File(outputDir, file);
+            Assert.assertTrue(sourceFile.exists(), "Source file " + file + " does not exist");
+        }
+    }
+    
+    private File createUniqueDirectory(String targetDir, String prefix) {
+        File dir = new File(targetDir, prefix + System.currentTimeMillis());
+        if (!dir.mkdir()) {
+            throw new RuntimeException("Failed to create unqiue directory " + dir);
+        }
+        return dir;
+    }
+               
+}

Propchange: geronimo/server/trunk/testsuite/commands-testsuite/jaxws/src/test/java/org/apache/geronimo/testsuite/jaxws/CXFToolsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/commands-testsuite/jaxws/src/test/java/org/apache/geronimo/testsuite/jaxws/CXFToolsTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/commands-testsuite/jaxws/src/test/java/org/apache/geronimo/testsuite/jaxws/CXFToolsTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message