Below are two unit tests for Object[] as a value in a TransactionMap:
1) testObjectVec1 =
a) Object array vv[] is get from TransactionMap,
b) item at vv[2] is set to null
c) the array vv[] is put to the TransactionMap
d) rollback is called
2) testObjectVec2 =
a) Object array vv[] is get from TransactionMap,
b) item at vv[2] is set to null
c) array vv[] is copied to a new array vvCopy[]
d) the new array vvCopy[] is put to the TransactionMap
e) rollback is called
Both tests 1) and 2) fail at:
assertNotNull(vvv[2]);
Thus it seems that rollback is not working correctly?
@Test
public void testObjectVec1() {
//Create a new MVStore file
File file = new File(System.getProperty("java.io.tmpdir"),
"testTransactionMapWithSet.dat");
if (file.exists()) {
file.delete();
}
MVStore s = new
MVStore.Builder().fileName(file.getAbsolutePath()).open();
TransactionStore ts = new TransactionStore(s);
ts.init();
Transaction tx = ts.begin();
TransactionMap<Integer,Object[]> setMap = tx.openMap("testMap");
Object[] v = new Object[3];
v[0] = 1;
v[1] = "hi-1";
v[2] = 2;
setMap.put(0, v);
tx.commit();
tx = ts.begin();
TransactionMap<Integer,Object[]> setMap2 = tx.openMap("testMap");
Object[] vv = setMap2.get(0);
vv[2] = null;
setMap2.put(0, vv);
tx.rollback();
tx = ts.begin();
TransactionMap<Integer,Object[]> setMap3 = tx.openMap("testMap");
Object[] vvv = setMap3.get(0);
System.out.println("vvv[0]="+vvv[0]+" vvv[1]="+vvv[1]+" vvv[2]="+vvv[2]);
tx.rollback();
//ASSERT FAILS!
assertNotNull(vvv[2]);
//Close all
ts.close();
s.close();
}
@Test
public void testObjectVec2() {
//Create a new MVStore file
File file = new File(System.getProperty("java.io.tmpdir"),
"testTransactionMapWithSet.dat");
if (file.exists()) {
file.delete();
}
MVStore s = new
MVStore.Builder().fileName(file.getAbsolutePath()).open();
TransactionStore ts = new TransactionStore(s);
ts.init();
Transaction tx = ts.begin();
TransactionMap<Integer,Object[]> setMap = tx.openMap("testMap");
Object[] v = new Object[3];
v[0] = 1;
v[1] = "hi-1";
v[2] = 2;
setMap.put(0, v);
tx.commit();
tx = ts.begin();
TransactionMap<Integer,Object[]> setMap2 = tx.openMap("testMap");
Object[] vv = setMap2.get(0);
vv[2] = null;
Object[] vvCopy = Arrays.copyOf(vv, vv.length);
setMap2.put(0, vvCopy);
tx.rollback();
tx = ts.begin();
TransactionMap<Integer,Object[]> setMap3 = tx.openMap("testMap");
Object[] vvv = setMap3.get(0);
System.out.println("vvv[0]="+vvv[0]+" vvv[1]="+vvv[1]+" vvv[2]="+vvv[2]);
tx.rollback();
//ASSERT FAILS!
assertNotNull(vvv[2]);
//Close all
ts.close();
s.close();
}
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.