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/11/01 19:32:58 UTC
svn commit: r470024 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting:
functionTests/tests/lang/PrepareExecuteDDL.java
functionTests/tests/lang/_Suite.java junit/JDBC.java
junit/TestConfiguration.java
Author: djd
Date: Wed Nov 1 10:32:58 2006
New Revision: 470024
URL: http://svn.apache.org/viewvc?view=rev&rev=470024
Log:
DERBY-1974 Add utility method TestConfiguration.sqlAuthorizationDecorator to change the default
database to one that has SQL authorization mode enabled. Have PrepareExecuteDDL use this decorator
and add this test to lang._Suite. Fix a bug in assertDrainResults() where the wrong variable
was being used to check an assert.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrepareExecuteDDL.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrepareExecuteDDL.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrepareExecuteDDL.java?view=diff&rev=470024&r1=470023&r2=470024
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrepareExecuteDDL.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/PrepareExecuteDDL.java Wed Nov 1 10:32:58 2006
@@ -23,6 +23,7 @@
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
import java.sql.*;
@@ -80,12 +81,15 @@
/**
* Create a suite of tests, one per statement in DDL.
+ * This test is for testing the embedded dependency system
+ * though possibly it could be used for testing in client
+ * as well.
*/
public static Test suite() {
TestSuite suite = new TestSuite("PrepareExecuteDDL");
for (int i = 0; i < DDL.length; i++)
suite.addTest(new PrepareExecuteDDL("testPrepareExcute", DDL[i]));
- return suite;
+ return TestConfiguration.sqlAuthorizationDecorator(suite);
}
private final String ddl;
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?view=diff&rev=470024&r1=470023&r2=470024
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java Wed Nov 1 10:32:58 2006
@@ -58,7 +58,7 @@
// the nightly runs.
// suite.addTest(largeCodeGen.suite());
- // suite.addTest(PrepareExecuteDDL.suite());
+ suite.addTest(PrepareExecuteDDL.suite());
suite.addTest(LangScripts.suite());
suite.addTest(GroupByExpressionTest.suite());
suite.addTest(MathTrigFunctionsTest.suite());
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java?view=diff&rev=470024&r1=470023&r2=470024
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java Wed Nov 1 10:32:58 2006
@@ -439,7 +439,7 @@
}
rs.close();
- if (rows >= 0)
+ if (expectedRows >= 0)
Assert.assertEquals("Unexpected row count:", expectedRows, rows);
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?view=diff&rev=470024&r1=470023&r2=470024
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java Wed Nov 1 10:32:58 2006
@@ -41,6 +41,8 @@
* Default values for configurations
*/
private final static String DEFAULT_DBNAME = "wombat";
+ private final static String DEFAULT_DBNAME_SQL = "dbsqlauth";
+
private final static String DEFAULT_USER_NAME = "APP";
private final static String DEFAULT_USER_PASSWORD = "APP";
private final static int DEFAULT_PORT = 1527;
@@ -58,11 +60,6 @@
private final static String KEY_PORT = "port";
private final static String KEY_VERBOSE = "derby.tests.debug";
private final static String KEY_SINGLE_LEG_XA = "derbyTesting.xa.single";
-
- /**
- * Possible values of system properties.
- */
- private final static String UNUSED = "file://unused/";
/**
* Simple count to provide a unique number for database
@@ -280,10 +277,60 @@
new DropDatabaseSetup(test));
}
+ /**
+ * Decorate a test changing the default user name and password.
+ * Typically used along with DatabasePropertyTestSetup.builtinAuthentication.
+ * The tearDown method resets the default user and password value to
+ * their previous settings.
+ *
+ * @param test Test to decorate
+ * @param user New default user
+ * @param password New password
+ * @return decorated test
+ *
+ * @see DatabasePropertyTestSetup#builtinAuthentication(Test, String[], String)
+ */
public static Test changeUserDecorator(Test test, String user, String password)
{
return new ChangeUserSetup(test, user, password);
- }
+ }
+
+ /**
+ * Decorate a test to use the default database that has
+ * was created in SQL authorization mode.
+ * The tearDown reverts the configuration to the previous
+ * configuration.
+ *
+ * Tests can use this in conjunction with
+ * DatabasePropertyTestSetup.builtinAuthentication
+ * to set up BUILTIN authentication and changeUserDecorator
+ * to switch users.
+ *
+ * @param test Test to be decorated
+ * @return decorated test.
+ *
+ * @see DatabasePropertyTestSetup#builtinAuthentication(Test, String[], String)
+ */
+ public static Test sqlAuthorizationDecorator(Test test)
+ {
+ TestConfiguration config = TestConfiguration.getCurrent();
+ TestConfiguration newDBconfig =
+ new TestConfiguration(config, DEFAULT_DBNAME_SQL);
+
+ // Set the SQL authorization mode as a database property
+ // with a modified DatabasePropertyTestSetup that does not
+ // reset it.
+ final Properties sqlAuth = new Properties();
+ sqlAuth.setProperty("derby.database.sqlAuthorization", "true");
+ Test setSQLAuthMode = new DatabasePropertyTestSetup(test,
+ sqlAuth, true) {
+ protected void tearDown() {
+ }
+ };
+
+ return new ChangeConfigurationSetup(newDBconfig, setSQLAuthMode);
+ }
+
/**
* Default embedded configuration
*