db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1067326 - in /db/derby/code/branches/10.5: ./ java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
Date Fri, 04 Feb 2011 23:02:07 GMT
Author: kmarsden
Date: Fri Feb  4 23:02:06 2011
New Revision: 1067326

URL: http://svn.apache.org/viewvc?rev=1067326&view=rev
Log:
DERBY-4997 SysinfoTest version output filtering is fragile with new java versions
merge 1067250 from trunk.


Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb  4 23:02:06 2011
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.6:942027,957000,962738,965351,987678,1055601
-/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304,980684,986689,986834,999119,1002291,1002682,1002853
 ,1021426,1025795,1040658,1053724,1055169,1062096,1063809,1065061
+/db/derby/code/trunk:757811,764912,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792001,792254,792434,793089,793588,794106,794276,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915177,915733,916075,916897,917771,918152,918359,921028,927430,928065,929085,931076,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304,980684,986689,986834,999119,1002291,1002682,1002853
 ,1021426,1025795,1040658,1053724,1055169,1062096,1063809,1065061,1067250

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java?rev=1067326&r1=1067325&r2=1067326&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
Fri Feb  4 23:02:06 2011
@@ -24,6 +24,7 @@ package org.apache.derbyTesting.function
 import java.io.File;
 import java.net.URL;
 import java.security.AccessController;
+import java.util.ArrayList;
 import java.util.Properties;
 
 import junit.framework.Test;
@@ -45,7 +46,7 @@ import org.apache.derbyTesting.junit.Tes
 public class SysinfoTest extends BaseJDBCTestCase {
 
     private static String TARGET_POLICY_FILE_NAME="sysinfo.policy";
-    private String [] OUTPUT;
+    private ArrayList OUTPUT;
 
     /**
      * Set to true before adding a test to the suite to add some extra properties.
@@ -62,41 +63,30 @@ public class SysinfoTest extends BaseJDB
         /**
          * Output from sysinfo without the extra properties. 
          */
-        String [] OUTPUT1 = {
-            "--------- Derby Network Server Information --------" , 
-            "derby.drda.maxThreads=0" ,
-            "derby.drda.sslMode=off" , 
-            "derby.drda.keepAlive=true" , 
-            "derby.drda.minThreads=0" , 
-            "derby.drda.portNumber=1527" , 
-            "derby.drda.logConnections=false" ,
-            "derby.drda.timeSlice=0" , 
-            "derby.drda.startNetworkServer=false" , 
-            "derby.drda.traceAll=false" ,
-            "--------- Derby Information --------" , 
-            "------------------------------------------------------" , 
-            "----------------- Locale Information -----------------" , 
-            "------------------------------------------------------"};
+
+        ArrayList OUTPUT1 = new ArrayList();
+        OUTPUT1.add("--------- Derby Network Server Information --------");
+        OUTPUT1.add("derby.drda.maxThreads=0");
+        OUTPUT1.add("derby.drda.sslMode=off"); 
+        OUTPUT1.add("derby.drda.keepAlive=true"); 
+        OUTPUT1.add("derby.drda.minThreads=0");
+        OUTPUT1.add("derby.drda.portNumber=1527");
+        OUTPUT1.add("derby.drda.logConnections=false");
+        OUTPUT1.add("derby.drda.timeSlice=0"); 
+        OUTPUT1.add("derby.drda.startNetworkServer=false"); 
+        OUTPUT1.add("derby.drda.traceAll=false");
+        OUTPUT1.add("--------- Derby Information --------"); 
+        OUTPUT1.add("------------------------------------------------------"); 
+        OUTPUT1.add("----------------- Locale Information -----------------" ); 
+        OUTPUT1.add("------------------------------------------------------");
 
         /**
          * Output by sysinfo with the extra properties.
          */
-        String [] OUTPUT2 = {
-            "--------- Derby Network Server Information --------" , 
-            "derby.drda.securityMechanism=USER_ONLY_SECURITY" , 
-            "derby.drda.maxThreads=0" ,
-            "derby.drda.sslMode=off" ,
-            "derby.drda.keepAlive=true" , 
-            "derby.drda.minThreads=0" , 
-            "derby.drda.portNumber=1527" , 
-            "derby.drda.logConnections=false" ,
-            "derby.drda.timeSlice=0" ,
-            "derby.drda.startNetworkServer=false" , 
-            "derby.drda.traceAll=false" ,
-            "--------- Derby Information --------" , 
-            "------------------------------------------------------" , 
-            "----------------- Locale Information -----------------" , 
-            "------------------------------------------------------"};
+
+        ArrayList OUTPUT2 = (ArrayList) OUTPUT1.clone();
+        OUTPUT2.add("--------- Derby Network Server Information --------"); 
+        OUTPUT2.add("derby.drda.securityMechanism=USER_ONLY_SECURITY"); 
 
         if (useProperties)
             OUTPUT = OUTPUT2;
@@ -208,9 +198,6 @@ public class SysinfoTest extends BaseJDB
 
         Process p = execJavaCmd(SysInfoCmd);
         String s = readProcessOutput(p);
-
-        s = sed(s);
-
         print("testSysinfo", s);
         assertMatchingStringExists(s);
     }
@@ -224,8 +211,6 @@ public class SysinfoTest extends BaseJDB
 
         String s = NetworkServerTestSetup.
         getNetworkServerControl(TestConfiguration.getCurrent().getPort()).getSysinfo();
-        s = sed(s);
-
         print("testSysinfoMethod", s);
         assertMatchingStringExists(s);
     }		
@@ -243,44 +228,11 @@ public class SysinfoTest extends BaseJDB
                 "-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         Process p = execJavaCmd(SysInfoLocaleCmd);
         String s = readProcessOutput(p);
-        s = sed(s);
-
         print("testSysinfoLocale", s);
         assertMatchingStringExists(s);
     }
 
     /**
-     * Removes lines containing a number of preset words from the given string.
-     * Also trims the string to make it easier to compare.
-     * 
-     * @param s the string to remove lines from
-     * @return the string with the lines removed
-     */
-    private String sed(String s) {
-        /**
-         * Lines containing these strings will be deleted from the output before
-         * asserting that output is correct.
-         * ibm jvm prints extra line for java.fullversion
-         */
-        String[] sed = {"Version", "version", "Java", "OS",
-        		"J9VM", "JIT", "GC",
-                "[0-9*]\\.[0-9*]\\.[0-9*]","JRE - JDBC","derby.drda.traceDirectory",
-                "Unable to access Protection Domain","listing properties",
-                "Current Locale",           //Remove these because locale info is
-                "Found support for locale:" //not printed when running from jars..
-        };                          
-
-        for (int i = 0; i < sed.length; i++) {
-            // first, replace \r\n with \n, that's needed if we're on
-            // windows
-            s = s.replaceAll("\r\n", "\n");
-            s = s.replaceAll("(?m)^.*" + sed[i] + ".*\n", "");
-        }
-        s = s.trim();
-        return s;
-    }
-
-    /**
      * Prints strings to System.out to make it easier to update the tests
      * when the output changes if derby.tests.debug is true.
      * 
@@ -316,33 +268,24 @@ public class SysinfoTest extends BaseJDB
         }
         return url.getPath();
     }
+
     
+    /**
+     *  Check sysinfo output to make sure that it contains strings
+     *  specfied in OUTPUT. This was changed in DERBY-4997 to no
+     *  longer use a sed method to strip out the unchecked lines,
+     *  but rather to just make sure the ones we want to check are 
+     *  there
+     *  
+     * @param actualOutput Actual sysinfo output 
+     */
     private void assertMatchingStringExists(String actualOutput) {
-        String delimiter = "\n";
-        String [] actualOutputArray = actualOutput.split(delimiter);
-        int lineCount = actualOutputArray.length;
-        assertEquals(OUTPUT.length, lineCount);
-        for (int i=0 ; i<lineCount ; i++)
-        {
-            String fullExpOutput="";
-            for (int j=0 ; j < OUTPUT.length; j++) {
-                fullExpOutput=fullExpOutput + OUTPUT[j] + "\n";
-            }
-            String ns = actualOutputArray[i];
-            assertTrue("Output string: " + ns + 
-                "\ndoesn't match any of the expected strings: \n" + 
-                fullExpOutput,
-                searchMatchingString(ns));
-        }
+        for (int i=0; i < OUTPUT.size(); i ++ ) {
+            String s = (String) OUTPUT.get(i);
+            assertTrue("cannot find " + s + " in actualOutput:" + actualOutput,
+                    actualOutput.indexOf(s) >=0);            
+        }        
     }
         
-    private boolean searchMatchingString(String substring){
-        for (int i=0; i<OUTPUT.length;i++)
-        {
-            if (!substring.equals(OUTPUT[i]))
-                continue;
-            else return true;
-        }
-        return false;
-    }
+ 
 }



Mime
View raw message