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 applyTo()
        public virtual void ApplyTo()
        {
            //Test that truncate commands correctly remove entries from the cache.

            //given
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log  log       = logProvider.getLog(this.GetType());
            long fromIndex = 2L;
            TruncateLogCommand truncateLogCommand = new TruncateLogCommand(fromIndex);
            InFlightCache      inFlightCache      = new ConsecutiveInFlightCache();

            inFlightCache.Put(0L, new RaftLogEntry(0L, valueOf(0)));
            inFlightCache.Put(1L, new RaftLogEntry(1L, valueOf(1)));
            inFlightCache.Put(2L, new RaftLogEntry(2L, valueOf(2)));
            inFlightCache.Put(3L, new RaftLogEntry(3L, valueOf(3)));

            //when
            truncateLogCommand.ApplyTo(inFlightCache, log);

            //then
            assertNotNull(inFlightCache.Get(0L));
            assertNotNull(inFlightCache.Get(1L));
            assertNull(inFlightCache.Get(2L));
            assertNull(inFlightCache.Get(3L));

            logProvider.AssertAtLeastOnce(inLog(this.GetType()).debug("Start truncating in-flight-map from index %d. Current map:%n%s", fromIndex, inFlightCache));
        }
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 shouldLogReasonForDroppingIndex() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogReasonForDroppingIndex()
        {
            // given
            AssertableLogProvider logProvider = new AssertableLogProvider();

            // when
            (new FailedIndexProxy(forSchema(forLabel(0, 0), IndexProviderDescriptor.UNDECIDED).withId(1).withoutCapabilities(), "foo", mock(typeof(IndexPopulator)), IndexPopulationFailure.Failure("it broke"), _indexCountsRemover, logProvider)).drop();

            // then
            logProvider.AssertAtLeastOnce(inLog(typeof(FailedIndexProxy)).info("FailedIndexProxy#drop index on foo dropped due to:\nit broke"));
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldComplainIfServerPortIsAlreadyTaken() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldComplainIfServerPortIsAlreadyTaken()
        {
            using (ServerSocket socket = new ServerSocket(0, 0, InetAddress.LocalHost))
            {
                ListenSocketAddress   contestedAddress = new ListenSocketAddress(socket.InetAddress.HostName, socket.LocalPort);
                AssertableLogProvider logProvider      = new AssertableLogProvider();
                CommunityNeoServer    server           = CommunityServerBuilder.server(logProvider).onAddress(contestedAddress).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build();
                try
                {
                    server.Start();

                    fail("Should have reported failure to start");
                }
                catch (ServerStartupException e)
                {
                    assertThat(e.Message, containsString("Starting Neo4j failed"));
                }

                logProvider.AssertAtLeastOnce(AssertableLogProvider.inLog(containsString("CommunityNeoServer")).error("Failed to start Neo4j on %s: %s", contestedAddress, format("Address %s is already in use, cannot bind to it.", contestedAddress)));
                server.Stop();
            }
        }