[jboss-cvs] JBossAS SVN: r111217 - branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 20 03:44:43 EDT 2011


Author: rsvoboda at redhat.com
Date: 2011-04-20 03:44:42 -0400 (Wed, 20 Apr 2011)
New Revision: 111217

Modified:
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ProbeTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/RunTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ScriptsTestBase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ShutdownTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/TwiddleTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsclientTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsconsumeTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsprovideTestCase.java
   branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WstoolsTestCase.java
Log:
JBQA-4571 - tests to verify taht IPv4 is forced in .sh and .bat files

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ProbeTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ProbeTestCase.java	2011-04-20 07:43:04 UTC (rev 111216)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ProbeTestCase.java	2011-04-20 07:44:42 UTC (rev 111217)
@@ -23,10 +23,6 @@
 package org.jboss.test.scripts.test;
 
 import java.io.File ;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.jboss.test.JBossTestSetup ;
 
 /**
  * Unit tests of probe.sh and probe.bat.
@@ -65,7 +61,20 @@
 	   System.out.println("Working directory: " + getBinDir()) ;
 	   System.out.println("Dist directory: " + getDistDir()) ;	   
    }
-   
+
+    /**
+     * Tests if IPv4 is forced to be used
+     */
+    public void testIPv4() {
+        String suffix = isWindows() ? ".bat" : ".sh";
+        String ipv4Text = "-Djava.net.preferIPv4Stack=true";
+        File file = new File(getBinDir() + FS + "probe" + suffix);
+
+        if (!fileContainsText(file, ipv4Text)) {
+            fail("File " + file.getAbsolutePath()  + " doesn't contain '" + ipv4Text + "' text");
+        }
+    }
+
    /**
     * Tests probe "help" command 
     *  

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/RunTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/RunTestCase.java	2011-04-20 07:43:04 UTC (rev 111216)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/RunTestCase.java	2011-04-20 07:44:42 UTC (rev 111217)
@@ -93,7 +93,20 @@
 	   System.out.println("Log directory: " + getLogDir()) ;
 	   System.out.println("Server config: " + getServerConfig()) ;
    }
-   
+
+    /**
+     * Tests if IPv4 is forced to be used
+     */
+    public void testIPv4() {
+        String suffix = isWindows() ? ".bat" : ".sh";
+        String ipv4Text = "-Djava.net.preferIPv4Stack=true";
+        File file = new File(getBinDir() + FS + "run" + suffix);
+
+        if (!fileContainsText(file, ipv4Text)) {
+            fail("File " + file.getAbsolutePath()  + " doesn't contain '" + ipv4Text + "' text");
+        }
+    }
+
    /**
     * Tests run "help" command (no args)
     *  

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ScriptsTestBase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ScriptsTestBase.java	2011-04-20 07:43:04 UTC (rev 111216)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ScriptsTestBase.java	2011-04-20 07:44:42 UTC (rev 111217)
@@ -21,19 +21,9 @@
  */
 package org.jboss.test.scripts.test;
 
-import java.lang.InterruptedException ;
-import java.io.OutputStream ;
-import java.io.ByteArrayOutputStream ;
-import java.io.BufferedReader ;
-import java.io.InputStreamReader ;
-import java.io.PrintWriter ;
-import java.io.StringWriter ;
-import java.io.FileReader ;
-import java.io.FileWriter ;
-import java.io.File ;
-import java.io.FileInputStream ;
-import java.io.FileOutputStream ;
-import java.io.FileNotFoundException ;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
 import java.io.IOException ;
 
 import java.net.URL ;
@@ -455,4 +445,33 @@
             final File cxfClientFile = new File(getDistDir() + FS + "client" + FS + "jbossws-cxf-client.jar");
             return cxfClientFile.exists();
         }
+
+        /**
+         * Checks if File contains specified text.
+         * 
+         * @param text 
+         * @param file
+         * @return true if file contains specified text
+         */
+        protected boolean fileContainsText(File file, String text) {
+            boolean containText = false;
+            try {
+                BufferedReader input = new BufferedReader(new FileReader(file));
+                try {
+                    String line = null;
+                    while ((line = input.readLine()) != null) {
+                        if (line.contains(text)) {
+                            containText = true;
+                            break;
+                        }
+                    }
+                } finally {
+                    input.close();
+                }
+            } catch (Exception ex) {
+                fail("Exception " + ex.getMessage());
+            }
+
+            return containText;
+        }
 }

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ShutdownTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ShutdownTestCase.java	2011-04-20 07:43:04 UTC (rev 111216)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/ShutdownTestCase.java	2011-04-20 07:44:42 UTC (rev 111217)
@@ -87,7 +87,20 @@
 	   System.out.println("Log directory: " + getLogDir()) ;
 	   System.out.println("Server config: " + getServerConfig()) ;
    }
-   
+
+    /**
+     * Tests if IPv4 is forced to be used
+     */
+    public void testIPv4() {
+        String suffix = isWindows() ? ".bat" : ".sh";
+        String ipv4Text = "-Djava.net.preferIPv4Stack=true";
+        File file = new File(getBinDir() + FS + "shutdown" + suffix);
+
+        if (!fileContainsText(file, ipv4Text)) {
+            fail("File " + file.getAbsolutePath()  + " doesn't contain '" + ipv4Text + "' text");
+        }
+    }
+
    /**
     * Tests run "help" command (no args)
     *  

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/TwiddleTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/TwiddleTestCase.java	2011-04-20 07:43:04 UTC (rev 111216)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/TwiddleTestCase.java	2011-04-20 07:44:42 UTC (rev 111217)
@@ -53,7 +53,20 @@
 	   System.out.println("Working directory: " + getBinDir()) ;
 	   System.out.println("Dist directory: " + getDistDir()) ;	   
    }
-   
+
+    /**
+     * Tests if IPv4 is forced to be used
+     */
+    public void testIPv4() {
+        String suffix = isWindows() ? ".bat" : ".sh";
+        String ipv4Text = "-Djava.net.preferIPv4Stack=true";
+        File file = new File(getBinDir() + FS + "twiddle" + suffix);
+
+        if (!fileContainsText(file, ipv4Text)) {
+            fail("File " + file.getAbsolutePath()  + " doesn't contain '" + ipv4Text + "' text");
+        }
+    }
+
    /**
     * Tests twiddle "help" command (no args)
     *  

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsclientTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsclientTestCase.java	2011-04-20 07:43:04 UTC (rev 111216)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsclientTestCase.java	2011-04-20 07:44:42 UTC (rev 111217)
@@ -63,6 +63,19 @@
     }
 
     /**
+     * Tests if IPv4 is forced to be used
+     */
+    public void testIPv4() {
+        String suffix = isWindows() ? ".bat" : ".sh";
+        String ipv4Text = "-Djava.net.preferIPv4Stack=true";
+        File file = new File(getBinDir() + FS + "wsrunclient" + suffix);
+
+        if (!fileContainsText(file, ipv4Text)) {
+            fail("File " + file.getAbsolutePath()  + " doesn't contain '" + ipv4Text + "' text");
+        }
+    }
+
+    /**
      * Tests run "help" command (no args)
      *
      * @throws Exception

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsconsumeTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsconsumeTestCase.java	2011-04-20 07:43:04 UTC (rev 111216)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsconsumeTestCase.java	2011-04-20 07:44:42 UTC (rev 111217)
@@ -59,6 +59,19 @@
     }
 
     /**
+     * Tests if IPv4 is forced to be used
+     */
+    public void testIPv4() {
+        String suffix = isWindows() ? ".bat" : ".sh";
+        String ipv4Text = "-Djava.net.preferIPv4Stack=true";
+        File file = new File(getBinDir() + FS + "wsconsume" + suffix);
+
+        if (!fileContainsText(file, ipv4Text)) {
+            fail("File " + file.getAbsolutePath()  + " doesn't contain '" + ipv4Text + "' text");
+        }
+    }
+
+    /**
      * Tests run "help" command (no args)
      *
      * @throws Exception
@@ -123,8 +136,6 @@
         assertFalse(getOrderJavaFile.getAbsolutePath() + " exists", getOrderJavaFile.exists());
     }
 
-    
-
     /**
      * Tests generate only sources command
      *

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsprovideTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsprovideTestCase.java	2011-04-20 07:43:04 UTC (rev 111216)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WsprovideTestCase.java	2011-04-20 07:44:42 UTC (rev 111217)
@@ -61,6 +61,19 @@
     }
 
     /**
+     * Tests if IPv4 is forced to be used
+     */
+    public void testIPv4() {
+        String suffix = isWindows() ? ".bat" : ".sh";
+        String ipv4Text = "-Djava.net.preferIPv4Stack=true";
+        File file = new File(getBinDir() + FS + "wsprovide" + suffix);
+
+        if (!fileContainsText(file, ipv4Text)) {
+            fail("File " + file.getAbsolutePath()  + " doesn't contain '" + ipv4Text + "' text");
+        }
+    }
+
+    /**
      * Tests run "help" command (no args)
      *
      * @throws Exception

Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WstoolsTestCase.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WstoolsTestCase.java	2011-04-20 07:43:04 UTC (rev 111216)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/scripts/test/WstoolsTestCase.java	2011-04-20 07:44:42 UTC (rev 111217)
@@ -66,6 +66,24 @@
     }
 
     /**
+     * Tests if IPv4 is forced to be used
+     */
+    public void testIPv4() {
+        if (isCXFInstalled() && !isWSToolsPresent()) {
+            System.out.println("Installed CXF and no WSTools command line script as expected (EAP 5.1.x) ");
+            return;
+        }
+        String suffix = isWindows() ? ".bat" : ".sh";
+        String ipv4Text = "-Djava.net.preferIPv4Stack=true";
+        File file = new File(getBinDir() + FS + "wstools" + suffix);
+
+        if (!fileContainsText(file, ipv4Text)) {
+            fail("File " + file.getAbsolutePath()  + " doesn't contain '" + ipv4Text + "' text");
+        }
+    }
+
+
+    /**
      * Tests run "help" command (no args)
      *
      * @throws Exception



More information about the jboss-cvs-commits mailing list