Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOpenTheNextChannelWhenItExists() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldOpenTheNextChannelWhenItExists()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.io.fs.StoreChannel newStoreChannel = mock(org.neo4j.io.fs.StoreChannel.class);
            StoreChannel newStoreChannel = mock(typeof(StoreChannel));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge bridge = new org.neo4j.kernel.impl.transaction.log.ReaderLogVersionBridge(logFiles);
            ReaderLogVersionBridge bridge = new ReaderLogVersionBridge(_logFiles);

            when(_channel.Version).thenReturn(_version);
            when(_channel.LogFormatVersion).thenReturn(CURRENT_LOG_VERSION);
            when(_fs.fileExists(any(typeof(File)))).thenReturn(true);
            when(_fs.open(any(typeof(File)), eq(OpenMode.READ))).thenReturn(newStoreChannel);
            when(newStoreChannel.read(ArgumentMatchers.any <ByteBuffer>())).then(invocationOnMock =>
            {
                ByteBuffer buffer = invocationOnMock.getArgument(0);
                buffer.putLong(encodeLogVersion(_version + 1));
                buffer.putLong(42);
                return(LOG_HEADER_SIZE);
            });

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogVersionedStoreChannel result = bridge.next(channel);
            LogVersionedStoreChannel result = bridge.Next(_channel);

            // then
            PhysicalLogVersionedStoreChannel expected = new PhysicalLogVersionedStoreChannel(newStoreChannel, _version + 1, CURRENT_LOG_VERSION);

            assertEquals(expected, result);
            verify(_channel, times(1)).close();
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDropMessagesIfForDifferentClusterId() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDropMessagesIfForDifferentClusterId()
        {
            // given
            _handler.start(_clusterId);

            // when
            _handler.handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_ReceivedInstantClusterIdAwareMessage.of(Instant.now(), new ClusterId(System.Guid.randomUUID()), new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat(new MemberId(System.Guid.randomUUID()), 0L, 0, 0)
                                                                                                                           ));

            // then
            verify(@delegate, Mockito.never()).handle(ArgumentMatchers.any(typeof(Org.Neo4j.causalclustering.core.consensus.RaftMessages_ReceivedInstantClusterIdAwareMessage)));
        }
Ejemplo n.º 3
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)));
        }