db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r1151691 - in /db/derby/code/trunk/java: testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java tools/org/apache/derby/impl/tools/ij/utilMain.java
Date Thu, 28 Jul 2011 00:30:25 GMT
Author: bpendleton
Date: Thu Jul 28 00:30:24 2011
New Revision: 1151691

URL: http://svn.apache.org/viewvc?rev=1151691&view=rev
Log:
DERBY-5342: make ScriptTestCase support ij properties

This patch was contributed by Houx Zhang (houxzhang at gmail dot com)

This patch refactors the ij utilMain class so that the code
that supports the properties:

	- ij.showNoConnectionsAtStart
	- ij.showNoCountForSelect

is extracted into a separate method so that it can be called
from goScript. In addition, ScriptTestCase is modified so that
it sets these properties to 'true' (other test cases may
subsequently set them to 'false' for testing purposes).


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java?rev=1151691&r1=1151690&r2=1151691&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java
Thu Jul 28 00:30:24 2011
@@ -26,6 +26,7 @@ import java.sql.Connection;
 import java.util.Locale;
 
 import org.apache.derby.iapi.tools.i18n.LocalizedResource;
+import org.apache.derbyTesting.junit.BaseTestCase;
 import org.apache.derbyTesting.junit.Derby;
 
 import junit.framework.Test;
@@ -206,6 +207,8 @@ public abstract class ScriptTestCase ext
      * Set up the new locale for the test
      */
     protected void setUp() {
+        BaseTestCase.setSystemProperty("ij.showNoConnectionsAtStart", "true");
+        BaseTestCase.setSystemProperty("ij.showNoCountForSelect", "true");
         oldLocale = Locale.getDefault();
 
         AccessController.doPrivileged(new java.security.PrivilegedAction() {

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java?rev=1151691&r1=1151690&r2=1151691&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/utilMain.java Thu Jul 28
00:30:24 2011
@@ -239,23 +239,7 @@ public class utilMain implements java.se
 			}
 			firstRun = false;
 
-      		//check if the property is set to not show select count and set the static variable
-      		//accordingly. 
-    		boolean showNoCountForSelect = Boolean.valueOf(util.getSystemProperty("ij.showNoCountForSelect")).booleanValue();
-      		JDBCDisplayUtil.showSelectCount = !showNoCountForSelect;
-
-      		//check if the property is set to not show initial connections and accordingly set
the
-      		//static variable.
-    		boolean showNoConnectionsAtStart = Boolean.valueOf(util.getSystemProperty("ij.showNoConnectionsAtStart")).booleanValue();
-
-    		if (!(showNoConnectionsAtStart)) {
-         		try {
-           			ijResult result = ijParser.showConnectionsMethod(true);
- 					displayResult(out,result,connEnv[currCE].getConnection());
-         		} catch (SQLException ex) {
-           			handleSQLException(out,ex);
-         		}
-      		}
+			supportIJProperties(connEnv[currCE]);
     	}
 		this.out = out;
 		runScriptGuts();
@@ -272,14 +256,36 @@ public class utilMain implements java.se
 	public int goScript(Connection conn,
 			LocalizedInput in)
 	{
-		JDBCDisplayUtil.showSelectCount = false;
-		connEnv[0].addSession(conn, (String) null);
+	    connEnv[0].addSession(conn, (String) null);
+        ijParser.setConnection(connEnv[0], (numConnections > 1));
+	    supportIJProperties(connEnv[0]);   
+	    		
 		fileInput = initialFileInput = !in.isStandardInput();
 		commandGrabber[0].ReInit(in);
 		return runScriptGuts();
 	}
 	
-	/**
+	private void supportIJProperties(ConnectionEnv env) {
+	  //check if the property is set to not show select count and set the static variable
+        //accordingly. 
+        boolean showNoCountForSelect = Boolean.valueOf(util.getSystemProperty("ij.showNoCountForSelect")).booleanValue();
+        JDBCDisplayUtil.showSelectCount = !showNoCountForSelect;
+
+        //check if the property is set to not show initial connections and accordingly set
the
+        //static variable.
+        boolean showNoConnectionsAtStart = Boolean.valueOf(util.getSystemProperty("ij.showNoConnectionsAtStart")).booleanValue();
+
+        if (!(showNoConnectionsAtStart)) {
+            try {
+                ijResult result = ijParser.showConnectionsMethod(true);
+                displayResult(out,result,env.getConnection());
+            } catch (SQLException ex) {
+                handleSQLException(out,ex);
+            }
+        }        
+    }
+
+    /**
 	 * Run the guts of the script. Split out to allow
 	 * calling from the full ij and the minimal goScript.
      * @return The number of errors seen in the script.



Mime
View raw message