[jbossws-commits] JBossWS SVN: r7288 - framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Jun 3 08:56:10 EDT 2008


Author: heiko.braun at jboss.com
Date: 2008-06-03 08:56:10 -0400 (Tue, 03 Jun 2008)
New Revision: 7288

Modified:
   framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/ScriptTestCase.java
Log:
Fix ScriptTestCase: Provide correct JAVA_HOME

Modified: framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/ScriptTestCase.java
===================================================================
--- framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/ScriptTestCase.java	2008-06-03 12:55:39 UTC (rev 7287)
+++ framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/smoke/tools/ScriptTestCase.java	2008-06-03 12:56:10 UTC (rev 7288)
@@ -23,8 +23,7 @@
 
 // $Id$
 
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
 
 import org.jboss.wsf.test.JBossWSTest;
 
@@ -50,6 +49,8 @@
    private String TEST_DIR;
    private String OS;
 
+   private String origJavaHome;
+
    protected void setUp() throws Exception
    {
       super.setUp();
@@ -57,10 +58,26 @@
       JBOSS_HOME = System.getProperty("jboss.home");
       CLASSES_DIR = System.getProperty("test.classes.directory");
       TEST_DIR = createResourceFile("..").getAbsolutePath();
-      JAVA_HOME = System.getProperty("java.home");
+      origJavaHome = System.getProperty("java.home");
       OS = System.getProperty("os.name").toLowerCase();
+      
+	  
+      // the script requires the system JAVA_HOME, which points to the JDK not the JRE            
+	  if(origJavaHome.indexOf("/jre")!=-1)
+      {
+         String JDK_HOME = origJavaHome.substring(0, origJavaHome.indexOf("/jre"));
+         System.setProperty("java.home", JDK_HOME);
+         JAVA_HOME= JDK_HOME;
+      }
    }
 
+
+   protected void tearDown() throws Exception
+   {
+      // reset surefire's JAVA_HOME
+      System.setProperty("java.home", origJavaHome);
+   }
+
    public void testWSConsumeFromCommandLine() throws Exception
    {
       if (isWindowsOS())
@@ -72,7 +89,7 @@
       String absWsdlLoc = getResourceFile(WSDL_LOCATION).getAbsolutePath();
       String absOutput = new File(TEST_DIR, "wsconsume/java").getAbsolutePath();
 
-      String command = JBOSS_HOME + "/bin/wsconsume.sh -k -o " + absOutput + " " + absWsdlLoc;
+      String command = JBOSS_HOME + "/bin/wsconsume.sh -v -k -o " + absOutput + " " + absWsdlLoc;
       Process p = executeCommand(command);
 
       // check status code
@@ -116,9 +133,32 @@
    {
       // check status code
       int status = p.waitFor();
+      dumpStream(p.getInputStream());
+      dumpStream(p.getErrorStream());
+
       assertTrue(s + " did exit with status " + status, status == 0);
    }
 
+   private void dumpStream(InputStream in)
+   {
+      try
+      {
+         BufferedInputStream bin = new BufferedInputStream (in);
+         StringBuffer out = new StringBuffer();
+         byte[] b = new byte[4096];
+         for (int n; (n = bin.read(b)) != -1;)
+         {
+            out.append(new String(b, 0, n));
+         }
+
+         System.out.println(out.toString());
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException("", e);
+      }
+   }
+
    private boolean isWindowsOS()
    {
       return ((OS.indexOf("nt") > -1) || (OS.indexOf("windows") > -1));




More information about the jbossws-commits mailing list