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 km...@apache.org on 2006/02/23 23:23:17 UTC
svn commit: r380246 - in
/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests:
master/testProperties.out tests/derbynet/testProperties.java
Author: kmarsden
Date: Thu Feb 23 14:23:12 2006
New Revision: 380246
URL: http://svn.apache.org/viewcvs?rev=380246&view=rev
Log:
DERBY-1041 - Modify derbynet/testProperties.java test to run with 10.1client/10.2 server
Attaching a patch 'derby-1041_10.1_v1.diff' for 10.1 branch. Patch does following:
* Modifies the test derbynet/testProperties.java to use a different stream for the shutdown process.
* Modifies master file
Ran derbynet/testProperties.java with 10.1 client and 10.2 server jars. Also ran the test with10.1 jars in DerbyNetClient and DerbyNet frameworks. Tests run with Sun JDK 1.4.2 on Win XP.
Contributed by Deepa Remesh
Modified:
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java
Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out?rev=380246&r1=380245&r2=380246&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/testProperties.out Thu Feb 23 14:23:12 2006
@@ -3,21 +3,17 @@
org.apache.derby.drda.NetworkServerControl start
Successfully Connected
org.apache.derby.drda.NetworkServerControl shutdown
-Shutdown successful.
Testing System properties Port 1529
-----Dderby.drda.portNumber=1529 org.apache.derby.drda.NetworkServerControl start
Successfully Connected
org.apache.derby.drda.NetworkServerControl shutdown -p 1529
-Shutdown successful.
Testing command line option. Port 1530
org.apache.derby.drda.NetworkServerControl start -p 1530
Successfully Connected
org.apache.derby.drda.NetworkServerControl shutdown -p 1530
-Shutdown successful.
Testing start server by specifying system properties without values
First shutdown server started on default port by the test harness
org.apache.derby.drda.NetworkServerControl shutdown -p 1527
-Shutdown successful.
-Dderby.drda.logConnections -Dderby.drda.traceAll -Dderby.drda.traceDirectory -Dderby.drda.keepAlive -Dderby.drda.timeSlice -Dderby.drda.host -Dderby.drda.portNumber -Dderby.drda.minThreads -Dderby.drda.maxThreads -Dderby.drda.startNetworkServer -Dderby.drda.debug org.apache.derby.drda.NetworkServerControl start
-- listing properties --
derby.drda.maxThreads=0
@@ -31,5 +27,4 @@
derby.drda.traceAll=false
Successfully Connected
org.apache.derby.drda.NetworkServerControl shutdown -p 1527
-Shutdown successful.
End test
Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java?rev=380246&r1=380245&r2=380246&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProperties.java Thu Feb 23 14:23:12 2006
@@ -54,6 +54,12 @@
private static jvm jvm;
private static Vector vCmd;
private static BufferedOutputStream bos = null;
+
+ // File and stream for output from shutdown process. We do not want the
+ // shutdown process to write to System.out because shutdown message has
+ // changed in later version (10.2)
+ private static final File outputFile = new File("shutdown.tmp");
+ private static BufferedOutputStream shutdownStream = null;
//Command to start server specifying system properties without values
private static String[] startServerCmd =
@@ -75,11 +81,11 @@
* Execute the given command and dump the results to standard out
*
* @param args command and arguments
- * @param wait true =wait for completion
- * @exception Exception
+ * @param buf OutputStream for process outputs
+ * @throws Exception
*/
- private static void execCmdDumpResults (String[] args) throws Exception
+ private static void execCmdDumpResults (String[] args, BufferedOutputStream buf) throws Exception
{
// We need the process inputstream and errorstream
ProcessStreamResult prout = null;
@@ -87,8 +93,8 @@
// Start a process to run the command
Process pr = execCmd(args);
- prout = new ProcessStreamResult(pr.getInputStream(), bos, null);
- prerr = new ProcessStreamResult(pr.getErrorStream(), bos, null);
+ prout = new ProcessStreamResult(pr.getInputStream(), buf, null);
+ prerr = new ProcessStreamResult(pr.getErrorStream(), buf, null);
// wait until all the results have been processed
prout.Wait();
@@ -128,8 +134,13 @@
/**
* Issue derbyServer command if port is null, NetworkServerControl <cmd>
* else NetworkServerControl <cmd> -p <portstring>
+ *
+ * @param cmd Network server command
+ * @param portString port
+ * @param buf OutputStream for process
+ * @throws Exception
*/
- private static void derbyServerCmd(String cmd, String portString) throws Exception
+ private static void derbyServerCmd(String cmd, String portString, BufferedOutputStream buf) throws Exception
{
String [] cmdArr = null;
// For start we don't wait or capture results, just
@@ -146,7 +157,7 @@
if (!wait)
execCmd(cmdArr);
else
- execCmdDumpResults(cmdArr);
+ execCmdDumpResults(cmdArr, buf);
}
private static void waitForStart(String portString, int timeToWait) throws Exception
@@ -196,6 +207,10 @@
try
{
bos = new BufferedOutputStream(System.out, 1024);
+ if(!outputFile.exists())
+ outputFile.createNewFile();
+ FileOutputStream fos = new FileOutputStream(outputFile);
+ shutdownStream = new BufferedOutputStream(fos);
System.out.println("Start testProperties to test property priority");
@@ -211,25 +226,25 @@
derbyProperties.store(propFile,"testing derby.properties");
propFile.close();
//test start no parameters - Pickup 1528 from derby.properties
- derbyServerCmd("start",null);
+ derbyServerCmd("start",null, bos);
waitForStart("1528",15000);
System.out.println("Successfully Connected");
//shutdown - also picks up from derby.properties
- derbyServerCmd("shutdown",null);
+ derbyServerCmd("shutdown",null, shutdownStream);
System.out.println("Testing System properties Port 1529 ");
//test start with system property. Overrides derby.properties
- derbyServerCmd("start","-Dderby.drda.portNumber=1529");
+ derbyServerCmd("start","-Dderby.drda.portNumber=1529", bos);
waitForStart("1529",15000);
System.out.println("Successfully Connected");
//shutdown - also picks up from System Properties
- derbyServerCmd("shutdown","1529");
+ derbyServerCmd("shutdown","1529", shutdownStream);
System.out.println("Testing command line option. Port 1530");
- derbyServerCmd("start","1530");
+ derbyServerCmd("start","1530", bos);
waitForStart("1530",15000);
System.out.println("Successfully Connected");
//shutdown - with command line option
- derbyServerCmd("shutdown","1530");
+ derbyServerCmd("shutdown","1530", shutdownStream);
/**********************************************************************
* Test start server specifying system properties without values
@@ -238,31 +253,34 @@
System.out.println("First shutdown server started on default port by the test harness");
//Shutdown the server started by test
- derbyServerCmd("shutdown","1527");
+ derbyServerCmd("shutdown","1527", shutdownStream);
execCmd(startServerCmd);
waitForStart("1527",15000);
//check that default properties are used
listProperties("1527");
System.out.println("Successfully Connected");
- derbyServerCmd("shutdown","1527");
+ derbyServerCmd("shutdown","1527", shutdownStream);
System.out.println("End test");
bos.close();
+ fos.close();
+ shutdownStream.close();
}
catch (Exception e)
{
e.printStackTrace();
// If something went wrong,
// make sure all these servers are shutdown
- try {derbyServerCmd("shutdown","1527");} catch (Exception se) {}
- try {derbyServerCmd("shutdown","1528");} catch (Exception se) {}
- try {derbyServerCmd("shutdown","1529");} catch (Exception se) {}
- try {derbyServerCmd("shutdown","1530");} catch (Exception se) {}
+ try {derbyServerCmd("shutdown","1527", shutdownStream);} catch (Exception se) {}
+ try {derbyServerCmd("shutdown","1528", shutdownStream);} catch (Exception se) {}
+ try {derbyServerCmd("shutdown","1529", shutdownStream);} catch (Exception se) {}
+ try {derbyServerCmd("shutdown","1530", shutdownStream);} catch (Exception se) {}
}
finally {
try {
File fileToDelete = new File("derby.properties");
fileToDelete.delete();
+ outputFile.delete();
} catch (Exception e)
{
e.printStackTrace();