org.apache.curator.framework.api.transaction.TransactionCheckBuilder Java Examples
The following examples show how to use
org.apache.curator.framework.api.transaction.TransactionCheckBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobNodeStorageTest.java From shardingsphere-elasticjob-lite with Apache License 2.0 | 6 votes |
@Test public void assertExecuteInTransactionSuccess() throws Exception { CuratorFramework client = mock(CuratorFramework.class); CuratorTransaction curatorTransaction = mock(CuratorTransaction.class); TransactionCheckBuilder transactionCheckBuilder = mock(TransactionCheckBuilder.class); CuratorTransactionBridge curatorTransactionBridge = mock(CuratorTransactionBridge.class); CuratorTransactionFinal curatorTransactionFinal = mock(CuratorTransactionFinal.class); when(regCenter.getRawClient()).thenReturn(client); when(client.inTransaction()).thenReturn(curatorTransaction); when(curatorTransaction.check()).thenReturn(transactionCheckBuilder); when(transactionCheckBuilder.forPath("/")).thenReturn(curatorTransactionBridge); when(curatorTransactionBridge.and()).thenReturn(curatorTransactionFinal); TransactionCreateBuilder transactionCreateBuilder = mock(TransactionCreateBuilder.class); when(curatorTransactionFinal.create()).thenReturn(transactionCreateBuilder); when(transactionCreateBuilder.forPath("/test_transaction")).thenReturn(curatorTransactionBridge); when(curatorTransactionBridge.and()).thenReturn(curatorTransactionFinal); jobNodeStorage.executeInTransaction(curatorTransactionFinalForCallback -> curatorTransactionFinalForCallback.create().forPath("/test_transaction").and()); verify(regCenter).getRawClient(); verify(client).inTransaction(); verify(curatorTransaction).check(); verify(transactionCheckBuilder).forPath("/"); verify(curatorTransactionBridge, times(2)).and(); verify(curatorTransactionFinal).create(); verify(transactionCreateBuilder).forPath("/test_transaction"); verify(curatorTransactionFinal).commit(); }
Example #2
Source File: JobNodeStorageTest.java From shardingsphere-elasticjob-lite with Apache License 2.0 | 6 votes |
@Test(expected = RuntimeException.class) public void assertExecuteInTransactionFailure() throws Exception { CuratorFramework client = mock(CuratorFramework.class); CuratorTransaction curatorTransaction = mock(CuratorTransaction.class); TransactionCheckBuilder transactionCheckBuilder = mock(TransactionCheckBuilder.class); CuratorTransactionBridge curatorTransactionBridge = mock(CuratorTransactionBridge.class); CuratorTransactionFinal curatorTransactionFinal = mock(CuratorTransactionFinal.class); when(regCenter.getRawClient()).thenReturn(client); when(client.inTransaction()).thenReturn(curatorTransaction); when(curatorTransaction.check()).thenReturn(transactionCheckBuilder); when(transactionCheckBuilder.forPath("/")).thenReturn(curatorTransactionBridge); when(curatorTransactionBridge.and()).thenReturn(curatorTransactionFinal); when(curatorTransactionBridge.and()).thenThrow(new RuntimeException()); jobNodeStorage.executeInTransaction(curatorTransactionFinalForCallback -> curatorTransactionFinalForCallback.create().forPath("/test_transaction").and()); verify(regCenter).getRawClient(); verify(client).inTransaction(); verify(curatorTransaction).check(); verify(transactionCheckBuilder).forPath("/"); verify(curatorTransactionBridge, times(2)).and(); verify(curatorTransactionFinal).create(); verify(curatorTransactionFinal, times(0)).commit(); }
Example #3
Source File: MockCurator.java From vespa with Apache License 2.0 | 4 votes |
@Override public TransactionCheckBuilder check() { ensureNotCommitted(); throw new UnsupportedOperationException("Not implemented in MockCurator"); }
Example #4
Source File: TransactionOpImpl.java From curator with Apache License 2.0 | 4 votes |
@Override public TransactionCheckBuilder<CuratorOp> check() { ExtractingCuratorOp op = new ExtractingCuratorOp(); return CuratorTransactionImpl.<CuratorOp>makeTransactionCheckBuilder(client, op, op.getRecord()); }