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 rh...@apache.org on 2006/09/01 18:38:15 UTC
svn commit: r439372 - in /db/derby/code/branches/10.2/java: demo/toursdb/
testing/org/apache/derbyTesting/functionTests/tests/jdbc4/
testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
testing/org/apache/derbyTesting/functionTests/tests/lang/ ...
Author: rhillegas
Date: Fri Sep 1 09:38:14 2006
New Revision: 439372
URL: http://svn.apache.org/viewvc?rev=439372&view=rev
Log:
DERBY-1725: Port the following patches from the trunk to the 10.2 branch: No JIRA (438996, 438972, 438971), DERBY-1555 (438975).
Modified:
db/derby/code/branches/10.2/java/demo/toursdb/build.xml
db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java
db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Modified: db/derby/code/branches/10.2/java/demo/toursdb/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/demo/toursdb/build.xml?rev=439372&r1=439371&r2=439372&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/demo/toursdb/build.xml (original)
+++ db/derby/code/branches/10.2/java/demo/toursdb/build.xml Fri Sep 1 09:38:14 2006
@@ -108,7 +108,8 @@
<target name="jarup">
<zip destfile="${derby.demo.src.dir}/toursdb/toursdb.jar"
- basedir="${derby.demo.src.dir}/toursdb/toursdb"/>
+ basedir="${derby.demo.src.dir}/toursdb"
+ includes="toursdb/**"/>
<echo message="Finished building toursdb"/>
</target>
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java?rev=439372&r1=439371&r2=439372&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java Fri Sep 1 09:38:14 2006
@@ -30,7 +30,6 @@
package org.apache.derbyTesting.functionTests.tests.jdbc4;
-import java.security.PrivilegedActionException;
import java.sql.*;
import java.util.*;
import junit.framework.*;
@@ -107,7 +106,7 @@
autoloadingCurrentDriver = true;
}
- } catch (PrivilegedActionException e) {
+ } catch (SecurityException e) {
// can't read property, assume not autoloading.
}
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java?rev=439372&r1=439371&r2=439372&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java Fri Sep 1 09:38:14 2006
@@ -24,6 +24,7 @@
import org.apache.derbyTesting.junit.BaseTestCase;
import org.apache.derbyTesting.junit.JDBC;
import org.apache.derbyTesting.junit.NetworkServerTestSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -63,7 +64,10 @@
{
suite.addTest(ScrollResultSetTest.suite());
}
-
- return new NetworkServerTestSetup(suite);
+
+ if (TestConfiguration.runningInDerbyHarness())
+ return new NetworkServerTestSetup(suite);
+
+ return suite;
}
}
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java?rev=439372&r1=439371&r2=439372&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java Fri Sep 1 09:38:14 2006
@@ -25,10 +25,22 @@
import org.apache.derbyTesting.functionTests.util.ScriptTestCase;
import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+/**
+ * LangScripts runs SQL scripts (.sql files) in the lang package
+ * and compares the output to a canon file in the
+ * standard master package.
+ * <BR>
+ * Its suite() method returns a set of tests where each test is an instance of
+ * this class for an individual script wrapped in a clean database decorator.
+ * <BR>
+ * It can also be used as a command line program to run one or more
+ * language based SQL scripts as tests.
+ *
+ */
public final class LangScripts extends ScriptTestCase {
/**
- * Language SQL scripts that run under all configurations.
+ * Language SQL scripts (.sql files) that run under all configurations.
*/
private static final String[] SQL_LANGUAGE_TESTS = {
"case",
@@ -36,7 +48,7 @@
};
/**
- * Language SQL scripts that run under Derby's clients configurations.
+ * Language SQL scripts (.sql files) that run under Derby's client configurations.
*/
private static final String[] DERBY_TESTS = {
"bit2",
@@ -44,7 +56,7 @@
};
/**
- * Language SQL scripts that only run in embedded.
+ * Language SQL scripts (.sql files) that only run in embedded.
*/
private static final String[] EMBEDDED_TESTS = {
"arithmetic",
@@ -53,8 +65,9 @@
};
/**
- * Run a set of language SQL scripts passed in on the
- * command line.
+ * Run a set of language SQL scripts (.sql files) passed in on the
+ * command line. Note the .sql suffix must not be provided as
+ * part of the script name.
* <code>
* example
* java org.apache.derbyTesting.functionTests.tests.lang.LangScripts case union
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=439372&r1=439371&r2=439372&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Fri Sep 1 09:38:14 2006
@@ -139,7 +139,7 @@
*/
protected static void setSystemProperty(final String name,
final String value)
- throws PrivilegedActionException {
+ {
AccessController.doPrivileged
(new java.security.PrivilegedAction(){
@@ -160,7 +160,7 @@
* @param name name of the property
*/
protected static void removeSystemProperty(final String name)
- throws PrivilegedActionException {
+ {
AccessController.doPrivileged
(new java.security.PrivilegedAction(){
@@ -181,7 +181,7 @@
* @param name name of the property
*/
protected static String getSystemProperty(final String name)
- throws PrivilegedActionException {
+ {
return (String )AccessController.doPrivileged
(new java.security.PrivilegedAction(){
@@ -200,10 +200,9 @@
* file or a SQL script.
* @param name Resource name, typically - org.apache.derbyTesing.something
* @return URL to the resource, null if it does not exist.
- * @throws PrivilegedActionException
*/
protected static URL getTestResource(final String name)
- throws PrivilegedActionException {
+ {
return (URL)AccessController.doPrivileged
(new java.security.PrivilegedAction(){
Modified: db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=439372&r1=439371&r2=439372&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java (original)
+++ db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java Fri Sep 1 09:38:14 2006
@@ -36,21 +36,102 @@
* Class which holds information about the configuration of a Test.
*/
public class TestConfiguration {
+ /**
+ * Default values for configurations
+ */
+ private final static String DEFAULT_DBNAME = "wombat";
+ private final static String DEFAULT_USER_NAME = "APP";
+ private final static String DEFAULT_USER_PASSWORD = "APP";
+ private final static int DEFAULT_PORT = 1527;
+ private final static String DEFAULT_FRAMEWORK = "embedded";
+ private final static String DEFAULT_HOSTNAME = "localhost";
+
+ /**
+ * Keys to use to look up values in properties files.
+ */
+ private final static String KEY_DBNAME = "databaseName";
+ private final static String KEY_FRAMEWORK = "framework";
+ private final static String KEY_USER_PASSWORD = "password";
+ private final static String KEY_USER_NAME = "user";
+ 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_SINGLE_LEG_XA = "derbyTesting.xa.single";
+
+ /**
+ * Possible values of system properties.
+ */
+ private final static String UNUSED = "file://unused/";
+
/**
- * Default Derby test configuration object.
+ * Default Derby test configuration object based
+ * upon system properties set by the old harness.
*/
- private static final TestConfiguration DERBY_TEST_CONFIG =
+ private static final TestConfiguration DERBY_HARNESS_CONFIG =
new TestConfiguration(getSystemProperties());
/**
+ * Default configuration for standalone JUnit tests,
+ * an embedded configuration.
+ */
+ private static final TestConfiguration JUNIT_CONFIG
+ = new TestConfiguration();
+
+ /**
+ * The default configuration.
+ */
+ private static final TestConfiguration DEFAULT_CONFIG;
+
+ /**
+ * Are we running in the harness, assume so if framework
+ * was set so the
+ */
+ private static final boolean runningInDerbyHarness;
+
+ static {
+ boolean assumeHarness = false;
+
+ // In the harness if the default configuration according
+ // to system properties is not embedded.
+ if (!DERBY_HARNESS_CONFIG.getJDBCClient().isEmbedded())
+ assumeHarness = true;
+
+ // Assume harness if database name is not default
+ if (!DERBY_HARNESS_CONFIG.getDatabaseName().equals(DEFAULT_DBNAME))
+ assumeHarness = true;
+
+ // Assume harness if user name is not default
+ if (!DERBY_HARNESS_CONFIG.getUserName().equals(DEFAULT_USER_NAME))
+ assumeHarness = true;
+
+ // If derby.system.home set externally at startup assume
+ // running in harness
+ if (BaseTestCase.getSystemProperty("derby.system.home") != null)
+ assumeHarness = true;
+
+ // for now always assume harness - still testing this code
+ assumeHarness = true;
+
+ DEFAULT_CONFIG = assumeHarness ? DERBY_HARNESS_CONFIG : JUNIT_CONFIG;
+ runningInDerbyHarness = assumeHarness;
+
+ if (!assumeHarness) {
+ File dsh = new File("system");
+
+ BaseTestCase.setSystemProperty("derby.system.home",
+ dsh.getAbsolutePath());
+ }
+ }
+
+ /**
* Current configuration is stored in a ThreadLocal to
* allow the potential for multiple tests to be running
* concurrently with different configurations.
*/
private static final ThreadLocal CURRENT_CONFIG = new ThreadLocal() {
protected Object initialValue() {
- return DERBY_TEST_CONFIG;
+ return DEFAULT_CONFIG;
}
};
@@ -390,6 +471,18 @@
{
return SecurityManagerSetup.isJars;
}
+
+ /**
+ * Is this JUnit test being run by the old harness.
+ * Temp method to ease the switch over by allowing
+ * suites to alter their behaviour based upon the
+ * need to still run under the old harness.
+ * @return
+ */
+ public static boolean runningInDerbyHarness()
+ {
+ return runningInDerbyHarness;
+ }
/**
* Return if it has to run under single legged xa transaction
@@ -467,32 +560,6 @@
private boolean isVerbose;
private final boolean singleLegXA;
- /**
- * Default values for configurations
- */
- private final static String DEFAULT_DBNAME = "wombat";
- private final static String DEFAULT_USER_NAME = "APP";
- private final static String DEFAULT_USER_PASSWORD = "APP";
- private final static int DEFAULT_PORT = 1527;
- private final static String DEFAULT_FRAMEWORK = "embedded";
- private final static String DEFAULT_HOSTNAME = "localhost";
-
- /**
- * Keys to use to look up values in properties files.
- */
- private final static String KEY_DBNAME = "databaseName";
- private final static String KEY_FRAMEWORK = "framework";
- private final static String KEY_USER_PASSWORD = "password";
- private final static String KEY_USER_NAME = "user";
- 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_SINGLE_LEG_XA = "derbyTesting.xa.single";
-
- /**
- * Possible values of system properties.
- */
- private final static String UNUSED = "file://unused/";
/**
* Generate properties which can be set on a
@@ -505,7 +572,7 @@
*/
public static Properties getDefaultDataSourceProperties() {
return getDataSourcePropertiesForDatabase(
- DERBY_TEST_CONFIG.getDatabaseName());
+ getCurrent().getDatabaseName());
}
/**
@@ -523,9 +590,9 @@
(String databaseName)
{
Properties attrs = new Properties();
- if (!(DERBY_TEST_CONFIG.getJDBCClient() == JDBCClient.EMBEDDED)) {
- attrs.setProperty("serverName", DERBY_TEST_CONFIG.getHostName());
- attrs.setProperty("portNumber", Integer.toString(DERBY_TEST_CONFIG.getPort()));
+ if (!(getCurrent().getJDBCClient() == JDBCClient.EMBEDDED)) {
+ attrs.setProperty("serverName", getCurrent().getHostName());
+ attrs.setProperty("portNumber", Integer.toString(getCurrent().getPort()));
}
attrs.setProperty("databaseName", databaseName);
attrs.setProperty("connectionAttributes", "create=true");