harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r436644 [5/6] - /incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/
Date Fri, 25 Aug 2006 04:29:36 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java?rev=436644&r1=436643&r2=436644&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java Thu Aug 24 21:29:34 2006
@@ -1,174 +1,174 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed 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.harmony.sql.tests.java.sql;
-
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.util.Properties;
-
-/**
- * A simple implementation of a class implementing a JDBC Driver, for use in the
- * testing of the java.sql.DriverManager class
- * 
- */
-public class TestHelper_Driver1 implements Driver {
-
-	int majorVersion = 1;
-
-	int minorVersion = 0;
-
-	String baseURL = "jdbc:mikes1";
-
-	String[] dataSources = { "data1", "data2", "data3" };
-
-	static Driver theDriver;
-
-	static {
-		theDriver = new TestHelper_Driver1();
-		/*
-		 * System.out.println("Driver1 classloader: " +
-		 * theDriver.getClass().getClassLoader() ); System.out.println("Driver1
-		 * object is: " + theDriver );
-		 */
-		try {
-			DriverManager.registerDriver(theDriver);
-		} catch (SQLException e) {
-			System.out.println("Failed to register driver!");
-		}
-	} // end static block initializer
-
-	protected TestHelper_Driver1() {
-		super();
-	} // end constructor TestHelper_Driver1()
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#acceptsURL(java.lang.String) @param url a url
-	 *      specification for a datasource or a general url for this driver
-	 */
-	public boolean acceptsURL(String url) throws SQLException {
-		// Check on the supplied String...
-		if (url == null)
-			return false;
-		// Everything's fine if the quoted url starts with the base url for this
-		// driver
-		if (url.startsWith(baseURL))
-			return true;
-		return false;
-	} // end method acceptsURL
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#connect(java.lang.String, java.util.Properties)
-	 */
-	static String validuser = "theuser";
-
-	static String validpassword = "thepassword";
-
-	static String userProperty = "user";
-
-	static String passwordProperty = "password";
-
-	public Connection connect(String url, Properties info) throws SQLException {
-		// Does the URL have the right form?
-		if (this.acceptsURL(url)) {
-			// The datasource name is the remainder of the url after the ":"
-			String datasource = url.substring(baseURL.length() + 1);
-			// Loop over the valid datasources supported by this driver
-			for (int i = 0; i < dataSources.length; i++) {
-				if (datasource.equals(dataSources[i])) {
-					// Check for user and password, except for datasource =
-					// data1
-					// which is set up not to require a user/password
-					// combination
-					if (datasource.equals("data1")) {
-						// do nothing...
-					} else {
-						if (info == null)
-							throw new SQLException("Properties bundle is null");
-						String user = (String) info.get(userProperty);
-						String password = (String) info.get(passwordProperty);
-						if (user == null || password == null) {
-							throw new SQLException(
-									"Userid and/or password not supplied");
-						} else {
-							if (!user.equals(validuser)
-									|| !password.equals(validpassword)) {
-								throw new SQLException(
-										"Userid and/or password not valid");
-							} // end if
-						} // end if
-					} // end if
-					// It all checks out - so return a connection
-					Connection connection = new TestHelper_Connection1();
-					return connection;
-				} // end if
-			} // end for
-		} // end if
-		return null;
-	} // end method connect(String, Properties)
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#getMajorVersion()
-	 */
-	public int getMajorVersion() {
-
-		return majorVersion;
-	} // end method getMajorVersion()
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#getMinorVersion()
-	 */
-	public int getMinorVersion() {
-
-		return minorVersion;
-	} // end method getMinorVersion()
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#getPropertyInfo(java.lang.String,
-	 *      java.util.Properties)
-	 */
-	public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
-			throws SQLException {
-		DriverPropertyInfo[] theInfos = {
-				new DriverPropertyInfo(userProperty, "*"),
-				new DriverPropertyInfo(passwordProperty, "*"), };
-		return theInfos;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#jdbcCompliant()
-	 */
-	public boolean jdbcCompliant() {
-		// Basic version here returns false
-		return false;
-	}
-
-}
-
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.harmony.sql.tests.java.sql;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * A simple implementation of a class implementing a JDBC Driver, for use in the
+ * testing of the java.sql.DriverManager class
+ * 
+ */
+public class TestHelper_Driver1 implements Driver {
+
+	int majorVersion = 1;
+
+	int minorVersion = 0;
+
+	String baseURL = "jdbc:mikes1";
+
+	String[] dataSources = { "data1", "data2", "data3" };
+
+	static Driver theDriver;
+
+	static {
+		theDriver = new TestHelper_Driver1();
+		/*
+		 * System.out.println("Driver1 classloader: " +
+		 * theDriver.getClass().getClassLoader() ); System.out.println("Driver1
+		 * object is: " + theDriver );
+		 */
+		try {
+			DriverManager.registerDriver(theDriver);
+		} catch (SQLException e) {
+			System.out.println("Failed to register driver!");
+		}
+	} // end static block initializer
+
+	protected TestHelper_Driver1() {
+		super();
+	} // end constructor TestHelper_Driver1()
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#acceptsURL(java.lang.String) @param url a url
+	 *      specification for a datasource or a general url for this driver
+	 */
+	public boolean acceptsURL(String url) throws SQLException {
+		// Check on the supplied String...
+		if (url == null)
+			return false;
+		// Everything's fine if the quoted url starts with the base url for this
+		// driver
+		if (url.startsWith(baseURL))
+			return true;
+		return false;
+	} // end method acceptsURL
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#connect(java.lang.String, java.util.Properties)
+	 */
+	static String validuser = "theuser";
+
+	static String validpassword = "thepassword";
+
+	static String userProperty = "user";
+
+	static String passwordProperty = "password";
+
+	public Connection connect(String url, Properties info) throws SQLException {
+		// Does the URL have the right form?
+		if (this.acceptsURL(url)) {
+			// The datasource name is the remainder of the url after the ":"
+			String datasource = url.substring(baseURL.length() + 1);
+			// Loop over the valid datasources supported by this driver
+			for (int i = 0; i < dataSources.length; i++) {
+				if (datasource.equals(dataSources[i])) {
+					// Check for user and password, except for datasource =
+					// data1
+					// which is set up not to require a user/password
+					// combination
+					if (datasource.equals("data1")) {
+						// do nothing...
+					} else {
+						if (info == null)
+							throw new SQLException("Properties bundle is null");
+						String user = (String) info.get(userProperty);
+						String password = (String) info.get(passwordProperty);
+						if (user == null || password == null) {
+							throw new SQLException(
+									"Userid and/or password not supplied");
+						} else {
+							if (!user.equals(validuser)
+									|| !password.equals(validpassword)) {
+								throw new SQLException(
+										"Userid and/or password not valid");
+							} // end if
+						} // end if
+					} // end if
+					// It all checks out - so return a connection
+					Connection connection = new TestHelper_Connection1();
+					return connection;
+				} // end if
+			} // end for
+		} // end if
+		return null;
+	} // end method connect(String, Properties)
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#getMajorVersion()
+	 */
+	public int getMajorVersion() {
+
+		return majorVersion;
+	} // end method getMajorVersion()
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#getMinorVersion()
+	 */
+	public int getMinorVersion() {
+
+		return minorVersion;
+	} // end method getMinorVersion()
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#getPropertyInfo(java.lang.String,
+	 *      java.util.Properties)
+	 */
+	public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
+			throws SQLException {
+		DriverPropertyInfo[] theInfos = {
+				new DriverPropertyInfo(userProperty, "*"),
+				new DriverPropertyInfo(passwordProperty, "*"), };
+		return theInfos;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#jdbcCompliant()
+	 */
+	public boolean jdbcCompliant() {
+		// Basic version here returns false
+		return false;
+	}
+
+}
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java?rev=436644&r1=436643&r2=436644&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java Thu Aug 24 21:29:34 2006
@@ -1,48 +1,48 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed 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.harmony.sql.tests.java.sql;
-
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-/**
- * Basic JDBC driver implementation to help with tests
- * 
- */
-public class TestHelper_Driver2 extends TestHelper_Driver1 {
-
-	static {
-		Driver theDriver = new TestHelper_Driver2();
-		/*
-		 * System.out.println("Driver2 classloader: " +
-		 * theDriver.getClass().getClassLoader() ); System.out.println("Driver2
-		 * object is: " + theDriver );
-		 */
-		try {
-			DriverManager.registerDriver(theDriver);
-		} catch (SQLException e) {
-			System.out.println("Failed to register driver!");
-		}
-	} // end static block initializer
-
-	protected TestHelper_Driver2() {
-		super();
-		baseURL = "jdbc:mikes2";
-	} // end constructor TestHelper_Driver1()
-
-} // end class TestHelper_Driver2
-
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.harmony.sql.tests.java.sql;
+
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+/**
+ * Basic JDBC driver implementation to help with tests
+ * 
+ */
+public class TestHelper_Driver2 extends TestHelper_Driver1 {
+
+	static {
+		Driver theDriver = new TestHelper_Driver2();
+		/*
+		 * System.out.println("Driver2 classloader: " +
+		 * theDriver.getClass().getClassLoader() ); System.out.println("Driver2
+		 * object is: " + theDriver );
+		 */
+		try {
+			DriverManager.registerDriver(theDriver);
+		} catch (SQLException e) {
+			System.out.println("Failed to register driver!");
+		}
+	} // end static block initializer
+
+	protected TestHelper_Driver2() {
+		super();
+		baseURL = "jdbc:mikes2";
+	} // end constructor TestHelper_Driver1()
+
+} // end class TestHelper_Driver2
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver3.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver3.java?rev=436644&r1=436643&r2=436644&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver3.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver3.java Thu Aug 24 21:29:34 2006
@@ -1,34 +1,34 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed 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.harmony.sql.tests.java.sql;
-
-
-/**
- * TODO Type description
- * 
- */
-public class TestHelper_Driver3 extends TestHelper_Driver1 {
-
-	/*
-	 * This driver does NOT automatically register itself...
-	 */
-
-	public TestHelper_Driver3() {
-		super();
-		baseURL = "jdbc:mikes3";
-	} // end constructor TestHelper_Driver1()
-
-} // end class TestHelper_Driver3
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.harmony.sql.tests.java.sql;
+
+
+/**
+ * TODO Type description
+ * 
+ */
+public class TestHelper_Driver3 extends TestHelper_Driver1 {
+
+	/*
+	 * This driver does NOT automatically register itself...
+	 */
+
+	public TestHelper_Driver3() {
+		super();
+		baseURL = "jdbc:mikes3";
+	} // end constructor TestHelper_Driver1()
+
+} // end class TestHelper_Driver3

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver3.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver4.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver4.java?rev=436644&r1=436643&r2=436644&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver4.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver4.java Thu Aug 24 21:29:34 2006
@@ -1,167 +1,167 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed 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.harmony.sql.tests.java.sql;
-
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.DriverPropertyInfo;
-import java.sql.SQLException;
-import java.util.Properties;
-
-/**
- * Basic JDBC driver implementation to help with tests
- * 
- */
-public class TestHelper_Driver4 implements Driver {
-
-	int majorVersion = 1;
-
-	int minorVersion = 0;
-
-	String baseURL;
-
-	String[] dataSources = { "data1", "data2", "data3" };
-
-	static {
-		Driver theDriver = new TestHelper_Driver4();
-		try {
-			DriverManager.registerDriver(theDriver);
-		} catch (SQLException e) {
-			System.out.println("Failed to register driver!");
-		}
-	} // end static block initializer
-
-	protected TestHelper_Driver4() {
-		super();
-		baseURL = "jdbc:mikes4";
-	} // end constructor TestHelper_Driver4()
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#acceptsURL(java.lang.String) @param url a url
-	 *      specification for a datasource or a general url for this driver
-	 */
-	public boolean acceptsURL(String url) throws SQLException {
-		// Check on the supplied String...
-		if (url == null)
-			return false;
-		// Everything's fine if the quoted url starts with the base url for this
-		// driver
-		if (url.startsWith(baseURL))
-			return true;
-		return false;
-	} // end method acceptsURL
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#connect(java.lang.String, java.util.Properties)
-	 */
-	static String validuser = "theuser";
-
-	static String validpassword = "thepassword";
-
-	static String userProperty = "user";
-
-	static String passwordProperty = "password";
-
-	public Connection connect(String url, Properties info) throws SQLException {
-		// Does the URL have the right form?
-		if (this.acceptsURL(url)) {
-			// The datasource name is the remainder of the url after the ":"
-			String datasource = url.substring(baseURL.length() + 1);
-			// Loop over the valid datasources supported by this driver
-			for (int i = 0; i < dataSources.length; i++) {
-				if (datasource.equals(dataSources[i])) {
-					// Check for user and password, except for datasource =
-					// data1
-					// which is set up not to require a user/password
-					// combination
-					if (datasource.equals("data1")) {
-						// do nothing...
-					} else {
-						if (info == null)
-							throw new SQLException("Properties bundle is null");
-						String user = (String) info.get(userProperty);
-						String password = (String) info.get(passwordProperty);
-						if (user == null || password == null) {
-							throw new SQLException(
-									"Userid and/or password not supplied");
-						} else {
-							if (!user.equals(validuser)
-									|| !password.equals(validpassword)) {
-								throw new SQLException(
-										"Userid and/or password not valid");
-							} // end if
-						} // end if
-					} // end if
-					// It all checks out - so return a connection
-					Connection connection = new TestHelper_Connection1();
-					return connection;
-				} // end if
-			} // end for
-		} // end if
-		return null;
-	} // end method connect(String, Properties)
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#getMajorVersion()
-	 */
-	public int getMajorVersion() {
-
-		return majorVersion;
-	} // end method getMajorVersion()
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#getMinorVersion()
-	 */
-	public int getMinorVersion() {
-
-		return minorVersion;
-	} // end method getMinorVersion()
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#getPropertyInfo(java.lang.String,
-	 *      java.util.Properties)
-	 */
-	public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
-			throws SQLException {
-		DriverPropertyInfo[] theInfos = {
-				new DriverPropertyInfo(userProperty, "*"),
-				new DriverPropertyInfo(passwordProperty, "*"), };
-		return theInfos;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see java.sql.Driver#jdbcCompliant()
-	 */
-	public boolean jdbcCompliant() {
-		// Basic version here returns false
-		return false;
-	}
-
-} // end class TestHelper_Driver4
-
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.harmony.sql.tests.java.sql;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * Basic JDBC driver implementation to help with tests
+ * 
+ */
+public class TestHelper_Driver4 implements Driver {
+
+	int majorVersion = 1;
+
+	int minorVersion = 0;
+
+	String baseURL;
+
+	String[] dataSources = { "data1", "data2", "data3" };
+
+	static {
+		Driver theDriver = new TestHelper_Driver4();
+		try {
+			DriverManager.registerDriver(theDriver);
+		} catch (SQLException e) {
+			System.out.println("Failed to register driver!");
+		}
+	} // end static block initializer
+
+	protected TestHelper_Driver4() {
+		super();
+		baseURL = "jdbc:mikes4";
+	} // end constructor TestHelper_Driver4()
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#acceptsURL(java.lang.String) @param url a url
+	 *      specification for a datasource or a general url for this driver
+	 */
+	public boolean acceptsURL(String url) throws SQLException {
+		// Check on the supplied String...
+		if (url == null)
+			return false;
+		// Everything's fine if the quoted url starts with the base url for this
+		// driver
+		if (url.startsWith(baseURL))
+			return true;
+		return false;
+	} // end method acceptsURL
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#connect(java.lang.String, java.util.Properties)
+	 */
+	static String validuser = "theuser";
+
+	static String validpassword = "thepassword";
+
+	static String userProperty = "user";
+
+	static String passwordProperty = "password";
+
+	public Connection connect(String url, Properties info) throws SQLException {
+		// Does the URL have the right form?
+		if (this.acceptsURL(url)) {
+			// The datasource name is the remainder of the url after the ":"
+			String datasource = url.substring(baseURL.length() + 1);
+			// Loop over the valid datasources supported by this driver
+			for (int i = 0; i < dataSources.length; i++) {
+				if (datasource.equals(dataSources[i])) {
+					// Check for user and password, except for datasource =
+					// data1
+					// which is set up not to require a user/password
+					// combination
+					if (datasource.equals("data1")) {
+						// do nothing...
+					} else {
+						if (info == null)
+							throw new SQLException("Properties bundle is null");
+						String user = (String) info.get(userProperty);
+						String password = (String) info.get(passwordProperty);
+						if (user == null || password == null) {
+							throw new SQLException(
+									"Userid and/or password not supplied");
+						} else {
+							if (!user.equals(validuser)
+									|| !password.equals(validpassword)) {
+								throw new SQLException(
+										"Userid and/or password not valid");
+							} // end if
+						} // end if
+					} // end if
+					// It all checks out - so return a connection
+					Connection connection = new TestHelper_Connection1();
+					return connection;
+				} // end if
+			} // end for
+		} // end if
+		return null;
+	} // end method connect(String, Properties)
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#getMajorVersion()
+	 */
+	public int getMajorVersion() {
+
+		return majorVersion;
+	} // end method getMajorVersion()
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#getMinorVersion()
+	 */
+	public int getMinorVersion() {
+
+		return minorVersion;
+	} // end method getMinorVersion()
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#getPropertyInfo(java.lang.String,
+	 *      java.util.Properties)
+	 */
+	public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
+			throws SQLException {
+		DriverPropertyInfo[] theInfos = {
+				new DriverPropertyInfo(userProperty, "*"),
+				new DriverPropertyInfo(passwordProperty, "*"), };
+		return theInfos;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.sql.Driver#jdbcCompliant()
+	 */
+	public boolean jdbcCompliant() {
+		// Basic version here returns false
+		return false;
+	}
+
+} // end class TestHelper_Driver4
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver4.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver5.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver5.java?rev=436644&r1=436643&r2=436644&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver5.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver5.java Thu Aug 24 21:29:34 2006
@@ -1,42 +1,42 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed 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.harmony.sql.tests.java.sql;
-
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-/**
- * Basic JDBC driver implementation to help with tests
- * 
- */
-public class TestHelper_Driver5 extends TestHelper_Driver4 {
-
-	static {
-		Driver theDriver = new TestHelper_Driver5();
-		try {
-			DriverManager.registerDriver(theDriver);
-		} catch (SQLException e) {
-			System.out.println("Failed to register driver!");
-		}
-	} // end static block initializer
-
-	protected TestHelper_Driver5() {
-		super();
-		baseURL = "jdbc:mikes5";
-	} // end constructor TestHelper_Driver5()
-
-} // end class TestHelper_Driver5
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.harmony.sql.tests.java.sql;
+
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+/**
+ * Basic JDBC driver implementation to help with tests
+ * 
+ */
+public class TestHelper_Driver5 extends TestHelper_Driver4 {
+
+	static {
+		Driver theDriver = new TestHelper_Driver5();
+		try {
+			DriverManager.registerDriver(theDriver);
+		} catch (SQLException e) {
+			System.out.println("Failed to register driver!");
+		}
+	} // end static block initializer
+
+	protected TestHelper_Driver5() {
+		super();
+		baseURL = "jdbc:mikes5";
+	} // end constructor TestHelper_Driver5()
+
+} // end class TestHelper_Driver5

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver5.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_DriverManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_DriverManager.java?rev=436644&r1=436643&r2=436644&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_DriverManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_DriverManager.java Thu Aug 24 21:29:34 2006
@@ -1,111 +1,111 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed 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.harmony.sql.tests.java.sql;
-
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-import junit.framework.TestCase;
-
-/**
- * Helper class for the Driver manager tes - it allows the test code to be
- * loaded under a different classloader, necessary for testing the
- * DeregisterDriver function of DriverManager
- * 
- */
-public class TestHelper_DriverManager extends TestCase {
-
-	static Driver testDriver = null;
-
-	static TestHelper_DriverManager theHelper;
-
-	static {
-		theHelper = new TestHelper_DriverManager();
-		// theHelper.testDeregister();
-	} // end static
-
-	public TestHelper_DriverManager() {
-		super();
-	} // end constructor TestHelper_DriverManager()
-
-	public static void setDriver(Driver theDriver) {
-		testDriver = theDriver;
-		// System.out.println("TestHelper_DriverManager: Test Driver set!");
-
-		theHelper.checkDeregister();
-	} // end method setDriver( Driver )
-
-	public void checkDeregister() {
-
-		String baseURL = "jdbc:mikes1";
-
-		// System.out.println("Calling checkDeregister in
-		// TestHelper_DriverManager....");
-
-		Driver aDriver;
-
-		// System.out.println("checkDeregister classloader: " +
-		// this.getClass().getClassLoader() );
-
-		// Try to get a driver from the general pool... this should fail
-		try {
-			aDriver = DriverManager.getDriver(baseURL);
-			fail(
-					"testDeregisterDriver: Didn't get exception when getting valid driver from other classloader.");
-		} catch (SQLException e) {
-			// e.printStackTrace();
-			assertTrue(
-					"testDeregisterDriver: Got exception when getting valid driver from other classloader.",
-					true);
-			// return;
-		} // end try
-
-		// OK, now THIS driver was loaded by someone else....
-		aDriver = testDriver;
-
-		// printClassLoader( aDriver );
-
-		// Deregister this driver
-		try {
-			DriverManager.deregisterDriver(aDriver);
-			// We shouldn't get here - but if we do, we need to re-register the
-			// driver to
-			// prevent subsequent tests from failing due to inability to get to
-			// this driver...
-			DriverManager.registerDriver(aDriver);
-			fail(
-					"checkDeregisterDriver: Didn't get Security Exception deregistering invalid driver.");
-		} catch (SecurityException s) {
-			// This is the exception we should get...
-			// System.out.println("checkDeregisterDriver: got expected Security
-			// Exception");
-		} catch (Exception e) {
-			fail(
-					"checkDeregisterDriver: Got wrong exception type when deregistering invalid driver.");
-		} // end try
-
-	} // end method testDeRegister
-
-	static void printClassLoader(Object theObject) {
-		Class theClass = theObject.getClass();
-		ClassLoader theClassLoader = theClass.getClassLoader();
-		System.out.println("ClassLoader is: " + theClassLoader.toString()
-				+ " for object: " + theObject.toString());
-	} // end method printClassLoader( Object )
-
-} // end class TestHelper_DriverManager
-
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.harmony.sql.tests.java.sql;
+
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import junit.framework.TestCase;
+
+/**
+ * Helper class for the Driver manager tes - it allows the test code to be
+ * loaded under a different classloader, necessary for testing the
+ * DeregisterDriver function of DriverManager
+ * 
+ */
+public class TestHelper_DriverManager extends TestCase {
+
+	static Driver testDriver = null;
+
+	static TestHelper_DriverManager theHelper;
+
+	static {
+		theHelper = new TestHelper_DriverManager();
+		// theHelper.testDeregister();
+	} // end static
+
+	public TestHelper_DriverManager() {
+		super();
+	} // end constructor TestHelper_DriverManager()
+
+	public static void setDriver(Driver theDriver) {
+		testDriver = theDriver;
+		// System.out.println("TestHelper_DriverManager: Test Driver set!");
+
+		theHelper.checkDeregister();
+	} // end method setDriver( Driver )
+
+	public void checkDeregister() {
+
+		String baseURL = "jdbc:mikes1";
+
+		// System.out.println("Calling checkDeregister in
+		// TestHelper_DriverManager....");
+
+		Driver aDriver;
+
+		// System.out.println("checkDeregister classloader: " +
+		// this.getClass().getClassLoader() );
+
+		// Try to get a driver from the general pool... this should fail
+		try {
+			aDriver = DriverManager.getDriver(baseURL);
+			fail(
+					"testDeregisterDriver: Didn't get exception when getting valid driver from other classloader.");
+		} catch (SQLException e) {
+			// e.printStackTrace();
+			assertTrue(
+					"testDeregisterDriver: Got exception when getting valid driver from other classloader.",
+					true);
+			// return;
+		} // end try
+
+		// OK, now THIS driver was loaded by someone else....
+		aDriver = testDriver;
+
+		// printClassLoader( aDriver );
+
+		// Deregister this driver
+		try {
+			DriverManager.deregisterDriver(aDriver);
+			// We shouldn't get here - but if we do, we need to re-register the
+			// driver to
+			// prevent subsequent tests from failing due to inability to get to
+			// this driver...
+			DriverManager.registerDriver(aDriver);
+			fail(
+					"checkDeregisterDriver: Didn't get Security Exception deregistering invalid driver.");
+		} catch (SecurityException s) {
+			// This is the exception we should get...
+			// System.out.println("checkDeregisterDriver: got expected Security
+			// Exception");
+		} catch (Exception e) {
+			fail(
+					"checkDeregisterDriver: Got wrong exception type when deregistering invalid driver.");
+		} // end try
+
+	} // end method testDeRegister
+
+	static void printClassLoader(Object theObject) {
+		Class theClass = theObject.getClass();
+		ClassLoader theClassLoader = theClass.getClassLoader();
+		System.out.println("ClassLoader is: " + theClassLoader.toString()
+				+ " for object: " + theObject.toString());
+	} // end method printClassLoader( Object )
+
+} // end class TestHelper_DriverManager
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_DriverManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimeTest.java?rev=436644&r1=436643&r2=436644&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimeTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimeTest.java Thu Aug 24 21:29:34 2006
@@ -1,259 +1,259 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
- * 
- * Licensed 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.harmony.sql.tests.java.sql;
-
-import java.sql.Time;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
-/**
- * JUnit Testcase for the java.sql.Time class
- * 
- */
-public class TimeTest extends TestCase {
-
-	static long TIME_TEST1 = 38720000; // 10:45:20 GMT
-
-	static long TIME_TEST2 = 80279000; // 22:17:59 GMT
-
-	static long TIME_TEST3 = -38720000; // 13:14:40 GMT
-
-	static String STRING_TEST1 = "10:45:20";
-
-	static String STRING_TEST2 = "22:17:59";
-
-	static String STRING_TEST3 = "13:14:40";
-
-	static String STRING_INVALID1 = "ABCDEFGHI";
-
-	static String STRING_INVALID2 = "233104";
-
-	static String STRING_INVALID3 = "21-43-48";
-
-	static String STRING_OUTRANGE = "35:99:66";
-
-	static long[] TIME_ARRAY = { TIME_TEST1, TIME_TEST2, TIME_TEST3 };
-
-	static String[] STRING_GMT_ARRAY = { STRING_TEST1, STRING_TEST2,
-			STRING_TEST3 };
-
-	static String[] STRING_LA_ARRAY = { "02:45:20", "14:17:59", "05:14:40" };
-
-	static String[] STRING_JP_ARRAY = { "19:45:20", "07:17:59", "22:14:40" };
-
-	static String[] INVALID_STRINGS = { STRING_INVALID1, STRING_INVALID2,
-			STRING_INVALID3 };
-
-	// Timezones
-	static String TZ_LONDON = "GMT"; // GMT (!) PS London != GMT (?!?)
-
-	static String TZ_PACIFIC = "America/Los_Angeles"; // GMT - 8
-
-	static String TZ_JAPAN = "Asia/Tokyo"; // GMT + 9
-
-	static String[] TIMEZONES = { TZ_LONDON, TZ_PACIFIC, TZ_JAPAN };
-
-	static String[][] STRING_ARRAYS = { STRING_GMT_ARRAY, STRING_LA_ARRAY,
-			STRING_JP_ARRAY };
-
-	public void testTimeintintint() {
-		Time theTime = new Time(10, 45, 20);
-
-		// The date should have been created
-		assertNotNull(theTime);
-	} // end method testTimeintintint()
-
-	public void testTime() {
-		Time theTime = new Time(TIME_TEST1);
-
-		// The date should have been created
-		assertNotNull(theTime);
-	} // end method testTime()
-
-	public void testToString() {
-
-		// Loop through the timezones testing the String conversion for each
-		for (int i = 0; i < TIME_ARRAY.length; i++) {
-			testToString(TIMEZONES[i], TIME_ARRAY, STRING_ARRAYS[i]);
-		} // end for
-
-	} // end method test
-
-	private void testToString(String timeZone, long[] theTimes,
-			String[] theTimeStrings) {
-		// Set the timezone
-		TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
-		String theTimeZoneName = TimeZone.getDefault().getDisplayName();
-		/* System.out.println("testToString: Timezone is: " + theTimeZoneName ); */
-
-		for (int i = 0; i < theTimes.length; i++) {
-			// Create the Time object
-			Time theTime = new Time(theTimes[i]);
-			// Convert to a time string ... and compare
-			String JDBCString = theTime.toString();
-			assertTrue(JDBCString.equals(theTimeStrings[i]));
-		} // end for
-
-	} // end testToString( String, long[], String[] )
-
-	/*
-	 * Method test for valueOf
-	 */
-	public void testValueOfString() {
-
-		TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
-
-		Time theReturn;
-		Time[] theReturns = { new Time(38720000), new Time(80279000),
-				new Time(47680000), new Time(0), new Time(0), new Time(0),
-				new Time(0) };
-		String[] parm1 = { "10:45:20", "22:17:59", "13:14:40", null,
-				"ABCDEFGHI", "233104", "21-43-48" };
-		Exception[] theExceptions = { null, null, null,
-				new IllegalArgumentException(), new IllegalArgumentException(),
-				new IllegalArgumentException(), new IllegalArgumentException() };
-
-		int loopCount = parm1.length;
-		for (int i = 0; i < loopCount; i++) {
-			try {
-				theReturn = Time.valueOf(parm1[i]);
-				if (theExceptions[i] != null)
-					assertTrue(false);
-				assertTrue(theReturn.equals(theReturns[i]));
-			} catch (Exception e) {
-				assertTrue(e.getClass().equals(theExceptions[i].getClass()));
-				assertTrue(e.getMessage() == theExceptions[i].getMessage());
-			} // end try
-		} // end for
-
-	} // end method testValueOfString
-
-	public void testSetTime() {
-
-		// Ensure that the timezone is set to GMT
-		TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
-
-		Time theTime = new Time(TIME_TEST1);
-
-		assertTrue(theTime.toString().equals(STRING_TEST1));
-
-		theTime.setTime(TIME_TEST2);
-
-		assertTrue(theTime.toString().equals(STRING_TEST2));
-
-	} // end method testSetTime()
-
-	public void testSetDate() {
-		Time theTime = new Time(TIME_TEST1);
-
-		try {
-			theTime.setDate(10);
-			assertTrue(false);
-		} catch (Exception e) {
-			/*
-			 * System.out.println("testSetDate: IllegalArgumentException thrown
-			 * as expected");
-			 */
-		} // end try
-	} // end method testSetDate()
-
-	public void testSetMonth() {
-		Time theTime = new Time(TIME_TEST1);
-
-		try {
-			theTime.setMonth(2);
-			assertTrue(false);
-		} catch (Exception e) {
-			/*
-			 * System.out.println("testSetMonth: IllegalArgumentException thrown
-			 * as expected");
-			 */
-		} // end try
-	} // end method testSetMonth()
-
-	public void testSetYear() {
-		Time theTime = new Time(TIME_TEST1);
-
-		try {
-			theTime.setYear(99);
-			assertTrue(false);
-		} catch (Exception e) {
-			/*
-			 * System.out.println("testSetYear: IllegalArgumentException thrown
-			 * as expected");
-			 */
-		} // end try
-	} // end method testSetYear()
-
-	public void testGetDate() {
-		Time theTime = new Time(TIME_TEST1);
-
-		try {
-			int theDate = theTime.getDate();
-			assertTrue(false);
-		} catch (Exception e) {
-			/*
-			 * System.out.println("testGetDate: IllegalArgumentException thrown
-			 * as expected");
-			 */
-		} // end try
-	} // end method test
-
-	public void testGetDay() {
-		Time theTime = new Time(TIME_TEST1);
-
-		try {
-			int theDay = theTime.getDay();
-			assertTrue(false);
-		} catch (Exception e) {
-			/*
-			 * System.out.println("testGetDay: IllegalArgumentException thrown
-			 * as expected");
-			 */
-		} // end try
-	} // end method test
-
-	public void testGetMonth() {
-		Time theTime = new Time(TIME_TEST1);
-
-		try {
-			int theDate = theTime.getMonth();
-			assertTrue(false);
-		} catch (Exception e) {
-			/*
-			 * System.out.println("testGetMonth: IllegalArgumentException thrown
-			 * as expected");
-			 */
-		} // end try
-	} // end method test
-
-	public void testGetYear() {
-		Time theTime = new Time(TIME_TEST1);
-
-		try {
-			int theDate = theTime.getYear();
-			assertTrue(false);
-		} catch (Exception e) {
-			/*
-			 * System.out.println("testGetYear: IllegalArgumentException thrown
-			 * as expected");
-			 */
-		} // end try
-	} // end method test
-
-} // end class TimeTest
-
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.harmony.sql.tests.java.sql;
+
+import java.sql.Time;
+import java.util.TimeZone;
+
+import junit.framework.TestCase;
+
+/**
+ * JUnit Testcase for the java.sql.Time class
+ * 
+ */
+public class TimeTest extends TestCase {
+
+	static long TIME_TEST1 = 38720000; // 10:45:20 GMT
+
+	static long TIME_TEST2 = 80279000; // 22:17:59 GMT
+
+	static long TIME_TEST3 = -38720000; // 13:14:40 GMT
+
+	static String STRING_TEST1 = "10:45:20";
+
+	static String STRING_TEST2 = "22:17:59";
+
+	static String STRING_TEST3 = "13:14:40";
+
+	static String STRING_INVALID1 = "ABCDEFGHI";
+
+	static String STRING_INVALID2 = "233104";
+
+	static String STRING_INVALID3 = "21-43-48";
+
+	static String STRING_OUTRANGE = "35:99:66";
+
+	static long[] TIME_ARRAY = { TIME_TEST1, TIME_TEST2, TIME_TEST3 };
+
+	static String[] STRING_GMT_ARRAY = { STRING_TEST1, STRING_TEST2,
+			STRING_TEST3 };
+
+	static String[] STRING_LA_ARRAY = { "02:45:20", "14:17:59", "05:14:40" };
+
+	static String[] STRING_JP_ARRAY = { "19:45:20", "07:17:59", "22:14:40" };
+
+	static String[] INVALID_STRINGS = { STRING_INVALID1, STRING_INVALID2,
+			STRING_INVALID3 };
+
+	// Timezones
+	static String TZ_LONDON = "GMT"; // GMT (!) PS London != GMT (?!?)
+
+	static String TZ_PACIFIC = "America/Los_Angeles"; // GMT - 8
+
+	static String TZ_JAPAN = "Asia/Tokyo"; // GMT + 9
+
+	static String[] TIMEZONES = { TZ_LONDON, TZ_PACIFIC, TZ_JAPAN };
+
+	static String[][] STRING_ARRAYS = { STRING_GMT_ARRAY, STRING_LA_ARRAY,
+			STRING_JP_ARRAY };
+
+	public void testTimeintintint() {
+		Time theTime = new Time(10, 45, 20);
+
+		// The date should have been created
+		assertNotNull(theTime);
+	} // end method testTimeintintint()
+
+	public void testTime() {
+		Time theTime = new Time(TIME_TEST1);
+
+		// The date should have been created
+		assertNotNull(theTime);
+	} // end method testTime()
+
+	public void testToString() {
+
+		// Loop through the timezones testing the String conversion for each
+		for (int i = 0; i < TIME_ARRAY.length; i++) {
+			testToString(TIMEZONES[i], TIME_ARRAY, STRING_ARRAYS[i]);
+		} // end for
+
+	} // end method test
+
+	private void testToString(String timeZone, long[] theTimes,
+			String[] theTimeStrings) {
+		// Set the timezone
+		TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+		String theTimeZoneName = TimeZone.getDefault().getDisplayName();
+		/* System.out.println("testToString: Timezone is: " + theTimeZoneName ); */
+
+		for (int i = 0; i < theTimes.length; i++) {
+			// Create the Time object
+			Time theTime = new Time(theTimes[i]);
+			// Convert to a time string ... and compare
+			String JDBCString = theTime.toString();
+			assertTrue(JDBCString.equals(theTimeStrings[i]));
+		} // end for
+
+	} // end testToString( String, long[], String[] )
+
+	/*
+	 * Method test for valueOf
+	 */
+	public void testValueOfString() {
+
+		TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+
+		Time theReturn;
+		Time[] theReturns = { new Time(38720000), new Time(80279000),
+				new Time(47680000), new Time(0), new Time(0), new Time(0),
+				new Time(0) };
+		String[] parm1 = { "10:45:20", "22:17:59", "13:14:40", null,
+				"ABCDEFGHI", "233104", "21-43-48" };
+		Exception[] theExceptions = { null, null, null,
+				new IllegalArgumentException(), new IllegalArgumentException(),
+				new IllegalArgumentException(), new IllegalArgumentException() };
+
+		int loopCount = parm1.length;
+		for (int i = 0; i < loopCount; i++) {
+			try {
+				theReturn = Time.valueOf(parm1[i]);
+				if (theExceptions[i] != null)
+					assertTrue(false);
+				assertTrue(theReturn.equals(theReturns[i]));
+			} catch (Exception e) {
+				assertTrue(e.getClass().equals(theExceptions[i].getClass()));
+				assertTrue(e.getMessage() == theExceptions[i].getMessage());
+			} // end try
+		} // end for
+
+	} // end method testValueOfString
+
+	public void testSetTime() {
+
+		// Ensure that the timezone is set to GMT
+		TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+
+		Time theTime = new Time(TIME_TEST1);
+
+		assertTrue(theTime.toString().equals(STRING_TEST1));
+
+		theTime.setTime(TIME_TEST2);
+
+		assertTrue(theTime.toString().equals(STRING_TEST2));
+
+	} // end method testSetTime()
+
+	public void testSetDate() {
+		Time theTime = new Time(TIME_TEST1);
+
+		try {
+			theTime.setDate(10);
+			assertTrue(false);
+		} catch (Exception e) {
+			/*
+			 * System.out.println("testSetDate: IllegalArgumentException thrown
+			 * as expected");
+			 */
+		} // end try
+	} // end method testSetDate()
+
+	public void testSetMonth() {
+		Time theTime = new Time(TIME_TEST1);
+
+		try {
+			theTime.setMonth(2);
+			assertTrue(false);
+		} catch (Exception e) {
+			/*
+			 * System.out.println("testSetMonth: IllegalArgumentException thrown
+			 * as expected");
+			 */
+		} // end try
+	} // end method testSetMonth()
+
+	public void testSetYear() {
+		Time theTime = new Time(TIME_TEST1);
+
+		try {
+			theTime.setYear(99);
+			assertTrue(false);
+		} catch (Exception e) {
+			/*
+			 * System.out.println("testSetYear: IllegalArgumentException thrown
+			 * as expected");
+			 */
+		} // end try
+	} // end method testSetYear()
+
+	public void testGetDate() {
+		Time theTime = new Time(TIME_TEST1);
+
+		try {
+			int theDate = theTime.getDate();
+			assertTrue(false);
+		} catch (Exception e) {
+			/*
+			 * System.out.println("testGetDate: IllegalArgumentException thrown
+			 * as expected");
+			 */
+		} // end try
+	} // end method test
+
+	public void testGetDay() {
+		Time theTime = new Time(TIME_TEST1);
+
+		try {
+			int theDay = theTime.getDay();
+			assertTrue(false);
+		} catch (Exception e) {
+			/*
+			 * System.out.println("testGetDay: IllegalArgumentException thrown
+			 * as expected");
+			 */
+		} // end try
+	} // end method test
+
+	public void testGetMonth() {
+		Time theTime = new Time(TIME_TEST1);
+
+		try {
+			int theDate = theTime.getMonth();
+			assertTrue(false);
+		} catch (Exception e) {
+			/*
+			 * System.out.println("testGetMonth: IllegalArgumentException thrown
+			 * as expected");
+			 */
+		} // end try
+	} // end method test
+
+	public void testGetYear() {
+		Time theTime = new Time(TIME_TEST1);
+
+		try {
+			int theDate = theTime.getYear();
+			assertTrue(false);
+		} catch (Exception e) {
+			/*
+			 * System.out.println("testGetYear: IllegalArgumentException thrown
+			 * as expected");
+			 */
+		} // end try
+	} // end method test
+
+} // end class TimeTest
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message