//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ParameterizedTest(name = "V{0}") @ValueSource(longs = {org.neo4j.bolt.v1.BoltProtocolV1.VERSION, org.neo4j.bolt.v2.BoltProtocolV2.VERSION, org.neo4j.bolt.v3.BoltProtocolV3.VERSION}) void shouldCreateBoltProtocol(long protocolVersion) throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldCreateBoltProtocol(long protocolVersion) { EmbeddedChannel channel = new EmbeddedChannel(); BoltChannel boltChannel = new BoltChannel("bolt-1", "bolt", channel); BoltStateMachineFactory stateMachineFactory = mock(typeof(BoltStateMachineFactory)); BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); when(stateMachineFactory.NewStateMachine(protocolVersion, boltChannel)).thenReturn(stateMachine); BoltConnectionFactory connectionFactory = mock(typeof(BoltConnectionFactory)); BoltConnection connection = mock(typeof(BoltConnection)); when(connectionFactory.NewConnection(boltChannel, stateMachine)).thenReturn(connection); BoltProtocolFactory factory = new DefaultBoltProtocolFactory(connectionFactory, stateMachineFactory, NullLogService.Instance); BoltProtocol protocol = factory(protocolVersion, boltChannel); protocol.Install(); // handler with correct version is created assertEquals(protocolVersion, protocol.Version()); // it uses the expected worker verify(connectionFactory).newConnection(eq(boltChannel), any(typeof(BoltStateMachine))); // and halts this same worker when closed verify(connection, never()).stop(); channel.close(); verify(connection).stop(); channel.finishAndReleaseAll(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static org.neo4j.bolt.runtime.BoltStateMachine newMachineWithTransaction() throws org.neo4j.bolt.security.auth.AuthenticationException, org.neo4j.bolt.runtime.BoltConnectionFatality public static BoltStateMachine NewMachineWithTransaction() { BoltStateMachine machine = NewMachine(); Init(machine); RunBegin(machine); return(machine); }
public BoltProtocolV1(BoltChannel channel, BoltConnectionFactory connectionFactory, BoltStateMachineFactory stateMachineFactory, LogService logging) { this._channel = channel; this._logging = logging; BoltStateMachine stateMachine = stateMachineFactory.NewStateMachine(Version(), channel); this._connection = connectionFactory.NewConnection(channel, stateMachine); this._neo4jPack = CreatePack(); this._messageReader = CreateMessageReader(channel, _neo4jPack, _connection, logging); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCloseConnectionAfterAuthenticationFailure() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCloseConnectionAfterAuthenticationFailure() { // Given BoltStateMachine machine = Env.newMachine(_boltChannel); // When... then InitMessage init = new InitMessage(USER_AGENT, newBasicAuthToken("neo4j", "j4oen")); BoltResponseRecorder recorder = new BoltResponseRecorder(); verifyKillsConnection(() => machine.process(init, recorder)); // ...and assertThat(recorder.NextResponse(), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_Security.Unauthorized)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToActOnSessionWhenUpdatingCredentials() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToActOnSessionWhenUpdatingCredentials() { BoltStateMachine machine = Env.newMachine(_boltChannel); BoltResponseRecorder recorder = new BoltResponseRecorder(); // when InitMessage message = new InitMessage(USER_AGENT, map("scheme", "basic", "principal", "neo4j", "credentials", UTF8.encode("neo4j"), "new_credentials", UTF8.encode("secret"))); machine.Process(message, recorder); machine.Process(new RunMessage("CREATE ()", EMPTY_MAP), recorder); // then assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeeded()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void testMessageDecoding(org.neo4j.bolt.messaging.RequestMessage message) throws Exception private static void TestMessageDecoding(RequestMessage message) { Neo4jPack neo4jPack = new Neo4jPackV1(); BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); BoltRequestMessageReader reader = NewReader(stateMachine); PackedInputArray innput = new PackedInputArray(serialize(neo4jPack, message)); Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = neo4jPack.NewUnpacker(innput); reader.Read(unpacker); verify(stateMachine).process(eq(message), any()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGiveKernelVersionOnInit() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldGiveKernelVersionOnInit() { // Given it is important for client applications to programmatically // identify expired credentials as the cause of not being authenticated BoltStateMachine machine = Env.newMachine(_boltChannel); BoltResponseRecorder recorder = new BoltResponseRecorder(); string version = "Neo4j/" + Version.Neo4jVersion; // When InitMessage init = new InitMessage(USER_AGENT, newBasicAuthToken("neo4j", "neo4j")); machine.Process(init, recorder); machine.Process(new RunMessage("CREATE ()", EMPTY_MAP), recorder); // Then assertThat(recorder.NextResponse(), succeededWithMetadata("server", stringValue(version))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGiveCredentialsExpiredStatusOnExpiredCredentials() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldGiveCredentialsExpiredStatusOnExpiredCredentials() { // Given it is important for client applications to programmatically // identify expired credentials as the cause of not being authenticated BoltStateMachine machine = Env.newMachine(_boltChannel); BoltResponseRecorder recorder = new BoltResponseRecorder(); // When InitMessage init = new InitMessage(USER_AGENT, newBasicAuthToken("neo4j", "neo4j")); machine.Process(init, recorder); machine.Process(new RunMessage("CREATE ()", EMPTY_MAP), recorder); // Then assertThat(recorder.NextResponse(), succeededWithMetadata("credentials_expired", TRUE)); assertThat(recorder.NextResponse(), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_Security.CredentialsExpired)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static org.neo4j.bolt.runtime.BoltStateMachine init(org.neo4j.bolt.runtime.BoltStateMachine machine) throws org.neo4j.bolt.security.auth.AuthenticationException, org.neo4j.bolt.runtime.BoltConnectionFatality public static BoltStateMachine Init(BoltStateMachine machine) { return(Init(machine, null)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void runBegin(org.neo4j.bolt.runtime.BoltStateMachine machine) throws org.neo4j.bolt.runtime.BoltConnectionFatality private static void RunBegin(BoltStateMachine machine) { machine.Process(new RunMessage("BEGIN", EmptyParams), nullResponseHandler()); machine.Process(DiscardAllMessage.INSTANCE, nullResponseHandler()); assertThat(machine, hasTransaction()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static org.neo4j.bolt.runtime.BoltStateMachine init(org.neo4j.bolt.runtime.BoltStateMachine machine, String owner) throws org.neo4j.bolt.security.auth.AuthenticationException, org.neo4j.bolt.runtime.BoltConnectionFatality private static BoltStateMachine Init(BoltStateMachine machine, string owner) { machine.Process(new InitMessage(USER_AGENT, string.ReferenceEquals(owner, null) ? emptyMap() : singletonMap(Org.Neo4j.Kernel.api.security.AuthToken_Fields.PRINCIPAL, owner)), nullResponseHandler()); return(machine); }
public static BoltRequestMessageReader RequestMessageReader(BoltStateMachine stateMachine) { return(new BoltRequestMessageReaderV3(new SynchronousBoltConnection(stateMachine), mock(typeof(BoltResponseMessageWriter)), NullLogService.Instance)); }