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/17 08:31:04 UTC
svn commit: r556825 [7/10] - in
/harmony/enhanced/classlib/branches/java6/modules:
archive/src/main/java/java/util/jar/ archive/src/main/java/java/util/zip/
archive/src/main/java/org/apache/harmony/archive/internal/nls/
archive/src/main/java/org/apache...
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java Mon Jul 16 23:30:22 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/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverPropertyInfoTest.java Mon Jul 16 23:30:22 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/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ParameterMetaDataTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ParameterMetaDataTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ParameterMetaDataTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ParameterMetaDataTest.java Mon Jul 16 23:30:22 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/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetMetaDataTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetMetaDataTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetMetaDataTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetMetaDataTest.java Mon Jul 16 23:30:22 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/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/ResultSetTest.java Mon Jul 16 23:30:22 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/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
Binary files /tmp/tmpLp-0uy and /tmp/tmph0vqZD differ
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java Mon Jul 16 23:30:22 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/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
Binary files /tmp/tmpoLobaL and /tmp/tmp9fyQjJ differ
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/StatementTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/StatementTest.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/StatementTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/StatementTest.java Mon Jul 16 23:30:22 2007
@@ -25,68 +25,68 @@
public class StatementTest extends TestCase {
- /*
- * Public statics test
- */
- public void testPublicStatics() {
-
- HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
- thePublicStatics.put("NO_GENERATED_KEYS", new Integer(2));
- thePublicStatics.put("RETURN_GENERATED_KEYS", new Integer(1));
- thePublicStatics.put("EXECUTE_FAILED", new Integer(-3));
- thePublicStatics.put("SUCCESS_NO_INFO", new Integer(-2));
- thePublicStatics.put("CLOSE_ALL_RESULTS", new Integer(3));
- thePublicStatics.put("KEEP_CURRENT_RESULT", new Integer(2));
- thePublicStatics.put("CLOSE_CURRENT_RESULT", new Integer(1));
-
- /*
- * System.out.println( "NO_GENERATED_KEYS: " +
- * Statement.NO_GENERATED_KEYS ); System.out.println(
- * "RETURN_GENERATED_KEYS: " + Statement.RETURN_GENERATED_KEYS );
- * System.out.println( "EXECUTE_FAILED: " + Statement.EXECUTE_FAILED );
- * System.out.println( "SUCCESS_NO_INFO: " + Statement.SUCCESS_NO_INFO );
- * System.out.println( "CLOSE_ALL_RESULTS: " +
- * Statement.CLOSE_ALL_RESULTS ); System.out.println(
- * "KEEP_CURRENT_RESULT: " + Statement.KEEP_CURRENT_RESULT );
- * System.out.println( "CLOSE_CURRENT_RESULT: " +
- * Statement.CLOSE_CURRENT_RESULT );
- */
-
- Class<?> statementClass;
- try {
- statementClass = Class.forName("java.sql.Statement");
- } catch (ClassNotFoundException e) {
- fail("java.sql.Statement class not found!");
- return;
- } // end try
-
- Field[] theFields = statementClass.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("NO_GENERATED_KEYS", new Integer(2));
+ thePublicStatics.put("RETURN_GENERATED_KEYS", new Integer(1));
+ thePublicStatics.put("EXECUTE_FAILED", new Integer(-3));
+ thePublicStatics.put("SUCCESS_NO_INFO", new Integer(-2));
+ thePublicStatics.put("CLOSE_ALL_RESULTS", new Integer(3));
+ thePublicStatics.put("KEEP_CURRENT_RESULT", new Integer(2));
+ thePublicStatics.put("CLOSE_CURRENT_RESULT", new Integer(1));
+
+ /*
+ * System.out.println( "NO_GENERATED_KEYS: " +
+ * Statement.NO_GENERATED_KEYS ); System.out.println(
+ * "RETURN_GENERATED_KEYS: " + Statement.RETURN_GENERATED_KEYS );
+ * System.out.println( "EXECUTE_FAILED: " + Statement.EXECUTE_FAILED );
+ * System.out.println( "SUCCESS_NO_INFO: " + Statement.SUCCESS_NO_INFO );
+ * System.out.println( "CLOSE_ALL_RESULTS: " +
+ * Statement.CLOSE_ALL_RESULTS ); System.out.println(
+ * "KEEP_CURRENT_RESULT: " + Statement.KEEP_CURRENT_RESULT );
+ * System.out.println( "CLOSE_CURRENT_RESULT: " +
+ * Statement.CLOSE_CURRENT_RESULT );
+ */
+
+ Class<?> statementClass;
+ try {
+ statementClass = Class.forName("java.sql.Statement");
+ } catch (ClassNotFoundException e) {
+ fail("java.sql.Statement class not found!");
+ return;
+ } // end try
+
+ Field[] theFields = statementClass.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 StatementTest
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_ClassLoader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_ClassLoader.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_ClassLoader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_ClassLoader.java Mon Jul 16 23:30:22 2007
@@ -26,194 +26,197 @@
public class TestHelper_ClassLoader extends ClassLoader {
- public TestHelper_ClassLoader() {
- super(null);
- }
-
- /**
- * Loads a class specified by its name
- * <p>
- * This classloader makes the assumption that any class it is asked to load
- * is in the current directory....
- */
- @Override
+ public TestHelper_ClassLoader() {
+ super(null);
+ }
+
+ /**
+ * Loads a class specified by its name
+ * <p>
+ * This classloader makes the assumption that any class it is asked to load
+ * is in the current directory....
+ */
+ @Override
public Class<?> findClass(String className) throws ClassNotFoundException {
- Class<?> theClass = null;
+ Class<?> theClass = null;
- if (!className.equals("org.apache.harmony.sql.tests.java.sql.TestHelper_DriverManager")) {
+ if (!className
+ .equals("org.apache.harmony.sql.tests.java.sql.TestHelper_DriverManager")) {
return null;
}
- String classNameAsFile = className.replace('.', '/') + ".class";
- // System.out.println("findClass - class filename = " + classNameAsFile
- // );
-
- String classPath = System.getProperty("java.class.path");
- // System.out.println("Test class loader - classpath = " + classPath );
-
- String theSeparator = String.valueOf(File.pathSeparatorChar);
- String[] theClassPaths = classPath.split(theSeparator);
- for (int i = 0; (i < theClassPaths.length) && (theClass == null); i++) {
- // Ignore jar files...
- if (theClassPaths[i].endsWith(".jar")) {
- theClass = loadClassFromJar(theClassPaths[i], className,
- classNameAsFile);
- } else {
- theClass = loadClassFromFile(theClassPaths[i], className,
- classNameAsFile);
- } // end if
- } // end for
+ String classNameAsFile = className.replace('.', '/') + ".class";
+ // System.out.println("findClass - class filename = " + classNameAsFile
+ // );
+
+ String classPath = System.getProperty("java.class.path");
+ // System.out.println("Test class loader - classpath = " + classPath );
+
+ String theSeparator = String.valueOf(File.pathSeparatorChar);
+ String[] theClassPaths = classPath.split(theSeparator);
+ for (int i = 0; (i < theClassPaths.length) && (theClass == null); i++) {
+ // Ignore jar files...
+ if (theClassPaths[i].endsWith(".jar")) {
+ theClass = loadClassFromJar(theClassPaths[i], className,
+ classNameAsFile);
+ } else {
+ theClass = loadClassFromFile(theClassPaths[i], className,
+ classNameAsFile);
+ } // end if
+ } // end for
- return theClass;
- } // end method findClass( String )
+ return theClass;
+ } // end method findClass( String )
- @Override
+ @Override
public Class<?> loadClass(String className) throws ClassNotFoundException {
- // Allowed classes:
- String[] disallowedClasses = { "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver1",
- "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver2",
- "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver4",
- "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver5" };
+ // Allowed classes:
+ String[] disallowedClasses = {
+ "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver1",
+ "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver2",
+ "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver4",
+ "org.apache.harmony.sql.tests.java.sql.TestHelper_Driver5" };
- Class<?> theClass;
+ Class<?> theClass;
- theClass = findLoadedClass(className);
- if (theClass != null) {
+ theClass = findLoadedClass(className);
+ if (theClass != null) {
return theClass;
}
- theClass = this.findClass(className);
+ theClass = this.findClass(className);
- if (theClass == null) {
- for (String element : disallowedClasses) {
- if (element.equals(className)) {
- return null;
- } // end if
- } // end for
- theClass = Class.forName(className);
- } // end if
-
- return theClass;
- } // end method loadClass( String )
-
- private Class<?> loadClassFromFile(String pathName, String className,
- String classNameAsFile) {
- Class<?> theClass = null;
- FileInputStream theInput = null;
- File theFile = null;
- try {
- theFile = new File(pathName, classNameAsFile);
- if (theFile.exists()) {
- int length = (int) theFile.length();
- theInput = new FileInputStream(theFile);
- byte[] theBytes = new byte[length + 100];
- int dataRead = 0;
- while (dataRead < length) {
- int count = theInput.read(theBytes, dataRead,
- theBytes.length - dataRead);
- if (count == -1) {
+ if (theClass == null) {
+ for (String element : disallowedClasses) {
+ if (element.equals(className)) {
+ return null;
+ } // end if
+ } // end for
+ theClass = Class.forName(className);
+ } // end if
+
+ return theClass;
+ } // end method loadClass( String )
+
+ private Class<?> loadClassFromFile(String pathName, String className,
+ String classNameAsFile) {
+ Class<?> theClass = null;
+ FileInputStream theInput = null;
+ File theFile = null;
+ try {
+ theFile = new File(pathName, classNameAsFile);
+ if (theFile.exists()) {
+ int length = (int) theFile.length();
+ theInput = new FileInputStream(theFile);
+ byte[] theBytes = new byte[length + 100];
+ int dataRead = 0;
+ while (dataRead < length) {
+ int count = theInput.read(theBytes, dataRead,
+ theBytes.length - dataRead);
+ if (count == -1) {
break;
}
- dataRead += count;
- }
+ dataRead += count;
+ }
- if (dataRead > 0) {
- // Create the class from the bytes read in...
- theClass = this.defineClass(className, theBytes, 0, dataRead);
- ClassLoader testClassLoader = theClass.getClassLoader();
- if (testClassLoader != this) {
- System.out.println("findClass - wrong classloader!!");
- }
- }
- }
- } catch (Exception e) {
- System.out.println("findClass - exception reading class file.");
- e.printStackTrace();
- } finally {
- try {
- if (theInput != null) {
+ if (dataRead > 0) {
+ // Create the class from the bytes read in...
+ theClass = this.defineClass(className, theBytes, 0,
+ dataRead);
+ ClassLoader testClassLoader = theClass.getClassLoader();
+ if (testClassLoader != this) {
+ System.out.println("findClass - wrong classloader!!");
+ }
+ }
+ }
+ } catch (Exception e) {
+ System.out.println("findClass - exception reading class file.");
+ e.printStackTrace();
+ } finally {
+ try {
+ if (theInput != null) {
theInput.close();
}
- } catch (Exception e) {
- }
- }
- return theClass;
- }
-
- /*
- * Loads a named class from a specified JAR file
- */
- private Class<?> loadClassFromJar(String jarfileName, String className,
- String classNameAsFile) {
- Class<?> theClass = null;
-
- // First, try to open the Jar file
- JarFile theJar = null;
- try {
- theJar = new JarFile(jarfileName);
- JarEntry theEntry = theJar.getJarEntry(classNameAsFile);
-
- if (theEntry == null) {
- // System.out.println("TestHelper_Classloader - did not find
- // class file in Jar " + jarfileName );
- return theClass;
- } // end if
+ } catch (Exception e) {
+ }
+ }
+ return theClass;
+ }
+
+ /*
+ * Loads a named class from a specified JAR file
+ */
+ private Class<?> loadClassFromJar(String jarfileName, String className,
+ String classNameAsFile) {
+ Class<?> theClass = null;
+
+ // First, try to open the Jar file
+ JarFile theJar = null;
+ try {
+ theJar = new JarFile(jarfileName);
+ JarEntry theEntry = theJar.getJarEntry(classNameAsFile);
+
+ if (theEntry == null) {
+ // System.out.println("TestHelper_Classloader - did not find
+ // class file in Jar " + jarfileName );
+ return theClass;
+ } // end if
- theEntry.getMethod();
- InputStream theStream = theJar.getInputStream(theEntry);
+ theEntry.getMethod();
+ InputStream theStream = theJar.getInputStream(theEntry);
- long size = theEntry.getSize();
- if (size < 0) {
+ long size = theEntry.getSize();
+ if (size < 0) {
size = 100000;
}
- byte[] theBytes = new byte[(int) size + 100];
+ byte[] theBytes = new byte[(int) size + 100];
- int dataRead = 0;
- while (dataRead < size) {
- int count = theStream.read(theBytes, dataRead, theBytes.length
- - dataRead);
- if (count == -1) {
+ int dataRead = 0;
+ while (dataRead < size) {
+ int count = theStream.read(theBytes, dataRead, theBytes.length
+ - dataRead);
+ if (count == -1) {
break;
}
- dataRead += count;
- } // end while
+ dataRead += count;
+ } // end while
- // System.out.println("loadClassFromJar: read " + dataRead + " bytes
- // from class file");
- if (dataRead > 0) {
- // Create the class from the bytes read in...
- theClass = this.defineClass(className, theBytes, 0, dataRead);
- /* System.out.println("findClass: created Class object."); */
- ClassLoader testClassLoader = theClass.getClassLoader();
- if (testClassLoader != this) {
- System.out.println("findClass - wrong classloader!!");
- } else {
- System.out
- .println("Testclassloader loaded class from jar: "
- + className);
- } // end if
- } // end if
- } catch (IOException ie) {
- System.out
- .println("TestHelper_ClassLoader: IOException opening Jar "
- + jarfileName);
- } catch (Exception e) {
- System.out
- .println("TestHelper_ClassLoader: Exception loading class from Jar ");
- } catch (ClassFormatError ce) {
- System.out
- .println("TestHelper_ClassLoader: ClassFormatException loading class from Jar ");
- } finally {
- try {
- if (theJar != null) {
+ // System.out.println("loadClassFromJar: read " + dataRead + " bytes
+ // from class file");
+ if (dataRead > 0) {
+ // Create the class from the bytes read in...
+ theClass = this.defineClass(className, theBytes, 0, dataRead);
+ /* System.out.println("findClass: created Class object."); */
+ ClassLoader testClassLoader = theClass.getClassLoader();
+ if (testClassLoader != this) {
+ System.out.println("findClass - wrong classloader!!");
+ } else {
+ System.out
+ .println("Testclassloader loaded class from jar: "
+ + className);
+ } // end if
+ } // end if
+ } catch (IOException ie) {
+ System.out
+ .println("TestHelper_ClassLoader: IOException opening Jar "
+ + jarfileName);
+ } catch (Exception e) {
+ System.out
+ .println("TestHelper_ClassLoader: Exception loading class from Jar ");
+ } catch (ClassFormatError ce) {
+ System.out
+ .println("TestHelper_ClassLoader: ClassFormatException loading class from Jar ");
+ } finally {
+ try {
+ if (theJar != null) {
theJar.close();
}
- } catch (Exception e) {
- } // end try
- } // end try
+ } catch (Exception e) {
+ } // end try
+ } // end try
- return theClass;
- } // end method loadClassFromJar(
+ return theClass;
+ } // end method loadClassFromJar(
} // end class TestHelper_ClassLoader
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Connection1.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Connection1.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Connection1.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Connection1.java Mon Jul 16 23:30:22 2007
@@ -46,8 +46,9 @@
return null;
}
- public Statement createStatement(int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
+ public Statement createStatement(int resultSetType,
+ int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
return null;
}
@@ -97,12 +98,13 @@
}
public CallableStatement prepareCall(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
return null;
}
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
- throws SQLException {
+ public CallableStatement prepareCall(String sql, int resultSetType,
+ int resultSetConcurrency) throws SQLException {
return null;
}
@@ -111,7 +113,8 @@
}
public PreparedStatement prepareStatement(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+ int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
return null;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver1.java Mon Jul 16 23:30:22 2007
@@ -104,7 +104,8 @@
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
throws SQLException {
- DriverPropertyInfo[] theInfos = { new DriverPropertyInfo(userProperty, "*"),
+ DriverPropertyInfo[] theInfos = {
+ new DriverPropertyInfo(userProperty, "*"),
new DriverPropertyInfo(passwordProperty, "*"), };
return theInfos;
}
Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java?view=diff&rev=556825&r1=556824&r2=556825
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestHelper_Driver2.java Mon Jul 16 23:30:22 2007
@@ -27,24 +27,24 @@
*/
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
+ 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()
+ protected TestHelper_Driver2() {
+ super();
+ baseURL = "jdbc:mikes2";
+ } // end constructor TestHelper_Driver1()
} // end class TestHelper_Driver2