You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2011/03/31 22:55:02 UTC

svn commit: r1087433 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ suites/ tests/tools/

Author: myrnavl
Date: Thu Mar 31 20:55:01 2011
New Revision: 1087433

URL: http://svn.apache.org/viewvc?rev=1087433&view=rev
Log:
DERBY-5084; convert ijConnName.sql to a ScriptTest junit test
  Converts test with exception of one run-but-not-checked test case.
  patch contributed by Houx Zhang (houxzhang at gmail dot com).

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IjConnNameTest.java   (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName_sed.properties
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out?rev=1087433&r1=1087432&r2=1087433&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ijConnName.out Thu Mar 31 20:55:01 2011
@@ -1,4 +1,5 @@
-ij> --
+ERROR XJ004: Database 'nevercreated' not found.
+ij(CONNECTION0)> --
 --   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.
@@ -16,7 +17,16 @@ ij> --
 --
 -- assumes the connection connOne is set up already
 -- and that connThree, connFour failed to be setup correctly (bad URLs)
--- expect connOne to be active
+
+--disconnect connection created by ScriptTestCase 
+show connections;
+CONNECTION0* - 	jdbc:derby:wombat
+CONNONE - 	jdbc:derby:wombat
+* = current connection
+WARNING 01J01: Database 'wombat' not created, connection made to existing database instead.
+ij(CONNECTION0)> disconnect CONNECTION0;
+ij> set connection connOne;
+ij> -- expect connOne to be active
 show connections;
 CONNONE* - 	jdbc:derby:wombat
 * = current connection
@@ -53,4 +63,7 @@ ij> disconnect current;
 ij> -- see no more connections to use
 show connections;
 No connections available.
+ij> -- shutdown system
+connect 'jdbc:derby:;shutdown=true';
+ERROR XJ015: Derby system shutdown.
 ij> 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall?rev=1087433&r1=1087432&r2=1087433&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbytools.runall Thu Mar 31 20:55:01 2011
@@ -7,5 +7,4 @@ tools/ij3.sql
 tools/ij4.sql
 tools/ij5.sql
 tools/ij6.sql
-tools/ijConnName.sql
 tools/URLCheck.sql

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IjConnNameTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IjConnNameTest.java?rev=1087433&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IjConnNameTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/IjConnNameTest.java Thu Mar 31 20:55:01 2011
@@ -0,0 +1,113 @@
+package org.apache.derbyTesting.functionTests.tests.tools;
+
+import java.io.File;
+
+import java.security.AccessController;
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+import org.apache.derbyTesting.functionTests.util.ScriptTestCase;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
+
+
+
+
+/**
+ * Test case for ijConnName.sql. 
+ *
+ */
+public class IjConnNameTest extends ScriptTestCase {
+
+    private static String test_script = "ijConnName";
+
+    public IjConnNameTest(String name) {
+        super(name, true);
+    }    
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("IjConnNameTest");
+        
+        // Test does not run on J2ME
+        if (JDBC.vmSupportsJSR169())
+            return suite;
+        
+        Properties props = new Properties();
+        
+        props.setProperty("ij.connection.connOne", "jdbc:derby:wombat;create=true");
+        props.setProperty("ij.connection.connFour", "jdbc:derby:nevercreated");     
+        
+        props.setProperty("ij.showNoConnectionsAtStart", "true");
+        props.setProperty("ij.showNoCountForSelect", "true");
+        
+        Test test = new SystemPropertyTestSetup(new IjConnNameTest(test_script), props);
+        //test = SecurityManagerSetup.noSecurityManager(test);
+        test = new CleanDatabaseTestSetup(test);   
+        
+        return getIJConfig(test); 
+    }
+    
+    public void tearDown() throws Exception {
+        // attempt to get rid of the extra database.
+        // this also will get done if there are failures, and the database will
+        // not be saved in the 'fail' directory.
+        AccessController.doPrivileged(new java.security.PrivilegedAction() {
+            public Object run() {
+                    removeDatabase("lemming" );
+                return null;
+            }
+            
+            void removeDatabase(String dbName)
+            {
+                //TestConfiguration config = TestConfiguration.getCurrent();
+                dbName = dbName.replace('/', File.separatorChar);
+                String dsh = getSystemProperty("derby.system.home");
+                if (dsh == null) {
+                    fail("not implemented");
+                } else {
+                    dbName = dsh + File.separator + dbName;
+                }
+                removeDirectory(dbName);
+            }
+
+            void removeDirectory(String path)
+            {
+                final File dir = new File(path);
+                removeDir(dir);
+            }
+
+            private void removeDir(File dir) {
+                
+                // Check if anything to do!
+                // Database may not have been created.
+                if (!dir.exists())
+                    return;
+
+                String[] list = dir.list();
+
+                // Some JVMs return null for File.list() when the
+                // directory is empty.
+                if (list != null) {
+                    for (int i = 0; i < list.length; i++) {
+                        File entry = new File(dir, list[i]);
+
+                        if (entry.isDirectory()) {
+                            removeDir(entry);
+                        } else {
+                            entry.delete();
+                            //assertTrue(entry.getPath(), entry.delete());
+                        }
+                    }
+                }
+                dir.delete();
+                //assertTrue(dir.getPath(), dir.delete());
+            }
+        });
+        super.tearDown();
+    }   
+}

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java?rev=1087433&r1=1087432&r2=1087433&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java Thu Mar 31 20:55:01 2011
@@ -55,6 +55,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(SysinfoCPCheckTest.suite());
         suite.addTest(SysinfoLocaleTest.suite());
         suite.addTest(IjSecurityManagerTest.suite());
+        suite.addTest(IjConnNameTest.suite());
         
         // SysinfoAPITest currently fails when run against jars, so is
         // disabled. Only the first jar file on the classpath properly

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql?rev=1087433&r1=1087432&r2=1087433&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ijConnName.sql Thu Mar 31 20:55:01 2011
@@ -17,6 +17,11 @@
 -- assumes the connection connOne is set up already
 -- and that connThree, connFour failed to be setup correctly (bad URLs)
 
+--disconnect connection created by ScriptTestCase 
+show connections;
+disconnect CONNECTION0;
+set connection connOne; 
+
 -- expect connOne to be active
 show connections;
 connect 'jdbc:derby:lemming;create=true' as connTwo;
@@ -40,3 +45,6 @@ disconnect current;
 
 -- see no more connections to use
 show connections;
+
+-- shutdown system
+connect 'jdbc:derby:;shutdown=true';