Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowCommitIfClientHoldsNoLocks() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowCommitIfClientHoldsNoLocks()
        {
            // Given
            MasterImpl.SPI         spi                 = mock(typeof(MasterImpl.SPI));
            Config                 config              = config();
            DefaultConversationSPI conversationSpi     = MockedConversationSpi();
            ConversationManager    conversationManager = new ConversationManager(conversationSpi, config);

            when(spi.Accessible).thenReturn(true);
            when(spi.GetTransactionChecksum(anyLong())).thenReturn(1L);
            MockEmptyResponse(spi);

            MasterImpl master = new MasterImpl(spi, conversationManager, mock(typeof(MasterImpl.Monitor)), config);

            master.Start();
            HandshakeResult handshake = master.Handshake(1, newStoreIdForCurrentVersion()).response();

            const int                 noLockSession = -1;
            RequestContext            ctx           = new RequestContext(handshake.Epoch(), 1, noLockSession, 0, 0);
            TransactionRepresentation tx            = mock(typeof(TransactionRepresentation));

            // When
            master.Commit(ctx, tx);

            // Then
            verify(spi).applyPreparedTransaction(tx);
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failingToStartTxShouldNotLeadToNPE() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FailingToStartTxShouldNotLeadToNPE()
        {
            // Given
            MasterImpl.SPI         spi             = MockedSpi();
            DefaultConversationSPI conversationSpi = MockedConversationSpi();
            Config config = config();
            ConversationManager conversationManager = new ConversationManager(conversationSpi, config);

            when(spi.Accessible).thenReturn(true);
            when(conversationSpi.AcquireClient()).thenThrow(new Exception("Nope"));
            when(spi.GetTransactionChecksum(anyLong())).thenReturn(1L);
            MockEmptyResponse(spi);

            MasterImpl instance = new MasterImpl(spi, conversationManager, mock(typeof(MasterImpl.Monitor)), config);

            instance.Start();
            Response <HandshakeResult> response  = instance.Handshake(1, newStoreIdForCurrentVersion());
            HandshakeResult            handshake = response.ResponseConflict();

            // When
            try
            {
                instance.NewLockSession(new RequestContext(handshake.Epoch(), 1, 2, 0, 0));
                fail("Should have failed.");
            }
            catch (Exception e)
            {
                // Then
                assertThat(e, instanceOf(typeof(Exception)));
                assertThat(e.Message, equalTo("Nope"));
            }
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAllowCommitIfThereIsNoMatchingLockSession() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotAllowCommitIfThereIsNoMatchingLockSession()
        {
            // Given
            MasterImpl.SPI         spi             = mock(typeof(MasterImpl.SPI));
            DefaultConversationSPI conversationSpi = MockedConversationSpi();
            Config config = config();
            ConversationManager conversationManager = new ConversationManager(conversationSpi, config);

            when(spi.Accessible).thenReturn(true);
            when(spi.GetTransactionChecksum(anyLong())).thenReturn(1L);
            MockEmptyResponse(spi);

            MasterImpl master = new MasterImpl(spi, conversationManager, mock(typeof(MasterImpl.Monitor)), config);

            master.Start();
            HandshakeResult handshake = master.Handshake(1, newStoreIdForCurrentVersion()).response();

            RequestContext ctx = new RequestContext(handshake.Epoch(), 1, 2, 0, 0);

            // When
            try
            {
                master.Commit(ctx, mock(typeof(TransactionRepresentation)));
                fail("Should have failed.");
            }
            catch (TransactionNotPresentOnMasterException e)
            {
                // Then
                assertThat(e.Message, equalTo((new TransactionNotPresentOnMasterException(ctx)).Message));
            }
        }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void givenStartedAndAccessibleWhenNewLockSessionThenSucceeds() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void GivenStartedAndAccessibleWhenNewLockSessionThenSucceeds()
        {
            // Given
            MasterImpl.SPI spi    = MockedSpi();
            Config         config = config();

            when(spi.Accessible).thenReturn(true);
            when(spi.GetTransactionChecksum(anyLong())).thenReturn(1L);

            MasterImpl instance = new MasterImpl(spi, mock(typeof(ConversationManager)), mock(typeof(MasterImpl.Monitor)), config);

            instance.Start();
            HandshakeResult handshake = instance.Handshake(1, newStoreIdForCurrentVersion()).response();

            // When
            try
            {
                instance.NewLockSession(new RequestContext(handshake.Epoch(), 1, 2, 0, 0));
            }
            catch (Exception e)
            {
                fail(e.Message);
            }
        }