db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r527317 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ master/DerbyNet/ master/DerbyNetClient/ master/j9_13/ master/j9_22/ suites/ tests/jdbcapi/
Date Tue, 10 Apr 2007 21:42:35 GMT
Author: myrnavl
Date: Tue Apr 10 14:42:33 2007
New Revision: 527317

URL: http://svn.apache.org/viewvc?view=rev&rev=527317
Log:
DERBY-2492 - convert checkDriver test to junit test DriverTest

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
  (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver_derby.properties
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude?view=diff&rev=527317&r1=527316&r2=527317
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClientUseprocess.exclude
Tue Apr 10 14:42:33 2007
@@ -5,7 +5,6 @@
 # jdbcapi/bestrowidentifier.sql - test fails when db2jcc is in classpath, complaining about
 #     java.lang.ExceptionInInitializerError 
 #     and access denied (java.lang.RuntimePermission loadLibrary.db2jcct2). (????!)
-# jdbcapi/checkDriver.java subtest createdbwithspaces fails, probably expecting different
dir
 # junitTests/derbyNet/CompatibilityTest.java - exits the suite
 # derbynet/DerbyNetAutoStart.java - exits the suite...
 # derbynet/NSinSameJVM.java - fails with different thread names. probably ok...
@@ -28,7 +27,6 @@
 #
 jdbcapi/HoldabilityTest.junit
 jdbcapi/bestrowidentifier.sql
-jdbcapi/checkDriver.java
 junitTests/derbyNet/CompatibilityTest.java
 derbynet/DerbyNetAutoStart.java
 derbynet/NSinSameJVM.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude?view=diff&rev=527317&r1=527316&r2=527317
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetUseprocess.exclude
Tue Apr 10 14:42:33 2007
@@ -6,7 +6,6 @@
 # jdbcapi/bestrowidentifier.sql - test fails when db2jcc is in classpath, complaining about
 #     java.lang.ExceptionInInitializerError 
 #     and access denied (java.lang.RuntimePermission loadLibrary.db2jcct2). (????!)
-# jdbcapi/checkDriver.java - subtest createdbwithspaces fails, probably expecting different
dir
 # derbynet/NSinSameJVM.java - diff between thread and main. kind of ok, but fails.
 # derbynet/DerbyNetAutoStart.java - exits suite...
 # derbynet/getCurrentProperties.java - fails with different sessions
@@ -25,7 +24,6 @@
 jdbcapi/maxfieldsize.java
 jdbcapi/HoldabilityTest.junit
 jdbcapi/bestrowidentifier.sql
-jdbcapi/checkDriver.java
 derbynet/NSinSameJVM.java
 derbynet/DerbyNetAutoStart.java
 derbynet/getCurrentProperties.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall?view=diff&rev=527317&r1=527316&r2=527317
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
Tue Apr 10 14:42:33 2007
@@ -1,5 +1,4 @@
 jdbcapi/bestrowidentifier.sql
-jdbcapi/checkDriver.java
 jdbcapi/nullSQLText.java
 jdbcapi/resultsetStream.java
 jdbcapi/parameterMapping.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java?view=auto&rev=527317
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
Tue Apr 10 14:42:33 2007
@@ -0,0 +1,504 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.jdbcapi.DriverTest
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+
+package org.apache.derbyTesting.functionTests.tests.jdbcapi;
+
+import java.io.File;
+import java.security.AccessController;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+*
+* This test tests java.sql.Driver methods.
+* Right now it just tests acceptsURL and some attributes  
+* Not tested in this test: 
+*   - Tests for getPropertyInfo
+*   - tests for connection attributes
+*/
+
+public class DriverTest extends BaseJDBCTestCase {
+
+    // DERBY-618 - Database name with spaces
+    private static String DB_NAME_WITH_SPACES = "db name with spaces";
+    
+    /**
+     * Set of additional databases for tests that
+     * require a one-off database. The additional
+     * database decorator wraps all the tests and phases.
+     * They are only created if a test opens a
+     * connection against them. In hard upgrade the test
+     * must explictly upgrade the database.
+     * The databases are shutdown at the end of each phase.
+     */
+    static final String[] ADDITIONAL_DBS = {
+        DB_NAME_WITH_SPACES,
+        "testcreatedb1", 
+        "testcreatedb2"
+    };
+    
+    public DriverTest(String name) {
+        super(name);
+    }
+    
+    public static Test suite() {
+        // java.sql.Driver is not supported with JSR169, so return empty suite
+        if (JDBC.vmSupportsJSR169())
+        {
+            return new TestSuite(
+                "DriverTest tests java.sql.Driver, not supported with JSR169");
+        }
+        TestSuite suite = new TestSuite("DriverTest");
+        suite.addTest(baseSuite("DriverTest:embedded"));
+            suite.addTest(TestConfiguration.clientServerDecorator(
+                baseSuite("DriverTest:client")));
+        return suite;
+    }
+    
+    public static Test baseSuite(String name) {
+        
+        TestSuite suite = new TestSuite("DriverTest");
+        setBaseProps(suite, new DriverTest("testDriverCompliantVersion"));
+        setBaseProps(suite, new DriverTest("testAcceptsURL"));
+        setBaseProps(suite, new DriverTest("testEmbeddedAttributes"));
+        setBaseProps(suite, new DriverTest("testClientAttributes"));
+        setBaseProps(suite, new DriverTest("testClientURL"));
+        setBaseProps(suite, new DriverTest("testDbNameWithSpaces"));
+        
+        // This test needs to run in a new single use database as we're setting
+        // a number of properties
+        TestSetup setup = TestConfiguration.singleUseDatabaseDecorator(suite);
+        
+        // also, we need a couple of extra databases
+        for (int i = 0; i < ADDITIONAL_DBS.length; i++)
+        {
+            setup = TestConfiguration.additionalDatabaseDecorator(setup,
+                    ADDITIONAL_DBS[i]);
+        }
+        
+        return setup;
+    }
+    
+    private static void setBaseProps(TestSuite suite, Test test) 
+    {
+        Properties dbprops = new Properties();
+
+        // Use DatabasePropertyTestSetup to add some settings.
+        // DatabasePropertyTestSetup uses SYSCS_SET_DATABASE_PROPERTY
+        // so users are added at database level.
+        // Note, that authentication is not switched on.
+        dbprops.setProperty("derby.infolog.append", "true");
+        dbprops.setProperty("derby.debug.true", "AuthenticationTrace");
+        dbprops.setProperty("derby.user.APP", "xxxx");
+        dbprops.setProperty("derby.user.testuser", "testpass");
+        String dbName = TestConfiguration.getCurrent().getDefaultDatabaseName();
+        dbprops.setProperty("derby.database.users." + dbName, "testuser,APP");
+        test = new DatabasePropertyTestSetup (test, dbprops, true);
+        suite.addTest(test);
+    }
+    
+    /**
+     * Load the driver and check java.sql.Driver.jdbcCompliant() and
+     * driver.get*Version
+     * @throws Exception
+     */
+    public static void testDriverCompliantVersion() throws Exception 
+    {   
+        String dbName = TestConfiguration.getCurrent().getDefaultDatabaseName();
+        String url = TestConfiguration.getCurrent().getJDBCUrl(dbName);
+
+        loadDriver();
+        String defaultdburl = url + ";create=true";
+        
+        // Test that we loaded the right driver by making a connection
+        Driver driver = DriverManager.getDriver(defaultdburl);
+        Properties props = new Properties();
+        props.put("user", "testuser");
+        props.put("password", "testpass");
+        Connection conn = DriverManager.getConnection(defaultdburl, props);
+        // Driver should be jdbc compliant.
+        assertTrue(driver.jdbcCompliant());
+
+        // compare driver.get*Version() with DatabaseMetadata.getDriver*Version.
+        DatabaseMetaData dbmd = conn.getMetaData();
+
+        assertEquals(dbmd.getDriverMajorVersion(), driver.getMajorVersion());
+        assertEquals(dbmd.getDriverMinorVersion(), driver.getMinorVersion());
+        
+        conn.close();
+    }
+    
+    /**
+     * Check that drivers accept the correct urls and reject those for other supported drivers.
+     * 
+     * @throws SQLException, Exception
+     */
+    public static void testAcceptsURL() throws SQLException, Exception {
+        String dbName = TestConfiguration.getCurrent().getDefaultDatabaseName();
+        String orgurl = TestConfiguration.getCurrent().getJDBCUrl(dbName);
+
+        loadDriver();
+        String defaultdburl = orgurl + ";create=true";
+        
+        // Test that we loaded the right driver by making a connection
+        Driver driver = DriverManager.getDriver(defaultdburl);
+
+        int  frameworkOffset;
+        int EMBEDDED_OFFSET = 0;
+        int DERBYNETCLIENT_OFFSET = 1;
+        int DERBYNET_OFFSET = 2;   // JCC
+        if (usingDerbyNetClient())
+            frameworkOffset = DERBYNETCLIENT_OFFSET;
+        else if (usingDerbyNet())
+            frameworkOffset = DERBYNET_OFFSET; // JCC
+        else // assume (usingEmbedded())
+            frameworkOffset = EMBEDDED_OFFSET;
+        
+        // URLS to check.  New urls need to also be added to the acceptsUrl table
+        String EMBEDDED_URL = "jdbc:derby:";
+        String INVALID_URL = "jdbc:db2j:";
+        String hostName = TestConfiguration.getCurrent().getHostName();
+        int port = TestConfiguration.getCurrent().getPort();
+        String CLIENT_URL = 
+            "jdbc:derby://"+hostName+":"+port+"/"+dbName+";create=true";
+        String JCC_URL = 
+            "jdbc:derby:net://"+hostName+":"+port+"/"+dbName+";create=true";
+        
+        String[] urls = new String[]
+        {
+            EMBEDDED_URL,
+            CLIENT_URL,
+            JCC_URL,
+            INVALID_URL,
+        };
+
+        // Table that shows whether tested urls should return true for 
+        // acceptsURL under the given framework
+        // The acceptsURLTable uses  the frameworkOffset column int he table 
+        // to check for valid results for each framework
+        boolean[][] acceptsURLTable = new boolean[][]
+        {
+        // Framework/url      EMBEDDED     DERBYNETCLIENT       DERBYNET (JCC)
+        /* EMBEDDED_URL*/  {   true      ,  false           ,   false    },
+        /* CLIENT_URL  */  {   false     ,  true            ,   false    },     
+        /* JCC_URL     */  {   false     ,  false           ,   true     },
+        /* INVALID_URL */  {   false     ,  false           ,   false    } 
+        };
+
+        for (int u = 0; u < urls.length;u++)
+        {
+            String url = urls[u];
+            boolean expectedAcceptance = acceptsURLTable[u][frameworkOffset];
+            boolean actualAcceptance = driver.acceptsURL(url);
+            assertEquals(expectedAcceptance, actualAcceptance);
+        }
+    }
+    
+    /**
+     * Tests that embedded attributes can be specified in either url or info 
+     * argument to connect
+     * DERBY-530. Only valid for embedded driver and client. JCC has a 
+     * different url format for embedded attributes
+     */
+    public static void testEmbeddedAttributes() throws SQLException
+    {
+        // JCC can't take embedded attributes in info or as normal url 
+        // attributes, so not tested here.
+        if (usingDerbyNet())
+            return;
+        
+        String dbName = TestConfiguration.getCurrent().getDefaultDatabaseName();
+        String protocol = 
+            TestConfiguration.getCurrent().getJDBCClient().getUrlBase();
+        if (usingDerbyNetClient())
+            protocol = protocol + TestConfiguration.getCurrent().getHostName()
+            + ":" + TestConfiguration.getCurrent().getPort() + "/";
+        String url = TestConfiguration.getCurrent().getJDBCUrl(dbName);
+        
+        Properties info = new Properties();
+        // create attribute as property
+        info.setProperty("create","true");
+        // networkserver / DerbyNetClient tags on create to url
+        if (usingEmbedded())
+            assertConnect(true, protocol + "testcreatedb1", info);
+        else
+            assertConnect(false, protocol + "testcreatedb1", info);
+        
+        // create attribute in url
+        if (usingEmbedded())
+            assertConnect(false, protocol + "testcreatedb2;create=true", null);
+        else 
+            assertConnect(true, protocol + "testcreatedb2;create=true", null);
+        
+        // user/password in properties
+        info.clear();
+        info.setProperty("user","APP");
+        info.setProperty("password", "xxxx");
+        if (usingEmbedded())
+            assertConnect(true, url, info);
+        else 
+            assertConnect(false, url, info);
+        
+        // user/password  in url
+        assertConnect(false, 
+            url + ";user=testuser;password=testpass", null);
+        
+        // user in url, password in property
+        info.clear();
+        info.setProperty("password","testpass");
+        assertConnect(false, url + ";user=testusr",info);
+
+        // different users in url and in properties. URL is the winner
+        info.clear();
+        info.setProperty("user","APP");
+        info.setProperty("password","xxxx");
+        assertConnect(false, 
+            url + ";user=testuser;password=testpass", null);
+        
+        // shutdown with properties
+        info.clear();
+        info.setProperty("shutdown","true");                
+        try {
+            assertConnect(false, protocol + "testcreatedb1", info);
+        } catch (SQLException se)
+        {
+            assertSQLState("08006", se);
+        }
+    }
+        
+    /**
+     * Tests that client side attributes cann be specified in either url or
+     * as info argument to connect.
+     * DERBY-530. 
+     */
+    public static void testClientAttributes() throws SQLException
+    {
+        if (!usingDerbyNetClient())
+            return;
+        
+        String dbName = TestConfiguration.getCurrent().getDefaultDatabaseName();
+        String url = TestConfiguration.getCurrent().getJDBCUrl(dbName);
+
+        Properties info = new Properties();
+        String traceFile = "trace1.out";
+        
+        // traceFile attribute in url
+        assertConnect(true, url + ";traceFile=" + traceFile, info);
+        
+        traceFile = "trace2.out";
+        // traceFile attribute in property
+        info.setProperty("traceFile",traceFile);
+        assertConnect(false, url, info);
+        assertTraceFilesExist();
+    }
+
+    /**
+     * Check that trace files exist
+     */
+    private static void assertTraceFilesExist() 
+    {
+        
+        AccessController.doPrivileged(new java.security.PrivilegedAction() {
+            public Object run() {
+                for (int i=0 ; i < 2 ; i++)
+                {   
+                    String traceFileName = "trace" + (i+1) + ".out";
+                    File traceFile = new File(traceFileName);
+                    //System.out.println("user.dir=" + System.getProperty("user.dir"));
+                    //System.out.println("fullpath = " + traceFile.getAbsolutePath());
+                        assertTrue(traceFile.exists());
+                } 
+                return null;
+            }
+        });
+    }
+
+    /**
+     * Tests client URLs to see connection is successful or the correct exception is thrown.
+     */
+    public static void testClientURL() throws SQLException {
+        if (!usingDerbyNetClient())
+            return;
+        
+        String dbName = TestConfiguration.getCurrent().getDefaultDatabaseName();
+        String protocol = 
+            TestConfiguration.getCurrent().getJDBCClient().getUrlBase();
+        if (usingDerbyNetClient())
+            protocol = protocol + TestConfiguration.getCurrent().getHostName()
+            + ":" + TestConfiguration.getCurrent().getPort() + "/";
+        
+        Properties info = null;     //test with null Properties object
+
+        String CLIENT_URL_WITH_COLON1 = protocol + dbName + ":create=true";
+        //String CLIENT_URL_WITH_COLON2 = protocol + DERBY_SYSTEM_HOME + 
+        //   File.separator + dbName + ":create=true";
+        // String CLIENT_URL_WITH_DOUBLE_QUOTES1 = 
+        //     protocol + "\"" + dbName + "\";create=true";  
+        // String CLIENT_URL_WITH_DOUBLE_QUOTES2 = protocol + "\"" + 
+        //     DERBY_SYSTEM_HOME + File.separator + dbName + "\";create=true"; 
+        // String CLIENT_URL_WITH_SINGLE_QUOTES1 = protocol + "'" + 
+        //     DERBY_SYSTEM_HOME + File.separator + dbName + "';create=true"; 
+        String CLIENT_URL_WITH_SINGLE_QUOTES2 = 
+            protocol + "'" + dbName + "';create=true";
+        
+        //Client URLS
+        String[] clientUrls = new String[]
+        {
+            CLIENT_URL_WITH_COLON1,
+            //CLIENT_URL_WITH_COLON2,
+            //CLIENT_URL_WITH_DOUBLE_QUOTES1,
+            //CLIENT_URL_WITH_DOUBLE_QUOTES2,
+            //CLIENT_URL_WITH_SINGLE_QUOTES1,
+            CLIENT_URL_WITH_SINGLE_QUOTES2
+        };
+        
+        for (int i = 0; i < clientUrls.length;i++)
+        {
+            String url = clientUrls[i];
+            try{
+                if (url.equals(CLIENT_URL_WITH_COLON1))
+                {
+                    Driver driver = DriverManager.getDriver(url);
+                    assertNull(driver.connect(url,info));
+                }
+                else
+                    assertConnect(true, url, info);
+            }
+            catch(SQLException se){
+                fail ("did not expect an exception");
+            }
+        }
+    }   
+    
+    /**
+     * Tests URL with spaces in database name to check create and connect works. 
+     * (DERBY-618). Make sure that the specified database gets created. We need 
+     * to check this because even without the patch for DERBY-618, no exception
+     * gets thrown when we try to connect to a database name with spaces. 
+     * Instead, client driver extracts the database name as the string before 
+     * the first occurence of space separator. Hence the database which gets 
+     * created is wrong. e.g, if we specified database name as 
+     * "db name with spaces", the database that got created by client driver 
+     * was "db", which was wrong. We can check this by checking the correct URL
+     * is returned by call to conn.getMetaData().getURL(). This is currently 
+     * checked inside the testConnect method. We do not explicilty check the 
+     * database directory creation since this check fails in remote server 
+     * testing.       
+     * 
+     * @throws SQLException
+     */
+    public static void testDbNameWithSpaces() throws SQLException {
+        
+        Properties info = null;
+        String url = null;
+        
+        String protocol = 
+            TestConfiguration.getCurrent().getJDBCClient().getUrlBase();
+        if (usingDerbyNetClient())
+            protocol = protocol + TestConfiguration.getCurrent().getHostName()
+            + ":" + TestConfiguration.getCurrent().getPort() + "/";
+        else if (usingDerbyNet())
+            protocol = protocol + "net:" + 
+            TestConfiguration.getCurrent().getHostName() + ":" + 
+            TestConfiguration.getCurrent().getPort() + "/";
+        
+        String EMBEDDED_URL_WITH_SPACES = 
+            protocol + DB_NAME_WITH_SPACES + ";create=true";
+        String CLIENT_URL_WITH_SPACES = 
+            protocol + DB_NAME_WITH_SPACES + ";create=true";
+        String JCC_URL_WITH_SPACES = 
+            protocol + DB_NAME_WITH_SPACES + ";create=true";
+        
+        if(usingEmbedded())
+            url = EMBEDDED_URL_WITH_SPACES;
+        else if(usingDerbyNetClient()) 
+            url = CLIENT_URL_WITH_SPACES;
+        else if(usingDerbyNet()) {
+            url = JCC_URL_WITH_SPACES;
+            // JCC requires user and password
+            info =  new Properties();
+            info.put("user", "tester");
+            info.put("password", "testpass");
+        }
+        
+        assertConnect(false, url, info);
+    }
+    
+    /**
+     * Do java.sql.Driver.connect(String url, Properties info call)
+     * 
+     * @param expectUrlEqualsGetUrl boolean indicating embedded would
+     *                  expect the url passed in to equal metadata.getURL()
+     * @param url       url to pass to Driver.connect()
+     * @param info      properties to pass to Driver.Connect()
+     * 
+     * @throws SQLException on error.
+     */
+    private static Connection assertConnect(
+        boolean expectUrlEqualsGetUrl, String url, Properties info) 
+    throws SQLException
+    {
+        Driver driver = DriverManager.getDriver(url);
+
+        Connection conn = driver.connect(url,info);
+        assertNotNull(conn);
+   
+        if (expectUrlEqualsGetUrl)
+            assertEquals(url, conn.getMetaData().getURL());
+        else
+            assertNotSame(url, conn.getMetaData().getURL());
+        ResultSet rs = 
+            conn.createStatement().executeQuery("VALUES(CURRENT SCHEMA)");
+        rs.next();
+        assertEquals(
+            rs.getString(1), conn.getMetaData().getUserName().toUpperCase());
+        conn.close();
+        return conn;
+    }
+
+    /**
+       Load the appropriate driver for the current framework
+     */
+    private static void loadDriver()
+    {
+        String driverClass =
+            TestConfiguration.getCurrent().getJDBCClient().getJDBCDriverName();
+        try {
+            Class.forName(driverClass).newInstance();
+        } catch (Exception e) {
+            fail ("could not instantiate driver");
+        }
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java?view=diff&rev=527317&r1=527316&r2=527317
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
Tue Apr 10 14:42:33 2007
@@ -52,7 +52,6 @@
             // "dataSourceReference", TODO: investigate failure/convert
             
             // from old jdbcapi.runall
-            // "checkDriver",  TODO: investigate failure/convert
             "derbyStress",
             // "nullSQLText",  TODO: investigate failure/convert
             // "prepStmtMetaData",  TODO: convert - different canon for client

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java?view=diff&rev=527317&r1=527316&r2=527317
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
Tue Apr 10 14:42:33 2007
@@ -74,6 +74,7 @@
 		suite.addTest(ClosedObjectTest.suite());
                 suite.addTest(SetTransactionIsolationTest.suite());
 		suite.addTest(AuthenticationTest.suite());
+		suite.addTest(DriverTest.suite());
         
         // Old harness .java tests that run using the HarnessJavaTest
         // adapter and continue to use a single master file.



Mime
View raw message