You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/07/16 11:03:03 UTC
svn commit: r556562 [3/6] - in
/harmony/enhanced/classlib/trunk/modules/sql/src: main/java/java/sql/
main/java/javax/sql/ main/java/javax/sql/rowset/
main/java/javax/sql/rowset/serial/ main/java/javax/sql/rowset/spi/
main/java/javax/transaction/xa/ mai...
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DateTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DateTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DateTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DateTest.java Mon Jul 16 02:02:56 2007
@@ -29,352 +29,351 @@
*/
public class DateTest extends TestCase {
- // A calendar object created in the GMT time zone
- static Calendar aCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ // A calendar object created in the GMT time zone
+ static Calendar aCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- // Some interesting millisecond time values
- // These millisecond times are all in GMT, effectively
- static long TIME_AN_HOUR = 3600000; // 1000 * 60 * 60 ms
+ // Some interesting millisecond time values
+ // These millisecond times are all in GMT, effectively
+ static long TIME_AN_HOUR = 3600000; // 1000 * 60 * 60 ms
- static long TIME_EPOCH = 0;
+ static long TIME_EPOCH = 0;
- static long TIME_NOW = System.currentTimeMillis();
+ static long TIME_NOW = System.currentTimeMillis();
- static long TIME_NEGATIVE = -3600001;
+ static long TIME_NEGATIVE = -3600001;
- static long TIME_TESTDATE1 = getTime(1999, Calendar.DECEMBER, 31, 23, 59,
- 59);
+ static long TIME_TESTDATE1 = getTime(1999, Calendar.DECEMBER, 31, 23, 59,
+ 59);
- static long TIME_TESTDATE2 = getTime(2010, Calendar.JUNE, 10, 20, 3, 16);
+ static long TIME_TESTDATE2 = getTime(2010, Calendar.JUNE, 10, 20, 3, 16);
- static long TIME_TESTDATE3 = getTime(1931, Calendar.APRIL, 21, 1, 25, 1);
+ static long TIME_TESTDATE3 = getTime(1931, Calendar.APRIL, 21, 1, 25, 1);
- static long TIME_LOWERLIMIT = Long.MIN_VALUE;
+ static long TIME_LOWERLIMIT = Long.MIN_VALUE;
- static long TIME_UPPERLIMIT = Long.MAX_VALUE;
+ static long TIME_UPPERLIMIT = Long.MAX_VALUE;
- // Date strings
- static String SQL_DATESTRING1 = "1999-12-31";
+ // Date strings
+ static String SQL_DATESTRING1 = "1999-12-31";
- static String SQL_DATESTRING2 = "2010-06-10";
+ static String SQL_DATESTRING2 = "2010-06-10";
- static String SQL_DATESTRING3 = "1931-04-21";
+ static String SQL_DATESTRING3 = "1931-04-21";
- static String SQL_EPOCHSTRING = "1970-01-01";
+ static String SQL_EPOCHSTRING = "1970-01-01";
- static String SQL_DATEDAY1 = "1970-01-02";
+ static String SQL_DATEDAY1 = "1970-01-02";
- static String SQL_NEGATIVE = "1969-12-31";
+ static String SQL_NEGATIVE = "1969-12-31";
- static long[] TIME_ARRAY = new long[] { TIME_TESTDATE1, TIME_TESTDATE2,
- TIME_TESTDATE3, TIME_NEGATIVE, TIME_EPOCH };
+ static long[] TIME_ARRAY = new long[] { TIME_TESTDATE1, TIME_TESTDATE2,
+ TIME_TESTDATE3, TIME_NEGATIVE, TIME_EPOCH };
- // Date string array for London (GMT)
- static String[] SQL_DATEARRAY = new String[] { SQL_DATESTRING1,
- SQL_DATESTRING2, SQL_DATESTRING3, SQL_NEGATIVE, SQL_EPOCHSTRING };
+ // Date string array for London (GMT)
+ static String[] SQL_DATEARRAY = new String[] { SQL_DATESTRING1,
+ SQL_DATESTRING2, SQL_DATESTRING3, SQL_NEGATIVE, SQL_EPOCHSTRING };
- // Date string array for New York - sometimes a day earlier than London
- static String[] SQL_NYARRAY = new String[] { "1999-12-31", "2010-06-10",
- "1931-04-20", "1969-12-31", "1969-12-31" };
+ // Date string array for New York - sometimes a day earlier than London
+ static String[] SQL_NYARRAY = new String[] { "1999-12-31", "2010-06-10",
+ "1931-04-20", "1969-12-31", "1969-12-31" };
- // Date string for Tokyo
- static String[] SQL_JAPANARRAY = new String[] { "2000-01-01", "2010-06-11",
- "1931-04-21", "1970-01-01", "1970-01-01" };
+ // Date string for Tokyo
+ static String[] SQL_JAPANARRAY = new String[] { "2000-01-01", "2010-06-11",
+ "1931-04-21", "1970-01-01", "1970-01-01" };
- static String[][] SQL_TZ_DATEARRAYS = new String[][] { SQL_DATEARRAY,
- SQL_NYARRAY, SQL_JAPANARRAY };
+ static String[][] SQL_TZ_DATEARRAYS = new String[][] { SQL_DATEARRAY,
+ SQL_NYARRAY, SQL_JAPANARRAY };
- // Timezones
- static String TZ_LONDON = "Europe/London"; // Note: != GMT
+ // Timezones
+ static String TZ_LONDON = "Europe/London"; // Note: != GMT
- static String TZ_PACIFIC = "America/Los_Angeles"; // GNT - 8
+ static String TZ_PACIFIC = "America/Los_Angeles"; // GNT - 8
- static String TZ_JAPAN = "Asia/Tokyo"; // GMT + 9
+ static String TZ_JAPAN = "Asia/Tokyo"; // GMT + 9
- static String[] TIMEZONES = { TZ_LONDON, TZ_PACIFIC, TZ_JAPAN };
+ static String[] TIMEZONES = { TZ_LONDON, TZ_PACIFIC, TZ_JAPAN };
- /*
- * Helper method to create a long milliseconds time from a supplied date and
- * time
- */
- static private long getTime(int year, int month, int date, int hour,
- int minute, int second) {
- aCal.set(year, month, date, hour, minute, second);
- return aCal.getTimeInMillis();
- } // end method getTime( int, int, int, int, int, int )
-
- /*
- * Test of the Date(int, int, int) constructor - now deprecated but still
- * functioning
- */
- @SuppressWarnings("deprecation")
+ /*
+ * Helper method to create a long milliseconds time from a supplied date and
+ * time
+ */
+ static private long getTime(int year, int month, int date, int hour,
+ int minute, int second) {
+ aCal.set(year, month, date, hour, minute, second);
+ return aCal.getTimeInMillis();
+ } // end method getTime( int, int, int, int, int, int )
+
+ /*
+ * Test of the Date(int, int, int) constructor - now deprecated but still
+ * functioning
+ */
+ @SuppressWarnings("deprecation")
public void testDateintintint() {
- int init1[] = { 99, 8099, 9000, 99999, 99, 99, -1, -100 };
- int init2[] = { 11, 0, 0, 0, 999, 0, 0, -111 };
- int init3[] = { 31, 0, 0, 0, 0, 999, 0, -999 };
+ int init1[] = { 99, 8099, 9000, 99999, 99, 99, -1, -100 };
+ int init2[] = { 11, 0, 0, 0, 999, 0, 0, -111 };
+ int init3[] = { 31, 0, 0, 0, 0, 999, 0, -999 };
- for (int i = 0; i < init1.length; i++) {
+ for (int i = 0; i < init1.length; i++) {
Date theDate = new Date(init1[i], init2[i], init3[i]);
assertNotNull(theDate);
} // end for
- } // end method testDateintintint
+ } // end method testDateintintint
+
+ /*
+ * Test of the Date( long ) constructor
+ */
+ public void testDatelong() {
- /*
- * Test of the Date( long ) constructor
- */
- public void testDatelong() {
-
- long init1[] = { TIME_TESTDATE1, TIME_TESTDATE2, TIME_TESTDATE3,
- TIME_NEGATIVE, TIME_LOWERLIMIT, TIME_UPPERLIMIT, TIME_EPOCH,
- TIME_NOW };
+ long init1[] = { TIME_TESTDATE1, TIME_TESTDATE2, TIME_TESTDATE3,
+ TIME_NEGATIVE, TIME_LOWERLIMIT, TIME_UPPERLIMIT, TIME_EPOCH,
+ TIME_NOW };
- for (long element : init1) {
+ for (long element : init1) {
Date theDate = new Date(element);
assertNotNull(theDate);
} // end for
- } // end method testDatelong
+ } // end method testDatelong
- /*
- * Test of the (deprecated) int Date.getHours() method - which always throws
- * an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ /*
+ * Test of the (deprecated) int Date.getHours() method - which always throws
+ * an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testGetHours() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.getHours();
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.getHours();
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testGetHours()
-
- /*
- * Test of the (deprecated) int Date.getMinutes() method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testGetHours()
+
+ /*
+ * Test of the (deprecated) int Date.getMinutes() method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testGetMinutes() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.getMinutes();
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.getMinutes();
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testGetMinutes()
-
- /*
- * Test of the (deprecated) int Date.getSeconds() method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testGetMinutes()
+
+ /*
+ * Test of the (deprecated) int Date.getSeconds() method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testGetSeconds() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.getSeconds();
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.getSeconds();
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testGetSeconds()
-
- /*
- * Test of the (deprecated) Date.setHours( int ) method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testGetSeconds()
+
+ /*
+ * Test of the (deprecated) Date.setHours( int ) method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testSetHours() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.setHours(22);
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.setHours(22);
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testSetHours( int )
-
- /*
- * Test of the (deprecated) Date.setMinutes( int ) method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testSetHours( int )
+
+ /*
+ * Test of the (deprecated) Date.setMinutes( int ) method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testSetMinutes() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.setMinutes(54);
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.setMinutes(54);
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
-
- } // end method testSetMinutes( int )
-
- /*
- * Test of the (deprecated) Date.setSeconds( int ) method - which always
- * throws an IllegalArgumentException
- */
- @SuppressWarnings("deprecation")
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+
+ } // end method testSetMinutes( int )
+
+ /*
+ * Test of the (deprecated) Date.setSeconds( int ) method - which always
+ * throws an IllegalArgumentException
+ */
+ @SuppressWarnings("deprecation")
public void testSetSeconds() {
- Date theDate = new Date(TIME_TESTDATE1);
- try {
- theDate.setSeconds(36);
+ Date theDate = new Date(TIME_TESTDATE1);
+ try {
+ theDate.setSeconds(36);
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException ie) {
- //expected
- } // end try
- } // end method testSetSeconds( int )
-
- /*
- * Test of the String Date.toString() method This method is sensitive to the
- * time zone setting and this test sets the time zone before calling the
- * toString() method.
- */
- public void testToString() {
- // This test is set up for GMT time zone, so need to set the time zone
- // to GMT first
- TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
-
- for (int i = 0; i < TIME_ARRAY.length; i++) {
- Date theDate = new Date(TIME_ARRAY[i]);
- assertEquals(SQL_DATEARRAY[i], theDate.toString());
- } // end for
-
- } // end method testToString()
-
- /*
- * Test of the void setTime(int) method This does depend on the Time Zone
- * settings and sets up the time zone to one of a group of specific time
- * zones and tests the method using each of these time zones in turn.
- */
- public void testSetTimelong() {
-
- // Loop over the array of test timezones
- for (int i = 0; i < TIMEZONES.length; i++) {
- testSetTimelong(TIMEZONES[i], SQL_TZ_DATEARRAYS[i]);
- } // end for
-
- } // end method testSetTimelong()
-
- /*
- * Internal method for testing Date.setTime with a specific time zone
- */
- private void testSetTimelong(String timeZoneName, String[] dateArray) {
-
- if (timeZoneName != null) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZoneName));
- } // end if
-
- Date theDate = new Date(TIME_TESTDATE1);
-
- // Loop over the array of test times & dates
- for (int i = 0; i < dateArray.length; i++) {
- theDate.setTime(TIME_ARRAY[i]);
- assertEquals(dateArray[i], theDate.toString());
- } // end for
-
- } // end method testSetTimelong()
-
- /*
- * Test of the Date.valueOf( String ) method This test is not dependent on
- * the default Time Zone setting
- */
- public void testValueOf() {
- String SQL_NOTVALID1 = "ABCDEF"; // Invalid date string
- String SQL_NOTVALID2 = "12321.43.56"; // Invalid date string
- String SQL_NOTVALID3 = null; // Invalid date string
- String[] SQL_INVALIDARRAY = { SQL_NOTVALID1, SQL_NOTVALID2,
- SQL_NOTVALID3 };
+ } catch (IllegalArgumentException ie) {
+ // expected
+ } // end try
+ } // end method testSetSeconds( int )
+
+ /*
+ * Test of the String Date.toString() method This method is sensitive to the
+ * time zone setting and this test sets the time zone before calling the
+ * toString() method.
+ */
+ public void testToString() {
+ // This test is set up for GMT time zone, so need to set the time zone
+ // to GMT first
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+
+ for (int i = 0; i < TIME_ARRAY.length; i++) {
+ Date theDate = new Date(TIME_ARRAY[i]);
+ assertEquals(SQL_DATEARRAY[i], theDate.toString());
+ } // end for
+
+ } // end method testToString()
+
+ /*
+ * Test of the void setTime(int) method This does depend on the Time Zone
+ * settings and sets up the time zone to one of a group of specific time
+ * zones and tests the method using each of these time zones in turn.
+ */
+ public void testSetTimelong() {
+
+ // Loop over the array of test timezones
+ for (int i = 0; i < TIMEZONES.length; i++) {
+ testSetTimelong(TIMEZONES[i], SQL_TZ_DATEARRAYS[i]);
+ } // end for
+
+ } // end method testSetTimelong()
- Date theDate;
+ /*
+ * Internal method for testing Date.setTime with a specific time zone
+ */
+ private void testSetTimelong(String timeZoneName, String[] dateArray) {
+
+ if (timeZoneName != null) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZoneName));
+ } // end if
+
+ Date theDate = new Date(TIME_TESTDATE1);
+
+ // Loop over the array of test times & dates
+ for (int i = 0; i < dateArray.length; i++) {
+ theDate.setTime(TIME_ARRAY[i]);
+ assertEquals(dateArray[i], theDate.toString());
+ } // end for
+
+ } // end method testSetTimelong()
+
+ /*
+ * Test of the Date.valueOf( String ) method This test is not dependent on
+ * the default Time Zone setting
+ */
+ public void testValueOf() {
+ String SQL_NOTVALID1 = "ABCDEF"; // Invalid date string
+ String SQL_NOTVALID2 = "12321.43.56"; // Invalid date string
+ String SQL_NOTVALID3 = null; // Invalid date string
+ String[] SQL_INVALIDARRAY = { SQL_NOTVALID1, SQL_NOTVALID2,
+ SQL_NOTVALID3 };
+
+ Date theDate;
- for (String element : SQL_DATEARRAY) {
- theDate = Date.valueOf(element);
+ for (String element : SQL_DATEARRAY) {
+ theDate = Date.valueOf(element);
assertEquals(element, theDate.toString());
- } // end for
+ } // end for
- for (String element : SQL_INVALIDARRAY) {
- try {
- theDate = Date.valueOf(element);
+ for (String element : SQL_INVALIDARRAY) {
+ try {
+ theDate = Date.valueOf(element);
fail("Should throw IllegalArgumentException.");
- } catch (IllegalArgumentException e) {
- //expected
- } // end try
- } // end for
+ } catch (IllegalArgumentException e) {
+ // expected
+ } // end try
+ } // end for
+
+ } // end method testValueOf()
- } // end method testValueOf()
-
/**
* @tests java.sql.Date#valueOf(String )
*/
public void test_valueOf_IllegalArgumentException() {
- try{
+ try {
Date.valueOf("1996-10-07-01");
fail("should throw NumberFormatException");
} catch (NumberFormatException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("-10-07-01");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("--01");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("1991--");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("-01-");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("-10-w2-01");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("07-w2-");
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("1997-w2-w2");
fail("should throw NumberFormatException");
} catch (NumberFormatException e) {
- //expected
+ // expected
}
-
- try{
+
+ try {
Date.valueOf("1996--01");
fail("should throw NumberFormatException");
} catch (NumberFormatException e) {
- //expected
+ // expected
}
}
} // end class DateTest
-
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java Mon Jul 16 02:02:56 2007
@@ -41,145 +41,146 @@
*/
public class DriverManagerTest extends TestCase {
- // Set of driver names to use
- static final String DRIVER1 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver1";
+ // Set of driver names to use
+ static final String DRIVER1 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver1";
- static final String DRIVER2 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver2";
+ static final String DRIVER2 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver2";
- static final String DRIVER3 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver3";
+ static final String DRIVER3 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver3";
- static final String DRIVER4 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver4";
+ static final String DRIVER4 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver4";
- static final String DRIVER5 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver5";
+ static final String DRIVER5 = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver5";
- static final String INVALIDDRIVER1 = "abc.klm.Foo";
+ static final String INVALIDDRIVER1 = "abc.klm.Foo";
- static String[] driverNames = { DRIVER1, DRIVER2 };
+ static String[] driverNames = { DRIVER1, DRIVER2 };
- static int numberLoaded;
+ static int numberLoaded;
- static String baseURL1 = "jdbc:mikes1";
+ static String baseURL1 = "jdbc:mikes1";
- static String baseURL4 = "jdbc:mikes4";
+ static String baseURL4 = "jdbc:mikes4";
- static final String JDBC_PROPERTY = "jdbc.drivers";
+ static final String JDBC_PROPERTY = "jdbc.drivers";
- static TestHelper_ClassLoader testClassLoader = new TestHelper_ClassLoader();
+ static TestHelper_ClassLoader testClassLoader = new TestHelper_ClassLoader();
- // Static initializer to load the drivers so that they are available to all
- // the
- // test methods as needed.
- @Override
+ // Static initializer to load the drivers so that they are available to all
+ // the
+ // test methods as needed.
+ @Override
public void setUp() {
- numberLoaded = loadDrivers();
- } // end setUp()
+ numberLoaded = loadDrivers();
+ } // end setUp()
- /**
- * Test for the method DriverManager.deregisterDriver
- * @throws SQLException
- */
- public void testDeregisterDriver() throws SQLException {
- // First get one of the drivers loaded by the test
+ /**
+ * Test for the method DriverManager.deregisterDriver
+ *
+ * @throws SQLException
+ */
+ public void testDeregisterDriver() throws SQLException {
+ // First get one of the drivers loaded by the test
Driver aDriver;
aDriver = DriverManager.getDriver(baseURL4);
- // Deregister this driver
+ // Deregister this driver
DriverManager.deregisterDriver(aDriver);
- assertFalse("testDeregisterDriver: Driver was not deregistered.",
- isDriverLoaded(aDriver));
+ assertFalse("testDeregisterDriver: Driver was not deregistered.",
+ isDriverLoaded(aDriver));
- // Re-register this driver (so subsequent tests have it available)
+ // Re-register this driver (so subsequent tests have it available)
DriverManager.registerDriver(aDriver);
- assertTrue("testDeregisterDriver: Driver did not reload.",
- isDriverLoaded(aDriver));
+ assertTrue("testDeregisterDriver: Driver did not reload.",
+ isDriverLoaded(aDriver));
- // Test deregistering a null driver
+ // Test deregistering a null driver
DriverManager.deregisterDriver(null);
- // Test deregistering a driver which was not loaded by this test's
- // classloader
- // TODO - need to load a driver with a different classloader!!
- aDriver = DriverManager.getDriver(baseURL1);
-
- try {
- Class<?> driverClass = Class.forName(
- "org.apache.harmony.sql.tests.java.sql.TestHelper_DriverManager", true,
- testClassLoader);
-
- // Give the Helper class one of our drivers....
- Class<?>[] methodClasses = { Class.forName("java.sql.Driver") };
- Method theMethod = driverClass.getDeclaredMethod("setDriver",
- methodClasses);
- Object[] args = { aDriver };
- theMethod.invoke(null, args);
- } catch (Exception e) {
- System.out
- .println("testDeregisterDriver: Got exception allocating TestHelper");
- e.printStackTrace();
- return;
- } // end try
-
- // Check that the driver was not deregistered
- assertTrue(
- "testDeregisterDriver: Driver was incorrectly deregistered.",
- DriverManagerTest.isDriverLoaded(aDriver));
-
- } // end method testDeregisterDriver()
-
- static void printClassLoader(Object theObject) {
- Class<? extends Object> theClass = theObject.getClass();
- ClassLoader theClassLoader = theClass.getClassLoader();
- System.out.println("ClassLoader is: " + theClassLoader.toString()
- + " for object: " + theObject.toString());
- } // end method printClassLoader( Object )
-
- static boolean isDriverLoaded(Driver theDriver) {
- Enumeration<?> driverList = DriverManager.getDrivers();
- while (driverList.hasMoreElements()) {
- if ((Driver) driverList.nextElement() == theDriver) {
+ // Test deregistering a driver which was not loaded by this test's
+ // classloader
+ // TODO - need to load a driver with a different classloader!!
+ aDriver = DriverManager.getDriver(baseURL1);
+
+ try {
+ Class<?> driverClass = Class
+ .forName(
+ "org.apache.harmony.sql.tests.java.sql.TestHelper_DriverManager",
+ true, testClassLoader);
+
+ // Give the Helper class one of our drivers....
+ Class<?>[] methodClasses = { Class.forName("java.sql.Driver") };
+ Method theMethod = driverClass.getDeclaredMethod("setDriver",
+ methodClasses);
+ Object[] args = { aDriver };
+ theMethod.invoke(null, args);
+ } catch (Exception e) {
+ System.out
+ .println("testDeregisterDriver: Got exception allocating TestHelper");
+ e.printStackTrace();
+ return;
+ } // end try
+
+ // Check that the driver was not deregistered
+ assertTrue(
+ "testDeregisterDriver: Driver was incorrectly deregistered.",
+ DriverManagerTest.isDriverLoaded(aDriver));
+
+ } // end method testDeregisterDriver()
+
+ static void printClassLoader(Object theObject) {
+ Class<? extends Object> theClass = theObject.getClass();
+ ClassLoader theClassLoader = theClass.getClassLoader();
+ System.out.println("ClassLoader is: " + theClassLoader.toString()
+ + " for object: " + theObject.toString());
+ } // end method printClassLoader( Object )
+
+ static boolean isDriverLoaded(Driver theDriver) {
+ Enumeration<?> driverList = DriverManager.getDrivers();
+ while (driverList.hasMoreElements()) {
+ if ((Driver) driverList.nextElement() == theDriver) {
return true;
}
- } // end while
- return false;
- } // end method isDriverLoaded( Driver )
-
- /*
- * Class under test for Connection getConnection(String)
- */
- // valid connection - data1 does not require a user and password...
- static String validConnectionURL = "jdbc:mikes1:data1";
-
- // invalid connection - data2 requires a user & password
- static String invalidConnectionURL1 = "jdbc:mikes1:data2";
+ } // end while
+ return false;
+ } // end method isDriverLoaded( Driver )
- // invalid connection - URL is gibberish
- static String invalidConnectionURL2 = "xyz1:abc3:456q";
+ /*
+ * Class under test for Connection getConnection(String)
+ */
+ // valid connection - data1 does not require a user and password...
+ static String validConnectionURL = "jdbc:mikes1:data1";
+
+ // invalid connection - data2 requires a user & password
+ static String invalidConnectionURL1 = "jdbc:mikes1:data2";
+
+ // invalid connection - URL is gibberish
+ static String invalidConnectionURL2 = "xyz1:abc3:456q";
- // invalid connection - URL is null
- static String invalidConnectionURL3 = null;
+ // invalid connection - URL is null
+ static String invalidConnectionURL3 = null;
- static String[] invalidConnectionURLs = { invalidConnectionURL2,
+ static String[] invalidConnectionURLs = { invalidConnectionURL2,
invalidConnectionURL3 };
- public void testGetConnectionString() throws SQLException {
- Connection theConnection = null;
- // validConnection - no user & password required
- theConnection = DriverManager.getConnection(validConnectionURL);
- assertNotNull(theConnection);
+ public void testGetConnectionString() throws SQLException {
+ Connection theConnection = null;
+ // validConnection - no user & password required
+ theConnection = DriverManager.getConnection(validConnectionURL);
+ assertNotNull(theConnection);
assertNotNull(DriverManager.getConnection(invalidConnectionURL1));
- for (String element : invalidConnectionURLs) {
- try {
- theConnection = DriverManager
- .getConnection(element);
- fail("Should throw SQLException");
- } catch (SQLException e) {
- //expected
- } // end try
- } // end for
- } // end method testGetConnectionString()
-
+ for (String element : invalidConnectionURLs) {
+ try {
+ theConnection = DriverManager.getConnection(element);
+ fail("Should throw SQLException");
+ } catch (SQLException e) {
+ // expected
+ } // end try
+ } // end for
+ } // end method testGetConnectionString()
+
/**
* @tests java.sql.DriverManager#getConnection(String, Properties)
*/
@@ -191,203 +192,199 @@
} catch (SQLException e) {
assertEquals("08001", e.getSQLState()); //$NON-NLS-1$
}
-
+
try {
- DriverManager.getConnection(null,
- new Properties());
+ DriverManager.getConnection(null, new Properties());
fail("Should throw SQLException.");
} catch (SQLException e) {
assertEquals("08001", e.getSQLState()); //$NON-NLS-1$
}
}
- /*
- * Class under test for Connection getConnection(String, Properties)
- */
- public void testGetConnectionStringProperties() throws SQLException {
- String validURL1 = "jdbc:mikes1:data2";
- String validuser1 = "theuser";
- String validpassword1 = "thepassword";
- String invalidURL1 = "xyz:abc1:foo";
- String invalidURL2 = "jdbc:mikes1:crazyone";
- String invalidURL3 = "";
- String invaliduser1 = "jonny nouser";
- String invalidpassword1 = "whizz";
- Properties nullProps = null;
- Properties validProps = new Properties();
- validProps.setProperty("user", validuser1);
- validProps.setProperty("password", validpassword1);
- Properties invalidProps1 = new Properties();
- invalidProps1.setProperty("user", invaliduser1);
- invalidProps1.setProperty("password", invalidpassword1);
- String[] invalidURLs = { null, invalidURL1,
- invalidURL2, invalidURL3 };
- Properties[] invalidProps = { nullProps, invalidProps1};
-
-
+ /*
+ * Class under test for Connection getConnection(String, Properties)
+ */
+ public void testGetConnectionStringProperties() throws SQLException {
+ String validURL1 = "jdbc:mikes1:data2";
+ String validuser1 = "theuser";
+ String validpassword1 = "thepassword";
+ String invalidURL1 = "xyz:abc1:foo";
+ String invalidURL2 = "jdbc:mikes1:crazyone";
+ String invalidURL3 = "";
+ String invaliduser1 = "jonny nouser";
+ String invalidpassword1 = "whizz";
+ Properties nullProps = null;
+ Properties validProps = new Properties();
+ validProps.setProperty("user", validuser1);
+ validProps.setProperty("password", validpassword1);
+ Properties invalidProps1 = new Properties();
+ invalidProps1.setProperty("user", invaliduser1);
+ invalidProps1.setProperty("password", invalidpassword1);
+ String[] invalidURLs = { null, invalidURL1, invalidURL2, invalidURL3 };
+ Properties[] invalidProps = { nullProps, invalidProps1 };
- Connection theConnection = null;
- // validConnection - user & password required
+ Connection theConnection = null;
+ // validConnection - user & password required
theConnection = DriverManager.getConnection(validURL1, validProps);
assertNotNull(theConnection);
- // invalid Connections
- for (int i = 0; i < invalidURLs.length; i++) {
- theConnection = null;
- try {
- theConnection = DriverManager.getConnection(invalidURLs[i],
- validProps);
- fail("Should throw SQLException");
- } catch (SQLException e) {
- //expected
- } // end try
- } // end for
+ // invalid Connections
+ for (int i = 0; i < invalidURLs.length; i++) {
+ theConnection = null;
+ try {
+ theConnection = DriverManager.getConnection(invalidURLs[i],
+ validProps);
+ fail("Should throw SQLException");
+ } catch (SQLException e) {
+ // expected
+ } // end try
+ } // end for
for (Properties invalidProp : invalidProps) {
assertNotNull(DriverManager.getConnection(validURL1, invalidProp));
- }
- } // end method testGetConnectionStringProperties()
+ }
+ } // end method testGetConnectionStringProperties()
- /*
- * Class under test for Connection getConnection(String, String, String)
- */
- public void testGetConnectionStringStringString() throws SQLException {
- String validURL1 = "jdbc:mikes1:data2";
- String validuser1 = "theuser";
- String validpassword1 = "thepassword";
- String invalidURL1 = "xyz:abc1:foo";
- String invaliduser1 = "jonny nouser";
- String invalidpassword1 = "whizz";
- String[] invalid1 = { null, validuser1, validpassword1 };
- String[] invalid2 = { validURL1, null, validpassword1 };
- String[] invalid3 = { validURL1, validuser1, null };
- String[] invalid4 = { invalidURL1, validuser1, validpassword1 };
- String[] invalid5 = { validURL1, invaliduser1, invalidpassword1 };
- String[] invalid6 = { validURL1, validuser1, invalidpassword1 };
- String[][] invalids1 = { invalid1, invalid4};
- String[][] invalids2 = {invalid2, invalid3, invalid5, invalid6 };
+ /*
+ * Class under test for Connection getConnection(String, String, String)
+ */
+ public void testGetConnectionStringStringString() throws SQLException {
+ String validURL1 = "jdbc:mikes1:data2";
+ String validuser1 = "theuser";
+ String validpassword1 = "thepassword";
+ String invalidURL1 = "xyz:abc1:foo";
+ String invaliduser1 = "jonny nouser";
+ String invalidpassword1 = "whizz";
+ String[] invalid1 = { null, validuser1, validpassword1 };
+ String[] invalid2 = { validURL1, null, validpassword1 };
+ String[] invalid3 = { validURL1, validuser1, null };
+ String[] invalid4 = { invalidURL1, validuser1, validpassword1 };
+ String[] invalid5 = { validURL1, invaliduser1, invalidpassword1 };
+ String[] invalid6 = { validURL1, validuser1, invalidpassword1 };
+ String[][] invalids1 = { invalid1, invalid4 };
+ String[][] invalids2 = { invalid2, invalid3, invalid5, invalid6 };
- Connection theConnection = null;
- // validConnection - user & password required
+ Connection theConnection = null;
+ // validConnection - user & password required
theConnection = DriverManager.getConnection(validURL1, validuser1,
validpassword1);
assertNotNull(theConnection);
- for (String[] theData : invalids1) {
- theConnection = null;
- try {
- theConnection = DriverManager.getConnection(theData[0],
- theData[1], theData[2]);
- fail("Should throw SQLException.");
- } catch (SQLException e) {
- //expected
- } // end try
- } // end for
+ for (String[] theData : invalids1) {
+ theConnection = null;
+ try {
+ theConnection = DriverManager.getConnection(theData[0],
+ theData[1], theData[2]);
+ fail("Should throw SQLException.");
+ } catch (SQLException e) {
+ // expected
+ } // end try
+ } // end for
for (String[] theData : invalids2) {
assertNotNull(DriverManager.getConnection(theData[0], theData[1],
theData[2]));
- }
- } // end method testGetConnectionStringStringString()
+ }
+ } // end method testGetConnectionStringStringString()
- static String validURL1 = "jdbc:mikes1";
+ static String validURL1 = "jdbc:mikes1";
- static String validURL2 = "jdbc:mikes2";
+ static String validURL2 = "jdbc:mikes2";
- static String invalidURL1 = "xyz:acb";
+ static String invalidURL1 = "xyz:acb";
- static String invalidURL2 = null;
+ static String invalidURL2 = null;
- static String[] validURLs = { validURL1, validURL2 };
+ static String[] validURLs = { validURL1, validURL2 };
- static String[] invalidURLs = { invalidURL1, invalidURL2 };
+ static String[] invalidURLs = { invalidURL1, invalidURL2 };
- static String exceptionMsg1 = "No suitable driver";
+ static String exceptionMsg1 = "No suitable driver";
- public void testGetDriver() throws SQLException {
- for (String element : validURLs) {
+ public void testGetDriver() throws SQLException {
+ for (String element : validURLs) {
Driver validDriver = DriverManager.getDriver(element);
assertNotNull(validDriver);
} // end for
- for (String element : invalidURLs) {
- try {
- DriverManager.getDriver(element);
+ for (String element : invalidURLs) {
+ try {
+ DriverManager.getDriver(element);
fail("Should throw SQLException");
- } catch (SQLException e) {
+ } catch (SQLException e) {
assertEquals("08001", e.getSQLState());
- assertEquals(exceptionMsg1, e.getMessage());
- } // end try
- } // end for
-
- } // end method testGetDriver()
-
- public void testGetDrivers() {
- // Load a driver manager
- Enumeration<Driver> driverList = DriverManager.getDrivers();
- int i = 0;
- while (driverList.hasMoreElements()) {
- Driver theDriver = driverList.nextElement();
+ assertEquals(exceptionMsg1, e.getMessage());
+ } // end try
+ } // end for
+
+ } // end method testGetDriver()
+
+ public void testGetDrivers() {
+ // Load a driver manager
+ Enumeration<Driver> driverList = DriverManager.getDrivers();
+ int i = 0;
+ while (driverList.hasMoreElements()) {
+ Driver theDriver = driverList.nextElement();
assertNotNull(theDriver);
- i++;
- } // end while
+ i++;
+ } // end while
- // Check that all the drivers are in the list...
- assertEquals("testGetDrivers: Don't see all the loaded drivers - ", i,
- numberLoaded);
- } // end method testGetDrivers()
-
- static int timeout1 = 25;
-
- public void testGetLoginTimeout() {
- DriverManager.setLoginTimeout(timeout1);
- assertEquals(timeout1, DriverManager.getLoginTimeout());
- } // end method testGetLoginTimeout()
+ // Check that all the drivers are in the list...
+ assertEquals("testGetDrivers: Don't see all the loaded drivers - ", i,
+ numberLoaded);
+ } // end method testGetDrivers()
+
+ static int timeout1 = 25;
+
+ public void testGetLoginTimeout() {
+ DriverManager.setLoginTimeout(timeout1);
+ assertEquals(timeout1, DriverManager.getLoginTimeout());
+ } // end method testGetLoginTimeout()
- @SuppressWarnings("deprecation")
+ @SuppressWarnings("deprecation")
public void testGetLogStream() {
- assertNull(DriverManager.getLogStream());
+ assertNull(DriverManager.getLogStream());
- DriverManager.setLogStream(testPrintStream);
- assertTrue(DriverManager.getLogStream() == testPrintStream);
+ DriverManager.setLogStream(testPrintStream);
+ assertTrue(DriverManager.getLogStream() == testPrintStream);
- DriverManager.setLogStream(null);
- } // end method testGetLogStream()
+ DriverManager.setLogStream(null);
+ } // end method testGetLogStream()
- public void testGetLogWriter() {
- assertNull(DriverManager.getLogWriter());
+ public void testGetLogWriter() {
+ assertNull(DriverManager.getLogWriter());
- DriverManager.setLogWriter(testPrintWriter);
+ DriverManager.setLogWriter(testPrintWriter);
- assertTrue(DriverManager.getLogWriter() == testPrintWriter);
+ assertTrue(DriverManager.getLogWriter() == testPrintWriter);
- DriverManager.setLogWriter(null);
- } // end method testGetLogWriter()
+ DriverManager.setLogWriter(null);
+ } // end method testGetLogWriter()
- static String testMessage = "DriverManagerTest: test message for print stream";
+ static String testMessage = "DriverManagerTest: test message for print stream";
- @SuppressWarnings("deprecation")
+ @SuppressWarnings("deprecation")
public void testPrintln() {
- // System.out.println("testPrintln");
- DriverManager.println(testMessage);
+ // System.out.println("testPrintln");
+ DriverManager.println(testMessage);
- DriverManager.setLogWriter(testPrintWriter);
- DriverManager.println(testMessage);
+ DriverManager.setLogWriter(testPrintWriter);
+ DriverManager.println(testMessage);
- String theOutput = outputStream.toString();
- // System.out.println("testPrintln: output= " + theOutput );
- assertTrue(theOutput.startsWith(testMessage));
+ String theOutput = outputStream.toString();
+ // System.out.println("testPrintln: output= " + theOutput );
+ assertTrue(theOutput.startsWith(testMessage));
- DriverManager.setLogWriter(null);
+ DriverManager.setLogWriter(null);
- DriverManager.setLogStream(testPrintStream);
- DriverManager.println(testMessage);
+ DriverManager.setLogStream(testPrintStream);
+ DriverManager.println(testMessage);
- theOutput = outputStream2.toString();
- // System.out.println("testPrintln: output= " + theOutput );
- assertTrue(theOutput.startsWith(testMessage));
+ theOutput = outputStream2.toString();
+ // System.out.println("testPrintln: output= " + theOutput );
+ assertTrue(theOutput.startsWith(testMessage));
- DriverManager.setLogStream(null);
- } // end method testPrintln()
+ DriverManager.setLogStream(null);
+ } // end method testPrintln()
- public void testRegisterDriver() throws ClassNotFoundException,
+ public void testRegisterDriver() throws ClassNotFoundException,
SQLException, IllegalAccessException, InstantiationException {
String EXTRA_DRIVER_NAME = "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver3";
@@ -409,178 +406,177 @@
} // end testRegisterDriver()
- static int validTimeout1 = 15;
+ static int validTimeout1 = 15;
- static int validTimeout2 = 0;
+ static int validTimeout2 = 0;
- static int[] validTimeouts = { validTimeout1, validTimeout2 };
+ static int[] validTimeouts = { validTimeout1, validTimeout2 };
- static int invalidTimeout1 = -10;
+ static int invalidTimeout1 = -10;
- public void testSetLoginTimeout() {
- for (int element : validTimeouts) {
- DriverManager.setLoginTimeout(element);
+ public void testSetLoginTimeout() {
+ for (int element : validTimeouts) {
+ DriverManager.setLoginTimeout(element);
- assertEquals(element, DriverManager.getLoginTimeout());
- } // end for
- // Invalid timeouts
- DriverManager.setLoginTimeout(invalidTimeout1);
+ assertEquals(element, DriverManager.getLoginTimeout());
+ } // end for
+ // Invalid timeouts
+ DriverManager.setLoginTimeout(invalidTimeout1);
assertEquals(invalidTimeout1, DriverManager.getLoginTimeout());
- } // end testSetLoginTimeout()
+ } // end testSetLoginTimeout()
- static ByteArrayOutputStream outputStream2 = new ByteArrayOutputStream();
+ static ByteArrayOutputStream outputStream2 = new ByteArrayOutputStream();
- static PrintStream testPrintStream = new PrintStream(outputStream2);
+ static PrintStream testPrintStream = new PrintStream(outputStream2);
- @SuppressWarnings("deprecation")
+ @SuppressWarnings("deprecation")
public void testSetLogStream() {
- // System.out.println("testSetLogStream");
- DriverManager.setLogStream(testPrintStream);
+ // System.out.println("testSetLogStream");
+ DriverManager.setLogStream(testPrintStream);
- assertSame(testPrintStream, DriverManager.getLogStream());
+ assertSame(testPrintStream, DriverManager.getLogStream());
- DriverManager.setLogStream(null);
+ DriverManager.setLogStream(null);
- assertNull(DriverManager.getLogStream());
+ assertNull(DriverManager.getLogStream());
- // Now let's deal with the case where there is a SecurityManager in
- // place
- TestSecurityManager theSecManager = new TestSecurityManager();
- System.setSecurityManager(theSecManager);
+ // Now let's deal with the case where there is a SecurityManager in
+ // place
+ TestSecurityManager theSecManager = new TestSecurityManager();
+ System.setSecurityManager(theSecManager);
- theSecManager.setLogAccess(false);
+ theSecManager.setLogAccess(false);
- try {
- DriverManager.setLogStream(testPrintStream);
- fail("Should throw SecurityException.");
- } catch (SecurityException s) {
- //expected
- }
+ try {
+ DriverManager.setLogStream(testPrintStream);
+ fail("Should throw SecurityException.");
+ } catch (SecurityException s) {
+ // expected
+ }
- theSecManager.setLogAccess(true);
+ theSecManager.setLogAccess(true);
- DriverManager.setLogStream(testPrintStream);
+ DriverManager.setLogStream(testPrintStream);
- System.setSecurityManager(null);
- } // end method testSetLogStream()
+ System.setSecurityManager(null);
+ } // end method testSetLogStream()
- static ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ static ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- static PrintWriter testPrintWriter = new PrintWriter(outputStream);
+ static PrintWriter testPrintWriter = new PrintWriter(outputStream);
- /**
- * Test for the setLogWriter method
- */
- public void testSetLogWriter() {
- // System.out.println("testSetLogWriter");
- DriverManager.setLogWriter(testPrintWriter);
+ /**
+ * Test for the setLogWriter method
+ */
+ public void testSetLogWriter() {
+ // System.out.println("testSetLogWriter");
+ DriverManager.setLogWriter(testPrintWriter);
- assertSame(testPrintWriter, DriverManager.getLogWriter());
+ assertSame(testPrintWriter, DriverManager.getLogWriter());
- DriverManager.setLogWriter(null);
+ DriverManager.setLogWriter(null);
- assertNull("testDriverManager: Log writer not null:", DriverManager
- .getLogWriter());
+ assertNull("testDriverManager: Log writer not null:", DriverManager
+ .getLogWriter());
- // Now let's deal with the case where there is a SecurityManager in
- // place
- TestSecurityManager theSecManager = new TestSecurityManager();
- System.setSecurityManager(theSecManager);
+ // Now let's deal with the case where there is a SecurityManager in
+ // place
+ TestSecurityManager theSecManager = new TestSecurityManager();
+ System.setSecurityManager(theSecManager);
- theSecManager.setLogAccess(false);
+ theSecManager.setLogAccess(false);
- try {
- DriverManager.setLogWriter(testPrintWriter);
- fail("Should throw SecurityException.");
- } catch (SecurityException s) {
- //expected
- }
+ try {
+ DriverManager.setLogWriter(testPrintWriter);
+ fail("Should throw SecurityException.");
+ } catch (SecurityException s) {
+ // expected
+ }
- theSecManager.setLogAccess(true);
+ theSecManager.setLogAccess(true);
DriverManager.setLogWriter(testPrintWriter);
- System.setSecurityManager(null);
- } // end method testSetLogWriter()
+ System.setSecurityManager(null);
+ } // end method testSetLogWriter()
- /*
- * Method which loads a set of JDBC drivers ready for use by the various
- * tests @return the number of drivers loaded
- */
- static boolean driversLoaded = false;
+ /*
+ * Method which loads a set of JDBC drivers ready for use by the various
+ * tests @return the number of drivers loaded
+ */
+ static boolean driversLoaded = false;
- private static int loadDrivers() {
- if (driversLoaded) {
+ private static int loadDrivers() {
+ if (driversLoaded) {
return numberLoaded;
}
- /*
- * First define a value for the System property "jdbc.drivers" - before
- * the DriverManager class is loaded - this property defines a set of
- * drivers which the DriverManager will load during its initialization
- * and which will be loaded on the System ClassLoader - unlike the ones
- * loaded later by this method which are loaded on the Application
- * ClassLoader.
- */
- int numberLoaded = 0;
- String theSystemDrivers = DRIVER4 + ":" + DRIVER5 + ":"
- + INVALIDDRIVER1;
- System.setProperty(JDBC_PROPERTY, theSystemDrivers);
- numberLoaded += 2;
-
- for (String element : driverNames) {
- try {
- Class<?> driverClass = Class.forName(element);
+ /*
+ * First define a value for the System property "jdbc.drivers" - before
+ * the DriverManager class is loaded - this property defines a set of
+ * drivers which the DriverManager will load during its initialization
+ * and which will be loaded on the System ClassLoader - unlike the ones
+ * loaded later by this method which are loaded on the Application
+ * ClassLoader.
+ */
+ int numberLoaded = 0;
+ String theSystemDrivers = DRIVER4 + ":" + DRIVER5 + ":"
+ + INVALIDDRIVER1;
+ System.setProperty(JDBC_PROPERTY, theSystemDrivers);
+ numberLoaded += 2;
+
+ for (String element : driverNames) {
+ try {
+ Class<?> driverClass = Class.forName(element);
assertNotNull(driverClass);
- // System.out.println("Loaded driver - classloader = " +
- // driverClass.getClassLoader());
- numberLoaded++;
- } catch (ClassNotFoundException e) {
- System.out.println("DriverManagerTest: failed to load Driver: "
- + element);
- } // end try
- } // end for
- /*
- * System.out.println("DriverManagerTest: number of drivers loaded: " +
- * numberLoaded);
- */
- driversLoaded = true;
- return numberLoaded;
- } // end method loadDrivers()
-
- class TestSecurityManager extends SecurityManager {
-
- boolean logAccess = true;
-
- SQLPermission sqlPermission = new SQLPermission("setLog");
-
- RuntimePermission setManagerPermission = new RuntimePermission(
- "setSecurityManager");
-
- TestSecurityManager() {
- super();
- } // end method TestSecurityManager()
-
- void setLogAccess(boolean allow) {
- logAccess = allow;
- } // end method setLogAccess( boolean )
+ // System.out.println("Loaded driver - classloader = " +
+ // driverClass.getClassLoader());
+ numberLoaded++;
+ } catch (ClassNotFoundException e) {
+ System.out.println("DriverManagerTest: failed to load Driver: "
+ + element);
+ } // end try
+ } // end for
+ /*
+ * System.out.println("DriverManagerTest: number of drivers loaded: " +
+ * numberLoaded);
+ */
+ driversLoaded = true;
+ return numberLoaded;
+ } // end method loadDrivers()
+
+ class TestSecurityManager extends SecurityManager {
+
+ boolean logAccess = true;
+
+ SQLPermission sqlPermission = new SQLPermission("setLog");
+
+ RuntimePermission setManagerPermission = new RuntimePermission(
+ "setSecurityManager");
+
+ TestSecurityManager() {
+ super();
+ } // end method TestSecurityManager()
+
+ void setLogAccess(boolean allow) {
+ logAccess = allow;
+ } // end method setLogAccess( boolean )
- @Override
+ @Override
public void checkPermission(Permission thePermission) {
- if (thePermission.equals(sqlPermission)) {
- if (!logAccess) {
- throw new SecurityException("Cannot set the sql Log Writer");
- } // end if
- return;
- } // end if
-
- if (thePermission.equals(setManagerPermission)) {
- return;
- } // end if
- // super.checkPermission( thePermission );
- } // end method checkPermission( Permission )
-
- } // end class TestSecurityManager
-
-
+ if (thePermission.equals(sqlPermission)) {
+ if (!logAccess) {
+ throw new SecurityException("Cannot set the sql Log Writer");
+ } // end if
+ return;
+ } // end if
+
+ if (thePermission.equals(setManagerPermission)) {
+ return;
+ } // end if
+ // super.checkPermission( thePermission );
+ } // end method checkPermission( Permission )
+
+ } // end class TestSecurityManager
+
/**
* @tests {@link java.sql.DriverManager#registerDriver(Driver)}
*
@@ -604,7 +600,7 @@
Driver d = DriverManager.getDriver("jdbc:dummy_protocol:dummy_subname");
assertNotNull(d);
}
-
+
/**
* Regression for HARMONY-4303
*/
@@ -614,7 +610,7 @@
String result = Support_Exec.execJava(arg, null, true);
assertEquals("", result);
}
-
+
private static class BadDummyDriver extends DummyDriver {
public boolean acceptsURL(String url) {
return false;
@@ -650,7 +646,6 @@
}
}
-
-} // end class DriverManagerTest
+} // end class DriverManagerTest
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java Mon Jul 16 02:02:56 2007
@@ -29,79 +29,79 @@
public class DriverPropertyInfoTest extends TestCase {
- /*
- * Public statics test
- */
- public void testPublicStatics() {
+ /*
+ * Public statics test
+ */
+ public void testPublicStatics() {
- } // end method testPublicStatics
+ } // end method testPublicStatics
- /*
- * Constructor test
- */
- public void testDriverPropertyInfoStringString() {
+ /*
+ * Constructor test
+ */
+ public void testDriverPropertyInfoStringString() {
- DriverPropertyInfo aDriverPropertyInfo = new DriverPropertyInfo(
- validName, validValue);
+ DriverPropertyInfo aDriverPropertyInfo = new DriverPropertyInfo(
+ validName, validValue);
- assertNotNull(aDriverPropertyInfo);
+ assertNotNull(aDriverPropertyInfo);
- aDriverPropertyInfo = new DriverPropertyInfo(null, null);
+ aDriverPropertyInfo = new DriverPropertyInfo(null, null);
- } // end method testDriverPropertyInfoStringString
+ } // end method testDriverPropertyInfoStringString
- /*
- * Public fields test
- */
- static String validName = "testname";
+ /*
+ * Public fields test
+ */
+ static String validName = "testname";
- static String validValue = "testvalue";
+ static String validValue = "testvalue";
- static String[] updateChoices = { "Choice1", "Choice2", "Choice3" };
+ static String[] updateChoices = { "Choice1", "Choice2", "Choice3" };
- static String updateValue = "updateValue";
+ static String updateValue = "updateValue";
- static boolean updateRequired = true;
+ static boolean updateRequired = true;
- static String updateDescription = "update description";
+ static String updateDescription = "update description";
- static String updateName = "updateName";
+ static String updateName = "updateName";
- public void testPublicFields() {
+ public void testPublicFields() {
- // Constructor here...
- DriverPropertyInfo aDriverPropertyInfo = new DriverPropertyInfo(
- validName, validValue);
+ // Constructor here...
+ DriverPropertyInfo aDriverPropertyInfo = new DriverPropertyInfo(
+ validName, validValue);
- assertTrue(Arrays.equals(testChoices, aDriverPropertyInfo.choices));
- assertEquals(testValue, aDriverPropertyInfo.value);
- assertEquals(testRequired, aDriverPropertyInfo.required);
- assertEquals(testDescription, aDriverPropertyInfo.description);
- assertEquals(testName, aDriverPropertyInfo.name);
+ assertTrue(Arrays.equals(testChoices, aDriverPropertyInfo.choices));
+ assertEquals(testValue, aDriverPropertyInfo.value);
+ assertEquals(testRequired, aDriverPropertyInfo.required);
+ assertEquals(testDescription, aDriverPropertyInfo.description);
+ assertEquals(testName, aDriverPropertyInfo.name);
- aDriverPropertyInfo.choices = updateChoices;
- aDriverPropertyInfo.value = updateValue;
- aDriverPropertyInfo.required = updateRequired;
- aDriverPropertyInfo.description = updateDescription;
- aDriverPropertyInfo.name = updateName;
+ aDriverPropertyInfo.choices = updateChoices;
+ aDriverPropertyInfo.value = updateValue;
+ aDriverPropertyInfo.required = updateRequired;
+ aDriverPropertyInfo.description = updateDescription;
+ aDriverPropertyInfo.name = updateName;
- assertTrue(Arrays.equals(updateChoices, aDriverPropertyInfo.choices));
- assertEquals(updateValue, aDriverPropertyInfo.value);
- assertEquals(updateRequired, aDriverPropertyInfo.required);
- assertEquals(updateDescription, aDriverPropertyInfo.description);
- assertEquals(updateName, aDriverPropertyInfo.name);
+ assertTrue(Arrays.equals(updateChoices, aDriverPropertyInfo.choices));
+ assertEquals(updateValue, aDriverPropertyInfo.value);
+ assertEquals(updateRequired, aDriverPropertyInfo.required);
+ assertEquals(updateDescription, aDriverPropertyInfo.description);
+ assertEquals(updateName, aDriverPropertyInfo.name);
- } // end method testPublicFields
+ } // end method testPublicFields
- // Default values...
- static String[] testChoices = null;
+ // Default values...
+ static String[] testChoices = null;
- static java.lang.String testValue = validValue;
+ static java.lang.String testValue = validValue;
- static boolean testRequired = false;
+ static boolean testRequired = false;
- static java.lang.String testDescription = null;
+ static java.lang.String testDescription = null;
- static java.lang.String testName = validName;
+ static java.lang.String testName = validName;
} // end class DriverPropertyInfoTest
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ParameterMetaDataTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ParameterMetaDataTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ParameterMetaDataTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ParameterMetaDataTest.java Mon Jul 16 02:02:56 2007
@@ -25,70 +25,70 @@
public class ParameterMetaDataTest extends TestCase {
- /*
- * Public statics test
- */
- public void testPublicStatics() {
-
- HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
- thePublicStatics.put("parameterModeOut", new Integer(4));
- thePublicStatics.put("parameterModeInOut", new Integer(2));
- thePublicStatics.put("parameterModeIn", new Integer(1));
- thePublicStatics.put("parameterModeUnknown", new Integer(0));
- thePublicStatics.put("parameterNullableUnknown", new Integer(2));
- thePublicStatics.put("parameterNullable", new Integer(1));
- thePublicStatics.put("parameterNoNulls", new Integer(0));
-
- /*
- * System.out.println( "parameterModeOut: " +
- * ParameterMetaData.parameterModeOut ); System.out.println(
- * "parameterModeInOut: " + ParameterMetaData.parameterModeInOut );
- * System.out.println( "parameterModeIn: " +
- * ParameterMetaData.parameterModeIn ); System.out.println(
- * "parameterModeUnknown: " + ParameterMetaData.parameterModeUnknown );
- * System.out.println( "parameterNullableUnknown: " +
- * ParameterMetaData.parameterNullableUnknown ); System.out.println(
- * "parameterNullable: " + ParameterMetaData.parameterNullable );
- * System.out.println( "parameterNoNulls: " +
- * ParameterMetaData.parameterNoNulls );
- */
-
- Class<?> parameterMetaDataClass;
- try {
- parameterMetaDataClass = Class
- .forName("java.sql.ParameterMetaData");
- } catch (ClassNotFoundException e) {
- fail("java.sql.ParameterMetaData class not found!");
- return;
- } // end try
-
- Field[] theFields = parameterMetaDataClass.getDeclaredFields();
- int requiredModifier = Modifier.PUBLIC + Modifier.STATIC
- + Modifier.FINAL;
-
- int countPublicStatics = 0;
- for (Field element : theFields) {
- String fieldName = element.getName();
- int theMods = element.getModifiers();
- if (Modifier.isPublic(theMods) && Modifier.isStatic(theMods)) {
- try {
- Object fieldValue = element.get(null);
- Object expectedValue = thePublicStatics.get(fieldName);
- if (expectedValue == null) {
- fail("Field " + fieldName + " missing!");
- } // end
- assertEquals("Field " + fieldName + " value mismatch: ",
- expectedValue, fieldValue);
- assertEquals("Field " + fieldName + " modifier mismatch: ",
- requiredModifier, theMods);
- countPublicStatics++;
- } catch (IllegalAccessException e) {
- fail("Illegal access to Field " + fieldName);
- } // end try
- } // end if
- } // end for
+ /*
+ * Public statics test
+ */
+ public void testPublicStatics() {
+
+ HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
+ thePublicStatics.put("parameterModeOut", new Integer(4));
+ thePublicStatics.put("parameterModeInOut", new Integer(2));
+ thePublicStatics.put("parameterModeIn", new Integer(1));
+ thePublicStatics.put("parameterModeUnknown", new Integer(0));
+ thePublicStatics.put("parameterNullableUnknown", new Integer(2));
+ thePublicStatics.put("parameterNullable", new Integer(1));
+ thePublicStatics.put("parameterNoNulls", new Integer(0));
+
+ /*
+ * System.out.println( "parameterModeOut: " +
+ * ParameterMetaData.parameterModeOut ); System.out.println(
+ * "parameterModeInOut: " + ParameterMetaData.parameterModeInOut );
+ * System.out.println( "parameterModeIn: " +
+ * ParameterMetaData.parameterModeIn ); System.out.println(
+ * "parameterModeUnknown: " + ParameterMetaData.parameterModeUnknown );
+ * System.out.println( "parameterNullableUnknown: " +
+ * ParameterMetaData.parameterNullableUnknown ); System.out.println(
+ * "parameterNullable: " + ParameterMetaData.parameterNullable );
+ * System.out.println( "parameterNoNulls: " +
+ * ParameterMetaData.parameterNoNulls );
+ */
+
+ Class<?> parameterMetaDataClass;
+ try {
+ parameterMetaDataClass = Class
+ .forName("java.sql.ParameterMetaData");
+ } catch (ClassNotFoundException e) {
+ fail("java.sql.ParameterMetaData class not found!");
+ return;
+ } // end try
+
+ Field[] theFields = parameterMetaDataClass.getDeclaredFields();
+ int requiredModifier = Modifier.PUBLIC + Modifier.STATIC
+ + Modifier.FINAL;
+
+ int countPublicStatics = 0;
+ for (Field element : theFields) {
+ String fieldName = element.getName();
+ int theMods = element.getModifiers();
+ if (Modifier.isPublic(theMods) && Modifier.isStatic(theMods)) {
+ try {
+ Object fieldValue = element.get(null);
+ Object expectedValue = thePublicStatics.get(fieldName);
+ if (expectedValue == null) {
+ fail("Field " + fieldName + " missing!");
+ } // end
+ assertEquals("Field " + fieldName + " value mismatch: ",
+ expectedValue, fieldValue);
+ assertEquals("Field " + fieldName + " modifier mismatch: ",
+ requiredModifier, theMods);
+ countPublicStatics++;
+ } catch (IllegalAccessException e) {
+ fail("Illegal access to Field " + fieldName);
+ } // end try
+ } // end if
+ } // end for
- } // end method testPublicStatics
+ } // end method testPublicStatics
} // end class ParameterMetaDataTest
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetMetaDataTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetMetaDataTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetMetaDataTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetMetaDataTest.java Mon Jul 16 02:02:56 2007
@@ -25,60 +25,60 @@
public class ResultSetMetaDataTest extends TestCase {
- /*
- * Public statics test
- */
- public void testPublicStatics() {
-
- HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
- thePublicStatics.put("columnNullableUnknown", new Integer(2));
- thePublicStatics.put("columnNullable", new Integer(1));
- thePublicStatics.put("columnNoNulls", new Integer(0));
-
- /*
- * System.out.println( "columnNullableUnknown: " +
- * ResultSetMetaData.columnNullableUnknown ); System.out.println(
- * "columnNullable: " + ResultSetMetaData.columnNullable );
- * System.out.println( "columnNoNulls: " +
- * ResultSetMetaData.columnNoNulls );
- */
-
- Class<?> resultSetMetaDataClass;
- try {
- resultSetMetaDataClass = Class
- .forName("java.sql.ResultSetMetaData");
- } catch (ClassNotFoundException e) {
- fail("java.sql.ResultSetMetaData class not found!");
- return;
- } // end try
-
- Field[] theFields = resultSetMetaDataClass.getDeclaredFields();
- int requiredModifier = Modifier.PUBLIC + Modifier.STATIC
- + Modifier.FINAL;
-
- int countPublicStatics = 0;
- for (Field element : theFields) {
- String fieldName = element.getName();
- int theMods = element.getModifiers();
- if (Modifier.isPublic(theMods) && Modifier.isStatic(theMods)) {
- try {
- Object fieldValue = element.get(null);
- Object expectedValue = thePublicStatics.get(fieldName);
- if (expectedValue == null) {
- fail("Field " + fieldName + " missing!");
- } // end
- assertEquals("Field " + fieldName + " value mismatch: ",
- expectedValue, fieldValue);
- assertEquals("Field " + fieldName + " modifier mismatch: ",
- requiredModifier, theMods);
- countPublicStatics++;
- } catch (IllegalAccessException e) {
- fail("Illegal access to Field " + fieldName);
- } // end try
- } // end if
- } // end for
+ /*
+ * Public statics test
+ */
+ public void testPublicStatics() {
+
+ HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
+ thePublicStatics.put("columnNullableUnknown", new Integer(2));
+ thePublicStatics.put("columnNullable", new Integer(1));
+ thePublicStatics.put("columnNoNulls", new Integer(0));
+
+ /*
+ * System.out.println( "columnNullableUnknown: " +
+ * ResultSetMetaData.columnNullableUnknown ); System.out.println(
+ * "columnNullable: " + ResultSetMetaData.columnNullable );
+ * System.out.println( "columnNoNulls: " +
+ * ResultSetMetaData.columnNoNulls );
+ */
+
+ Class<?> resultSetMetaDataClass;
+ try {
+ resultSetMetaDataClass = Class
+ .forName("java.sql.ResultSetMetaData");
+ } catch (ClassNotFoundException e) {
+ fail("java.sql.ResultSetMetaData class not found!");
+ return;
+ } // end try
+
+ Field[] theFields = resultSetMetaDataClass.getDeclaredFields();
+ int requiredModifier = Modifier.PUBLIC + Modifier.STATIC
+ + Modifier.FINAL;
+
+ int countPublicStatics = 0;
+ for (Field element : theFields) {
+ String fieldName = element.getName();
+ int theMods = element.getModifiers();
+ if (Modifier.isPublic(theMods) && Modifier.isStatic(theMods)) {
+ try {
+ Object fieldValue = element.get(null);
+ Object expectedValue = thePublicStatics.get(fieldName);
+ if (expectedValue == null) {
+ fail("Field " + fieldName + " missing!");
+ } // end
+ assertEquals("Field " + fieldName + " value mismatch: ",
+ expectedValue, fieldValue);
+ assertEquals("Field " + fieldName + " modifier mismatch: ",
+ requiredModifier, theMods);
+ countPublicStatics++;
+ } catch (IllegalAccessException e) {
+ fail("Illegal access to Field " + fieldName);
+ } // end try
+ } // end if
+ } // end for
- } // end method testPublicStatics
+ } // end method testPublicStatics
} // end class ResultSetMetaDataTest
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetTest.java Mon Jul 16 02:02:56 2007
@@ -25,77 +25,77 @@
public class ResultSetTest extends TestCase {
- /*
- * Public statics test
- */
- public void testPublicStatics() {
-
- HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
- thePublicStatics.put("CLOSE_CURSORS_AT_COMMIT",
- new java.lang.Integer(2));
- thePublicStatics.put("HOLD_CURSORS_OVER_COMMIT", new java.lang.Integer(
- 1));
- thePublicStatics.put("CONCUR_UPDATABLE", new java.lang.Integer(1008));
- thePublicStatics.put("CONCUR_READ_ONLY", new java.lang.Integer(1007));
- thePublicStatics.put("TYPE_SCROLL_SENSITIVE", new java.lang.Integer(
- 1005));
- thePublicStatics.put("TYPE_SCROLL_INSENSITIVE", new java.lang.Integer(
- 1004));
- thePublicStatics.put("TYPE_FORWARD_ONLY", new java.lang.Integer(1003));
- thePublicStatics.put("FETCH_UNKNOWN", new java.lang.Integer(1002));
- thePublicStatics.put("FETCH_REVERSE", new java.lang.Integer(1001));
- thePublicStatics.put("FETCH_FORWARD", new java.lang.Integer(1000));
-
- /*
- * System.out.println( "CLOSE_CURSORS_AT_COMMIT: " +
- * ResultSet.CLOSE_CURSORS_AT_COMMIT ); System.out.println(
- * "HOLD_CURSORS_OVER_COMMIT: " + ResultSet.HOLD_CURSORS_OVER_COMMIT );
- * System.out.println( "CONCUR_UPDATABLE: " + ResultSet.CONCUR_UPDATABLE );
- * System.out.println( "CONCUR_READ_ONLY: " + ResultSet.CONCUR_READ_ONLY );
- * System.out.println( "TYPE_SCROLL_SENSITIVE: " +
- * ResultSet.TYPE_SCROLL_SENSITIVE ); System.out.println(
- * "TYPE_SCROLL_INSENSITIVE: " + ResultSet.TYPE_SCROLL_INSENSITIVE );
- * System.out.println( "TYPE_FORWARD_ONLY: " +
- * ResultSet.TYPE_FORWARD_ONLY ); System.out.println( "FETCH_UNKNOWN: " +
- * ResultSet.FETCH_UNKNOWN ); System.out.println( "FETCH_REVERSE: " +
- * ResultSet.FETCH_REVERSE ); System.out.println( "FETCH_FORWARD: " +
- * ResultSet.FETCH_FORWARD );
- */
-
- Class<?> resultSetClass;
- try {
- resultSetClass = Class.forName("java.sql.ResultSet");
- } catch (ClassNotFoundException e) {
- fail("java.sql.ResultSet class not found!");
- return;
- } // end try
-
- Field[] theFields = resultSetClass.getDeclaredFields();
- int requiredModifier = Modifier.PUBLIC + Modifier.STATIC
- + Modifier.FINAL;
-
- int countPublicStatics = 0;
- for (Field element : theFields) {
- String fieldName = element.getName();
- int theMods = element.getModifiers();
- if (Modifier.isPublic(theMods) && Modifier.isStatic(theMods)) {
- try {
- Object fieldValue = element.get(null);
- Object expectedValue = thePublicStatics.get(fieldName);
- if (expectedValue == null) {
- fail("Field " + fieldName + " missing!");
- } // end
- assertEquals("Field " + fieldName + " value mismatch: ",
- expectedValue, fieldValue);
- assertEquals("Field " + fieldName + " modifier mismatch: ",
- requiredModifier, theMods);
- countPublicStatics++;
- } catch (IllegalAccessException e) {
- fail("Illegal access to Field " + fieldName);
- } // end try
- } // end if
- } // end for
+ /*
+ * Public statics test
+ */
+ public void testPublicStatics() {
+
+ HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
+ thePublicStatics.put("CLOSE_CURSORS_AT_COMMIT",
+ new java.lang.Integer(2));
+ thePublicStatics.put("HOLD_CURSORS_OVER_COMMIT", new java.lang.Integer(
+ 1));
+ thePublicStatics.put("CONCUR_UPDATABLE", new java.lang.Integer(1008));
+ thePublicStatics.put("CONCUR_READ_ONLY", new java.lang.Integer(1007));
+ thePublicStatics.put("TYPE_SCROLL_SENSITIVE", new java.lang.Integer(
+ 1005));
+ thePublicStatics.put("TYPE_SCROLL_INSENSITIVE", new java.lang.Integer(
+ 1004));
+ thePublicStatics.put("TYPE_FORWARD_ONLY", new java.lang.Integer(1003));
+ thePublicStatics.put("FETCH_UNKNOWN", new java.lang.Integer(1002));
+ thePublicStatics.put("FETCH_REVERSE", new java.lang.Integer(1001));
+ thePublicStatics.put("FETCH_FORWARD", new java.lang.Integer(1000));
+
+ /*
+ * System.out.println( "CLOSE_CURSORS_AT_COMMIT: " +
+ * ResultSet.CLOSE_CURSORS_AT_COMMIT ); System.out.println(
+ * "HOLD_CURSORS_OVER_COMMIT: " + ResultSet.HOLD_CURSORS_OVER_COMMIT );
+ * System.out.println( "CONCUR_UPDATABLE: " + ResultSet.CONCUR_UPDATABLE );
+ * System.out.println( "CONCUR_READ_ONLY: " + ResultSet.CONCUR_READ_ONLY );
+ * System.out.println( "TYPE_SCROLL_SENSITIVE: " +
+ * ResultSet.TYPE_SCROLL_SENSITIVE ); System.out.println(
+ * "TYPE_SCROLL_INSENSITIVE: " + ResultSet.TYPE_SCROLL_INSENSITIVE );
+ * System.out.println( "TYPE_FORWARD_ONLY: " +
+ * ResultSet.TYPE_FORWARD_ONLY ); System.out.println( "FETCH_UNKNOWN: " +
+ * ResultSet.FETCH_UNKNOWN ); System.out.println( "FETCH_REVERSE: " +
+ * ResultSet.FETCH_REVERSE ); System.out.println( "FETCH_FORWARD: " +
+ * ResultSet.FETCH_FORWARD );
+ */
+
+ Class<?> resultSetClass;
+ try {
+ resultSetClass = Class.forName("java.sql.ResultSet");
+ } catch (ClassNotFoundException e) {
+ fail("java.sql.ResultSet class not found!");
+ return;
+ } // end try
+
+ Field[] theFields = resultSetClass.getDeclaredFields();
+ int requiredModifier = Modifier.PUBLIC + Modifier.STATIC
+ + Modifier.FINAL;
+
+ int countPublicStatics = 0;
+ for (Field element : theFields) {
+ String fieldName = element.getName();
+ int theMods = element.getModifiers();
+ if (Modifier.isPublic(theMods) && Modifier.isStatic(theMods)) {
+ try {
+ Object fieldValue = element.get(null);
+ Object expectedValue = thePublicStatics.get(fieldName);
+ if (expectedValue == null) {
+ fail("Field " + fieldName + " missing!");
+ } // end
+ assertEquals("Field " + fieldName + " value mismatch: ",
+ expectedValue, fieldValue);
+ assertEquals("Field " + fieldName + " modifier mismatch: ",
+ requiredModifier, theMods);
+ countPublicStatics++;
+ } catch (IllegalAccessException e) {
+ fail("Illegal access to Field " + fieldName);
+ } // end try
+ } // end if
+ } // end for
- } // end method testPublicStatics
+ } // end method testPublicStatics
} // end class ResultSetTest
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
Binary files /tmp/tmpN_n1QP and /tmp/tmp8mL5cd differ
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java Mon Jul 16 02:02:56 2007
@@ -25,50 +25,49 @@
* JUnit Testcase for the java.sql.SQLPermission class
*
* Note that the SQLPermission class only defines 2 constructors and all other
- * methods are inherited. This testcase explicitly tets the constructors but also
- * implicitly tests some of the inherited query methods.
+ * methods are inherited. This testcase explicitly tets the constructors but
+ * also implicitly tests some of the inherited query methods.
*
*/
public class SQLPermissionTest extends TestCase {
- /*
- * Constructor test
- */
- public void testSQLPermissionStringString() {
- String validName = "setLog";
- String validActions = "theActions";
-
- SQLPermission thePermission = new SQLPermission(validName, validActions);
-
- assertNotNull(thePermission);
- assertEquals(validName, thePermission.getName());
- // System.out.println("The actions: " + thePermission.getActions() + "."
- // );
- assertEquals("", thePermission.getActions());
- } // end method testSQLPermissionStringString
-
- /*
- * Constructor test
- */
- public void testSQLPermissionString() {
- String validName = "setLog";
-
- SQLPermission thePermission = new SQLPermission(validName);
-
- assertNotNull(thePermission);
- assertEquals(validName, thePermission.getName());
-
- // Set an invalid name ...
- String invalidName = "foo";
-
- thePermission = new SQLPermission(invalidName);
-
- assertNotNull(thePermission);
- assertEquals(invalidName, thePermission.getName());
- assertEquals("", thePermission.getActions());
- } // end method testSQLPermissionString
+ /*
+ * Constructor test
+ */
+ public void testSQLPermissionStringString() {
+ String validName = "setLog";
+ String validActions = "theActions";
+
+ SQLPermission thePermission = new SQLPermission(validName, validActions);
+
+ assertNotNull(thePermission);
+ assertEquals(validName, thePermission.getName());
+ // System.out.println("The actions: " + thePermission.getActions() + "."
+ // );
+ assertEquals("", thePermission.getActions());
+ } // end method testSQLPermissionStringString
+
+ /*
+ * Constructor test
+ */
+ public void testSQLPermissionString() {
+ String validName = "setLog";
+
+ SQLPermission thePermission = new SQLPermission(validName);
+
+ assertNotNull(thePermission);
+ assertEquals(validName, thePermission.getName());
+
+ // Set an invalid name ...
+ String invalidName = "foo";
+
+ thePermission = new SQLPermission(invalidName);
+
+ assertNotNull(thePermission);
+ assertEquals(invalidName, thePermission.getName());
+ assertEquals("", thePermission.getActions());
+ } // end method testSQLPermissionString
} // end class SQLPermissionTest
-
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
Binary files /tmp/tmpXZu7Sd and /tmp/tmp3a6YuT differ