db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r797205 - in /db/derby/code/branches/10.3: ./ java/testing/org/apache/derbyTesting/junit/BaseTestCase.java java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Date Thu, 23 Jul 2009 19:51:33 GMT
Author: kmarsden
Date: Thu Jul 23 19:51:33 2009
New Revision: 797205

URL: http://svn.apache.org/viewvc?rev=797205&view=rev
Log:
DERBY-2667 Improve diagnostic information for failed derby JUnit tests

Port derby.tests.trace property to 10.3
merge 552047 from trunk
Original patch contributed by Ole  Solberg. 


Modified:
    db/derby/code/branches/10.3/   (props changed)
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
    db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Propchange: db/derby/code/branches/10.3/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 23 19:51:33 2009
@@ -1 +1 @@
-/db/derby/code/trunk:788436
+/db/derby/code/trunk:552046,788436

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=797205&r1=797204&r2=797205&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
Thu Jul 23 19:51:33 2009
@@ -75,6 +75,12 @@
      * setUp, tearDown methods and decorators.
      */
     public void runBare() throws Throwable {
+        boolean trace = TestConfiguration.getCurrent().doTrace();
+        long startTime = 0;
+        if ( trace )
+        {
+            startTime = System.currentTimeMillis();
+        }
 
         // install a default security manager if one has not already been
         // installed
@@ -86,7 +92,17 @@
             }
         }
     	 
-    	super.runBare();   
+        try {
+            super.runBare();   
+        }
+        finally{
+            if ( trace )
+            {
+                long timeUsed = System.currentTimeMillis() - startTime;
+                out.println();
+                out.print(getName() + " used " + timeUsed + " ms ");
+            }
+        }
     }
 
     /**

Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=797205&r1=797204&r2=797205&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
(original)
+++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Thu Jul 23 19:51:33 2009
@@ -79,6 +79,7 @@
     private final static String KEY_HOSTNAME = "hostName";
     private final static String KEY_PORT = "port";
     private final static String KEY_VERBOSE = "derby.tests.debug";    
+    private final static String KEY_TRACE = "derby.tests.trace";
     private final static String KEY_SSL = "ssl";
     
     /**
@@ -679,6 +680,9 @@
         this.isVerbose = Boolean.valueOf(
             getSystemProperties().getProperty(KEY_VERBOSE)).
             booleanValue();
+        this.doTrace = Boolean.valueOf(
+            getSystemProperties().getProperty(KEY_TRACE)).
+            booleanValue();
         
         this.jdbcClient = JDBCClient.getDefaultEmbedded();
         this.ssl = null;
@@ -699,6 +703,7 @@
         this.userPassword = copy.userPassword;
 
         this.isVerbose = copy.isVerbose;
+        this.doTrace = copy.doTrace;
         this.port = copy.port;
         
         this.jdbcClient = copy.jdbcClient;
@@ -720,6 +725,7 @@
         this.userPassword = copy.userPassword;
 
         this.isVerbose = copy.isVerbose;
+        this.doTrace = copy.doTrace;
         this.port = port;
         
         this.jdbcClient = client;
@@ -750,6 +756,7 @@
                 copy.passwordToken : passwordToken;
 
         this.isVerbose = copy.isVerbose;
+        this.doTrace = copy.doTrace;
         this.port = copy.port;
         
         this.jdbcClient = copy.jdbcClient;
@@ -807,6 +814,7 @@
         this.userPassword = copy.userPassword;
 
         this.isVerbose = copy.isVerbose;
+        this.doTrace = copy.doTrace;
         this.port = copy.port;
         
         this.jdbcClient = copy.jdbcClient;
@@ -834,6 +842,7 @@
                                          DEFAULT_USER_PASSWORD);
         hostName = props.getProperty(KEY_HOSTNAME, DEFAULT_HOSTNAME);
         isVerbose = Boolean.valueOf(props.getProperty(KEY_VERBOSE)).booleanValue();
+        doTrace =  Boolean.valueOf(props.getProperty(KEY_TRACE)).booleanValue();
         String portStr = props.getProperty(KEY_PORT);
         if (portStr != null) {
             try {
@@ -1108,6 +1117,10 @@
      * Set the verbosity, i.e., whether debug statements print.
      */
     public void	setVerbosity( boolean isChatty )	{ isVerbose = isChatty; }
+    /**
+     * Set JUnit test method tracing.
+     */
+    public void setTrace( boolean isChatty )    { doTrace = isChatty; }
     
     /**
      * Return verbose flag.
@@ -1117,6 +1130,14 @@
     public boolean isVerbose() {
         return isVerbose;
     }
+    /**
+     * Return JUnit test method trace flag.
+     *
+     * @return JUnit test method trace flag.
+     */
+    public boolean doTrace() {
+        return doTrace;
+    }
 
 	/**
 	 * <p>
@@ -1214,6 +1235,7 @@
     private final String hostName;
     private final JDBCClient jdbcClient;
     private boolean isVerbose;
+    private boolean doTrace;
     private String ssl;
     
     /**



Mime
View raw message