db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r614893 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/load/ testing/org/apache/derbyTesting/functionTests/tests/tools/ testing/org/apache/derbyTesting/junit/
Date Thu, 24 Jan 2008 15:01:52 GMT
Author: kmarsden
Date: Thu Jan 24 07:01:48 2008
New Revision: 614893

URL: http://svn.apache.org/viewvc?rev=614893&view=rev
Log:
DERBY-3068 testImportExportProcedureNegative(org.apache.derbyTesting.functionTests.tests.tools.ImportExportProcedureTest)junit.framework.ComparisonFailure:
Unexpected SQL state. expected:<38000> but was:<XIE0S>

Changed unexpectedException in import to close the stream first.
Changed ImportExportProcedureTest to delete files immediately after the test instead of before
the test that recreates the file.
Changed deleteFile to fail if it cannot delete the file.

Ran suites.All on IBM 1.5 3 times without errors, and on jdk16.  There may however still be
a problem with import as I did see the unchanged test fail on IBM 1.5. With the new test structure
it should be easier to identify the source of the problem if it happens again.



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/load/Import.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportAbstract.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/load/Import.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/load/Import.java?rev=614893&r1=614892&r2=614893&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/load/Import.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/load/Import.java Thu Jan 24 07:01:48
2008
@@ -84,7 +84,7 @@
 
 		}catch(Exception e)
 		{
-			throw LoadError.unexpectedError(e);
+			throw importError(e);
 		}
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportAbstract.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportAbstract.java?rev=614893&r1=614892&r2=614893&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportAbstract.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ImportAbstract.java Thu Jan
24 07:01:48 2008
@@ -21,6 +21,7 @@
 
 package org.apache.derby.impl.load;
 
+import java.io.IOException;
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.sql.ResultSetMetaData;
@@ -123,7 +124,7 @@
       lineNumber++;
       return (importReadData.readNextRow(nextRow));
     } catch (Exception ex) {
-		throw LoadError.unexpectedError(ex);
+		throw importError(ex);
 	}
   }
 
@@ -312,4 +313,24 @@
 			return false;
 
 	}
+        
+        /**
+         * Close the stream and wrap exception in a SQLException
+         * 
+         * @param ex  Exception causing the import error
+         * @throws SQLException
+         */
+        public  SQLException importError(Exception ex) {
+            Exception closeException = null;
+            if (importReadData != null)
+                try {
+                    importReadData.closeStream(); 
+                } catch (Exception e) {
+                    closeException = e;
+                }
+                SQLException le = LoadError.unexpectedError(ex);
+                if (closeException != null)
+                    le.setNextException(LoadError.unexpectedError(closeException));
+                return le;
+        }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java?rev=614893&r1=614892&r2=614893&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
Thu Jan 24 07:01:48 2008
@@ -1922,8 +1922,6 @@
             + "'extout/nodir/t1.dat' , null, null, null) ");
         assertStatementError("XIE0I", cSt);
 	
-	//DERBY-2925: need to delete existing files first.
-        SupportFilesSetup.deleteFile("extinout/t1.dat");
 
         //export table not found
         
@@ -1943,7 +1941,7 @@
         assertStatementError("38000", cSt);
        
 	//DERBY-2925: need to delete existing files first.
-        SupportFilesSetup.deleteFile("extout/t1.dat");
+        SupportFilesSetup.deleteFile("extinout/t1.dat");
  
         //export query is invalid (syntax error)
         
@@ -2048,7 +2046,7 @@
             "call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('IEP', 'T1' , "
             + "'extinout/t1.dat' , '\\a', '\\', null) ");
         assertStatementError("XIE0J", cSt);
-        
+                
         //DO A VALID EXPORT AND  IMPORT
         
         st.executeUpdate(
@@ -2070,6 +2068,8 @@
             + "'extinout/t1.dat' , null, null, 'utf-8', 0) ");
         assertUpdateCount(cSt, 0);
         
+        //  DERBY-2925: need to delete existing files 
+        SupportFilesSetup.deleteFile("extinout/t1.dat");
         rs = st.executeQuery(
             " select * from t1");
         

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java?rev=614893&r1=614892&r2=614893&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java
Thu Jan 24 07:01:48 2008
@@ -30,6 +30,7 @@
 import java.security.PrivilegedActionException;
 
 import junit.extensions.TestSetup;
+import junit.framework.Assert;
 import junit.framework.Test;
 
 /**
@@ -268,17 +269,20 @@
     }
 
 
-    public static boolean deleteFile(final String fileName) 
+    public static void deleteFile(final String fileName) 
     {
-        Boolean ret = (Boolean) AccessController.doPrivileged
+        AccessController.doPrivileged
             (new java.security.PrivilegedAction() {
                         
                     public Object run() {
-                        return Boolean.valueOf((new File(fileName)).delete());
+                        File delFile = new File(fileName);
+                        if (!delFile.exists())
+                                return null;
+                         Assert.assertTrue(delFile.delete());
+                         return null;
                     }
                 }
              );
             
-        return ret.booleanValue();
     }
 }



Mime
View raw message