Example #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));
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void acquiringATransactionThatHasAlreadyBeenAcquiredShouldThrowInvalidConcurrentTransactionAccess() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AcquiringATransactionThatHasAlreadyBeenAcquiredShouldThrowInvalidConcurrentTransactionAccess()
        {
            // Given
            AssertableLogProvider     logProvider = new AssertableLogProvider();
            TransactionHandleRegistry registry    = new TransactionHandleRegistry(Clocks.fakeClock(), 0, logProvider);
            TransactionHandle         handle      = mock(typeof(TransactionHandle));

            long id = registry.Begin(handle);

            registry.Release(id, handle);
            registry.Acquire(id);

            // When
            try
            {
                registry.Acquire(id);
                fail("Should have thrown exception");
            }
            catch (InvalidConcurrentTransactionAccess)
            {
                // expected
            }

            // then
            logProvider.AssertNoLoggingOccurred();
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void expiryTimeShouldBeSetToCurrentTimePlusTimeout() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ExpiryTimeShouldBeSetToCurrentTimePlusTimeout()
        {
            // Given
            AssertableLogProvider logProvider = new AssertableLogProvider();
            FakeClock             clock       = Clocks.fakeClock();
            int timeoutLength = 123;

            TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, timeoutLength, logProvider);
            TransactionHandle         handle   = mock(typeof(TransactionHandle));

            long id = registry.Begin(handle);

            // When
            long timesOutAt = registry.Release(id, handle);

            // Then
            assertThat(timesOutAt, equalTo(clock.Millis() + timeoutLength));

            // And when
            clock.Forward(1337, TimeUnit.MILLISECONDS);
            registry.Acquire(id);
            timesOutAt = registry.Release(id, handle);

            // Then
            assertThat(timesOutAt, equalTo(clock.Millis() + timeoutLength));
        }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void assertConsistentStore(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException
        public static void AssertConsistentStore(DatabaseLayout databaseLayout)
        {
            Config configuration         = Config.defaults(GraphDatabaseSettings.pagecache_memory, "8m");
            AssertableLogProvider logger = new AssertableLogProvider();

            ConsistencyCheckService.Result result = (new ConsistencyCheckService()).runFullConsistencyCheck(databaseLayout, configuration, ProgressMonitorFactory.NONE, NullLogProvider.Instance, false);

            assertTrue("Consistency check for " + databaseLayout + " found inconsistencies:\n\n" + logger.Serialize(), result.Successful);
        }
Example #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogFailedRule()
        public virtual void ShouldLogFailedRule()
        {
            AssertableLogProvider logProvider = new AssertableLogProvider();
            PreFlightTasks        check       = new PreFlightTasks(logProvider, WithOneFailingRule);

            check.Run();

            logProvider.AssertExactly(inLog(typeof(PreFlightTasks)).error("blah blah"));
        }
 private void VerifySectionReportedCorrectly(AssertableLogProvider logProvider)
 {
     logProvider.FormattedMessageMatcher().assertContains(VisibleMigrationProgressMonitor.MESSAGE_STARTED);
     for (int i = 10; i <= 100; i += 10)
     {
         logProvider.FormattedMessageMatcher().assertContains(i + "%");
     }
     logProvider.AssertNone(AssertableLogProvider.inLog(typeof(VisibleMigrationProgressMonitor)).info(containsString("110%")));
     logProvider.FormattedMessageMatcher().assertContains(VisibleMigrationProgressMonitor.MESSAGE_COMPLETED);
 }
Example #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void noNotificationForTransactionLogs()
        public virtual void NoNotificationForTransactionLogs()
        {
            AssertableLogProvider            internalLogProvider = new AssertableLogProvider(false);
            DefaultFileDeletionEventListener listener            = BuildListener(internalLogProvider);

            listener.FileDeleted(TransactionLogFiles.DEFAULT_NAME + ".0");
            listener.FileDeleted(TransactionLogFiles.DEFAULT_NAME + ".1");

            internalLogProvider.AssertNoLoggingOccurred();
        }
Example #8
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"));
        }
Example #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void notificationInLogAboutFileDeletion()
        public virtual void NotificationInLogAboutFileDeletion()
        {
            AssertableLogProvider            internalLogProvider = new AssertableLogProvider(false);
            DefaultFileDeletionEventListener listener            = BuildListener(internalLogProvider);

            listener.FileDeleted("testFile.db");
            listener.FileDeleted("anotherDirectory");

            internalLogProvider.RawMessageMatcher().assertContains("'testFile.db' which belongs to the store was deleted while database was running.");
            internalLogProvider.RawMessageMatcher().assertContains("'anotherDirectory' which belongs to the store was deleted while database was running.");
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void progressNeverReportMoreThenHundredPercent()
        public virtual void ProgressNeverReportMoreThenHundredPercent()
        {
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log log = logProvider.getLog(this.GetType());
            VisibleMigrationProgressMonitor monitor = new VisibleMigrationProgressMonitor(log);

            monitor.Started(1);
            MonitorSection(monitor, "First", 100, 1, 10, 99, 170);
            monitor.Completed();

            VerifySectionReportedCorrectly(logProvider);
        }
Example #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = org.neo4j.server.rest.transactional.error.InvalidTransactionId.class) public void gettingInterruptHandlerForUnknownIdShouldThrowErrorInvalidTransactionId() throws org.neo4j.server.rest.transactional.error.TransactionLifecycleException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void GettingInterruptHandlerForUnknownIdShouldThrowErrorInvalidTransactionId()
        {
            // Given
            AssertableLogProvider logProvider = new AssertableLogProvider();
            FakeClock             clock       = Clocks.fakeClock();
            int timeoutLength = 123;

            TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, timeoutLength, logProvider);

            // When
            registry.Terminate(456);
        }
Example #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void startStopDatabaseWithIndex()
        public virtual void StartStopDatabaseWithIndex()
        {
            Label  label    = Label.label("string");
            string property = "property";
            AssertableLogProvider logProvider = new AssertableLogProvider(true);
            GraphDatabaseService  db          = PrepareDb(label, property, logProvider);

            Db.shutdown();
            db = GetDatabase(logProvider);
            Db.shutdown();

            logProvider.FormattedMessageMatcher().assertNotContains("Failed to open index");
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void tracePageCacheFlushProgress()
        public virtual void TracePageCacheFlushProgress()
        {
            AssertableLogProvider logProvider = new AssertableLogProvider(true);
            GraphDatabaseService  database    = (new TestGraphDatabaseFactory()).setInternalLogProvider(logProvider).newEmbeddedDatabaseBuilder(TestDirectory.directory()).setConfig(GraphDatabaseSettings.tracer, "verbose").newGraphDatabase();

            using (Transaction transaction = database.BeginTx())
            {
                database.CreateNode();
                transaction.Success();
            }
            database.Shutdown();
            logProvider.FormattedMessageMatcher().assertContains("Flushing file");
            logProvider.FormattedMessageMatcher().assertContains("Page cache flush completed. Flushed ");
        }
Example #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGenerateTransactionId()
        public virtual void ShouldGenerateTransactionId()
        {
            // given
            AssertableLogProvider     logProvider = new AssertableLogProvider();
            TransactionHandleRegistry registry    = new TransactionHandleRegistry(Clocks.fakeClock(), 0, logProvider);
            TransactionHandle         handle      = mock(typeof(TransactionHandle));

            // when
            long id1 = registry.Begin(handle);
            long id2 = registry.Begin(handle);

            // then
            assertNotEquals(id1, id2);
            logProvider.AssertNoLoggingOccurred();
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportAllPercentageSteps()
        public virtual void ShouldReportAllPercentageSteps()
        {
            // GIVEN
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log log = logProvider.getLog(this.GetType());
            VisibleMigrationProgressMonitor monitor = new VisibleMigrationProgressMonitor(log);

            monitor.Started(1);

            // WHEN
            MonitorSection(monitor, "First", 100, 40, 25, 23, 10, 50);
            monitor.Completed();

            // THEN
            VerifySectionReportedCorrectly(logProvider);
        }
Example #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrottle()
        public virtual void ShouldThrottle()
        {
            // Given
            AssertableLogProvider logProvider = new AssertableLogProvider(true);

            StateTransitionLogger stateLogger = new StateTransitionLogger(logProvider, new AtomicBroadcastSerializer(new ObjectStreamFactory(), new ObjectStreamFactory()));

            // When
            stateLogger.StateTransition(new StateTransition(entered, Message.@internal(join), joining));
            stateLogger.StateTransition(new StateTransition(entered, Message.@internal(join), joining));
            stateLogger.StateTransition(new StateTransition(joining, Message.@internal(join), entered));
            stateLogger.StateTransition(new StateTransition(entered, Message.@internal(join), joining));

            // Then
            logProvider.AssertExactly(inLog(entered.GetType()).debug("ClusterState: entered-[join]->joining"), inLog(joining.GetType()).debug("ClusterState: joining-[join]->entered"), inLog(entered.GetType()).debug("ClusterState: entered-[join]->joining"));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldIncludeDurationInCompletionMessage()
        public virtual void ShouldIncludeDurationInCompletionMessage()
        {
            // given
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log       log   = logProvider.getLog(this.GetType());
            FakeClock clock = new FakeClock();
            VisibleMigrationProgressMonitor monitor = new VisibleMigrationProgressMonitor(log, clock);

            // when
            monitor.Started(1);
            clock.Forward(1500, TimeUnit.MILLISECONDS);
            monitor.Completed();

            // then
            logProvider.FormattedMessageMatcher().assertContains("took 1s 500ms");
        }
Example #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStoreSuspendedTransaction() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStoreSuspendedTransaction()
        {
            // Given
            AssertableLogProvider     logProvider = new AssertableLogProvider();
            TransactionHandleRegistry registry    = new TransactionHandleRegistry(Clocks.fakeClock(), 0, logProvider);
            TransactionHandle         handle      = mock(typeof(TransactionHandle));

            long id = registry.Begin(handle);

            // When
            registry.Release(id, handle);
            TransactionHandle acquiredHandle = registry.Acquire(id);

            // Then
            assertSame(handle, acquiredHandle);
            logProvider.AssertNoLoggingOccurred();
        }
Example #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOnlyLogLearnMissOnce()
        public virtual void ShouldOnlyLogLearnMissOnce()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider();
            AssertableLogProvider logProvider = new AssertableLogProvider();
            LearnerContextImpl    ctx         = new LearnerContextImpl(new InstanceId(1), mock(typeof(CommonContextState)), logProvider, mock(typeof(Timeouts)), mock(typeof(PaxosInstanceStore)), mock(typeof(AcceptorInstanceStore)), mock(typeof(ObjectInputStreamFactory)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(HeartbeatContextImpl)));

            // When
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(2L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(2L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L));

            // Then
            logProvider.AssertExactly(inLog(typeof(LearnerState)).warn(containsString("Did not have learned value for Paxos instance 1.")), inLog(typeof(LearnerState)).warn(containsString("Did not have learned value for Paxos instance 2.")), inLog(typeof(LearnerState)).warn(containsString("Did not have learned value for Paxos instance 1.")));
        }
Example #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRejectIfHttp()
        public virtual void ShouldRejectIfHttp()
        {
            // Given
            BoltProtocol        protocol       = NewBoltProtocol(1);
            BoltProtocolFactory handlerFactory = NewProtocolFactory(1, protocol);
            EmbeddedChannel     channel        = new EmbeddedChannel(new ProtocolHandshaker(handlerFactory, _boltChannel, _logProvider, false, true));

            // When
            FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "http://hello_world:10000");

            request.headers().setInt(HttpHeaderNames.CONTENT_LENGTH, 0);
            channel.writeInbound(request);

            // Then
            assertEquals(0, channel.outboundMessages().size());
            assertFalse(channel.Active);
            verify(protocol, never()).install();
            _logProvider.assertExactly(AssertableLogProvider.inLog(typeof(ProtocolHandshaker)).warn("Unsupported connection type: 'HTTP'. Bolt protocol only operates over a TCP connection or WebSocket."));
        }
Example #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogMessages()
        public virtual void ShouldLogMessages()
        {
            // given
            AssertableLogProvider logs    = new AssertableLogProvider();
            AsyncLogging          logging = new AsyncLogging(logs.GetLog("meta"));

            // when
            logging.Start();
            try
            {
                (new AsyncLogProvider(logging.EventSender(), logs)).getLog("test").info("hello");
            }
            finally
            {
                logging.Stop();
            }
            // then
            logs.AssertExactly(inLog("test").info(endsWith("hello")));
        }
Example #22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogWhenLoggingThreadStarts()
        public virtual void ShouldLogWhenLoggingThreadStarts()
        {
            // given
            AssertableLogProvider logs    = new AssertableLogProvider();
            AsyncLogging          logging = new AsyncLogging(logs.GetLog("meta"));

            // when
            (new AsyncLogProvider(logging.EventSender(), logs)).getLog("test").info("hello");

            // then
            logs.AssertNoLoggingOccurred();

            // when
            logging.Start();
            logging.Stop();

            // then
            logs.AssertExactly(inLog("test").info(endsWith("hello")));
        }
Example #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCountFileSizeRecursively() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCountFileSizeRecursively()
        {
            // file structure:
            //   storeDir/indexDir/indexFile (1 kB)
            //   storeDir/neostore (3 kB)
            File           storeDir = DirectoryConflict.directory("storeDir");
            DatabaseLayout layout   = DatabaseLayout.of(storeDir);
            File           indexDir = Directory(storeDir, "indexDir");

            File(indexDir, "indexFile", ( int )kibiBytes(1));
            File(storeDir, layout.MetadataStore().Name, (int)kibiBytes(3));

            AssertableLogProvider logProvider = new AssertableLogProvider();

            KernelDiagnostics.StoreFiles storeFiles = new KernelDiagnostics.StoreFiles(layout);
            storeFiles.Dump(logProvider.getLog(this.GetType()).debugLogger());

            logProvider.RawMessageMatcher().assertContains("Total size of store: 4.00 kB");
            logProvider.RawMessageMatcher().assertContains("Total size of mapped files: 3.00 kB");
        }
Example #24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPrintDiskUsage()
        public virtual void ShouldPrintDiskUsage()
        {
            // Not sure how to get around this w/o spying. The method that we're unit testing will construct
            // other File instances with this guy as parent and internally the File constructor uses the field 'path'
            // which, if purely mocked, won't be assigned. At the same time we want to control the total/free space methods
            // and what they return... a tough one.
            File           storeDir = Mockito.spy(new File("storeDir"));
            DatabaseLayout layout   = mock(typeof(DatabaseLayout));

            when(layout.DatabaseDirectory()).thenReturn(storeDir);
            when(storeDir.TotalSpace).thenReturn(100L);
            when(storeDir.FreeSpace).thenReturn(40L);

            AssertableLogProvider logProvider = new AssertableLogProvider();

            KernelDiagnostics.StoreFiles storeFiles = new KernelDiagnostics.StoreFiles(layout);
            storeFiles.Dump(logProvider.getLog(this.GetType()).debugLogger());

            logProvider.RawMessageMatcher().assertContains("100 / 40 / 40");
        }
Example #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldProvideInterruptHandlerForActiveTransaction() throws org.neo4j.server.rest.transactional.error.TransactionLifecycleException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldProvideInterruptHandlerForActiveTransaction()
        {
            // Given
            AssertableLogProvider logProvider = new AssertableLogProvider();
            FakeClock             clock       = Clocks.fakeClock();
            int timeoutLength = 123;

            TransactionHandleRegistry registry = new TransactionHandleRegistry(clock, timeoutLength, logProvider);
            TransactionHandle         handle   = mock(typeof(TransactionHandle));

            // Active Tx in Registry
            long id = registry.Begin(handle);

            // When
            registry.Terminate(id);

            // Then
            verify(handle, times(1)).terminate();
            verifyNoMoreInteractions(handle);
        }
Example #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotDuplicateToAnyLog()
        public virtual void ShouldNotDuplicateToAnyLog()
        {
            AssertableLogProvider userLogProvider  = new AssertableLogProvider();
            AssertableLogProvider debugLogProvider = new AssertableLogProvider();

            SimpleLogService logService = new SimpleLogService(userLogProvider, debugLogProvider);

            Monitors monitors = new Monitors();

            CoreMonitor.Register(logService.InternalLogProvider, logService.UserLogProvider, monitors);

            ClusterBinder.Monitor monitor = monitors.NewMonitor(typeof(ClusterBinder.Monitor));

            ClusterId clusterId = new ClusterId(System.Guid.randomUUID());

            monitor.BoundToCluster(clusterId);

            userLogProvider.RawMessageMatcher().assertContainsSingle(Matchers.allOf(Matchers.containsString("Bound to cluster with id " + clusterId.Uuid())));

            debugLogProvider.RawMessageMatcher().assertContainsSingle(Matchers.allOf(Matchers.containsString("Bound to cluster with id " + clusterId.Uuid())));
        }
Example #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSeeExpectedDiagnostics()
        public virtual void ShouldSeeExpectedDiagnostics()
        {
            AssertableLogProvider logProvider = new AssertableLogProvider();
            GraphDatabaseService  db          = (new TestGraphDatabaseFactory()).setInternalLogProvider(logProvider).newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.dump_configuration, Settings.TRUE).setConfig(GraphDatabaseSettings.pagecache_memory, "4M").newGraphDatabase();

            CleanupRule.add(db);

            // THEN we should have logged
            logProvider.RawMessageMatcher().assertContains("Network information");
            logProvider.RawMessageMatcher().assertContains("Disk space on partition");
            logProvider.RawMessageMatcher().assertContains("Local timezone");
            // page cache info
            logProvider.RawMessageMatcher().assertContains("Page cache: 4M");
            // neostore records
            foreach (MetaDataStore.Position position in MetaDataStore.Position.values())
            {
                logProvider.RawMessageMatcher().assertContains(position.name());
            }
            // transaction log info
            logProvider.RawMessageMatcher().assertContains("Transaction log");
            logProvider.RawMessageMatcher().assertContains("TimeZone version: ");
        }
Example #28
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();
            }
        }
Example #29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void acquiringANonExistentTransactionShouldThrowErrorInvalidTransactionId() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AcquiringANonExistentTransactionShouldThrowErrorInvalidTransactionId()
        {
            // Given
            AssertableLogProvider     logProvider = new AssertableLogProvider();
            TransactionHandleRegistry registry    = new TransactionHandleRegistry(Clocks.fakeClock(), 0, logProvider);

            long madeUpTransactionId = 1337;

            // When
            try
            {
                registry.Acquire(madeUpTransactionId);
                fail("Should have thrown exception");
            }
            catch (InvalidTransactionId)
            {
                // expected
            }

            // then
            logProvider.AssertNoLoggingOccurred();
        }
Example #30
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void transactionsShouldBeEvictedWhenUnusedLongerThanTimeout() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TransactionsShouldBeEvictedWhenUnusedLongerThanTimeout()
        {
            // Given
            FakeClock                 clock       = Clocks.fakeClock();
            AssertableLogProvider     logProvider = new AssertableLogProvider();
            TransactionHandleRegistry registry    = new TransactionHandleRegistry(clock, 0, logProvider);
            TransactionHandle         oldTx       = mock(typeof(TransactionHandle));
            TransactionHandle         newTx       = mock(typeof(TransactionHandle));
            TransactionHandle         handle      = mock(typeof(TransactionHandle));

            long txId1 = registry.Begin(handle);
            long txId2 = registry.Begin(handle);

            // And given one transaction was stored one minute ago, and another was stored just now
            registry.Release(txId1, oldTx);
            clock.Forward(1, TimeUnit.MINUTES);
            registry.Release(txId2, newTx);

            // When
            registry.RollbackSuspendedTransactionsIdleSince(clock.Millis() - 1000);

            // Then
            assertThat(registry.Acquire(txId2), equalTo(newTx));

            // And then the other should have been evicted
            try
            {
                registry.Acquire(txId1);
                fail("Should have thrown exception");
            }
            catch (InvalidTransactionId)
            {
                // ok
            }

            logProvider.AssertExactly(inLog(typeof(TransactionHandleRegistry)).info("Transaction with id 1 has been automatically rolled " + "back due to transaction timeout."));
        }