Example #1
0
        /*
         * Tests that we unfreeze active transactions after commit and after apply of batch if batch length (in time)
         * is larger than safeZone time.
         */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldUnfreezeKernelTransactionsAfterApplyIfBatchIsLarge()
        {
            // GIVEN
            int          maxBatchSize                = 10;
            long         idReuseSafeZoneTime         = 100;
            Dependencies dependencies                = mock(typeof(Dependencies));
            TransactionObligationFulfiller fulfiller = mock(typeof(TransactionObligationFulfiller));

            when(dependencies.ObligationFulfiller()).thenReturn(fulfiller);
            when(dependencies.LogService()).thenReturn(NullLogService.Instance);
            when(dependencies.VersionContextSupplier()).thenReturn(EmptyVersionContextSupplier.EMPTY);
            KernelTransactions kernelTransactions = mock(typeof(KernelTransactions));

            when(dependencies.KernelTransactions()).thenReturn(kernelTransactions);
            TransactionCommitProcess commitProcess = mock(typeof(TransactionCommitProcess));

            when(dependencies.CommitProcess()).thenReturn(commitProcess);
            TransactionCommittingResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(dependencies, maxBatchSize, idReuseSafeZoneTime));

            // WHEN
            int txCount       = maxBatchSize;
            int doesNotMatter = 1;

            unpacker.UnpackResponse(new DummyTransactionResponse(doesNotMatter, txCount, idReuseSafeZoneTime + 1), NO_OP_TX_HANDLER);

            // THEN
            InOrder inOrder = inOrder(commitProcess, kernelTransactions);

            inOrder.verify(commitProcess, times(1)).commit(any(), any(), any());
            inOrder.verify(kernelTransactions, times(1)).unblockNewTransactions();
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAwaitTransactionObligationsToBeFulfilled() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAwaitTransactionObligationsToBeFulfilled()
        {
            // GIVEN
            Dependencies dependencies = mock(typeof(Dependencies));
            TransactionObligationFulfiller fulfiller = mock(typeof(TransactionObligationFulfiller));

            when(dependencies.ObligationFulfiller()).thenReturn(fulfiller);
            when(dependencies.LogService()).thenReturn(NullLogService.Instance);
            TransactionCommittingResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(dependencies, 10, 0));

            // WHEN
            unpacker.UnpackResponse(new DummyObligationResponse(4), NO_OP_TX_HANDLER);

            // THEN
            verify(fulfiller, times(1)).fulfill(4L);
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCommitTransactionsInBatches() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCommitTransactionsInBatches()
        {
            // GIVEN
            Dependencies dependencies = mock(typeof(Dependencies));
            TransactionCountingTransactionCommitProcess commitProcess = new TransactionCountingTransactionCommitProcess(this);

            when(dependencies.CommitProcess()).thenReturn(commitProcess);
            when(dependencies.LogService()).thenReturn(NullLogService.Instance);
            when(dependencies.VersionContextSupplier()).thenReturn(EmptyVersionContextSupplier.EMPTY);
            KernelTransactions kernelTransactions = mock(typeof(KernelTransactions));

            when(dependencies.KernelTransactions()).thenReturn(kernelTransactions);
            TransactionCommittingResponseUnpacker unpacker = Life.add(new TransactionCommittingResponseUnpacker(dependencies, 5, 0));

            // WHEN
            unpacker.UnpackResponse(new DummyTransactionResponse(BASE_TX_ID + 1, 7), NO_OP_TX_HANDLER);

            // THEN
            commitProcess.AssertBatchSize(5);
            commitProcess.AssertBatchSize(2);
            commitProcess.AssertNoMoreBatches();
        }