summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2012-08-26 19:45:17 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2012-08-26 19:45:17 +0000
commit3e547e1d59bd61e8d1ad9bab945af5d0eafba061 (patch)
treeb2e062d7c1e87129fcfd901fbe33e64f460b7524 /test
parent64f98b1d1067fbaa4d7cf2a825e682f845c600a7 (diff)
downloadjackcess-3e547e1d59bd61e8d1ad9bab945af5d0eafba061.tar.gz
jackcess-3e547e1d59bd61e8d1ad9bab945af5d0eafba061.zip
Add some more functionality to Joiner to facilitate integrity enforcement (hasRows and deleteRows)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@640 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/JoinerTest.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/JoinerTest.java b/test/src/java/com/healthmarketscience/jackcess/JoinerTest.java
index 87f70fd..d2049c3 100644
--- a/test/src/java/com/healthmarketscience/jackcess/JoinerTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/JoinerTest.java
@@ -45,7 +45,7 @@ public class JoinerTest extends TestCase {
{
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX)) {
- Database db = open(testDB);
+ Database db = openCopy(testDB);
Table t1 = db.getTable("Table1");
Table t2 = db.getTable("Table2");
Table t3 = db.getTable("Table3");
@@ -74,11 +74,13 @@ public class JoinerTest extends TestCase {
assertSame(t1t3, t3t1Join.getToIndex());
doTestJoiner(t3t1Join, createT3T1Data());
+
+ doTestJoinerDelete(t2t1Join);
}
}
- private void doTestJoiner(Joiner join,
- Map<Integer,List<Map<String,Object>>> expectedData)
+ private static void doTestJoiner(
+ Joiner join, Map<Integer,List<Map<String,Object>>> expectedData)
throws Exception
{
final Set<String> colNames = new HashSet<String>(
@@ -98,10 +100,12 @@ public class JoinerTest extends TestCase {
assertEquals(expectedData.get(id), joinedRows);
if(!expectedRows.isEmpty()) {
+ assertTrue(join.hasRows(row));
assertEquals(expectedRows.get(0), join.findFirstRow(row));
assertEquals(row, revJoin.findFirstRow(expectedRows.get(0)));
} else {
+ assertFalse(join.hasRows(row));
assertNull(join.findFirstRow(row));
}
@@ -128,6 +132,24 @@ public class JoinerTest extends TestCase {
}
}
+ private static void doTestJoinerDelete(Joiner t2t1Join) throws Exception
+ {
+ assertEquals(4, countRows(t2t1Join.getToTable()));
+
+ Map<String,Object> row = createExpectedRow("id", 1);
+ assertTrue(t2t1Join.hasRows(row));
+
+ assertTrue(t2t1Join.deleteRows(row));
+
+ assertFalse(t2t1Join.hasRows(row));
+ assertFalse(t2t1Join.deleteRows(row));
+
+ assertEquals(2, countRows(t2t1Join.getToTable()));
+ for(Map<String,Object> t1Row : t2t1Join.getToTable()) {
+ assertFalse(t1Row.get("otherfk1").equals(1));
+ }
+ }
+
private static Map<Integer,List<Map<String,Object>>> createT2T1Data()
{
Map<Integer,List<Map<String,Object>>> data = new