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 rh...@apache.org on 2014/03/31 20:53:39 UTC

svn commit: r1583398 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest: ./ init/ tester/ utils/

Author: rhillegas
Date: Mon Mar 31 18:53:38 2014
New Revision: 1583398

URL: http://svn.apache.org/r1583398
Log:
DERBY-6533: Add a quiet mode to NsTest; commit derby-6533-01-aa-quietMode.diff.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestError.java   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestPrintStream.java   (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/README.txt
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/DbSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/Initializer.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/NWServerThread.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/BackupRestoreReEncryptTester.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester1.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester2.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester3.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/MemCheck.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java Mon Mar 31 18:53:38 2014
@@ -20,10 +20,14 @@
  */
 package org.apache.derbyTesting.system.nstest;
 
+import java.util.HashMap;
 import java.util.Properties;
 import java.sql.SQLException;
 import java.sql.DriverManager;
 import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.sql.Connection;
 
 import org.apache.derbyTesting.system.nstest.init.DbSetup;
@@ -53,8 +57,32 @@ import org.apache.derbyTesting.system.ns
  * turning off Backup/Restore/Re-Encryption.
  */
 
-public class NsTest extends Thread {
+public class NsTest extends Thread
+{
+    private static  final   String  BACKUP_FLAG = "derby.nstest.backupRestore";
+    private static  final   String  OUTPUT_FILE = "derby.nstest.outputFile";
+    private static  final   String  JUST_COUNT_ERRORS = "derby.nstest.justCountErrors";
+    private static  final   String  QUIET = "derby.nstest.quiet";
+    
+    private static  final   String  USAGE =
+        "Usage:\n" +
+        "\n" +
+        "    java org.apache.derbyTesting.system.nstest.NsTest [ DerbyClient | Embedded [ small ] ]\n" +
+        "\n" +
+        "If no arguments are specified, the test defaults to a client/server configuration (DerbyClient)\n" +
+        "\n" +
+        "The following flags can be set:\n" +
+        "\n" +
+        "    -D" + BACKUP_FLAG + "=false    Turns off backup, restore, and re-encryption.\n" +
+        "\n" +
+        "    -D" + OUTPUT_FILE + "=fileName    Redirects output and errors to a file.\n" +
+        "\n" +
+        "    -D" + JUST_COUNT_ERRORS + "=true    Makes the test run quietly at steady-state, counting errors, and printing a summary at the end.\n";
 
+    private static  final   String  ERROR_BANNER1 = "//////////////////////////////////////////////////////////////\n";
+    private static  final   String  ERROR_BANNER2 = "//    ";
+    
+    
 	public static final String dbName = "nstestdb";
 
 	public static final String user = "nstest";
@@ -86,6 +114,10 @@ public class NsTest extends Thread {
 	public static final String embedDriver = new String(
 	"org.apache.derby.jdbc.EmbeddedDriver");
 
+    /* where to log messages */
+    private static  PrintStream         statisticsLogger;
+    public static NsTestPrintStream   logger;
+    
 	public static Properties prop = new Properties();
 
 	public static int INIT = 0;
@@ -186,16 +218,52 @@ public class NsTest extends Thread {
     
 	private static NsTest[] testThreads = null;
 
+    private static  boolean _justCountErrors;
+    private static  HashMap<String,NsTestError> _errors = new HashMap<String,NsTestError>();
+
+    private static  boolean _statisticsAlreadyPrinted = false;
+
 	public static int numActiveTestThreads() {
 		int activeThreadCount=0;
-		for (int i = 0; i < testThreads.length ; i++)
-		{
-			if (testThreads[i] != null && testThreads[i].isAlive())
-			activeThreadCount++;
-		}
+
+        if ( testThreads != null )
+        {
+            for (int i = 0; i < testThreads.length ; i++)
+            {
+                if (testThreads[i] != null && testThreads[i].isAlive())
+                    activeThreadCount++;
+            }
+        }
+        
 		return activeThreadCount;
 	}
 
+    public  static  boolean justCountErrors() { return _justCountErrors; }
+
+	public static synchronized void addError( Throwable t )
+    {
+        String  key = getStackTrace( t );
+
+        NsTestError error = _errors.get( key );
+        if ( error != null ) { error.increment(); }
+        else
+        {
+            error = new NsTestError( t );
+            _errors.put( key, error );
+        }
+	}
+    private static  String  getStackTrace( Throwable t )
+    {
+        StringWriter    sw = new StringWriter();
+        PrintWriter     pw = new PrintWriter( sw );
+
+        t.printStackTrace( pw );
+        pw.flush();
+        sw.flush();
+
+        return sw.toString();
+    }
+
 	public static synchronized void addStats(int type, int addValue) {
 		switch (type) {
 		case 0:
@@ -259,7 +327,21 @@ public class NsTest extends Thread {
 	//
 	// ****************************************************************************
 	public static void main(String[] args) throws SQLException, IOException,
-	InterruptedException, Exception, Throwable {
+	InterruptedException, Exception, Throwable
+    {
+		String outputFile = System.getProperty( OUTPUT_FILE );
+        statisticsLogger = System.out;
+        if ( outputFile != null )
+        {
+            statisticsLogger = new PrintStream( outputFile );
+        }
+
+        _justCountErrors = Boolean.getBoolean( JUST_COUNT_ERRORS );
+
+        logger = new NsTestPrintStream( statisticsLogger, !_justCountErrors );
+
+        // add a shutdown hook to print statistics if someone types control-c to kill the test
+        Runtime.getRuntime().addShutdownHook( new Thread( new ShutdownHook() ) );
 
 		Connection conn = null;
 		if (args.length >= 1) {
@@ -270,7 +352,7 @@ public class NsTest extends Thread {
 				printUsage();
 				return;
 			}
-			System.out.println("Test nstest starting....., using driver: "
+			logger.println("Test nstest starting....., using driver: "
 					+ driver_type);
 		} else {
 			driver_type = "DerbyClient";
@@ -279,7 +361,7 @@ public class NsTest extends Thread {
 			String testConfiguration = args [1];
 			if (testConfiguration.equalsIgnoreCase("small"))
 			{
-				System.out.println("using small config");
+				logger.println("using small config");
 				setSmallConfig();
 			}    
 		}
@@ -288,17 +370,17 @@ public class NsTest extends Thread {
 		String jdbcUrl = "";
 		try {
 			if (driver_type.equalsIgnoreCase("Embedded")) {
-				// System.out.println("Driver embedd : " + driver_type);
-				System.out.println("Loading the embedded driver...");
+				// logger.println("Driver embedd : " + driver_type);
+				logger.println("Loading the embedded driver...");
 				Class.forName(embedDriver).newInstance();
 				jdbcUrl = embedDbURL + ";" + dataEncypt + ";" + bootPwd;
 				embeddedMode = true;
 			} else {
-				System.out.println("Driver type : " + driver_type);
-				System.out.println("Loading the Derby Client driver..."
+				logger.println("Driver type : " + driver_type);
+				logger.println("Loading the Derby Client driver..."
 						+ driver);
 				Class.forName(driver).newInstance();
-				System.out.println("Client Driver loaded");
+				logger.println("Client Driver loaded");
 				jdbcUrl = clientDbURL + ";" + dataEncypt + ";" + bootPwd;
 			}
 			if ((!embeddedMode) && START_SERVER_IN_SAME_VM) {
@@ -306,37 +388,37 @@ public class NsTest extends Thread {
 			}
 			prop.setProperty("user", user);
 			prop.setProperty("password", password);
-			System.out
+			logger
 			.println("Getting a connection using the url: " + jdbcUrl);
-			System.out.println("JDBC url= " + jdbcUrl);
+			logger.println("JDBC url= " + jdbcUrl);
 			conn = DriverManager.getConnection(jdbcUrl, prop);
 
 		} catch (SQLException sqe) {
 
-			System.out.println("\n\n " + sqe + sqe.getErrorCode() + " "
+			logger.println("\n\n " + sqe + sqe.getErrorCode() + " "
 					+ sqe.getSQLState());
 			if ((sqe.getErrorCode() == 40000)
 					|| sqe.getSQLState().equalsIgnoreCase("08001")) {
-				System.out
+				logger
 				.println("\n Unable to connect, test cannot proceed. Please verify if the Network Server is started on port 1900.");
 				// sqe.printStackTrace();
 				return;
 			}
 
 		} catch (ClassNotFoundException cnfe) {
-			System.out.println("Driver not found: " + cnfe.getMessage());
-			cnfe.printStackTrace();
+			logger.println("Driver not found: " + cnfe.getMessage());
+			cnfe.printStackTrace( logger );
 			return;
 
 		} catch (Exception e) {
-			e.printStackTrace();
-			System.out.println("Unexpected Failure");
+			e.printStackTrace( logger );
+			logger.println("Unexpected Failure");
 			printException("nstest.main() method ==> ", e);
 		}
 
 		// create test schema if it does not already exist
 		if (DbSetup.doIt(conn) == false) {
-			System.out.println("Error in dbSetup, test will exit");
+			logger.println("Error in dbSetup, test will exit");
 			System.exit(1);
 		}
 
@@ -344,7 +426,7 @@ public class NsTest extends Thread {
 		try {
 			conn.close();
 		} catch (Exception e) {
-			System.out
+			logger
 			.println("FAIL - Error closing the connection in nstest.main():");
 			printException("Closing connection in nstest.main()", e);
 		}
@@ -352,7 +434,7 @@ public class NsTest extends Thread {
 		// check memory in separate thread-- allows us to monitor usage during
 		// database calls
 		// 200,000 msec = 3min, 20 sec delay between checks
-		System.out.println("Starting memory checker thread");
+		logger.println("Starting memory checker thread");
 		MemCheck mc = new MemCheck(200000);
 		mc.start();
 
@@ -371,7 +453,7 @@ public class NsTest extends Thread {
 
 		if (NsTest.schemaCreated == false) {
 			// Table was created by this object, so we need to load it
-			System.out
+			logger
 			.println("Kicking off initialization threads that will populate the test table");
 			NsTest initThreads[] = new NsTest[INIT_THREADS];
 
@@ -391,7 +473,7 @@ public class NsTest extends Thread {
 		// created the schema
 		if (NsTest.schemaCreated) // true means that the schema was created by
 			// another jvm
-			System.out
+			logger
 			.println("Schema has already been created by another process!");
 
 		// The following 2 lines are used when you want to only create the test
@@ -399,7 +481,7 @@ public class NsTest extends Thread {
 		// not need to create one of their own.
 		// The CREATE_DATABASE_ONLY FLAG is set with the rest of the flags
 		if (CREATE_DATABASE_ONLY) {
-			System.out
+			logger
 			.println("Finished creating the database, TEST THREADS WILL NOT RUN!!");
 			// Finally also stop the memory checker thread, else the test will
 			// remain hung!
@@ -413,12 +495,12 @@ public class NsTest extends Thread {
 		// Now kick off the actual test threads that will do the work for us.
 		// Note that we use the value TESTER when initializing the threads.
 		// The total number of threads is NUMTESTER1+NUMTESTER2+NUMTESTER3
-		System.out
+		logger
 		.println("Kicking off test threads that will work over the test table");
 
 		int numTestThread = 0;
 		int maxTestThreads = 0;
-		String runBackup = System.getProperty("derby.nstest.backupRestore");
+		String runBackup = System.getProperty( BACKUP_FLAG );
 		if ((runBackup != null) && (runBackup.equalsIgnoreCase("false")))
 				maxTestThreads = NUMTESTER1 + NUMTESTER2 + NUMTESTER3;
 		else
@@ -433,7 +515,7 @@ public class NsTest extends Thread {
 			// Check for property setting to decide the need for starting
 			// BackupRestore thread
 			if ((runBackup != null) && (runBackup.equalsIgnoreCase("false"))) {
-				System.out.println("BackupRestore Thread not started...");
+				logger.println("BackupRestore Thread not started...");
 			} else {
 				// Otherwise, start the BackupRestore Thread by default
 				testThreads[numTestThread] = new NsTest(BACKUP, numTestThread);
@@ -463,45 +545,129 @@ public class NsTest extends Thread {
 		}
 
 		// Wait for the test threads to finish and join back
-		for (int j = 0; j < maxTestThreads; j++) {
-			System.out.println("Waiting for thread " + j
-					+ " to join back/finish");
+		for (int j = 0; j < maxTestThreads; j++)
+        {
+            logger.println("Waiting for thread " + j+ " to join back/finish");
 			testThreads[j].join();
 		}
 
 		// Print statistics
-		System.out.println("");
-		System.out.println("STATISTICS OF OPERATIONS DONE");
-		System.out.println("-----------------------------");
-		System.out.println("");
-		System.out.println("SUCCESSFUL: ");
-		System.out.println("	Number of INSERTS = " + numInserts);
-		System.out.println("	Number of UPDATES = " + numUpdates);
-		System.out.println("	Number of DELETES = " + numDeletes);
-		System.out.println("	Number of SELECTS = " + numSelects);
-		System.out.println("");
-		System.out.println("FAILED: ");
-		System.out.println("	Number of failed INSERTS = " + numFailedInserts);
-		System.out.println("	Number of failed UPDATES = " + numFailedUpdates);
-		System.out.println("	Number of failed DELETES = " + numFailedDeletes);
-		System.out.println("	Number of failed SELECTS = " + numFailedSelects);
-		System.out.println("");
-		System.out.println("  Note that this may not be the same as the server side connections made\n"
-				+ "   to the database especially if connection pooling is employed");
-		System.out.println("");
-		System.out
-		.println("NOTE: Failing operations could be because of locking issue that are\n"
-				+ "directly related to the application logic.  They are not necessarily bugs.");
+        printStatistics();
 
 		// Finally also stop the memory checker thread
 		mc.stopNow = true;
 		mc.join();
 
-		System.out
+		logger
 		.println("End of test nstest! Look for 'FAIL' messages in the output and derby.log");
 
 	}// end of main
 
+    public  static  void    printStatistics()
+    {
+        if ( _statisticsAlreadyPrinted ) { return; }
+        else { _statisticsAlreadyPrinted = true; }
+
+		statisticsLogger.println("");
+		statisticsLogger.println("STATISTICS OF OPERATIONS DONE");
+		statisticsLogger.println("-----------------------------");
+		statisticsLogger.println("");
+		statisticsLogger.println("SUCCESSFUL: ");
+		statisticsLogger.println("	Number of INSERTS = " + numInserts);
+		statisticsLogger.println("	Number of UPDATES = " + numUpdates);
+		statisticsLogger.println("	Number of DELETES = " + numDeletes);
+		statisticsLogger.println("	Number of SELECTS = " + numSelects);
+		statisticsLogger.println("");
+		statisticsLogger.println("FAILED: ");
+		statisticsLogger.println("	Number of failed INSERTS = " + numFailedInserts);
+		statisticsLogger.println("	Number of failed UPDATES = " + numFailedUpdates);
+		statisticsLogger.println("	Number of failed DELETES = " + numFailedDeletes);
+		statisticsLogger.println("	Number of failed SELECTS = " + numFailedSelects);
+		statisticsLogger.println("");
+		statisticsLogger.println("  Note that this may not be the same as the server side connections made\n"
+				+ "   to the database especially if connection pooling is employed");
+		statisticsLogger.println("");
+		statisticsLogger
+		.println("NOTE: Failing operations could be because of locking issue that are\n"
+				+ "directly related to the application logic.  They are not necessarily bugs.");
+
+        if ( _errors.size() > 0 )
+        {
+            countAndPrintSQLStates();
+            for ( String key  : _errors.keySet() )
+            {
+                printError( key );
+            }
+        }
+    }
+
+    /** Count and print the number of times each SQLState was seen in an error */
+    private static  void    countAndPrintSQLStates()
+    {
+        HashMap<String,int[]>   results = new HashMap<String,int[]>();
+
+        // count the number of times each SQL state was seen
+        for ( String key  : _errors.keySet() )
+        {
+            NsTestError error = _errors.get( key );
+            int         count = error.count();
+            Throwable   throwable = error.throwable();
+            if ( throwable instanceof SQLException )
+            {
+                SQLException    se = (SQLException) throwable;
+                String          sqlState = se.getSQLState();
+
+                if ( sqlState != null )
+                {
+                    int[]   holder = results.get( sqlState );
+                    if ( holder == null )
+                    {
+                        holder = new int[] { count };
+                        results.put( sqlState, holder );
+                    }
+                    else { holder[ 0 ] += count; }
+                }
+            }
+        }
+
+        // now print the counts
+        statisticsLogger.println( "\n" );
+        for ( String sqlState : results.keySet() )
+        {
+            statisticsLogger.println("	Number of " + sqlState + " = " + results.get( sqlState )[ 0 ] );
+        }
+        statisticsLogger.println( "\n" );
+    }
+
+    private static  void    printError( String key )
+    {
+        String          stackTrace = key;
+        NsTestError error = _errors.get( key );
+        Throwable   throwable = error.throwable();
+        int             count = error.count();
+        String      sqlState = (throwable instanceof SQLException) ? 
+            ((SQLException) throwable).getSQLState() : null;
+
+        StringBuilder   buffer = new StringBuilder();
+
+        buffer.append( ERROR_BANNER1 );
+        buffer.append( ERROR_BANNER2 );
+        buffer.append( "\n" );
+        buffer.append( ERROR_BANNER2 );
+        buffer.append( "Count = " + count );
+        if ( sqlState != null ) { buffer.append( ", SQLState = " + sqlState ); }
+        buffer.append( ", Message = " + throwable.getMessage() );
+        buffer.append( "\n" );
+        buffer.append( ERROR_BANNER2 );
+        buffer.append( "\n" );
+        buffer.append( ERROR_BANNER1 );
+        buffer.append( "\n" );
+        buffer.append( stackTrace );
+        buffer.append( "\n" );
+
+        statisticsLogger.println( buffer.toString() );
+    }
+
 	// ****************************************************************************
 	//
 	// run() - the main workhorse method of the threads that will either
@@ -540,7 +706,7 @@ public class NsTest extends Thread {
 	// ****************************************************************************
 	public void run() {
 
-		System.out.println(this.getName() + " is now running");
+		logger.println(this.getName() + " is now running");
 
 		if (this.type == INIT) {
 			Initializer Init = new Initializer(this.getName());
@@ -564,22 +730,22 @@ public class NsTest extends Thread {
 				Tstr4 = new BackupRestoreReEncryptTester(
 						"BackupRestoreReEncrypt" + this.getName());
 			} catch (IOException ioe) {
-				System.out
+				logger
 				.println(ioe
 						+ "=====> Unable to create backup log file, test cannot proceed ");
-				ioe.printStackTrace();
+				ioe.printStackTrace( logger );
 				return;
 			}
 			Tstr4.startTesting();
 
 		} else {
-			System.out
+			logger
 			.println("FAIL: Invalid thread type, should be INIT or TESTERx or BACKUP");
-			System.out.println("You should check the code and restart");
+			logger.println("You should check the code and restart");
 			return;
 		}
 
-		System.out.println(this.getName() + " finished and is now exiting");
+		logger.println(this.getName() + " finished and is now exiting");
 
 	}// end of run()
 
@@ -589,30 +755,37 @@ public class NsTest extends Thread {
 	// ***Method is synchronized so that the output file will contain sensible
 	// stack traces that are not
 	// ****mixed but rather one exception printed at a time
-	public static synchronized void printException(String where, Exception e) {
+    public static synchronized void printException(String where, Exception e)
+    {
+        if ( justCountErrors() )
+        {
+            addError( e );
+            return;
+        }
+        
 		if (e instanceof SQLException) {
 			SQLException se = (SQLException) e;
 			if (se.getSQLState() != null) { // SQLSTATE is NULL for a
 				if (se.getSQLState().equals("40001"))
-					System.out.println("deadlocked detected");
+					logger.println("deadlocked detected");
 				if (se.getSQLState().equals("40XL1"))
-					System.out.println(" lock timeout exception");
+					logger.println(" lock timeout exception");
 				if (se.getSQLState().equals("23500"))
-					System.out.println(" duplicate key violation");
+					logger.println(" duplicate key violation");
 			}
 			if (se.getNextException() != null) {
 				String m = se.getNextException().getSQLState();
-				System.out.println(se.getNextException().getMessage()
+				logger.println(se.getNextException().getMessage()
 						+ " SQLSTATE: " + m);
 			}
 		}
 		if (e.getMessage() == null) {
-			System.out.println("NULL error message detected");
-			System.out.println("Here is the NULL exection - " + e.toString());
-			System.out.println("Stack trace of the NULL exception - ");
-			e.printStackTrace(System.out);
+			logger.println("NULL error message detected");
+			logger.println("Here is the NULL exection - " + e.toString());
+			logger.println("Stack trace of the NULL exception - ");
+			e.printStackTrace( logger );
 		}
-		System.out.println("At this point - " + where
+		logger.println("At this point - " + where
 				+ ", exception thrown was : " + e.getMessage());
 
 	}
@@ -631,16 +804,24 @@ public class NsTest extends Thread {
 			nsw.start();
 			Thread.sleep(10000);
 		} catch (Exception e) {
-			e.printStackTrace();
+			e.printStackTrace( logger );
 			throw e;
 		}
 
 	}
 
-	public static void printUsage() {
-		System.out.println("Usage:");
-		System.out
-		.println("java org.apache.derbyTesting.system.nstest.NsTest DerbyClient|Embedded");
-		System.out.println("\nNo argument/Default value is 'DerbyClient'");
+	public static void printUsage()
+    {
+        _statisticsAlreadyPrinted = true;
+        System.out.println( USAGE );
 	}
+
+    public  static  class   ShutdownHook    implements  Runnable
+    {
+        public  void    run()
+        {
+            NsTest.printStatistics();
+        }
+    }
+    
 }

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestError.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestError.java?rev=1583398&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestError.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestError.java Mon Mar 31 18:53:38 2014
@@ -0,0 +1,81 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.system.nstest.NsTestError
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derbyTesting.system.nstest;
+
+/**
+ * <p>
+ * An descriptor for an error seen by NsTest. These are placed in a
+ * HashMap keyed by the error's stack trace.
+ * </p>
+ */
+public  class   NsTestError
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private Throwable   _throwable;
+    private int             _count;
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /** Construct from a Throwable */
+    public  NsTestError( Throwable throwable )
+    {
+        _throwable = throwable;
+        _count = 1;
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // ACCESSORS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /** Get the Throwable wrapped by this descriptor */
+    public  Throwable   throwable() { return _throwable; }
+
+    /** Get the number of times this error was seen */
+    public  int count() { return _count; }
+  
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // OTHER BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /** Increment the number of times this error was seen */
+    public  void    increment() { _count++; }
+    
+}
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestError.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestPrintStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestPrintStream.java?rev=1583398&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestPrintStream.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestPrintStream.java Mon Mar 31 18:53:38 2014
@@ -0,0 +1,128 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.system.nstest.NsTestPrintStream
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derbyTesting.system.nstest;
+
+import java.io.PrintStream;
+import java.util.Locale;
+
+/**
+ * <p>
+ * A stream whose output can be throttled.
+ * </p>
+ */
+public  class   NsTestPrintStream   extends PrintStream
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private boolean _chatty;
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /** Construct a quiet or chatty print stream */
+    public  NsTestPrintStream( PrintStream wrappedStream, boolean chatty )
+    {
+        super( wrappedStream );
+        _chatty = chatty;
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // OVERRIDDEN BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public PrintStream append( char c )
+    {
+        if ( _chatty ) { super.append( c ); }
+        return this;
+    }
+    public PrintStream append( CharSequence csq )
+    {
+        if ( _chatty ) { super.append( csq ); }
+        return this;
+    }
+    public PrintStream append( CharSequence csq, int start, int end )
+    {
+        if ( _chatty ) { super.append( csq, start, end ); }
+        return this;
+    }
+    public boolean checkError() { return super.checkError(); }
+    protected void clearError() { super.clearError(); }
+    public void close() { super.close(); }
+    public void flush() { super.flush(); }
+    public void print( boolean b )   { if ( _chatty ) { super.print( b ); } }
+    public void print( char c )   { if ( _chatty ) { super.print( c ); } }
+    public void print( int i )   { if ( _chatty ) { super.print( i ); } }
+    public void print( long l )   { if ( _chatty ) { super.print( l ); } }
+    public void print( float f )   { if ( _chatty ) { super.print( f ); } }
+    public void print( double d )   { if ( _chatty ) { super.print( d ); } }
+    public void print( char[] s )   { if ( _chatty ) { super.print( s ); } }
+    public void print( String s )   { if ( _chatty ) { super.print( s ); } }
+    public void print( Object obj )   { if ( _chatty ) { super.print( obj ); } }
+    public void println()   { if ( _chatty ) { super.println(); } }
+    public void println( boolean x )   { if ( _chatty ) { super.println( x ); } }
+    public void println( char x )   { if ( _chatty ) { super.println( x ); } }
+    public void println( int x )   { if ( _chatty ) { super.println( x ); } }
+    public void println( long x )   { if ( _chatty ) { super.println( x ); } }
+    public void println( float x )   { if ( _chatty ) { super.println( x ); } }
+    public void println( double x )   { if ( _chatty ) { super.println( x ); } }
+    public void println( char[] x )   { if ( _chatty ) { super.println( x ); } }
+    public void println( String x )   { if ( _chatty ) { super.println( x ); } }
+    public void println( Object x )   { if ( _chatty ) { super.println( x ); } }
+    public PrintStream printf( String format, Object... args )
+    {
+        if ( _chatty ) { super.printf( format, args ); }
+        return this;
+    }
+    public PrintStream printf( Locale l, String format, Object... args )
+    {
+        if ( _chatty ) { super.printf( l, format, args ); }
+        return this;
+    }
+    public PrintStream format( String format, Object... args )
+    {
+        if ( _chatty ) { super.format( format, args ); }
+        return this;
+    }
+    public PrintStream format( Locale l, String format, Object... args )
+    {
+        if ( _chatty ) { super.format( l, format, args ); }
+        return this;
+    }
+    public void write( byte[] buf, int off, int len )   { if ( _chatty ) { super.write( buf, off, len ); } }
+    public void write( int b )  { if ( _chatty ) { super.write( b ); } }
+
+}
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTestPrintStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/README.txt
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/README.txt?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/README.txt (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/README.txt Mon Mar 31 18:53:38 2014
@@ -66,7 +66,18 @@ variable settings used in the test are s
 HOW TO RUN:
 ===========
 Usage:
-java org.apache.derbyTesting.system.nstest.NsTest DerbyClient|Embedded [small]
+
+    java org.apache.derbyTesting.system.nstest.NsTest [ DerbyClient | Embedded [ small ] ]
+
+If no arguments are specified, the test defaults to a client/server configuration (DerbyClient)
+
+The following flags can be set:
+
+    -Dderby.nstest.backupRestore=false    Turns off backup, restore, and re-encryption.
+
+    -Dderby.nstest.outputFile=fileName    Redirects output and errors to a file.
+
+    -Dderby.nstest.justCountErrors=true    Makes the test run quietly at steady-state, counting errors, and printing a summary at the end.
 
 The main class to invoke is org.apache.derbyTesting.system.nstest.NsTest. This class
 takes a String argument of "DerbyClient"/"Embedded", default is DerbyClient. The test requires

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/DbSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/DbSetup.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/DbSetup.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/DbSetup.java Mon Mar 31 18:53:38 2014
@@ -41,12 +41,12 @@ public class DbSetup {
 		ResultSet rs = null;
 		boolean finished = false;
 
-		System.out.println("dbSetup.doIt() starting...");
+		NsTest.logger.println("dbSetup.doIt() starting...");
 
 		try {
 			conn.setAutoCommit(false);
 		} catch (Exception e) {
-			System.out.println("FAIL - setAutoCommit() failed:");
+			NsTest.logger.println("FAIL - setAutoCommit() failed:");
 			printException("setting autocommit in dbSetup", e);
 			return (false);
 		}
@@ -57,13 +57,13 @@ public class DbSetup {
 					+ " where tablename = 'NSTESTTAB'");
 			if (rs.next()) {
 				rs.close();
-				System.out.println("table 'NSTESTTAB' already exists");
+				NsTest.logger.println("table 'NSTESTTAB' already exists");
 				finished = true;
 				NsTest.schemaCreated = true; // indicates to other classes
 				// that the schema already exists
 			}
 		} catch (Exception e) {
-			System.out
+			NsTest.logger
 			.println("dbSetup.doIt() check existance of table: FAIL -- unexpected exception:");
 			printException(
 					"executing query or processing resultSet to check for table existence",
@@ -74,7 +74,7 @@ public class DbSetup {
 		// if we reach here then the table does not exist, so we create it
 		if (finished == false) {
 			try {
-				System.out
+				NsTest.logger
 				.println("creating table 'NSTESTTAB' and corresponding indices");
 				s.execute("create table nstesttab (" + "id int,"
 						+ "t_char char(100)," + "t_date date,"
@@ -112,7 +112,7 @@ public class DbSetup {
 				s
 				.execute("create index t_serialkey_ind on nstesttab (serialkey)");
 
-				System.out
+				NsTest.logger
 				.println("creating table 'NSTRIGTAB' and corresponding indices");
 				s.execute("create table NSTRIGTAB (" + "id int,"
 						+ "t_char char(100)," + "t_date date,"
@@ -135,8 +135,9 @@ public class DbSetup {
 						+ "OLDROW.T_clob,OLDROW.T_blob, "
 						+ "OLDROW.serialkey)");
 			} catch (Exception e) {
-				e.printStackTrace();
-				System.out
+                if ( NsTest.justCountErrors() ) { NsTest.printException( DbSetup.class.getName(), e ); }
+				else { e.printStackTrace( NsTest.logger ); }
+				NsTest.logger
 				.println("FAIL - unexpected exception in dbSetup.doIt() while creating schema:");
 				printException("executing statements to create schema", e);
 				return (false);
@@ -155,28 +156,34 @@ public class DbSetup {
 	// stack traces that are not
 	// ****mixed but rather one exception printed at a time
 	public static synchronized void printException(String where, Exception e) {
+        if ( NsTest.justCountErrors() )
+        {
+            NsTest.addError( e );
+            return;
+        }
+
 		if (e instanceof SQLException) {
 			SQLException se = (SQLException) e;
 
 			if (se.getSQLState().equals("40001"))
-				System.out.println("deadlocked detected");
+				NsTest.logger.println("deadlocked detected");
 			if (se.getSQLState().equals("40XL1"))
-				System.out.println(" lock timeout exception");
+				NsTest.logger.println(" lock timeout exception");
 			if (se.getSQLState().equals("23500"))
-				System.out.println(" duplicate key violation");
+				NsTest.logger.println(" duplicate key violation");
 			if (se.getNextException() != null) {
 				String m = se.getNextException().getSQLState();
-				System.out.println(se.getNextException().getMessage()
+				NsTest.logger.println(se.getNextException().getMessage()
 						+ " SQLSTATE: " + m);
 			}
 		}
 		if (e.getMessage() == null) {
-			System.out.println("NULL error message detected");
-			System.out.println("Here is the NULL exection - " + e.toString());
-			System.out.println("Stack trace of the NULL exception - ");
-			e.printStackTrace(System.out);
+			NsTest.logger.println("NULL error message detected");
+			NsTest.logger.println("Here is the NULL exection - " + e.toString());
+			NsTest.logger.println("Stack trace of the NULL exception - ");
+			e.printStackTrace( NsTest.logger );
 		}
-		System.out.println("During " + where + ", exception thrown was : "
+		NsTest.logger.println("During " + where + ", exception thrown was : "
 				+ e.getMessage());
 	}
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/Initializer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/Initializer.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/Initializer.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/Initializer.java Mon Mar 31 18:53:38 2014
@@ -52,7 +52,7 @@ public class Initializer {
 		// point, we just need to get a connection to the database
 		try {
 
-			System.out.println(thread_id
+			NsTest.logger.println(thread_id
 					+ " is getting a connection to the database...");
 
 			if (NsTest.embeddedMode) {
@@ -60,20 +60,20 @@ public class Initializer {
 						NsTest.prop);
 			} else {
 				if(NsTest.driver_type.equalsIgnoreCase("DerbyClient")) {
-					System.out.println("-->Using derby client url");
+					NsTest.logger.println("-->Using derby client url");
 					conn = DriverManager.getConnection(NsTest.clientDbURL,
 							NsTest.prop);
 				}
 			}
 		} catch (Exception e) {
-			System.out.println("FAIL: " + thread_id
+			NsTest.logger.println("FAIL: " + thread_id
 					+ " could not get the database connection");
 			printException("getting database connection in startInserts()", e);
 		}
 
 		// add one to the statistics of client side connections made per jvm
 		NsTest.addStats(NsTest.CONNECTIONS_MADE, 1);
-		System.out.println("Connection number: " + NsTest.numConnections);
+		NsTest.logger.println("Connection number: " + NsTest.numConnections);
 
 		// set autocommit to false to keep transaction control in your hand
 		if (NsTest.AUTO_COMMIT_OFF) {
@@ -81,7 +81,7 @@ public class Initializer {
 
 				conn.setAutoCommit(false);
 			} catch (Exception e) {
-				System.out.println("FAIL: " + thread_id
+				NsTest.logger.println("FAIL: " + thread_id
 						+ "'s setAutoCommit() failed:");
 				printException("setAutoCommit() in Initializer", e);
 			}
@@ -90,10 +90,10 @@ public class Initializer {
 		while (insertsRemaining-- >= 0) {
 			try {
 				int numInserts = dbutil.add_one_row(conn, thread_id);
-				//System.out.println("Intializer.java: exited add_one_row: "
+				//NsTest.logger.println("Intializer.java: exited add_one_row: "
 				//		+ numInserts + " rows");
 			} catch (Exception e) {
-				System.out.println(" FAIL: " + thread_id
+				NsTest.logger.println(" FAIL: " + thread_id
 						+ " unexpected exception:");
 				printException("add_one_row() in Initializer", e);
 				break;
@@ -105,7 +105,7 @@ public class Initializer {
 			try {
 				conn.commit();
 			} catch (Exception e) {
-				System.out
+				NsTest.logger
 						.println("FAIL: " + thread_id + "'s commit() failed:");
 				printException("commit in Initializer", e);
 			}
@@ -120,25 +120,31 @@ public class Initializer {
 	// stack traces that are not
 	// ****mixed but rather one exception printed at a time
 	public synchronized void printException(String where, Exception e) {
+        if ( NsTest.justCountErrors() )
+        {
+            NsTest.addError( e );
+            return;
+        }
+
 		if (e instanceof SQLException) {
 			SQLException se = (SQLException) e;
 
 			if (se.getSQLState().equals("40001"))
-				System.out.println("deadlocked detected");
+				NsTest.logger.println("deadlocked detected");
 			if (se.getSQLState().equals("40XL1"))
-				System.out.println(" lock timeout exception");
+				NsTest.logger.println(" lock timeout exception");
 			if (se.getSQLState().equals("23500"))
-				System.out.println(" duplicate key violation");
+				NsTest.logger.println(" duplicate key violation");
 			if (se.getNextException() != null) {
 				String m = se.getNextException().getSQLState();
-				System.out.println(se.getNextException().getMessage()
+				NsTest.logger.println(se.getNextException().getMessage()
 						+ " SQLSTATE: " + m);
 			}
 		}
 		if (e.getMessage() == null) {
-			e.printStackTrace(System.out);
+			e.printStackTrace( NsTest.logger );
 		}
-		System.out.println("During - " + where
+		NsTest.logger.println("During - " + where
 				+ ", the exception thrown was : " + e.getMessage());
 	}
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/NWServerThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/NWServerThread.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/NWServerThread.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/init/NWServerThread.java Mon Mar 31 18:53:38 2014
@@ -25,6 +25,8 @@ import java.net.InetAddress;
 
 import org.apache.derby.drda.NetworkServerControl;
 
+import org.apache.derbyTesting.system.nstest.NsTest;
+
 /**
  * NWServerThread: Start a Network Server in a new Thread, based on the
  * NsTest.START_SERVER_IN_SAME_VM setting
@@ -51,9 +53,10 @@ public class NWServerThread extends Thre
 			inetaddr = InetAddress.getByName(address);
 
 		} catch (Exception e) {
-			System.out
+			NsTest.logger
 					.println("Invalid host address passed, cannot start server");
-			e.printStackTrace();
+			if ( NsTest.justCountErrors() ) { NsTest.printException( NWServerThread.class.getName(), e ); }
+            else { e.printStackTrace( NsTest.logger ); }
 			throw e;
 		}
 	}
@@ -65,12 +68,13 @@ public class NWServerThread extends Thre
 	public void run() {
 		try {
 			NetworkServerControl nsw = new NetworkServerControl(inetaddr, port);
-			nsw.start(new PrintWriter(System.out));
-			System.out.println("===> Derby Network Server on " + address + ":"
+			nsw.start(new PrintWriter(NsTest.logger));
+			NsTest.logger.println("===> Derby Network Server on " + address + ":"
 					+ port + " <===");
 		} catch (Exception e) {
 			;
-			e.printStackTrace();
+            if ( NsTest.justCountErrors() ) { NsTest.printException( NWServerThread.class.getName(), e ); }
+			else { e.printStackTrace( NsTest.logger ); }
 		}
 	}
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/BackupRestoreReEncryptTester.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/BackupRestoreReEncryptTester.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/BackupRestoreReEncryptTester.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/BackupRestoreReEncryptTester.java Mon Mar 31 18:53:38 2014
@@ -85,7 +85,7 @@ public class BackupRestoreReEncryptTeste
 			// Get the connection. It will be closed at the end of the loop
 			connex = getConnection();
 			if (connex == null) {
-				System.out.println("FAIL: " + getThread_id()
+				NsTest.logger.println("FAIL: " + getThread_id()
 						+ " could not get the database connection");
 				return; // quit
 			}
@@ -101,18 +101,20 @@ public class BackupRestoreReEncryptTeste
 			} catch (Exception e) {
 				message = getTimestamp() + "FAILED - BackUp thread doBackup"
 						+ getThread_id() + " threw " + e;
-				System.out.println(message);
+				NsTest.logger.println(message);
 				log(message);
 				printException("call to doBackup() in BackupThread ", e);
-				e.printStackTrace();
+                if ( NsTest.justCountErrors() ) { NsTest.printException( BackupRestoreReEncryptTester.class.getName(), e ); }
+				else { e.printStackTrace( NsTest.logger ); }
 			}
 
 			try {
 				doRestoreandReEncrypt();
 
 			} catch (SQLException e) {
-				e.printStackTrace();
-				System.out
+                if ( NsTest.justCountErrors() ) { NsTest.printException( BackupRestoreReEncryptTester.class.getName(), e ); }
+				else { e.printStackTrace( NsTest.logger ); }
+				NsTest.logger
 						.println("FAILED at doRestoreandReEncrypt() - BackUp thread "
 								+ getThread_id() + " threw " + e);
 				printException(
@@ -121,7 +123,7 @@ public class BackupRestoreReEncryptTeste
 						+ " call to doRestoreandReEncrypt() in BackupThread FAILED "
 						+ e.getSQLState() + " " + e);
 
-				e.printStackTrace(logger);
+				e.printStackTrace( logger );
 			}
 
 			// close the connection
@@ -152,7 +154,7 @@ public class BackupRestoreReEncryptTeste
     
 		}// end of for (int i=0;...)
 
-		System.out.println("Thread " + getThread_id() + " is now terminating");
+		NsTest.logger.println("Thread " + getThread_id() + " is now terminating");
 
 	}// end of startTesting()
 
@@ -180,7 +182,7 @@ public class BackupRestoreReEncryptTeste
 					+ getThread_id() + " threw " + e;
 			log(message);
 			printException("call to doConsistCheck() in BackupThread ", e);
-			e.printStackTrace(logger);
+			e.printStackTrace( logger );
 		}
 		log("--------------------- B A C K U P  S E C T I O N  E N D ----------------------------");
 	}
@@ -226,12 +228,12 @@ public class BackupRestoreReEncryptTeste
 			log(getTimestamp() + " Database restored successfully " + dbUrl);
 		} catch (SQLException e) {
 			log(getTimestamp() + " FAILURE ! to restore database " + dbUrl);
-			e.printStackTrace(logger);
+			e.printStackTrace( logger );
 
 		}
 
 		// Consistency check not required everytime
-		conn.close();
+		if ( conn != null ) { conn.close(); }
 		dbUrl = restoreDbURL + ";" + NsTest.bootPwd;
 		doConsistCheck(dbUrl, dbType);
 		// DERBY-1737, hence create a new connection
@@ -311,6 +313,6 @@ public class BackupRestoreReEncryptTeste
 		logger.write(msg + "\n");
 		logger.flush();
 
-		System.out.println(msg);
+		NsTest.logger.println(msg);
 	}
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester1.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester1.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester1.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester1.java Mon Mar 31 18:53:38 2014
@@ -58,7 +58,7 @@ public class Tester1 extends TesterObjec
 		// this connection will remain open forever.
 		connex = getConnection();
 		if (connex == null) {
-			System.out.println("FAIL: " + getThread_id()
+			NsTest.logger.println("FAIL: " + getThread_id()
 					+ " could not get the database connection");
 			return; // quit
 		}
@@ -68,7 +68,7 @@ public class Tester1 extends TesterObjec
 		try {
 			connex.setAutoCommit(false);
 		} catch (Exception e) {
-			System.out.println("FAIL: " + getThread_id()
+			NsTest.logger.println("FAIL: " + getThread_id()
 					+ "'s setAutoCommit() failed:");
 			printException("setting AutoCommit", e);
 		}
@@ -95,14 +95,15 @@ public class Tester1 extends TesterObjec
 			case 0: // do a select operation
 				try {
 					int numSelected = doSelectOperation(NsTest.MAX_LOW_STRESS_ROWS);
-					System.out.println(getThread_id() + " selected "
+					NsTest.logger.println(getThread_id() + " selected "
 							+ numSelected + " rows");
 				} catch (Exception e) {
-					System.out
+					NsTest.logger
 							.println("--> Isolation Level is TRANSACTION_READ_UNCOMMITTED, hence SHOULD NOT FAIL ********* doSelect in thread "
 									+ getThread_id() + " threw " + e);
 					printException("doSelectOperation()", e);
-					e.printStackTrace();
+                    if ( NsTest.justCountErrors() ) { NsTest.printException( Tester1.class.getName(), e ); }
+					else { e.printStackTrace( NsTest.logger ); }
 				}
 				break;
 
@@ -122,7 +123,7 @@ public class Tester1 extends TesterObjec
 			try {
 				connex.commit();
 			} catch (Exception e) {
-				System.out
+				NsTest.logger
 						.println("FAIL: " + getThread_id() + "'s commit() failed:");
 				printException("committing Xn in Tester1", e);
 			}
@@ -130,7 +131,7 @@ public class Tester1 extends TesterObjec
 
 		// close the connection before the thread terminates
 		closeConnection();
-		System.out.println("Thread " + getThread_id()+ " is now terminating");
+		NsTest.logger.println("Thread " + getThread_id()+ " is now terminating");
 
 	}//end of startTesting()
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester2.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester2.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester2.java Mon Mar 31 18:53:38 2014
@@ -63,7 +63,7 @@ public class Tester2 extends TesterObjec
 			//the connection will now open. It closes at the end of the loop
 			connex = getConnection();
 			if (connex == null) {
-				System.out.println("FAIL: " + getThread_id()
+				NsTest.logger.println("FAIL: " + getThread_id()
 						+ " could not get database connection");
 				return; //quit
 			}
@@ -73,7 +73,7 @@ public class Tester2 extends TesterObjec
 			try {
 				connex.setAutoCommit(false);
 			} catch (Exception e) {
-				System.out.println("FAIL: " + getThread_id()
+				NsTest.logger.println("FAIL: " + getThread_id()
 						+ "'s setAutoCommit() failed:");
 				printException("setting AutoCommit in Tester2", e);
 			}
@@ -93,10 +93,10 @@ public class Tester2 extends TesterObjec
 				case 0: //do a select operation
 					try {
 						int numSelected = doSelectOperation(NsTest.MAX_LOW_STRESS_ROWS);
-						System.out.println(getThread_id() + " selected "
+						NsTest.logger.println(getThread_id() + " selected "
 								+ numSelected + " rows");
 					} catch (Exception e) {
-						System.out.println("doSelect in thread " + getThread_id()
+						NsTest.logger.println("doSelect in thread " + getThread_id()
 								+ " threw ");
 						printException("doSelectOperation() in Tester2", e);
 					}
@@ -117,7 +117,7 @@ public class Tester2 extends TesterObjec
 				try {
 					connex.commit();
 				} catch (Exception e) {
-					System.out.println("FAIL: " + getThread_id()
+					NsTest.logger.println("FAIL: " + getThread_id()
 							+ "'s commit() failed:");
 					printException("committing Xn in Tester2", e);
 				}
@@ -128,7 +128,7 @@ public class Tester2 extends TesterObjec
 
 		}//end of for (int i=0;...)
 
-		System.out.println("Thread " + getThread_id() + " is now terminating");
+		NsTest.logger.println("Thread " + getThread_id() + " is now terminating");
 
 	}//end of startTesting()
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester3.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester3.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester3.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/Tester3.java Mon Mar 31 18:53:38 2014
@@ -61,7 +61,7 @@ public class Tester3 extends TesterObjec
 			//Get the connection.  It will be closed at the end of the loop
 			connex = getConnection();
 			if (connex == null) {
-				System.out.println("FAIL: " + getThread_id()
+				NsTest.logger.println("FAIL: " + getThread_id()
 						+ " could not get the database connection");
 				return; //quit
 			}
@@ -73,9 +73,9 @@ public class Tester3 extends TesterObjec
 			//Now select nstest.NUM_HIGH_STRESS_ROWS number of rows
 			try {
 				int numSelected = doSelectOperation(NsTest.NUM_HIGH_STRESS_ROWS);
-				System.out.println(getThread_id()+" Tester3: Rows selected "+numSelected);
+				NsTest.logger.println(getThread_id()+" Tester3: Rows selected "+numSelected);
 			} catch (Exception e) {
-				System.out.println("doSelect in thread " + getThread_id()
+				NsTest.logger.println("doSelect in thread " + getThread_id()
 						+ " threw ");
 				printException("doSelectOperation() in Tester3 of "+getThread_id(), e);
 			}
@@ -87,7 +87,7 @@ public class Tester3 extends TesterObjec
 
 		}//end of for (int i=0;...)
 
-		System.out.println("Thread " + getThread_id() + " is now terminating");
+		NsTest.logger.println("Thread " + getThread_id() + " is now terminating");
 
 	}//end of startTesting()
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/tester/TesterObject.java Mon Mar 31 18:53:38 2014
@@ -53,7 +53,7 @@ public class TesterObject {
 	public TesterObject(String name) {
 		this.thread_id = name;
 		dbutil = new DbUtil(getThread_id());
-		System.out.println("==========> " + getThread_id()
+		NsTest.logger.println("==========> " + getThread_id()
 				+ " THREAD starting <======");
 	}
 
@@ -69,7 +69,7 @@ public class TesterObject {
 		Connection conn = null;
 		String jdbcurl = "";
 		try {
-			System.out.println(getThread_id()
+			NsTest.logger.println(getThread_id()
 					+ " is getting a connection to the database...");
 
 			if (NsTest.embeddedMode) {
@@ -79,19 +79,19 @@ public class TesterObject {
 					jdbcurl = NsTest.clientDbURL + ";" + NsTest.bootPwd;
 
 			}
-			System.out.println("-->Thread " + getThread_id()
+			NsTest.logger.println("-->Thread " + getThread_id()
 					+ " starting with url " + jdbcurl + " <--");
 			conn = DriverManager.getConnection(jdbcurl, NsTest.prop);
 		} catch (Exception e) {
-			e.printStackTrace();
-			System.out.println("FAIL: " + getThread_id()
+            e.printStackTrace( NsTest.logger );
+			NsTest.logger.println("FAIL: " + getThread_id()
 					+ " could not get the database connection");
 			printException("Failed getting database connection using "
 					+ jdbcurl, e);
 		}
 		// for statistical purposes, add one to the num of connections makde
 		NsTest.addStats(NsTest.CONNECTIONS_MADE, 1);
-		System.out.println("Connection number: " + NsTest.numConnections);
+		NsTest.logger.println("Connection number: " + NsTest.numConnections);
 		return conn; // null if there was a problem, else a valid connection
 	}
 
@@ -104,7 +104,7 @@ public class TesterObject {
 		try {
 			connex.setTransactionIsolation(level);
 		} catch (Exception e) {
-			System.out.println("FAIL: " + getThread_id()
+			NsTest.logger.println("FAIL: " + getThread_id()
 					+ " could not set isolation level");
 			printException("setting transaction isolation", e);
 		}
@@ -119,11 +119,11 @@ public class TesterObject {
 	// *******************************************************************************
 	public void closeConnection() {
 		try {
-			System.out.println(getThread_id()
+			NsTest.logger.println(getThread_id()
 					+ " is closing its connection to the database...");
 			connex.close();
 		} catch (Exception e) {
-			System.out.println("FAIL: " + getThread_id()
+			NsTest.logger.println("FAIL: " + getThread_id()
 					+ " could not close the database connection");
 			printException("closing database connection", e);
 		}
@@ -204,7 +204,7 @@ public class TesterObject {
 		ResultSet rSet = null;
 		Statement s = null;
 
-		System.out.println(getThread_id() + " is selecting " + numRowsToSelect
+		NsTest.logger.println(getThread_id() + " is selecting " + numRowsToSelect
 				+ " rows");
 		try {
 			// create the statement
@@ -219,7 +219,7 @@ public class TesterObject {
 					+ " t_varchar, serialkey from nstesttab where serialkey <= "
 					+ numRowsToSelect);
 		} catch (Exception e) {
-			System.out
+			NsTest.logger
 			.println("FAIL: doSelectOperation() had problems creating/executing query");
 			printException(
 					"FAIL: doSelectOperation() had problems creating/executing query",
@@ -285,16 +285,16 @@ public class TesterObject {
 		            numRowsSelected++;
 		        }
 		        NsTest.addStats(NsTest.SELECT, 1);
-		        System.out.println(this.thread_id + " selected " + numRowsSelected
+		        NsTest.logger.println(this.thread_id + " selected " + numRowsSelected
 		                + " rows");
 		    } catch (Exception e) {
-		        System.out
+		        NsTest.logger
 		        .println("FAIL: doSelectOperation() had problems working over the ResultSet");
 		        NsTest.addStats(NsTest.FAILED_SELECT, 1);
 		        printException("processing ResultSet during row data retrieval", e);
 		        rSet.close();
 		        s.close();
-		        System.out.println("Closed the select statement");
+		        NsTest.logger.println("Closed the select statement");
 		    }
 		}
 
@@ -303,10 +303,10 @@ public class TesterObject {
 			if ((rSet != null) && (s != null)) {
 				rSet.close();
 				s.close();
-				System.out.println("Closed the select statement");
+				NsTest.logger.println("Closed the select statement");
 			}
 		} catch (Exception e) {
-			System.out
+			NsTest.logger
 			.println("FAIL: doSelectOperation() had problems closing the ResultSet");
 			printException("closing ResultSet of query to get row data", e);
 		}
@@ -335,29 +335,35 @@ public class TesterObject {
 	// ***Method is synchronized so that the output file will contain sensible
 	// stack traces that are not mixed but one exception printed at a time
 	public synchronized void printException(String where, Exception e) {
+        if ( NsTest.justCountErrors() )
+        {
+            NsTest.addError( e );
+            return;
+        }
+
 		if (e instanceof SQLException) {
 			SQLException se = (SQLException) e;
 
 			if (se.getSQLState().equals("40001"))
-				System.out.println("TObj --> deadlocked detected");
+				NsTest.logger.println("TObj --> deadlocked detected");
 			if (se.getSQLState().equals("40XL1"))
-				System.out.println("TObj --> lock timeout exception");
+				NsTest.logger.println("TObj --> lock timeout exception");
 			if (se.getSQLState().equals("23500"))
-				System.out.println("TObj --> duplicate key violation");
+				NsTest.logger.println("TObj --> duplicate key violation");
 			if (se.getNextException() != null) {
 				String m = se.getNextException().getSQLState();
-				System.out.println(se.getNextException().getMessage()
+				NsTest.logger.println(se.getNextException().getMessage()
 						+ " SQLSTATE: " + m);
 			}
 		}
 		if (e.getMessage() == null) {
-			System.out.println("TObj -->NULL error message detected");
-			System.out.println("TObj -->Here is the NULL exception - "
+			NsTest.logger.println("TObj -->NULL error message detected");
+			NsTest.logger.println("TObj -->Here is the NULL exception - "
 					+ e.toString());
-			System.out.println("TObj -->Stack trace of the NULL exception - ");
-			e.printStackTrace(System.out);
+			NsTest.logger.println("TObj -->Stack trace of the NULL exception - ");
+			e.printStackTrace( NsTest.logger );
 		}
-		System.out.println("TObj -->At this point - " + where
+		NsTest.logger.println("TObj -->At this point - " + where
 				+ ", exception thrown was : " + e.getMessage());
 	}
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/DbUtil.java Mon Mar 31 18:53:38 2014
@@ -113,7 +113,7 @@ public class DbUtil {
 			
 			// Set value of column "id"
 			ps.setInt(1, ind);
-			// System.out.println("set int col 1 to " + ind);
+			// NsTest.logger.println("set int col 1 to " + ind);
 			
 			// Set value of column "t_char"
 			// scramble the string
@@ -121,87 +121,87 @@ public class DbUtil {
 			String cs2 = cs.substring(i1, 99) + cs.substring(0, i1);
 			int i2 = i1 < 89 ? i1 + 10 : i1;
 			ps.setString(2, cs2.substring(0, i2));
-			// System.out.println("set t_Char to " + cs2.substring(0,i2));
+			// NsTest.logger.println("set t_Char to " + cs2.substring(0,i2));
 			
-			// System.out.println("now setting date");
+			// NsTest.logger.println("now setting date");
 			// Set value of column "t_date"
 			dt.setTime(Math.abs(rand.nextLong() / 150000));
 			ps.setDate(3, dt);
-			// System.out.println("set t_date to " + dt.toString());
+			// NsTest.logger.println("set t_date to " + dt.toString());
 			
 			// Set value of column "t_decimal"
 			double t_dec = rand.nextDouble()
 			* Math.pow(10, Math.abs(rand.nextInt() % 6));
 			ps.setDouble(4, t_dec);
-			// System.out.println("set t_decimal to "+ t_dec);
+			// NsTest.logger.println("set t_decimal to "+ t_dec);
 			
 			// Set value of column "t_decimal_nn"
 			double t_dec_nn = rand.nextDouble();
 			ps.setDouble(5, t_dec_nn);
-			// System.out.println("set t_decimal_nn " + t_dec_nn);
+			// NsTest.logger.println("set t_decimal_nn " + t_dec_nn);
 			
 			// Set value of column "t_double"
 			double t_doub = rand.nextDouble()
 			* Math.pow(10, Math.abs(rand.nextInt() % 300));
 			ps.setDouble(6, t_doub);
-			// System.out.println("set t_double to "+ t_doub);
+			// NsTest.logger.println("set t_double to "+ t_doub);
 			
 			// Set value of column "t_float"
 			float t_flt = rand.nextFloat()
 			* (float) Math.pow(10, Math.abs(rand.nextInt() % 30));
 			ps.setFloat(7, t_flt);
-			// System.out.println("set t_float to " + t_flt);
+			// NsTest.logger.println("set t_float to " + t_flt);
 			
 			// Set value of column "t_int"
 			int t_intval = rand.nextInt();
 			ps.setInt(8, t_intval);
-			// System.out.println("set t_int to " + t_intval);
+			// NsTest.logger.println("set t_int to " + t_intval);
 			
 			// Set value of column "t_longint"
 			long t_longval = rand.nextLong();
 			ps.setLong(9, t_longval);
-			// System.out.println("set t_longint " + t_longval);
+			// NsTest.logger.println("set t_longint " + t_longval);
 			
 			// Set value of column "t_numeric_large"
 			double t_num_lrg = rand.nextDouble()
 			* Math.pow(10, Math.abs(rand.nextInt() % 20));
 			ps.setDouble(10, t_num_lrg);
-			// System.out.println("set t_numeric large to " + t_num_lrg);
+			// NsTest.logger.println("set t_numeric large to " + t_num_lrg);
 			
 			// Set value of column "t_real"
 			float t_fltval = rand.nextFloat()
 			* (float) Math.pow(10, Math.abs(rand.nextInt() % 7));
 			ps.setFloat(11, t_fltval);
-			// System.out.println("set t_real to " + t_fltval);
+			// NsTest.logger.println("set t_real to " + t_fltval);
 			
 			// Set value of column "t_smallint"
 			int t_smlint = rand.nextInt() % (256 * 128);
 			ps.setInt(12, t_smlint);
-			// System.out.println("set t_smallint to " + t_smlint);
+			// NsTest.logger.println("set t_smallint to " + t_smlint);
 			
 			// Set value of column "t_time"
 			tt.setTime(Math.abs(rand.nextInt()));
 			ps.setTime(13, tt);
-			// System.out.println("set t_time to " + tt.toString());
+			// NsTest.logger.println("set t_time to " + tt.toString());
 			
 			// Set value of column "t_timestamp"
 			ts.setTime(Math.abs(rand.nextLong() / 50000));
 			ps.setTimestamp(14, ts);
-			// System.out.println("set t_timestamp to " + ts.toString());
+			// NsTest.logger.println("set t_timestamp to " + ts.toString());
 			
 			// Set value of column "t_varchar"
 			ps.setString(15, cs.substring(Math.abs(rand.nextInt() % 100)));
-			// System.out.println("set t_varchar, now executing update stmt");
+			// NsTest.logger.println("set t_varchar, now executing update stmt");
 			try {
 				rowsAdded = ps.executeUpdate();
 			} catch (SQLException sqe) {
 				if (sqe.getSQLState().equalsIgnoreCase("40XL1")) {
-					System.out
+					NsTest.logger
 					.println("LOCK TIMEOUT obtained during insert - add_one_row() "
 							+ sqe.getSQLState());
 				}
 				else if (sqe.getSQLState().equalsIgnoreCase("23505")) {
-				    System.out
+				    NsTest.logger
 				    .println("prevented duplicate row - add_one_row(): "
 				            + sqe.getSQLState() + "; " + sqe.getMessage());
 
@@ -211,17 +211,17 @@ public class DbUtil {
 				
 			}
 			if (rowsAdded == 1) {
-				System.out.println(thread_id + " inserted 1 row with id "
+				NsTest.logger.println(thread_id + " inserted 1 row with id "
 						//+ id_ind + NsTest.SUCCESS);
                         + id_ind);
 			} else
-				System.out.println("FAIL: " + thread_id + " inserted " + rowsAdded + "rows");
+				NsTest.logger.println("FAIL: " + thread_id + " inserted " + rowsAdded + "rows");
 			
 		} catch (Exception e) {
-			System.out
+			NsTest.logger
 			.println("Exception when preparing or executing insert prepared stmt");
 			printException("executing/preparing insert stmt in dbUtil", e);
-			e.printStackTrace();
+			e.printStackTrace( NsTest.logger );
 			// ps.close();
 		}
 		
@@ -244,7 +244,7 @@ public class DbUtil {
 		conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
 		long skey = pick_one(conn, thread_id);
 		if (skey == 0) { // means we did not find a row
-			System.out.println(thread_id
+			NsTest.logger.println(thread_id
 					+ " could not find a row to update or there was an error.");
 			return rowsUpdated;
 		}
@@ -363,27 +363,28 @@ public class DbUtil {
 			
 		} // end of switch(type)
 		
-		//System.out.println(thread_id + " attempting  to update col " + column
+		//NsTest.logger.println(thread_id + " attempting  to update col " + column
 		//		+ " to " + ds2);
 		try {
 			rowsUpdated = ps2.executeUpdate();
 		} catch (SQLException sqe) {
-			System.out.println(sqe.getSQLState() + " " + sqe.getErrorCode()
+			NsTest.logger.println(sqe.getSQLState() + " " + sqe.getErrorCode()
 					+ " " + sqe.getMessage());
-			sqe.printStackTrace();
+			if ( NsTest.justCountErrors() ) { NsTest.printException( DbUtil.class.getName(), sqe ); }
+			else { sqe.printStackTrace( NsTest.logger ); }
 		} catch (Exception e) {
 			printException("Error in update_one_row()", e);
-			e.printStackTrace();
+			e.printStackTrace( NsTest.logger );
 		} finally {
 			conn
 			.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
 		}
 		
 		if (rowsUpdated > 0)
-			System.out.println(thread_id + " updated " + rowsUpdated
+			NsTest.logger.println(thread_id + " updated " + rowsUpdated
 					+ " row with serialkey " + skey + NsTest.SUCCESS);
 		else
-			System.out
+			NsTest.logger
 			.println(thread_id + " update failed, no such row exists");
 		
 	
@@ -408,17 +409,17 @@ public class DbUtil {
 			ps = conn
 			.prepareStatement(" delete from nstesttab where serialkey = ?");
 		} catch (Exception e) {
-			System.out
+			NsTest.logger
 			.println("Unexpected error preparing the statement in delete_one()");
 			printException("delete_one_row prepare ", e);
 			return rowsDeleted;
 		}
 		
 		long skey = pick_one(conn, thread_id);
-		//System.out.println(thread_id
+		//NsTest.logger.println(thread_id
 		//		+ " attempting  to delete a row with serialkey = " + skey);
 		if (skey == 0) { // means we did not find a row
-			System.out.println(thread_id
+			NsTest.logger.println(thread_id
 					+ " could not find a row to delete or there was an error.");
 			return rowsDeleted;
 		}
@@ -427,7 +428,7 @@ public class DbUtil {
 			ps.setLong(1, skey);
 			rowsDeleted = ps.executeUpdate();
 		} catch (Exception e) {
-			System.out
+			NsTest.logger
 			.println("Error in delete_one(): either with setLong() or executeUpdate");
 			printException("failure to execute delete stmt", e);
 		} finally {
@@ -437,10 +438,10 @@ public class DbUtil {
 		}
 		
 		if (rowsDeleted > 0)
-			System.out.println(thread_id + " deleted row with serialkey "
+			NsTest.logger.println(thread_id + " deleted row with serialkey "
 					+ skey + NsTest.SUCCESS);
 		else
-			System.out.println(thread_id + " delete for serialkey " + skey
+			NsTest.logger.println(thread_id + " delete for serialkey " + skey
 					+ " failed, no such row exists.");
 		
 		return rowsDeleted;
@@ -478,40 +479,47 @@ public class DbUtil {
 	// stack traces that are not
 	// ****mixed but rather one exception printed at a time
 	public synchronized void printException(String where, Exception e) {
-		System.out.println(e.toString());
+        if ( NsTest.justCountErrors() )
+        {
+            NsTest.addError( e );
+            return;
+        }
+
+		NsTest.logger.println(e.toString());
 		if (e instanceof SQLException) {
 			SQLException se = (SQLException) e;
 			
 			if (se.getSQLState().equals("40001"))
-				System.out.println(getThreadName()
+				NsTest.logger.println(getThreadName()
 						+ " dbUtil --> deadlocked detected");
 			if (se.getSQLState().equals("40XL1"))
-				System.out.println(getThreadName()
+				NsTest.logger.println(getThreadName()
 						+ " dbUtil --> lock timeout exception");
 			if (se.getSQLState().equals("23500"))
-				System.out.println(getThreadName()
+				NsTest.logger.println(getThreadName()
 						+ " dbUtil --> duplicate key violation");
 			if (se.getNextException() != null) {
 				String m = se.getNextException().getSQLState();
-				System.out.println(se.getNextException().getMessage()
+				NsTest.logger.println(se.getNextException().getMessage()
 						+ " SQLSTATE: " + m);
-				System.out.println(getThreadName()
+				NsTest.logger.println(getThreadName()
 						+ " dbUtil ---> Details of exception: " + se.toString()
 						+ " " + se.getErrorCode());
 			}
 		}
 		if (e.getMessage() == null) {
-			System.out.println(getThreadName()
+			NsTest.logger.println(getThreadName()
 					+ " dbUtil --> NULL error message detected");
-			System.out
+			NsTest.logger
 			.println(getThreadName()
 					+ " dbUtil --> Here is the NULL exection - "
 					+ e.toString());
-			System.out.println(getThreadName()
+			NsTest.logger.println(getThreadName()
 					+ " dbUtil --> Stack trace of the NULL exception - ");
-			e.printStackTrace(System.out);
+			if ( NsTest.justCountErrors() ) { NsTest.printException( DbUtil.class.getName(), e ); }
+			else { e.printStackTrace( NsTest.logger ); }
 		}
-		System.out.println(getThreadName() + " dbUtil ----> During " + where
+		NsTest.logger.println(getThreadName() + " dbUtil ----> During " + where
 				+ ", exception thrown was : " + e.toString());
 	}
 	

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/MemCheck.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/MemCheck.java?rev=1583398&r1=1583397&r2=1583398&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/MemCheck.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/utils/MemCheck.java Mon Mar 31 18:53:38 2014
@@ -60,12 +60,12 @@ public class MemCheck extends Thread {
 				}
 				else
 				{
-					System.out.println("no more test threads, finishing memcheck thread also");
+					NsTest.logger.println("no more test threads, finishing memcheck thread also");
 					showmem();
 					stopNow=true;
 				}
 			} catch (java.lang.InterruptedException ie) {
-				System.out.println("memcheck: unexpected error in sleep");
+				NsTest.logger.println("memcheck: unexpected error in sleep");
 			}
 		}
 	}
@@ -78,13 +78,13 @@ public class MemCheck extends Thread {
 		Date d = null;
 		rt = Runtime.getRuntime();
 		d = new Date();
-		System.out.println("total memory: " + rt.totalMemory() + " free: "
+		NsTest.logger.println("total memory: " + rt.totalMemory() + " free: "
 				+ rt.freeMemory() + " " + d.toString());
 
 	}
 
 	public static void main(String argv[]) {
-		System.out.println("memCheck starting");
+		NsTest.logger.println("memCheck starting");
 		MemCheck mc = new MemCheck();
 		mc.run();
 	}