[Libreoffice-commits] core.git: connectivity/qa dbaccess/qa
Stephan Bergmann
sbergman at redhat.com
Thu Nov 16 17:28:57 UTC 2017
connectivity/qa/connectivity/tools/AbstractDatabase.java | 9 -------
connectivity/qa/connectivity/tools/HsqlDatabase.java | 19 +++++++++++----
dbaccess/qa/complex/dbaccess/RowSet.java | 6 ++++
3 files changed, 22 insertions(+), 12 deletions(-)
New commits:
commit 84e1a01e2d1964a143f5b01fa0b70d9570dcb834
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Nov 16 08:30:07 2017 +0100
Delete test*.odb files
...that are created in java.io.tmpdir (e.g., /tmp on Linux) by
connectivity.tools.HsqlDatabase.createDBDocument() during e.g.
JunitTest_dbaccess_complex.
This revealed that connectivity.tools.AbstractDatabase.delete() (even if it
would have been called by the test) would have been non-effective at deleting
the file, as the java.io.File constructor used takes a pathname not a file URL
as argument, so the call to java.io.File.delete() would not have deleted the
relevant file (and returned false, rather).
Change-Id: I268e1d1732ac7a0db9ccde7d4ac4f09aa3811e11
Reviewed-on: https://gerrit.libreoffice.org/44801
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/connectivity/qa/connectivity/tools/AbstractDatabase.java b/connectivity/qa/connectivity/tools/AbstractDatabase.java
index f7295d948517..601b36e23038 100644
--- a/connectivity/qa/connectivity/tools/AbstractDatabase.java
+++ b/connectivity/qa/connectivity/tools/AbstractDatabase.java
@@ -124,14 +124,7 @@ public abstract class AbstractDatabase implements DatabaseAccess
delete();
}
- private void delete()
- {
- if (m_databaseDocumentFile != null)
- {
- final File file = new File(m_databaseDocumentFile);
- file.delete();
- }
- }
+ protected void delete() {}
/** returns the underlying database document
*/
diff --git a/connectivity/qa/connectivity/tools/HsqlDatabase.java b/connectivity/qa/connectivity/tools/HsqlDatabase.java
index 13b0f32d24ae..94e994bffdf6 100644
--- a/connectivity/qa/connectivity/tools/HsqlDatabase.java
+++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java
@@ -33,6 +33,7 @@ import helper.URLHelper;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
+import org.junit.Assert;
public class HsqlDatabase extends AbstractDatabase
{
@@ -54,10 +55,11 @@ public class HsqlDatabase extends AbstractDatabase
*/
private void createDBDocument() throws Exception
{
- final File documentFile = File.createTempFile("testdb", ".odb");
- if ( documentFile.exists() )
- documentFile.delete();
- m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath(documentFile);
+ Assert.assertNull(m_documentFile);
+ m_documentFile = File.createTempFile("testdb", ".odb");
+ if ( m_documentFile.exists() )
+ m_documentFile.delete();
+ m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath(m_documentFile);
m_databaseDocument = UnoRuntime.queryInterface(
XOfficeDatabaseDocument.class, m_orb.createInstance("com.sun.star.sdb.OfficeDatabaseDocument"));
@@ -72,6 +74,13 @@ public class HsqlDatabase extends AbstractDatabase
} );
}
+ @Override protected final void delete() {
+ if (m_documentFile != null) {
+ boolean ok = m_documentFile.delete();
+ Assert.assertTrue("delete " + m_documentFile.getPath(), ok);
+ }
+ }
+
/** drops the table with a given name
@param _name
@@ -188,4 +197,6 @@ public class HsqlDatabase extends AbstractDatabase
final XAppend appendTable = UnoRuntime.queryInterface( XAppend.class, suppTables.getTables() );
appendTable.appendByDescriptor(sdbcxDescriptor);
}
+
+ private File m_documentFile;
}
diff --git a/dbaccess/qa/complex/dbaccess/RowSet.java b/dbaccess/qa/complex/dbaccess/RowSet.java
index e617d2546525..4c5fcc6da793 100644
--- a/dbaccess/qa/complex/dbaccess/RowSet.java
+++ b/dbaccess/qa/complex/dbaccess/RowSet.java
@@ -47,6 +47,7 @@ import java.lang.reflect.Method;
import java.util.Random;
// ---------- junit imports -----------------
+import org.junit.After;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -127,6 +128,11 @@ public class RowSet extends TestCase
}
}
+ @After public final void closeAndDeleteDatabase() {
+ if (m_database != null) {
+ m_database.closeAndDelete();
+ }
+ }
/** creates a com.sun.star.sdb.RowSet to use during the test
* @param command
More information about the Libreoffice-commits
mailing list