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 km...@apache.org on 2005/02/08 19:04:14 UTC
svn commit: r152681 [5/5] - in
incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests:
harness/ master/DerbyNetClient/ suites/ tests/derbynet/ tests/jdbcapi/ util/
Propchange: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/parameterMapping.out
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/sysinfo.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/sysinfo.out?view=diff&r1=152680&r2=152681
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/sysinfo.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/sysinfo.out Tue Feb 8 10:04:07 2005
@@ -12,7 +12,6 @@
derby.drda.host=localhost
derby.drda.traceAll=false
----- Derby Information --------
-JRE - JDBC: J2SE 1.4 - JDBC 3.0
-----
----- Locale Information -----------------
Current Locale : [English/United States [en_US]]
@@ -41,7 +40,6 @@
derby.drda.host=localhost
derby.drda.traceAll=false
----- Derby Information --------
-JRE - JDBC: J2SE 1.4 - JDBC 3.0
-----
----- Locale Information -----------------
Current Locale : [English/United States [en_US]]
Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/noDerbyNetClient.runall
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/noDerbyNetClient.runall?view=diff&r1=152680&r2=152681
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/noDerbyNetClient.runall (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/noDerbyNetClient.runall Tue Feb 8 10:04:07 2005
@@ -1,4 +1,3 @@
-derbynet/dataSourcePermissions_net.java
# excluding resultsetStream.java because this test uses java.io.FileInputStream throughout the test
# excluding scrollCursors2.java because updatable resultsets & scroll sensitive cursors are not supported
# excluding batchUpdate.java for it hits a problem in networkserver ('beetle' 5561)
Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVM_app.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVM_app.properties?view=diff&r1=152680&r2=152681
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVM_app.properties (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSinSameJVM_app.properties Tue Feb 8 10:04:07 2005
@@ -1,3 +1,4 @@
-#Don't want harness to start up network server. It will be started
-#in test, so we set framework to embedded
-framework=embedded
+#Don't want harness to start up network server.
+#It will be started in test
+startServer=false
+
Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java?view=diff&r1=152680&r2=152681
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.java Tue Feb 8 10:04:07 2005
@@ -45,9 +45,11 @@
import org.apache.derby.tools.JDBCDisplayUtil;
import org.apache.derby.tools.ij;
import org.apache.derby.drda.NetworkServerControl;
+import org.apache.derbyTesting.functionTests.util.TestUtil;
import java.io.*;
import java.net.InetAddress;
import java.util.Hashtable;
+import java.util.Properties;
import javax.naming.*;
import javax.naming.directory.*;
@@ -71,7 +73,7 @@
// start the server on that port before calling runTest.
try {
- Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
+ TestUtil.loadDriver();
} catch (Exception e) {
e.printStackTrace();
}
@@ -119,8 +121,10 @@
public void setProperties() {
// Set required server properties.
- System.setProperty("database", "jdbc:derby:net://localhost:"
- + NETWORKSERVER_PORT + "/wombat;create=true");
+ System.setProperty("database",
+ TestUtil.getJdbcUrlPrefix("localhost",
+ NETWORKSERVER_PORT) +
+ "wombat;create=true");
System.setProperty("ij.user", "EDWARD");
System.setProperty("ij.password", "noodle");
@@ -128,10 +132,11 @@
public String getJDBCUrl(String db, String attrs) {
- String s = "jdbc:derby:net://localhost:" + NETWORKSERVER_PORT + "/" + db;
+ String s = TestUtil.getJdbcUrlPrefix("localhost", NETWORKSERVER_PORT)
+ + db;
if (attrs != null)
s = s + ":" + attrs + ";";
-
+ //System.out.println("getJDBCUrl:" + s);
return s;
}
@@ -139,65 +144,36 @@
public javax.sql.DataSource getDS(String database, String user, String
password)
{
- return (javax.sql.DataSource) getDataSourceWithReflection("com.ibm.db2.jcc.DB2SimpleDataSource",
- database,user,password);
-
+ Properties attrs = new Properties();
+ attrs.setProperty("databaseName", database);
+ if (user != null)
+ attrs.setProperty("user", user);
+ if (password != null)
+ attrs.setProperty("password", password);
+ attrs = addRequiredAttributes(attrs);
+ return TestUtil.getDataSource(attrs);
}
+
- public Object getDataSourceWithReflection(String classname, String database,
- String user, String password)
- {
- Class[] STRING_ARG_TYPE = {String.class};
- Class[] INT_ARG_TYPE = {Integer.TYPE};
- Object[] args = null;
- Object ds = null;
- Method sh = null;
- try {
- ds = Class.forName(classname).newInstance();
-
- // Need to use reflection to load indirectly
- // setDatabaseName
- sh = ds.getClass().getMethod("setDatabaseName", STRING_ARG_TYPE);
- args = new String[] {database};
- sh.invoke(ds, args);
- if (user != null) {
- // setUser
- sh = ds.getClass().getMethod("setUser", STRING_ARG_TYPE);
- args = new String[] {user};
- sh.invoke(ds, args);
- // setPassword
- sh = ds.getClass().getMethod("setPassword", STRING_ARG_TYPE);
- args = new String[] {password};
- sh.invoke(ds, args);
- }
-
- // setServerName
- sh = ds.getClass().getMethod("setServerName", STRING_ARG_TYPE);
- args = new String[] {"localhost"};
- sh.invoke(ds, args);
-
- //setPortNumber
- sh = ds.getClass().getMethod("setPortNumber", INT_ARG_TYPE);
- args = new Integer[] {new Integer(NETWORKSERVER_PORT)};
- sh.invoke(ds, args);
-
- //setDriverType
- sh = ds.getClass().getMethod("setDriverType", INT_ARG_TYPE);
- args = new Integer[] {new Integer(4)};
- sh.invoke(ds, args);
-
- } catch (Exception e)
- {
- System.out.println(e.getMessage());
- e.printStackTrace();
- }
- return ds;
- }
public javax.sql.ConnectionPoolDataSource getCPDS(String database, String user, String password) {
-
- return (javax.sql.ConnectionPoolDataSource) getDataSourceWithReflection("com.ibm.db2.jcc.DB2ConnectionPoolDataSource",database,user,password);
+ Properties attrs = new Properties();
+ attrs.setProperty("databaseName", database);
+ if (user != null)
+ attrs.setProperty("user", user);
+ if (password != null)
+ attrs.setProperty("password", password);
+ attrs = addRequiredAttributes(attrs);
+ return TestUtil.getConnectionPoolDataSource(attrs);
+ }
+ private Properties addRequiredAttributes(Properties attrs)
+ {
+ attrs.setProperty("driverType","4");
+ attrs.setProperty("serverName","localhost");
+ attrs.setProperty("portNumber","20000");
+ //attrs.setProperty("retrieveMessagesFromServerOnGetMessage","true");
+ return attrs;
}
public boolean supportsUnicodeNames() {
@@ -217,8 +193,9 @@
public void shutdown() {
try {
- DriverManager.getConnection("jdbc:derby:net://localhost:" +
- NETWORKSERVER_PORT + "/wombat;shutdown=true",
+ DriverManager.getConnection(TestUtil.getJdbcUrlPrefix("localhost",
+ NETWORKSERVER_PORT) +
+ "wombat;shutdown=true",
"EDWARD", "noodle");
System.out.println("FAIL - Shutdown returned connection");
Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net_app.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net_app.properties?view=diff&r1=152680&r2=152681
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net_app.properties (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net_app.properties Tue Feb 8 10:04:07 2005
@@ -19,9 +19,9 @@
#
#
excludeJCC=1.1
+startServer=false
database=wombat;create=true
derby.optimizer.noTimeout=true
-
ij.defaultResourcePackage=/org/apache/derbyTesting/functionTests/tests/lang/
ij.showNoConnectionsAtStart=true
ij.showNoCountForSelect=true
Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dataSourcePermissions.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dataSourcePermissions.java?view=diff&r1=152680&r2=152681
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dataSourcePermissions.java (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dataSourcePermissions.java Tue Feb 8 10:04:07 2005
@@ -148,7 +148,7 @@
} catch (SQLException sqle) {
System.out.println("EXPECTED CONNFAIL " + sqle.getMessage());
}
-
+
checkConnection(ds.getConnection("EDWARD", "noodle"));
checkConnection(ds.getConnection("FRANCES", "isabella"));
if (supportsUnicodeNames()) {
Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java?view=diff&r1=152680&r2=152681
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/TestUtil.java Tue Feb 8 10:04:07 2005
@@ -23,7 +23,11 @@
import java.sql.*;
import java.io.*;
+import java.lang.reflect.*;
+import java.util.Enumeration;
+import java.util.Hashtable;
import java.util.Locale;
+import java.util.Properties;
import org.apache.derby.iapi.reference.JDBC30Translation;
@@ -69,6 +73,13 @@
private static int framework = UNKNOWN_FRAMEWORK;
+
+ // DataSource Type strings used to build up datasource names.
+ // e.g. "Embed" + XA_DATASOURCE_STRING + "DataSource
+ private static String XA_DATASOURCE_STRING = "XA";
+ private static String CONNECTION_POOL_DATASOURCE_STRING = "ConnectionPool";
+ private static String REGULAR_DATASOURCE_STRING = "";
+
// Methods for making framework dependent decisions in tests.
/**
@@ -207,6 +218,151 @@
Class.forName(driverName).newInstance();
}
+
+ /**
+ * Get a data source for the appropriate framework
+ * @param attrs A set of attribute values to set on the datasource.
+ * The appropriate setter method wil b
+ * For example the property databaseName with value wombat,
+ * will mean ds.setDatabaseName("wombat") will be called
+ * @return datasource for current framework
+ */
+ public static javax.sql.DataSource getDataSource(Properties attrs)
+ {
+
+ String classname = getDataSourcePrefix() + REGULAR_DATASOURCE_STRING + "DataSource";
+ return (javax.sql.DataSource) getDataSourceWithReflection(classname, attrs);
+ }
+
+ /**
+ * Get an xa data source for the appropriate framework
+ * @param attrs A set of attribute values to set on the datasource.
+ * The appropriate setter method wil b
+ * For example the property databaseName with value wombat,
+ * will mean ds.setDatabaseName("wombat") will be called
+ * @return datasource for current framework
+ */
+ public static javax.sql.XADataSource getXADatasource(Properties attrs)
+ {
+
+ String classname = getDataSourcePrefix() + XA_DATASOURCE_STRING + "DataSource";
+ return (javax.sql.XADataSource) getDataSourceWithReflection(classname, attrs);
+ }
+
+
+ /**
+ * Get a ConnectionPoolDataSource for the appropriate framework
+ * @param attrs A set of attribute values to set on the datasource.
+ * The appropriate setter method wil b
+ * For example the property databaseName with value wombat,
+ * will mean ds.setDatabaseName("wombat") will be called
+ * @return datasource for current framework
+ */
+ public static javax.sql.ConnectionPoolDataSource getConnectionPoolDataSource(Properties attrs)
+ {
+
+ String classname = getDataSourcePrefix() + CONNECTION_POOL_DATASOURCE_STRING + "DataSource";
+ return (javax.sql.ConnectionPoolDataSource) getDataSourceWithReflection(classname, attrs);
+ }
+
+ private static String getDataSourcePrefix()
+ {
+ framework = getFramework();
+ switch(framework)
+ {
+ case OLD_NET_FRAMEWORK:
+ case DERBY_NET_FRAMEWORK:
+ case DB2JCC_FRAMEWORK:
+ return "com.ibm.db2.jcc.DB2";
+ case DERBY_NET_CLIENT_FRAMEWORK:
+ return "org.apache.derby.jdbc.Client";
+ case EMBEDDED_FRAMEWORK:
+ return "org.apache.derby.jdbc.Embed";
+ default:
+ Exception e = new Exception("FAIL: No DataSource Prefix for framework: " + framework);
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ static private Class[] STRING_ARG_TYPE = {String.class};
+ static private Class[] INT_ARG_TYPE = {Integer.TYPE};
+ static private Class[] BOOLEAN_ARG_TYPE = { Boolean.TYPE };
+ // A hashtable of special non-string attributes.
+ private static Hashtable specialAttributes = null;
+
+
+ private static Object getDataSourceWithReflection(String classname, Properties attrs)
+ {
+ Object[] args = null;
+ Object ds = null;
+ Method sh = null;
+
+
+ if (specialAttributes == null)
+ {
+ specialAttributes = new Hashtable();
+ specialAttributes.put("portNumber",INT_ARG_TYPE);
+ specialAttributes.put("driverType",INT_ARG_TYPE);
+ specialAttributes.put("retrieveMessagesFromServerOnGetMessage",
+ BOOLEAN_ARG_TYPE);
+ }
+
+ try {
+ ds = Class.forName(classname).newInstance();
+
+ for (Enumeration propNames = attrs.propertyNames();
+ propNames.hasMoreElements();)
+ {
+ String key = (String) propNames.nextElement();
+ Class[] argType = (Class[]) specialAttributes.get(key);
+ if (argType == null)
+ argType = STRING_ARG_TYPE;
+ String value = attrs.getProperty(key);
+ if (argType == INT_ARG_TYPE)
+ {
+ args = new Integer[]
+ { new Integer(Integer.parseInt(value)) };
+ }
+ else if (argType == BOOLEAN_ARG_TYPE)
+ {
+ args = new Boolean[] { new Boolean(value) };
+ }
+ else if (argType == STRING_ARG_TYPE)
+ {
+ args = new String[] { value };
+ }
+ else // No other property types supported right now
+ {
+ throw new Exception("FAIL: getDataSourceWithReflection: Argument type " + argType[0].getName() + " not supportted for attribute: " +
+ " key:" + key + " value:" +value);
+
+ }
+ String methodName = getSetterName(key);
+
+
+ // Need to use reflection to load indirectly
+ // setDatabaseName
+ sh = ds.getClass().getMethod(methodName, argType);
+ sh.invoke(ds, args);
+ }
+
+ } catch (Exception e)
+ {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ return ds;
+ }
+
+
+ private static String getSetterName(String attribute)
+ {
+ return "set" + Character.toUpperCase(attribute.charAt(0)) + attribute.substring(1);
+ }
+
+
+ // Some methods for test output.
public static void dumpSQLExceptions(SQLException sqle) {
TestUtil.dumpSQLExceptions(sqle, false);
}
@@ -464,11 +620,6 @@
}
-
-
-
-
-
Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml?view=diff&r1=152680&r2=152681
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/build.xml Tue Feb 8 10:04:07 2005
@@ -60,6 +60,24 @@
<include name="${this.dir}/*.java"/>
<include name="${this.dir}/StaticInitializers/*.java"/>
<include name="${this.dir}/VTIClasses/*.java"/>
+ <exclude name="${this.dir}/TestUtil.java"/>
+ </javac>
+<javac
+ 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="${java14compile.classpath}"/>
+ </classpath>
+ <!--exclude name=""/-->
+ <include name="${this.dir}/TestUtil.java"/>
</javac>
</target>