db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r170862 - in /incubator/derby/code/trunk/java: drda/org/apache/derby/drda/NetworkServerControl.java drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java testing/org/apache/derbyTesting/functionTests/tests/derbynet/testconnection.java
Date Thu, 19 May 2005 03:54:04 GMT
Author: kmarsden
Date: Wed May 18 20:54:01 2005
New Revision: 170862

URL: http://svn.apache.org/viewcvs?rev=170862&view=rev
Log:
Derby-214 Remove System.exit from NetworkServerControlImpl

Patch contributed by David Van Couvering
below are his comments
I relocated the execute method from NetworkServerImpl (previously called DB2jServerImpl) to
NetworkServerControl.

I modified derbynet/testconnection.java so that it checks and makes sure the exit status matches
what is expected (1 for error, 0 for no error).  


Modified:
    incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
    incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testconnection.java

Modified: incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java?rev=170862&r1=170861&r2=170862&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java (original)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java Wed
May 18 20:54:01 2005
@@ -231,7 +231,27 @@
 	 * See class comments for more information
 	 */
     public static void main(String args[]) {
-		NetworkServerControlImpl.execute(args);
+        NetworkServerControlImpl server = null;
+        try
+        {
+            server = new NetworkServerControlImpl();
+    		server.executeWork(args);
+        }
+        catch (Exception e)
+        {
+			//if there was an error, exit(1)
+			if ((e.getMessage() == null) ||
+				!e.getMessage().equals(NetworkServerControlImpl.UNEXPECTED_ERR))
+			{
+				if (server != null)
+					server.consoleExceptionPrint(e);
+				else
+					e.printStackTrace();  // default output stream is System.out
+			}
+			// else, we've already printed a trace, so just exit.
+			System.exit(1);
+		}
+		System.exit(0);
 		
 	}
 

Modified: incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=170862&r1=170861&r2=170862&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ incubator/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Wed May 18 20:54:01 2005
@@ -133,7 +133,7 @@
 	private final static String DRDA_PROP_DEBUG = "derby.drda.debug";
 	private final static String CLOUDSCAPE_DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
 
-	protected final static String UNEXPECTED_ERR = "Unexpected exception";
+	public final static String UNEXPECTED_ERR = "Unexpected exception";
 
 	private final static int MIN_MAXTHREADS = -1;
 	private final static int MIN_TIMESLICE = -1;
@@ -1719,36 +1719,6 @@
 		return bos.toString();
 	}
 
-	/**
-	 * Execute the command given on the command line
-	 *
-	 * @param args	array of arguments indicating command to be executed
-	 *
-	 * @exception Exception	throws an exception if an error occurs
-	 * see class comments for more information
-	 */
-	public static void execute(String args[]) 
-	{
-		NetworkServerControlImpl server = null;
-		try {
-			server = new NetworkServerControlImpl();
-			server.executeWork(args);
-		} catch (Exception e){
-			//if there was an error, exit(1)
-			if ((e.getMessage() == null) ||
-				!e.getMessage().equals(NetworkServerControlImpl.UNEXPECTED_ERR))
-			{
-				if (server != null)
-					server.consoleExceptionPrint(e);
-				else
-					e.printStackTrace();  // default output stream is System.out
-			}
-			// else, we've already printed a trace, so just exit.
-			System.exit(1);
-		}
-		System.exit(0);
-	}
-
 
 	/**
 	 * Execute the command given on the command line
@@ -1758,7 +1728,7 @@
 	 * @exception Exception	throws an exception if an error occurs
 	 * see class comments for more information
 	 */
-	protected void executeWork(String args[]) throws Exception
+	public void executeWork(String args[]) throws Exception
 	{
 		// For convenience just use NetworkServerControlImpls log writer for user messages
 		logWriter = makePrintWriter(System.out);

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testconnection.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testconnection.java?rev=170862&r1=170861&r2=170862&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testconnection.java
(original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testconnection.java
Wed May 18 20:54:01 2005
@@ -56,14 +56,29 @@
 		"ping", "-p", "9393"};
 
     private static  BufferedOutputStream bos = null;
+    
+    /**
+	 * Execute the given command and dump the results to standard out
+	 *
+	 * @param args	command and arguments
+	 * @exception Exception
+	 */
+    private static void execCmdDumpResults (String[] args)
+        throws Exception
+    {
+        execCmdDumpResults(args, 0);
+    }
+
 	/**
 	 * Execute the given command and dump the results to standard out
 	 *
 	 * @param args	command and arguments
+     * @param expectedExitCode the exit code that we expect from running this
 	 * @exception Exception
 	 */
 
-	private static void execCmdDumpResults (String[] args) throws Exception
+	private static void execCmdDumpResults (String[] args, int expectedExitCode)
+        throws Exception
 	{
         // We need the process inputstream and errorstream
         ProcessStreamResult prout = null;
@@ -99,6 +114,13 @@
 		// wait until all the results have been processed
 		prout.Wait();
 		prerr.Wait();
+        
+        // DERBY-214
+        if ( pr.exitValue() != expectedExitCode )
+        {
+            System.out.println("FAIL: expected exit code of " +
+                expectedExitCode + ", got exit code of " + pr.exitValue());
+        }
 
 	}
 
@@ -124,17 +146,17 @@
 			//test connection - specifying host and port
 			execCmdDumpResults(TestConnectionCmd2);	
 			//test connection - specifying non-existant host and port
-			execCmdDumpResults(TestConnectionCmd3);	
+			execCmdDumpResults(TestConnectionCmd3, 1);	
 			//test connection - specifying non-existant host with '-' in the name
-			execCmdDumpResults(TestConnectionCmd3a);	
+			execCmdDumpResults(TestConnectionCmd3a, 1);	
 			//test connection - specifying host but no port
 			execCmdDumpResults(TestConnectionCmd4);	
 			//test connection - specifying host and invalid port
-			execCmdDumpResults(TestConnectionCmd5);	
+			execCmdDumpResults(TestConnectionCmd5, 1);	
 			//test connection - specifying no host and valid port
 			execCmdDumpResults(TestConnectionCmd6);	
 			//test connection - specifying no host and invalid port
-			execCmdDumpResults(TestConnectionCmd7);	
+			execCmdDumpResults(TestConnectionCmd7, 1);	
 
 			System.out.println("End test");
 			bos.close();



Mime
View raw message