//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void processNextBatchShouldThrowAssertionErrorIfStatementOpen() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ProcessNextBatchShouldThrowAssertionErrorIfStatementOpen() { BoltConnection connection = NewConnection(1); connection.Enqueue(Jobs.noop()); connection.Enqueue(Jobs.noop()); // force to a message waiting loop when(_stateMachine.hasOpenStatement()).thenReturn(true); connection.ProcessNextBatch(); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: _logProvider.assertExactly(AssertableLogProvider.inLog(typeof(DefaultBoltConnection).FullName).error(startsWith("Unexpected error"), isA(typeof(AssertionError)))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void processNextBatchShouldDrainMaxBatchSizeItemsOnEachCall() public virtual void ProcessNextBatchShouldDrainMaxBatchSizeItemsOnEachCall() { IList <Job> drainedJobs = new List <Job>(); IList <Job> pushedJobs = new List <Job>(); BoltConnection connection = NewConnection(10); doAnswer(inv => ((IList <Job>)drainedJobs).AddRange(inv.getArgument(1))).when(_queueMonitor).drained(same(connection), anyCollection()); for (int i = 0; i < 15; i++) { Job newJob = Jobs.noop(); pushedJobs.Add(newJob); connection.Enqueue(newJob); } connection.ProcessNextBatch(); verify(_queueMonitor).drained(same(connection), anyCollection()); assertEquals(10, drainedJobs.Count); //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method: assertTrue(drainedJobs.containsAll(pushedJobs.subList(0, 10))); drainedJobs.Clear(); connection.ProcessNextBatch(); verify(_queueMonitor, times(2)).drained(same(connection), anyCollection()); assertEquals(5, drainedJobs.Count); //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method: assertTrue(drainedJobs.containsAll(pushedJobs.subList(10, 15))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void processNextBatchShouldReturnWhenConnectionIsStopped() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ProcessNextBatchShouldReturnWhenConnectionIsStopped() { BoltConnection connection = NewConnection(1); connection.Enqueue(Jobs.noop()); connection.Enqueue(Jobs.noop()); // force to a message waiting loop when(_stateMachine.shouldStickOnThread()).thenReturn(true); Future <bool> future = OtherThread.execute(state => connection.ProcessNextBatch()); connection.Stop(); OtherThread.get().awaitFuture(future); verify(_stateMachine).close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void enqueuedShouldQueueJob() public virtual void EnqueuedShouldQueueJob() { Job job = Jobs.noop(); BoltConnection connection = NewConnection(); connection.Enqueue(job); assertTrue(connection.HasPendingJobs()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void enqueuedShouldNotifyQueueMonitor() public virtual void EnqueuedShouldNotifyQueueMonitor() { Job job = Jobs.noop(); BoltConnection connection = NewConnection(); connection.Enqueue(job); verify(_queueMonitor).enqueued(connection, job); }
private void DispatchRandomSequenceOfMessages(BoltConnection connection) { IList <RequestMessage> sequence = _sequences[_rand.Next(_sequences.Count)]; foreach (RequestMessage message in sequence) { _sent.Add(message); connection.Enqueue(stateMachine => stateMachine.process(message, nullResponseHandler())); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogBoltConnectionAuthFatalityError() public virtual void ShouldLogBoltConnectionAuthFatalityError() { BoltConnection connection = NewConnection(); connection.Enqueue(machine => { throw new BoltConnectionAuthFatality(new AuthenticationException(Status.Security.Unauthorized, "inner error")); }); connection.ProcessNextBatch(); verify(_stateMachine).close(); _logProvider.assertExactly(AssertableLogProvider.inLog(containsString(typeof(BoltServer).Assembly.GetName().Name)).warn(containsString("inner error"))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void processNextBatchShouldCloseConnectionOnFatalAuthenticationError() public virtual void ProcessNextBatchShouldCloseConnectionOnFatalAuthenticationError() { BoltConnection connection = NewConnection(); connection.Enqueue(machine => { throw new BoltConnectionAuthFatality("auth failure", new Exception("inner error")); }); connection.ProcessNextBatch(); verify(_stateMachine).close(); _logProvider.assertNone(AssertableLogProvider.inLog(containsString(typeof(BoltServer).Assembly.GetName().Name)).warn(Matchers.any(typeof(string)))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void processNextBatchShouldNotifyQueueMonitorAboutDrain() public virtual void ProcessNextBatchShouldNotifyQueueMonitorAboutDrain() { IList <Job> drainedJobs = new List <Job>(); Job job = Jobs.noop(); BoltConnection connection = NewConnection(); doAnswer(inv => ((IList <Job>)drainedJobs).AddRange(inv.getArgument(1))).when(_queueMonitor).drained(same(connection), anyCollection()); connection.Enqueue(job); connection.ProcessNextBatch(); verify(_queueMonitor).drained(same(connection), anyCollection()); assertTrue(drainedJobs.Contains(job)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void processNextBatchShouldCloseConnectionAndLogOnUnexpectedException() public virtual void ProcessNextBatchShouldCloseConnectionAndLogOnUnexpectedException() { Exception exception = new Exception("unexpected exception"); BoltConnection connection = NewConnection(); connection.Enqueue(machine => { throw exception; }); connection.ProcessNextBatch(); verify(_stateMachine).close(); _logProvider.assertExactly(AssertableLogProvider.inLog(containsString(typeof(BoltServer).Assembly.GetName().Name)).error(containsString("Unexpected error detected in bolt session"), @is(exception))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void processNextBatchShouldCloseConnectionAndLogOnFatalBoltError() public virtual void ProcessNextBatchShouldCloseConnectionAndLogOnFatalBoltError() { BoltConnectionFatality exception = new BoltProtocolBreachFatality("fatal bolt error"); BoltConnection connection = NewConnection(); connection.Enqueue(machine => { throw exception; }); connection.ProcessNextBatch(); verify(_stateMachine).close(); _logProvider.assertExactly(AssertableLogProvider.inLog(containsString(typeof(BoltServer).Assembly.GetName().Name)).error(containsString("Protocol breach detected in bolt session"), @is(exception))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAlwaysReturnToReadyAfterReset() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAlwaysReturnToReadyAfterReset() { // given _life.start(); BoltConnection boltConnection = _connectionFactory.newConnection(_boltChannel, _machine); boltConnection.Enqueue(_machine => _machine.process(new InitMessage("ResetFuzzTest/0.0", emptyMap()), nullResponseHandler())); // Test random combinations of messages within a small budget of testing time. long deadline = DateTimeHelper.CurrentUnixTimeMillis() + 2 * 1000; // when while (DateTimeHelper.CurrentUnixTimeMillis() < deadline) { DispatchRandomSequenceOfMessages(boltConnection); AssertSchedulerWorks(boltConnection); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertSchedulerWorks(org.neo4j.bolt.runtime.BoltConnection connection) throws InterruptedException private void AssertSchedulerWorks(BoltConnection connection) { BoltResponseRecorder recorder = new BoltResponseRecorder(); connection.Enqueue(_machine => _machine.process(ResetMessage.INSTANCE, recorder)); try { RecordedBoltResponse response = recorder.NextResponse(); assertThat(response.Message(), equalTo(SUCCESS)); assertThat((( BoltStateMachineV1 )_machine).state(), instanceOf(typeof(ReadyState))); assertThat(_liveTransactions.get(), equalTo(0L)); } catch (AssertionError e) { //JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET: //ORIGINAL LINE: throw new AssertionError(String.format("Expected session to return to good state after RESET, but " + "assertion failed: %s.%n" + "Seed: %s%n" + "Messages sent:%n" + "%s", e.getMessage(), seed, org.neo4j.helpers.collection.Iterables.toString(sent, "\n")), e); throw new AssertionError(string.Format("Expected session to return to good state after RESET, but " + "assertion failed: %s.%n" + "Seed: %s%n" + "Messages sent:%n" + "%s", e.Message, _seed, Iterables.ToString(_sent, "\n")), e); } }