//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithModifierProtocols() public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithModifierProtocols() { // given _server.handle(InitialMagicMessage.Instance()); _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(RAFT_1.implementation()))); _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(SNAPPY.implementation()))); _server.handle(new ModifierProtocolRequest(GRATUITOUS_OBFUSCATION.canonicalName(), asSet(ROT13.implementation()))); // when IList <Pair <string, string> > modifierRequest = new IList <Pair <string, string> > { Pair.of(SNAPPY.category(), SNAPPY.implementation()), Pair.of(ROT13.category(), ROT13.implementation()) }; _server.handle(new SwitchOverRequest(RAFT_1.category(), RAFT_1.implementation(), modifierRequest)); // then verify(_channel).writeAndFlush(InitialMagicMessage.Instance()); verify(_channel).writeAndFlush(new SwitchOverResponse(SUCCESS)); ProtocolStack protocolStack = _server.protocolStackFuture().getNow(null); IList <ModifierProtocol> modifiers = new IList <ModifierProtocol> { SNAPPY, ROT13 }; assertThat(protocolStack, equalTo(new ProtocolStack(RAFT_1, modifiers))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithConfiguredModifierProtocols() public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithConfiguredModifierProtocols() { // given ISet <string> requestedVersions = asSet(TestProtocols_TestModifierProtocols.allVersionsOf(COMPRESSION)); string expectedNegotiatedVersion = SNAPPY.implementation(); IList <string> configuredVersions = singletonList(expectedNegotiatedVersion); IList <ModifierSupportedProtocols> supportedModifierProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, configuredVersions)); ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), supportedModifierProtocols); HandshakeServer server = new HandshakeServer(_applicationProtocolRepository, modifierProtocolRepository, _channel); server.Handle(InitialMagicMessage.Instance()); server.Handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(RAFT_1.implementation()))); server.Handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), requestedVersions)); // when IList <Pair <string, string> > modifierRequest = new IList <Pair <string, string> > { Pair.of(SNAPPY.category(), SNAPPY.implementation()) }; server.Handle(new SwitchOverRequest(RAFT_1.category(), RAFT_1.implementation(), modifierRequest)); // then verify(_channel).writeAndFlush(InitialMagicMessage.Instance()); verify(_channel).writeAndFlush(new SwitchOverResponse(SUCCESS)); ProtocolStack protocolStack = server.ProtocolStackFuture().getNow(null); IList <ModifierProtocol> modifiers = new IList <ModifierProtocol> { SNAPPY }; assertThat(protocolStack, equalTo(new ProtocolStack(RAFT_1, modifiers))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAcceptCorrectMagicValue() public void shouldAcceptCorrectMagicValue() { // when _server.handle(InitialMagicMessage.Instance()); // then AssertUnfinished(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCreateWithCorrectMagicValue() public virtual void ShouldCreateWithCorrectMagicValue() { // given InitialMagicMessage magicMessage = InitialMagicMessage.Instance(); // then assertTrue(magicMessage.CorrectMagic); assertEquals("NEO4J_CLUSTER", magicMessage.Magic()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotThrowIfMagicHasBeenSent() public virtual void ShouldNotThrowIfMagicHasBeenSent() { // given InitialMagicMessage.Instance().dispatch(_client); // when Message.dispatch(_client); // then pass }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackOnUnallowedApplicationProtocol() public void shouldExceptionallyCompleteProtocolStackOnUnallowedApplicationProtocol() { // given _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new ApplicationProtocolRequest(TestProtocols_TestApplicationProtocols.CATCHUP_1.category(), asSet(TestProtocols_TestApplicationProtocols.CATCHUP_1.implementation()))); // then AssertExceptionallyCompletedProtocolStackFuture(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldDeclineUnallowedApplicationProtocol() public void shouldDeclineUnallowedApplicationProtocol() { // given _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new ApplicationProtocolRequest(TestProtocols_TestApplicationProtocols.CATCHUP_1.category(), asSet(TestProtocols_TestApplicationProtocols.CATCHUP_1.implementation()))); // then verify(_channel).dispose(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAcceptCorrectMagic() public virtual void ShouldAcceptCorrectMagic() { // given CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, _modifierProtocolRepository); // when _client.handle(InitialMagicMessage.Instance()); // then assertFalse(protocolStackCompletableFuture.Done); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSendApplicationProtocolResponseForKnownProtocol() public void shouldSendApplicationProtocolResponseForKnownProtocol() { // given ISet <int> versions = asSet(1, 2, 3); _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), versions)); // then verify(_channel).writeAndFlush(new ApplicationProtocolResponse(SUCCESS, TestProtocols_TestApplicationProtocols.RAFT_3.category(), TestProtocols_TestApplicationProtocols.RAFT_3.implementation())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackWhenApplicationProtocolResponseForIncorrectProtocol() public virtual void ShouldExceptionallyCompleteProtocolStackWhenApplicationProtocolResponseForIncorrectProtocol() { // given CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, _modifierProtocolRepository); _client.handle(InitialMagicMessage.Instance()); // when _client.handle(new ApplicationProtocolResponse(StatusCode.Success, "zab", _raftVersion)); // then AssertCompletedExceptionally(protocolStackCompletableFuture); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackWhenProtocolStackNotSet() public virtual void ShouldExceptionallyCompleteProtocolStackWhenProtocolStackNotSet() { // given CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, _modifierProtocolRepository); _client.handle(InitialMagicMessage.Instance()); // when _client.handle(new SwitchOverResponse(StatusCode.Success)); // then AssertCompletedExceptionally(protocolStackCompletableFuture); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCloseConnectionIfKnownApplicationProtocol() public void shouldNotCloseConnectionIfKnownApplicationProtocol() { // given ISet <int> versions = asSet(1, 2, 3); _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), versions)); // then AssertUnfinished(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCloseConnectionForGivenModifierProtocol() public void shouldNotCloseConnectionForGivenModifierProtocol() { // given ISet <string> versions = asSet(SNAPPY.implementation(), LZO.implementation(), LZ4.implementation()); _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), versions)); // then AssertUnfinished(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackForUnknownApplicationProtocol() public void shouldExceptionallyCompleteProtocolStackForUnknownApplicationProtocol() { // given ISet <int> versions = asSet(1, 2, 3); _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new ApplicationProtocolRequest("UNKNOWN", versions)); // then AssertExceptionallyCompletedProtocolStackFuture(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackWhenApplicationProtocolResponseForUnsupportedVersion() public virtual void ShouldExceptionallyCompleteProtocolStackWhenApplicationProtocolResponseForUnsupportedVersion() { // given CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, _modifierProtocolRepository); _client.handle(InitialMagicMessage.Instance()); // when _client.handle(new ApplicationProtocolResponse(StatusCode.Success, _applicationProtocolIdentifier.canonicalName(), int.MaxValue)); // then AssertCompletedExceptionally(protocolStackCompletableFuture); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackIfSwitchOverBeforeNegotiation() public void shouldExceptionallyCompleteProtocolStackIfSwitchOverBeforeNegotiation() { // given int version = 1; _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new SwitchOverRequest(RAFT_1.category(), version, emptyList())); // then AssertExceptionallyCompletedProtocolStackFuture(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersFromNegotiatedProtocol() public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersFromNegotiatedProtocol() { // given int version = 1; _server.handle(InitialMagicMessage.Instance()); _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(version))); // when _server.handle(new SwitchOverRequest(RAFT_1.category(), version + 1, emptyList())); // then AssertExceptionallyCompletedProtocolStackFuture(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotSendSwitchOverRequestIfApplicationProtocolResponseNotReceivedOnModifierProtocolResponseReceive() public virtual void ShouldNotSendSwitchOverRequestIfApplicationProtocolResponseNotReceivedOnModifierProtocolResponseReceive() { // given CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, _modifierProtocolRepository); _client.handle(InitialMagicMessage.Instance()); // when _client.handle(new ModifierProtocolResponse(StatusCode.Success, ModifierProtocolCategory.COMPRESSION.canonicalName(), SNAPPY.implementation())); // then verify(_channel, never()).writeAndFlush(any(typeof(SwitchOverRequest))); assertFalse(protocolStackCompletableFuture.Done); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotSendSwitchOverRequestOnModifierProtocolResponseIfNotAllModifierProtocolResponsesReceived() public virtual void ShouldNotSendSwitchOverRequestOnModifierProtocolResponseIfNotAllModifierProtocolResponsesReceived() { // given CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, _modifierProtocolRepository); _client.handle(InitialMagicMessage.Instance()); _client.handle(new ApplicationProtocolResponse(StatusCode.Success, _applicationProtocolIdentifier.canonicalName(), _raftVersion)); // when _client.handle(new ModifierProtocolResponse(StatusCode.Success, Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocolCategory.Compression.canonicalName(), "woot")); // then verify(_channel, never()).writeAndFlush(any(typeof(SwitchOverRequest))); assertFalse(protocolStackCompletableFuture.Done); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackOnUnknownProtocolSwitchOver() public void shouldExceptionallyCompleteProtocolStackOnUnknownProtocolSwitchOver() { // given int version = 1; string unknownProtocolName = "UNKNOWN"; _server.handle(InitialMagicMessage.Instance()); _server.handle(new ApplicationProtocolRequest(unknownProtocolName, asSet(version))); // when _server.handle(new SwitchOverRequest(unknownProtocolName, version, emptyList())); // then AssertExceptionallyCompletedProtocolStackFuture(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCloseConnectionIfUnknownModifierProtocol() public void shouldNotCloseConnectionIfUnknownModifierProtocol() { // given ISet <string> versions = asSet(SNAPPY.implementation(), LZO.implementation(), LZ4.implementation()); _server.handle(InitialMagicMessage.Instance()); // when string protocolName = "let's just randomly reorder all the bytes"; _server.handle(new ModifierProtocolRequest(protocolName, versions)); // then AssertUnfinished(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSendFailModifierProtocolResponseForUnknownProtocol() public void shouldSendFailModifierProtocolResponseForUnknownProtocol() { // given ISet <string> versions = asSet(SNAPPY.implementation(), LZO.implementation(), LZ4.implementation()); _server.handle(InitialMagicMessage.Instance()); // when string protocolName = "let's just randomly reorder all the bytes"; _server.handle(new ModifierProtocolRequest(protocolName, versions)); // then verify(_channel).writeAndFlush(new ModifierProtocolResponse(FAILURE, protocolName, "")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotCloseConnectionIfUnknownModifierProtocolVersion() public void shouldNotCloseConnectionIfUnknownModifierProtocolVersion() { // given ISet <string> versions = asSet("not a real algorithm"); _server.handle(InitialMagicMessage.Instance()); // when string protocolName = COMPRESSION.canonicalName(); _server.handle(new ModifierProtocolRequest(protocolName, versions)); // then AssertUnfinished(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSendFailModifierProtocolResponseForUnknownVersion() public void shouldSendFailModifierProtocolResponseForUnknownVersion() { // given ISet <string> versions = asSet("Not a real protocol"); _server.handle(InitialMagicMessage.Instance()); // when string protocolName = COMPRESSION.canonicalName(); _server.handle(new ModifierProtocolRequest(protocolName, versions)); // then verify(_channel).writeAndFlush(new ModifierProtocolResponse(FAILURE, protocolName, "")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSendSwitchOverRequestIfNoModifierProtocolsToRequestOnApplicationProtocolResponse() public virtual void ShouldSendSwitchOverRequestIfNoModifierProtocolsToRequestOnApplicationProtocolResponse() { ModifierProtocolRepository repo = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), emptyList()); // given CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, repo); _client.handle(InitialMagicMessage.Instance()); // when _client.handle(new ApplicationProtocolResponse(StatusCode.Success, _applicationProtocolIdentifier.canonicalName(), _raftVersion)); // then verify(_channel).writeAndFlush(new SwitchOverRequest(_applicationProtocolIdentifier.canonicalName(), _raftVersion, emptyList())); assertFalse(protocolStackCompletableFuture.Done); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSendModifierProtocolResponseForGivenProtocol() public void shouldSendModifierProtocolResponseForGivenProtocol() { // given ISet <string> versions = asSet(TestProtocols_TestModifierProtocols.allVersionsOf(COMPRESSION)); _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), versions)); // then ModifierProtocol expected = TestProtocols_TestModifierProtocols.latest(COMPRESSION); verify(_channel).writeAndFlush(new ModifierProtocolResponse(SUCCESS, expected.category(), expected.implementation())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverBeforeNegotiation() public void shouldSendFailureIfSwitchOverBeforeNegotiation() { // given int version = 1; _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new SwitchOverRequest(RAFT_1.category(), version, emptyList())); // then InOrder inOrder = Mockito.inOrder(_channel); inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE)); inOrder.verify(_channel).dispose(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSendNegativeResponseAndCloseForUnknownApplicationProtocol() public void shouldSendNegativeResponseAndCloseForUnknownApplicationProtocol() { // given ISet <int> versions = asSet(1, 2, 3); _server.handle(InitialMagicMessage.Instance()); // when _server.handle(new ApplicationProtocolRequest("UNKNOWN", versions)); // then InOrder inOrder = Mockito.inOrder(_channel); inOrder.verify(_channel).writeAndFlush(ApplicationProtocolResponse.NoProtocol); inOrder.verify(_channel).dispose(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersByVersionFromNegotiatedModifiedProtocol() public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersByVersionFromNegotiatedModifiedProtocol() { // given int version = 1; _server.handle(InitialMagicMessage.Instance()); _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(version))); _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(SNAPPY.implementation()))); // when _server.handle(new SwitchOverRequest(RAFT_1.category(), version, new IList <Pair <string, string> > { Pair.of(COMPRESSION.canonicalName(), LZ4.implementation()) })); // then AssertExceptionallyCompletedProtocolStackFuture(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverDiffersFromNegotiatedProtocol() public void shouldSendFailureIfSwitchOverDiffersFromNegotiatedProtocol() { // given int version = 1; _server.handle(InitialMagicMessage.Instance()); _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(version))); // when _server.handle(new SwitchOverRequest(RAFT_1.category(), version + 1, emptyList())); // then InOrder inOrder = Mockito.inOrder(_channel); inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE)); inOrder.verify(_channel).dispose(); }