db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r633743 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe: run/Checks.java run/DriverUtility.java util/HandleCheckError.java util/OEChecks.java
Date Wed, 05 Mar 2008 01:28:51 GMT
Author: djd
Date: Tue Mar  4 17:28:49 2008
New Revision: 633743

URL: http://svn.apache.org/viewvc?rev=633743&view=rev
Log:
OE system test improvements - Ensure that the Checks text fixtures for the OETest actually
cause a failure if they find a problem, previously they were just printing an error since
that's what the core class OEChecks was doing. Adding a simple class HandleCheckError to allow
OEChecks to be isolated from JUnit but allow the JUnit Checks class to use Assert.fail() to
report issues found by OEChecks.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/HandleCheckError.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Checks.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/DriverUtility.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/OEChecks.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Checks.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Checks.java?rev=633743&r1=633742&r2=633743&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Checks.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/Checks.java Tue
Mar  4 17:28:49 2008
@@ -19,8 +19,8 @@
  */
 package org.apache.derbyTesting.system.oe.run;
 
-import java.sql.SQLException;
 import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.sql.Statement;
 
 import junit.framework.Assert;
@@ -28,7 +28,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.junit.JDBCPerfTestCase;
-import org.apache.derbyTesting.system.oe.client.Load;
+import org.apache.derbyTesting.system.oe.util.HandleCheckError;
 import org.apache.derbyTesting.system.oe.util.OEChecks;
 
 /**
@@ -65,7 +65,11 @@
     public void setUp() throws Exception
     {
         this.check = new OEChecks();
-        check.initialize(getConnection(),scale);
+        check.initialize(new HandleCheckError() {
+            public void handleCheckError(String error) {
+                fail(error);
+            }
+        }, getConnection(),scale);
     }
     /**
      * Return suite of tests that checks the row counts for all the tables in

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/DriverUtility.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/DriverUtility.java?rev=633743&r1=633742&r2=633743&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/DriverUtility.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/run/DriverUtility.java
Tue Mar  4 17:28:49 2008
@@ -24,6 +24,7 @@
 import java.sql.Connection;
 import org.apache.derbyTesting.system.oe.client.Load;
 import org.apache.derbyTesting.system.oe.load.SimpleInsert;
+import org.apache.derbyTesting.system.oe.util.HandleCheckError;
 import org.apache.derbyTesting.system.oe.util.OEChecks;
 
 /**
@@ -138,7 +139,7 @@
      */
     public void allChecks() throws Exception {
         OEChecks checks = new OEChecks();
-        checks.initialize(getConnection(), scale);
+        checks.initialize(new HandleCheckError(), getConnection(), scale);
         long start = System.currentTimeMillis();
         checks.checkAllRowCounts();
         long stop = System.currentTimeMillis();

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/HandleCheckError.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/HandleCheckError.java?rev=633743&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/HandleCheckError.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/HandleCheckError.java
Tue Mar  4 17:28:49 2008
@@ -0,0 +1,35 @@
+/*
+ *
+ * Derby - Class org.apache.derbyTesting.system.oe.util.HandleCheckError
+ *
+ * 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.oe.util;
+
+/**
+ * Simple class to isolate OEChecks from junit but allow its
+ * checks to be used in JUnit tests. This implementation
+ * just reports errors to System.out. In a JUnit environment
+ * an implementation can use Assert.fail() to report failures.
+ *
+ */
+public class HandleCheckError {
+    
+    public void handleCheckError(String error) throws Exception {
+        System.out.println(error);
+    }
+
+}

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/OEChecks.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/OEChecks.java?rev=633743&r1=633742&r2=633743&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/OEChecks.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/oe/util/OEChecks.java
Tue Mar  4 17:28:49 2008
@@ -30,6 +30,11 @@
  * Do some OEChecks on the Order Entry database.
  */
 public class OEChecks  {
+    
+    /**
+     * How to report an error.
+     */
+    private HandleCheckError errorHandler;
 
     /**
      * Warehouse scaling factor
@@ -38,9 +43,11 @@
 
     private Connection conn = null;
 
-    public void initialize(Connection conn, short scale)
+    public void initialize(HandleCheckError errorHandler,
+            Connection conn, short scale)
     throws Exception
     {
+        this.errorHandler = errorHandler;
         this.conn = conn;
         conn.setAutoCommit(false);
         this.scale = scale;
@@ -154,7 +161,7 @@
      */
     private void checkCountStar(String table, int expected) throws Exception {
         if( expected != rowsInTable(table))
-            System.out.println("ERROR:Number of rows loaded for " + table +
+            errorHandler.handleCheckError("ERROR:Number of rows loaded for " + table +
                     " not correct, expected="+expected +" rows found="+ 
                     rowsInTable(table));
 
@@ -196,7 +203,7 @@
         double low = ((double) expected) * 0.99;
         double high = ((double) expected) * 1.01;
         if ( (count < low) || (count >high))
-            System.out.println("ERROR! Initial rows" + count + " in " + 
+            errorHandler.handleCheckError("ERROR! Initial rows" + count + " in " + 
                 tableName + " is out of range.[" + low + "-" + high + "]");
         
     }



Mime
View raw message