You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2010/04/01 19:30:29 UTC
svn commit: r930052 - in
/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting:
functionTests/master/ functionTests/master/DerbyNet/ functionTests/suites/
functionTests/tests/derbynet/ junit/
Author: myrnavl
Date: Thu Apr 1 17:30:28 2010
New Revision: 930052
URL: http://svn.apache.org/viewvc?rev=930052&view=rev
Log:
DERBY-4536; testProperties and sysinfo_withproperties fail on 10.3 with ibm 1.6
because tests are dependent on hash-ordering.
step 1 - backport sysinfo and sysinfo_withproperties test conversion to junit to 10.4.
Added:
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
- copied unchanged from r688103, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
Removed:
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/sysinfo.out
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/master/sysinfo_withproperties.out
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.policy
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_sed.properties
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.policy
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_derby.properties
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties_sed.properties
Modified:
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientRemote.exclude
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetRemote.exclude
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientRemote.exclude
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientRemote.exclude?rev=930052&r1=930051&r2=930052&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientRemote.exclude (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientRemote.exclude Thu Apr 1 17:30:28 2010
@@ -11,8 +11,6 @@
# the server machine
# derbynet/maxthreads - tries to use NetworkServerControl statements
# derbynet/runtimeinfo - tries to use NetworkServerControl statements
-# derbynet/sysinfo - tries to use NetworkServerControl statements
-# derbynet/sysinfo_withproperties - tries to use NetworkServerControl statements and for the test, server needs to be
# started with specific property set - DERBY928 for reference
# thus not suitable for remote server testing in its current form. - DERBY-928
# derbynet/timeslice - tries to use NetworkServerControl statements
@@ -26,8 +24,6 @@ derbynet/dblook_test_net.java
derbynet/dblook_test_net_territory.java
derbynet/maxthreads.java
derbynet/runtimeinfo.java
-derbynet/sysinfo.java
-derbynet/sysinfo_withproperties.java
derbynet/timeslice.java
derbynet/DerbyNetAutoStart.java
lang/wisconsin.java
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude?rev=930052&r1=930051&r2=930052&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude Thu Apr 1 17:30:28 2010
@@ -8,8 +8,6 @@
# derbynet/dblook_test_net_territory.java - expects different dir structure
# stress/stress.multi - exits suite
# derbynet/runtimeinfo.java - different sessions
-# derbynet/sysinfo.java - needs other properties
-# derbynet/sysinfo_withproperties.java - needs other properties
# following fail for various reasons, many related to not being able to connect:
# lang/optimizerOverrides.sql
# lang/big.sql
@@ -23,8 +21,6 @@ derbynet/DerbyNetAutoStart.java
derbynet/dblook_test_net.java
derbynet/dblook_test_net_territory.java
derbynet/runtimeinfo.java
-derbynet/sysinfo.java
-derbynet/sysinfo_withproperties.java
stress/stress.multi
lang/optimizerOverrides.sql
lang/big.sql
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetRemote.exclude
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetRemote.exclude?rev=930052&r1=930051&r2=930052&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetRemote.exclude (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetRemote.exclude Thu Apr 1 17:30:28 2010
@@ -11,11 +11,9 @@
# the server machine
# derbynet/maxthreads - tries to use NetworkServerControl statements
# derbynet/runtimeinfo - tries to use NetworkServerControl statements
-# derbynet/sysinfo - tries to use NetworkServerControl statements
# thus not suitable for remote server testing in its current form. - DERBY-928
# derbynet/timeslice - tries to use NetworkServerControl statements
# derbynet/DerbyNetAutoStart - tries to start networkserver
-# derbynet/sysinfo_withproperties - tries to use NetworkServerControl statements and test requires server to
# be started with a specific property. see DERBY-928 for reference
# lang/wisconsin - optimization is quite different when running remote server.
# junitTests/derbyNet/CompatibilityTest.java - tries to start and shutdown the server
@@ -25,8 +23,6 @@ derbynet/dblook_test_net.java
derbynet/dblook_test_net_territory.java
derbynet/maxthreads.java
derbynet/runtimeinfo.java
-derbynet/sysinfo.java
-derbynet/sysinfo_withproperties.java
derbynet/timeslice.java
derbynet/DerbyNetAutoStart.java
lang/wisconsin.java
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude?rev=930052&r1=930051&r2=930052&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude Thu Apr 1 17:30:28 2010
@@ -7,8 +7,6 @@
# derbynet/dblook_test_net.java - fails, test misses properties
# derbynet/dblook_test_net_territory.java - fails, test misses properties
# derbynet/runtimeinfo.java - fails with already existing threads (maybe intermittent)
-# derbynet/sysinfo.java - fails because not access to java.class.path
-# derbynet/sysinfo_withproperties.java - fails because not access to java.class.path
# lang/optimizerOverrides.sql - fails...
# lang/big.sql - checks depend on dir structure
# lang/wisconsin.java - checks depend on dir structure
@@ -20,8 +18,6 @@ derbynet/DerbyNetAutoStart.java
derbynet/dblook_test_net.java
derbynet/dblook_test_net_territory.java
derbynet/runtimeinfo.java
-derbynet/sysinfo.java
-derbynet/sysinfo_withproperties.java
lang/optimizerOverrides.sql
lang/big.sql
lang/wisconsin.java
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall?rev=930052&r1=930051&r2=930052&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/suites/derbynetmats.runall Thu Apr 1 17:30:28 2010
@@ -3,8 +3,6 @@ derbynet/dblook_test_net_territory.java
derbynet/DerbyNetAutoStart.java
derbynet/maxthreads.java
derbynet/runtimeinfo.java
-derbynet/sysinfo.java
-derbynet/sysinfo_withproperties.java
derbynet/testProtocol.java
derbynet/timeslice.java
jdbcapi/metadataMultiConn.java
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java?rev=930052&r1=930051&r2=930052&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java Thu Apr 1 17:30:28 2010
@@ -473,7 +473,7 @@ public class ServerPropertiesTest exten
"org.apache.derby.drda.NetworkServerControl", "-p",
String.valueOf(fourthAlternatePort).toString(),
"-noSecurityManager", "start"};
- Utilities.execJavaCmd(commandArray);
+ execJavaCmd(commandArray);
if (!canPingServer(fourthAlternatePort, true)) {
actionResult = "Can not ping server specified with -p";
@@ -486,7 +486,7 @@ public class ServerPropertiesTest exten
"org.apache.derby.drda.NetworkServerControl", "-p",
String.valueOf(fourthAlternatePort).toString(),
"-noSecurityManager", "shutdown"};
- Utilities.execJavaCmd(commandArray);
+ execJavaCmd(commandArray);
if (canPingServer(fourthAlternatePort, false)) {
actionResult = "Can still ping server specified with -p";
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java?rev=930052&r1=930051&r2=930052&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java Thu Apr 1 17:30:28 2010
@@ -53,6 +53,7 @@ public class _Suite extends BaseTestCase
suite.addTest(BadConnectionTest.suite());
suite.addTest(NetHarnessJavaTest.suite());
suite.addTest(SecureServerTest.suite());
+ suite.addTest(SysinfoTest.suite());
suite.addTest(SSLTest.suite());
suite.addTest(NetIjTest.suite());
suite.addTest(NSinSameJVMTest.suite());
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=930052&r1=930051&r2=930052&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Thu Apr 1 17:30:28 2010
@@ -435,82 +435,113 @@ public abstract class BaseTestCase
});
}
- /**
+ /**
+ * Execute command using 'java' executable and verify that it completes
+ * with expected results
+ * @param expectedString String to compare the resulting output with. May be
+ * null if the output is not expected to be of interest.
+ * @param cmd array of java arguments for command
+ * @param expectedExitValue expected return value from the command
+ * @throws InterruptedException
+ * @throws IOException
+ */
+ public void assertExecJavaCmdAsExpected(String[] expectedString,
+ String[] cmd, int expectedExitValue) throws InterruptedException,
+ IOException {
+
+ Process pr = execJavaCmd(cmd);
+ String output = readProcessOutput(pr);
+ int exitValue = pr.exitValue();
+
+ Assert.assertEquals(expectedExitValue, exitValue);
+ if (expectedString != null) {
+ for (int i = 0; i < expectedString.length; i++) {
+ assertFalse(output.indexOf(expectedString[i]) < 0);
+ }
+ }
+ }
+
+
+ /**
+ * Execute a java command and return the process.
+ * The caller should decide what to do with the process, if anything,
+ * typical activities would be to do a pr.waitFor, or to
+ * get a getInputStream or getErrorStream
+ * Note, that for verifying the output of a Java process, there is
+ * assertExecJavaCmdAsExpected
+ *
+ * @param cmd array of java arguments for command
+ * @return the process that was started
+ * @throws IOException
+ */
+ public Process execJavaCmd(String[] cmd) throws IOException {
+ int totalSize = 3 + cmd.length;
+ String[] tcmd = new String[totalSize];
+ tcmd[0] = "java";
+ tcmd[1] = "-classpath";
+ tcmd[2] = BaseTestCase.getSystemProperty("java.class.path");
+
+ System.arraycopy(cmd, 0, tcmd, 3, cmd.length);
+
+ final String[] command = tcmd;
+
+ Process pr = null;
+ try {
+ pr = (Process) AccessController
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws IOException {
+ Process result = null;
+ result = Runtime.getRuntime().exec(command);
+ return result;
+ }
+ });
+ } catch (PrivilegedActionException pe) {
+ Exception e = pe.getException();
+ if (e instanceof IOException)
+ throw (IOException) e;
+ else
+ throw (SecurityException) e;
+ }
+ return pr;
+ }
+
/**
- * Execute command using 'java' executable and verify that it completes
- * with expected results
- * @param expectedString String to compare the resulting output with. May be
- * null if the output is not expected to be of interest.
- * @param cmd array of java arguments for command
- * @param expectedExitValue expected return value from the command
+ * Reads output from a process and returns it as a string.
+ * This will block until the process terminates.
+ *
+ * @param pr a running process
+ * @return output of the process
* @throws InterruptedException
- * @throws IOException
*/
- public void assertExecJavaCmdAsExpected(
- String[] expectedString, String[] cmd, int expectedExitValue)
- throws InterruptedException, IOException {
-
- int totalSize = 3 + cmd.length;
- String[] tcmd = new String[totalSize];
- tcmd[0] = "java";
- tcmd[1] = "-classpath";
- tcmd[2] = BaseTestCase.getSystemProperty("java.class.path");
-
- System.arraycopy(cmd, 0, tcmd, 3, cmd.length);
-
- final String[] command = tcmd;
- Process pr = null;
- try {
- pr = (Process) AccessController
- .doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws IOException {
- Process result = null;
- result = Runtime.getRuntime().exec(command);
- return result;
- }
- });
- } catch (PrivilegedActionException pe) {
- Exception e = pe.getException();
- if (e instanceof IOException)
- throw (IOException) e;
- else
- throw (SecurityException) e;
- }
- InputStream is = pr.getInputStream();
- if ( is == null )
- {
- fail("Unexpectedly receiving no text from the java command");
- }
-
- String output = "";
- try
- {
- char[] ca = new char[1024];
- // Create an InputStreamReader with default encoding; we're hoping
- // this to be en. If not, we may not match the expected string.
- InputStreamReader inStream;
- inStream = new InputStreamReader(is);
- // keep reading from the stream until all done
- while ((inStream.read(ca, 0, ca.length)) != -1)
- {
- output = output + new String(ca).trim();
- }
- } catch (Exception e) {
- fail("Exception accessing inputstream from javacommand");
- }
-
- // wait until the process exits
- pr.waitFor();
-
- Assert.assertEquals(expectedExitValue, pr.exitValue());
- if (expectedString != null)
- {
- for (int i=0 ; i<expectedString.length ; i++)
- {
- assertFalse(output.indexOf(expectedString[i]) < 0);
- }
- }
- }
+ public String readProcessOutput(Process pr) throws InterruptedException {
+ InputStream is = pr.getInputStream();
+ if (is == null) {
+ fail("Unexpectedly receiving no text from the process");
+ }
+
+ String output = "";
+ try {
+ char[] ca = new char[1024];
+ // Create an InputStreamReader with default encoding; we're hoping
+ // this to be en. If not, we may not match the expected string.
+ InputStreamReader inStream;
+ inStream = new InputStreamReader(is);
+
+ // keep reading from the stream until all done
+ int charsRead;
+ while ((charsRead = inStream.read(ca, 0, ca.length)) != -1)
+ {
+ output = output + new String(ca, 0, charsRead);
+ }
+ } catch (Exception e) {
+ fail("Exception accessing inputstream from process", e);
+ }
+
+ // wait until the process exits
+ pr.waitFor();
+
+ return output;
+ }
/**
* Remove the directory and its contents.
Modified: db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java?rev=930052&r1=930051&r2=930052&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java (original)
+++ db/derby/code/branches/10.4/java/testing/org/apache/derbyTesting/junit/Utilities.java Thu Apr 1 17:30:28 2010
@@ -154,51 +154,6 @@ public class Utilities {
System.out.println("};\n");
}
}
- /**
- * Execute a java command and return the process.
- * The caller should decide what to do with the process, if anything,
- * typical activities would be to do a pr.waitFor, or to
- * get a getInputStream or getErrorStream
- * Note, that for verifying the output of a Java process, there is
- * BaseTestCase.assertExecJavaCmdAsExpected
- *
- * @param args
- * @return the Process
- * @throws InterruptedException
- */
- public static Process execJavaCmd(String[] args) throws IOException, InterruptedException {
-
- int totalSize = 3 + args.length;
- String[] cmd = new String[totalSize];
- cmd[0] = "java";
- cmd[1] = "-classpath";
- cmd[2] = BaseTestCase.getSystemProperty("java.class.path");
-
- System.arraycopy(args, 0, cmd, 3, args.length);
-
- final String[] command = cmd;
- Process pr = null;
- try {
- pr = (Process) AccessController
- .doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws IOException {
- Process result = null;
-
- result = Runtime.getRuntime().exec(command);
-
- return result;
- }
- });
- } catch (PrivilegedActionException pe) {
- Exception e = pe.getException();
- if (e instanceof IOException)
- throw (IOException) e;
- else
- throw (SecurityException) e;
- }
-
- return pr;
- }
/**
* Calls the public method <code>getInfo</code> of the sysinfo tool within