@Override public Object invoke(HandleDing h, Object target, Object[] args, MethodProxy mp) { h.getHandle().checkpoint(String.valueOf(args[0])); return null; } }
public Object invoke(HandleDing h, Object target, Object[] args, MethodProxy mp) { h.getHandle().checkpoint(String.valueOf(args[0])); return null; } }
@Test public void testCheckpoint() throws Exception { h.begin(); h.checkpoint("a"); assertTrue(logged.contains("checkpoint a created")); h.rollback("a"); assertTrue(logged.contains("checkpoint a rolled back to")); h.checkpoint("b"); assertTrue(logged.contains("checkpoint b created")); h.release("b"); assertTrue(logged.contains("checkpoint b released")); h.commit(); } }
@Test public void testCheckpoint() throws Exception { h.begin(); h.checkpoint("a"); assertTrue(logged.contains("checkpoint a created")); h.rollback("a"); assertTrue(logged.contains("checkpoint a rolled back to")); h.checkpoint("b"); assertTrue(logged.contains("checkpoint b created")); h.release("b"); assertTrue(logged.contains("checkpoint b released")); h.commit(); } }
@Test public void testCheckpoint() throws Exception { Handle h = openHandle(); h.begin(); h.insert("insert into something (id, name) values (:id, :name)", 1, "Tom"); h.checkpoint("first"); h.insert("insert into something (id, name) values (:id, :name)", 1, "Martin"); assertEquals(Integer.valueOf(2), h.createQuery("select count(*) from something").mapTo(Integer.class).first()); h.rollback("first"); assertEquals(Integer.valueOf(1), h.createQuery("select count(*) from something").mapTo(Integer.class).first()); h.commit(); assertEquals(Integer.valueOf(1), h.createQuery("select count(*) from something").mapTo(Integer.class).first()); }
@Test public void testCheckpoint() throws Exception { Handle h = openHandle(); h.begin(); h.insert("insert into something (id, name) values (:id, :name)", 1, "Tom"); h.checkpoint("first"); h.insert("insert into something (id, name) values (:id, :name)", 1, "Martin"); assertEquals(Integer.valueOf(2), h.createQuery("select count(*) from something").map(new IntegerMapper()).first()); h.rollback("first"); assertEquals(Integer.valueOf(1), h.createQuery("select count(*) from something").map(new IntegerMapper()).first()); h.commit(); assertEquals(Integer.valueOf(1), h.createQuery("select count(*) from something").map(new IntegerMapper()).first()); }
@Test public void testReleaseCheckpoint() throws Exception { Handle h = openHandle(); h.begin(); h.checkpoint("first"); h.insert("insert into something (id, name) values (:id, :name)", 1, "Martin"); h.release("first"); try { h.rollback("first"); fail("Should have thrown an exception of some kind"); } catch (TransactionException e) { h.rollback(); assertTrue(true); } }
@Test public void testReleaseCheckpoint() throws Exception { Handle h = openHandle(); h.begin(); h.checkpoint("first"); h.insert("insert into something (id, name) values (:id, :name)", 1, "Martin"); h.release("first"); try { h.rollback("first"); fail("Should have thrown an exception of some kind"); } catch (TransactionException e) { h.rollback(); assertTrue(true); } }