Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void endLockSessionDoesNotUnpackResponse() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void EndLockSessionDoesNotUnpackResponse()
        {
            StoreId storeId       = new StoreId(1, 2, 3, 4, 5);
            long    txChecksum    = 123;
            long    lastAppliedTx = 5;

            ResponseUnpacker responseUnpacker = mock(typeof(ResponseUnpacker));

            MasterImpl.SPI masterImplSPI = MasterImplTest.mockedSpi(storeId);
            when(masterImplSPI.PackTransactionObligationResponse(any(typeof(RequestContext)), ArgumentMatchers.any())).thenReturn(Response.empty());
            when(masterImplSPI.GetTransactionChecksum(anyLong())).thenReturn(txChecksum);

            NewMasterServer(masterImplSPI);

            MasterClient client = NewMasterClient320(storeId, responseUnpacker);

            HandshakeResult handshakeResult;

            using (Response <HandshakeResult> handshakeResponse = client.Handshake(1, storeId))
            {
                handshakeResult = handshakeResponse.ResponseConflict();
            }
            verify(responseUnpacker).unpackResponse(any(typeof(Response)), any(typeof(TxHandler)));
            reset(responseUnpacker);

            RequestContext context = new RequestContext(handshakeResult.Epoch(), 1, 1, lastAppliedTx, txChecksum);

            client.EndLockSession(context, false);
            verify(responseUnpacker, never()).unpackResponse(any(typeof(Response)), any(typeof(TxHandler)));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailSubsequentRequestsAfterAllocateIdsAfterMasterSwitch() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailSubsequentRequestsAfterAllocateIdsAfterMasterSwitch()
        {
            // GIVEN
            MasterImpl.SPI spi = MasterImplTest.mockedSpi();
            IdAllocation   servedIdAllocation = IdAllocation(0, 999);

            when(spi.AllocateIds(any(typeof(IdType)))).thenReturn(servedIdAllocation);
            when(spi.GetTransactionChecksum(anyLong())).thenReturn(10L);
            StoreId         storeId   = newStoreIdForCurrentVersion();
            MasterImpl      master    = new MasterImpl(spi, mock(typeof(ConversationManager)), mock(typeof(MasterImpl.Monitor)), Config.defaults(ClusterSettings.server_id, "1"));
            HandshakeResult handshake = master.Handshake(1, storeId).response();

            master.Start();

            // WHEN/THEN
            IdAllocation idAllocation = master.AllocateIds(Context(handshake.Epoch()), IdType.NODE).response();

            assertEquals(servedIdAllocation.HighestIdInUse, idAllocation.HighestIdInUse);
            try
            {
                master.AllocateIds(Context(handshake.Epoch() + 1), IdType.NODE);
                fail("Should fail with invalid epoch");
            }
            catch (InvalidEpochException)
            {               // Good
            }
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = org.neo4j.kernel.impl.store.MismatchingStoreIdException.class) public void newClientsShouldNotIgnoreStoreIdDifferences() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void NewClientsShouldNotIgnoreStoreIdDifferences()
        {
            // Given
            MasterImpl.SPI masterImplSPI = MasterImplTest.mockedSpi(StoreIdTestFactory.newStoreIdForCurrentVersion(1, 2, 3, 4));
            when(masterImplSPI.GetTransactionChecksum(anyLong())).thenReturn(5L);

            NewMasterServer(masterImplSPI);

            StoreId      storeId      = StoreIdTestFactory.newStoreIdForCurrentVersion(5, 6, 7, 8);
            MasterClient masterClient = NewMasterClient320(storeId);

            // When
            masterClient.Handshake(1, storeId);
        }