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 dj...@apache.org on 2006/08/11 22:57:19 UTC
svn commit: r430894 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests:
tests/lang/LangScripts.java util/ScriptTestCase.java
Author: djd
Date: Fri Aug 11 13:57:18 2006
New Revision: 430894
URL: http://svn.apache.org/viewvc?rev=430894&view=rev
Log:
Junit improvements, have the ScriptTestCase use the openTestResource method in BaseTestCase to get the script
file to avoid exceptions with a security manager. Added a couple more tests to the language scripts and added
the clean database decorator to each test run.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java?rev=430894&r1=430893&r2=430894&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java Fri Aug 11 13:57:18 2006
@@ -22,6 +22,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.derbyTesting.functionTests.util.CleanDatabaseTestSetup;
import org.apache.derbyTesting.functionTests.util.ScriptTestCase;
public final class LangScripts extends ScriptTestCase {
@@ -33,6 +34,9 @@
"arithmetic",
"bit2",
"case",
+ "constantExpression",
+ "depend",
+ "derived",
"union",
};
@@ -65,13 +69,16 @@
/**
* Return a suite of language SQL tests from the list of
- * script names.
+ * script names. Each test is surrounded in a decorator
+ * that cleans the database.
*/
private static Test getSuite(String[] list)
{
TestSuite suite = new TestSuite();
for (int i = 0; i < list.length; i++)
- suite.addTest(new LangScripts(list[i]));
+ suite.addTest(
+ new CleanDatabaseTestSetup(
+ new LangScripts(list[i])));
return getIJConfig(suite);
}
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=430894&r1=430893&r2=430894&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 Fri Aug 11 13:57:18 2006
@@ -40,9 +40,15 @@
private final String inputEncoding;
private final String outputEncoding = "US-ASCII";
+
+ /**
+ * Default connection.
+ */
+ private Connection conn;
/**
- * Create a ScriptTestCase to run a single test.
+ * Create a ScriptTestCase to run a single test
+ * using a connection obtained from getConnection()
* @param script Base name of the .sql script
* excluding the .sql suffix.
*/
@@ -105,14 +111,14 @@
URL sql = getTestResource(resource);
assertNotNull("SQL script missing: " + resource, sql);
- InputStream sqlIn = sql.openStream();
+ InputStream sqlIn = openTestResource(sql);
ByteArrayOutputStream rawBytes =
new ByteArrayOutputStream(20 * 1024);
PrintStream printOut = new PrintStream(rawBytes);
- Connection conn = getConnection();
+ conn = getConnection();
org.apache.derby.tools.ij.runScript(
conn,
sqlIn,
@@ -120,7 +126,8 @@
printOut,
outputEncoding);
- conn.close();
+ if (!conn.isClosed() && !conn.getAutoCommit())
+ conn.commit();
printOut.flush();
printOut.close();
@@ -176,5 +183,14 @@
outFile.close();
throw t;
}
+ }
+
+ /**
+ * Clean up the connection on teardown.
+ */
+ protected void tearDown() throws Exception
+ {
+ JDBC.cleanup(conn);
+ super.tearDown();
}
}