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/30 01:51:29 UTC
svn commit: r438299 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting:
functionTests/tests/nist/NistScripts.java
functionTests/tests/nist/build.xml junit/ChangeConfigurationSetup.java
junit/ChangeUserSetup.java junit/TestConfiguration.java
Author: djd
Date: Tue Aug 29 16:51:29 2006
New Revision: 438299
URL: http://svn.apache.org/viewvc?rev=438299&view=rev
Log:
DERBY-1555 Add configuration decorator to change the default user for a configuaration
and use it in the NistScripts JUnit test. NistScripts is an initial pass at the setup of running
nist under JUnit, it fails at the moment in about a third of the test cases probably due to
output that is being sed'ed in the old harness and should not be.
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/NistScripts.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeUserSetup.java (with props)
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/build.xml
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/NistScripts.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/NistScripts.java?rev=438299&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/NistScripts.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/NistScripts.java Tue Aug 29 16:51:29 2006
@@ -0,0 +1,210 @@
+/*
+ *
+ * Derby - Class org.apache.derbyTesting.functionTests.tests.nist.NistScripts
+ *
+ * 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.functionTests.tests.nist;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.functionTests.util.ScriptTestCase;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Run the NIST scripts as a single suite.
+ *
+ */
+public final class NistScripts extends ScriptTestCase {
+
+ /**
+ * The complete set of NIST scripts for Derby.
+ * First element of array is the script name,
+ * second element is the user name for the connection.
+ */
+ private static final String[][] TESTS = {
+ {"schema1", "HU"},
+ { "basetab", "HU"},
+ { "schema5", "FLATER"},
+ { "schema8", "SUN"},
+ { "temp_schem10", "HU"},
+ { "temp_cts5sch2", "HU"},
+ { "temp_cts5tab", "CTS1"},
+ { "flattab", "FLATER"},
+ { "dml012", "HU"},
+ { "dml013", "HU"},
+ { "dml018", "HU"},
+ { "dml022", "HU"},
+ {"dml025", "HU"},
+ {"dml044", "HU"},
+ {"dml045", "HU"},
+ {"dml051", "HU"},
+ {"dml059", "HU"},
+ {"dml061", "HU"},
+ {"dml073", "HU"},
+ {"dml087", "FLATER"},
+ {"dml090", "HU"},
+ {"dml106", "FLATER"},
+ {"dml108", "FLATER"},
+ {"dml114", "FLATER"},
+ {"dml141", "FLATER"},
+ {"dml144", "FLATER"},
+ {"dml162", "FLATER"},
+ {"dml177", "FLATER"},
+ {"dml010", "HU"},
+ {"dml015", "HU"},
+ {"dml020", "HU"},
+ {"dml037", "HU"},
+ {"dml038", "HU"},
+ {"dml042", "HU"},
+ {"dml043", "HU"},
+ {"dml047", "HU"},
+ {"dml056", "HU"},
+ {"dml065", "HU"},
+ {"dml076", "HU"},
+ {"sdl012", "HU"},
+ {"dml029", "HU"},
+ {"yts796", "CTS1"},
+ {"dml075", "HU"},
+ {"dml024", "HU"},
+ {"dml070", "HU"},
+ {"dml147", "FLATER"},
+ {"dml009", "HU"},
+ {"dml008", "HU"},
+ {"dml014", "HU"},
+ {"dml016", "SULLIVAN1"},
+ {"dml021", "HU"},
+ {"dml034", "HU"},
+ {"dml023", "HU"},
+ {"dml026", "HU"},
+ {"dml033", "HU"},
+ {"dml039", "HU"},
+ {"dml050", "HU"},
+ {"dml052", "HU"},
+ {"dml053", "HU"},
+ {"dml055", "HU"},
+ {"dml057", "HU"},
+ {"dml058", "HU"},
+ {"dml155", "FLATER"},
+ {"xts729", "CTS1"},
+ {"xts730", "CTS1"},
+ {"yts797", "CTS1"},
+ {"yts798", "CTS1"},
+ {"dml069", "HU"},
+ {"dml080", "SCHANZLE"},
+ {"dml081", "SCHANZLE"},
+ {"dml083", "SCHANZLE"},
+ {"dml085", "SCHANZLE"},
+ {"dml132", "FLATER"},
+ {"dml099", "FLATER"},
+ {"dml049", "HU"},
+ {"dml173", "FLATER"},
+ {"dml174", "FLATER"},
+ {"dml179", "FLATER"},
+ {"yts812", "CTS1"},
+ {"dml001", "HU"},
+ {"dml004", "HU"},
+ {"dml035", "HU"},
+ {"dml046", "HU"},
+ {"dml060", "HU"},
+ {"dml068", "HU"},
+ {"yts799", "CTS1"},
+ {"dml001", "HU"},
+ {"dml079", "HU"},
+ {"dml165", "FLATER"},
+ {"dml104", "FLATER"},
+ {"dml112", "FLATER"},
+ {"dml148", "FLATER"},
+ {"dml019", "HU"},
+ {"dml149", "FLATER"},
+ {"dml168", "FLATER"},
+ {"dml170", "FLATER"},
+ {"xts752", "CTS1"},
+ {"xts753", "CTS1"},
+ {"cdr002", "SUN"},
+ {"cdr003", "SUN"},
+ {"cdr004", "SUN"},
+ {"cdr005", "SUN"},
+ {"cdr006", "SUN"},
+ {"cdr007", "SUN"},
+ {"cdr027", "SUN"},
+ {"cdr030", "SUN"},
+ {"dml134", "FLATER"},
+ {"dml005", "HU"},
+ {"dml011", "HU"},
+ {"dml027", "HU"},
+ {"dml082", "SCHANZLE"},
+ {"dml091", "SCHANZLE"},
+ {"dml119", "FLATER"},
+ {"dml130", "FLATER"},
+ {"dml158", "HU"},
+ {"dml178", "FLATER"},
+ {"dml181", "FLATER"},
+ {"dml182", "FLATER"},
+ {"xts701", "CTS1"},
+ {"xts731", "CTS1"},
+ {"xts740", "CTS1"},
+ {"xts742", "CTS1"},
+ {"xts760", "CTS1"},
+ {"yts811", "CTS1"},
+ {"dml160", "FLATER"},
+ {"schema4", "SULLIVAN1"}
+ };
+
+ /**
+ * Return the suite that runs the NIST SQL scripts.
+ */
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+
+ String suiteUser = null;
+ TestSuite userSuite = null;
+ for (int i = 0; i < TESTS.length; i++) {
+
+ String testScript = TESTS[i][0];
+ String testUser = TESTS[i][1];
+
+ Test test = new NistScripts(testScript);
+
+ if (testUser.equals(suiteUser))
+ {
+ userSuite.addTest(test);
+ continue;
+ }
+
+ // Add the new user suite with the change user decorator to
+ // the main suite but continue to add tests to the user suite.
+ userSuite = new TestSuite();
+ String password = testUser.concat("PWD");
+ suite.addTest(
+ TestConfiguration.changeUserDecorator(userSuite, testUser, password));
+ suiteUser = testUser;
+
+ userSuite.addTest(test);
+ }
+
+ return new CleanDatabaseTestSetup(getIJConfig(suite));
+ }
+
+ /*
+ * A single JUnit test that runs a single language SQL script.
+ */
+ private NistScripts(String nistScript){
+ super(nistScript);
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/NistScripts.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/build.xml?rev=438299&r1=438298&r2=438299&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/build.xml Tue Aug 29 16:51:29 2006
@@ -58,7 +58,7 @@
<!-- ============ Begin Targets ============== -->
- <target name="FTOtestsubdir" depends="copyfiles"/>
+ <target name="FTOtestsubdir" depends="copyfiles,nistsuites"/>
<!-- mkdir / init target may not be necessary, just here for reference... -->
<target name="init">
@@ -72,6 +72,28 @@
</copy>
</target>
+ <target name="nistsuites"
+ description="Build Nist">
+ <javac
+ source="1.3"
+ target="1.3"
+ bootclasspath="${empty}"
+ nowarn="on"
+ debug="${debug}"
+ depend="${depend}"
+ deprecation="${deprecation}"
+ optimize="${optimize}"
+ proceed="${proceed}"
+ verbose="${verbose}"
+ srcdir="${derby.testing.src.dir}"
+ destdir="${out.dir}">
+ <classpath>
+ <pathelement path="${compile.classpath}"/>
+ <pathelement path="${junit}"/>
+ </classpath>
+ <include name="${derby.testing.functest.dir}/tests/nist/*.java"/>
+ </javac>
+ </target>
<!-- ============= End Targets ============== -->
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java?rev=438299&r1=438298&r2=438299&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java Tue Aug 29 16:51:29 2006
@@ -1,3 +1,22 @@
+/*
+ *
+ * Derby - Class org.apache.derbyTesting.junit.ChangeConfigurationSetup
+ *
+ * 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.junit;
import junit.extensions.TestSetup;
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeUserSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeUserSetup.java?rev=438299&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeUserSetup.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeUserSetup.java Tue Aug 29 16:51:29 2006
@@ -0,0 +1,55 @@
+/*
+ *
+ * Derby - Class org.apache.derbyTesting.junit.ChangeUserSetup
+ *
+ * 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.junit;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+/**
+ * A decorator that changes the default user and password
+ * for the current configuration. Its tearDown method restores
+ * the previous configuration.
+ *
+ */
+final class ChangeUserSetup extends TestSetup {
+
+ private final String user;
+ private final String password;
+ private TestConfiguration old;
+
+ ChangeUserSetup(Test test, String user, String password)
+ {
+ super(test);
+ this.user = user;
+ this.password = password;
+ }
+
+ protected void setUp()
+ {
+ old = TestConfiguration.getCurrent();
+ TestConfiguration config = new TestConfiguration(old, user, password);
+ TestConfiguration.setCurrent(config);
+ }
+
+ protected void tearDown()
+ {
+ TestConfiguration.setCurrent(old);
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeUserSetup.java
------------------------------------------------------------------------------
svn:eol-style = native
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?rev=438299&r1=438298&r2=438299&view=diff
==============================================================================
--- 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 Tue Aug 29 16:51:29 2006
@@ -112,7 +112,10 @@
return (Test) sm.invoke(null, null);
}
-
+ public static Test changeUserDecorator(Test test, String user, String password)
+ {
+ return new ChangeUserSetup(test, user, password);
+ }
/**
* Default embedded configuration
*
@@ -129,7 +132,7 @@
url = createJDBCUrlWithDatabaseName(dbName);
}
-
+
private TestConfiguration(TestConfiguration copy, JDBCClient client,
String hostName, int port)
{
@@ -145,6 +148,30 @@
this.hostName = hostName;
this.url = createJDBCUrlWithDatabaseName(dbName);
+ }
+
+
+ /**
+ * Obtain a new configuration identical to the passed in
+ * one except for the default user and password.
+ * @param copy Configuration to copy.
+ * @param user New default user
+ * @param password New default password.
+ */
+ TestConfiguration(TestConfiguration copy, String user, String password)
+ {
+ this.dbName = copy.dbName;
+ this.userName = user;
+ this.userPassword = password;
+
+ this.isVerbose = copy.isVerbose;
+ this.singleLegXA = copy.singleLegXA;
+ this.port = copy.port;
+
+ this.jdbcClient = copy.jdbcClient;
+ this.hostName = copy.hostName;
+
+ this.url = copy.url;
}
/**