use of com.alibaba.druid.mock.MockSavepoint in project seata by seata.
the class ConnectionContextProxyTest method testGetAfterSavepoints.
@Test
@SuppressWarnings("unchecked")
public void testGetAfterSavepoints() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
Savepoint sp1 = new MockSavepoint();
Savepoint sp2 = new MockSavepoint();
Savepoint sp3 = new MockSavepoint();
connectionContext.appendSavepoint(sp1);
connectionContext.appendSavepoint(sp2);
connectionContext.appendSavepoint(sp3);
Method m = ConnectionContext.class.getDeclaredMethod("getAfterSavepoints", Savepoint.class);
m.setAccessible(true);
List<Savepoint> invoke = (List<Savepoint>) m.invoke(connectionContext, new Object[] { null });
Assertions.assertEquals(invoke.size(), 3);
invoke = (List<Savepoint>) m.invoke(connectionContext, sp2);
Assertions.assertEquals(invoke.size(), 2);
}
use of com.alibaba.druid.mock.MockSavepoint in project seata by seata.
the class ConnectionContextProxyTest method testRemoveSavepoint.
@Test
public void testRemoveSavepoint() {
Savepoint sp1 = new MockSavepoint();
connectionContext.appendSavepoint(sp1);
connectionContext.appendUndoItem(new SQLUndoLog());
connectionContext.appendLockKey("sp1-lock-key");
Savepoint sp2 = new MockSavepoint();
connectionContext.appendSavepoint(sp2);
Savepoint sp3 = new MockSavepoint();
connectionContext.appendSavepoint(sp3);
connectionContext.appendLockKey("sp3-lock-key");
connectionContext.appendUndoItem(new SQLUndoLog());
Assertions.assertEquals(connectionContext.getUndoItems().size(), 2);
Assertions.assertEquals(connectionContext.buildLockKeys(), "sp3-lock-key;sp1-lock-key");
connectionContext.removeSavepoint(sp3);
Assertions.assertEquals(connectionContext.getUndoItems().size(), 1);
Assertions.assertEquals(connectionContext.buildLockKeys(), "sp1-lock-key");
connectionContext.removeSavepoint(null);
Assertions.assertEquals(connectionContext.getUndoItems().size(), 0);
Assertions.assertNull(connectionContext.buildLockKeys());
}
use of com.alibaba.druid.mock.MockSavepoint in project seata by seata.
the class ConnectionContextProxyTest method testReleaseSavepoint.
@Test
public void testReleaseSavepoint() {
Savepoint sp1 = new MockSavepoint();
connectionContext.appendSavepoint(sp1);
connectionContext.appendUndoItem(new SQLUndoLog());
connectionContext.appendLockKey("sp1-lock-key");
Savepoint sp2 = new MockSavepoint();
connectionContext.appendSavepoint(sp2);
Savepoint sp3 = new MockSavepoint();
connectionContext.appendSavepoint(sp3);
connectionContext.appendLockKey("sp3-lock-key");
connectionContext.appendUndoItem(new SQLUndoLog());
Assertions.assertEquals(connectionContext.getUndoItems().size(), 2);
Assertions.assertEquals(connectionContext.buildLockKeys(), "sp3-lock-key;sp1-lock-key");
connectionContext.releaseSavepoint(sp3);
Assertions.assertEquals(connectionContext.getUndoItems().size(), 2);
Assertions.assertEquals(connectionContext.buildLockKeys(), "sp3-lock-key;sp1-lock-key");
connectionContext.releaseSavepoint(null);
Assertions.assertEquals(connectionContext.getUndoItems().size(), 2);
Assertions.assertEquals(connectionContext.buildLockKeys(), "sp3-lock-key;sp1-lock-key");
}
Aggregations