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 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)));
        }
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 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)));
        }
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 shouldCompareModifierProtocolsByListOrder()
        public virtual void ShouldCompareModifierProtocolsByListOrder()
        {
            IList <ModifierSupportedProtocols> supportedProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                LZO.implementation(), SNAPPY.implementation(), LZ4.implementation()
            }));

            IComparer <Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocol> comparator = ModifierProtocolRepository.GetModifierProtocolComparator(supportedProtocols).apply(COMPRESSION.canonicalName());

            assertThat(comparator.Compare(LZO, TestProtocols_TestModifierProtocols.Snappy), Matchers.greaterThan(0));
            assertThat(comparator.Compare(TestProtocols_TestModifierProtocols.Snappy, TestProtocols_TestModifierProtocols.Lz4), Matchers.greaterThan(0));
        }
Exemplo n.º 4
0
//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();
        }
Exemplo n.º 5
0
//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();
        }
Exemplo n.º 6
0
//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, ""));
        }
Exemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnModifierProtocolOfFirstConfiguredVersionRequestedAndSupported()
        public virtual void ShouldReturnModifierProtocolOfFirstConfiguredVersionRequestedAndSupported()
        {
            // given
            IList <ModifierSupportedProtocols> supportedProtocols = asList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                LZO.implementation(), SNAPPY.implementation(), LZ4.implementation()
            }), new ModifierSupportedProtocols(GRATUITOUS_OBFUSCATION, new IList <string> {
                NAME_CLASH.implementation()
            }));
            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), supportedProtocols);
            // when
            Optional <Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocol> modifierProtocol = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet("bzip2", SNAPPY.implementation(), LZ4.implementation(), LZO.implementation(), "fast_lz"));

            // then
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertThat(modifierProtocol.map(Protocol::implementation), OptionalMatchers.contains(LZO.implementation()));
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompleteProtocolStackOnSwitchoverResponse()
        public virtual void ShouldCompleteProtocolStackOnSwitchoverResponse()
        {
            // given
            ModifierProtocolRepository repo = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), asList(new ModifierSupportedProtocols(Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocolCategory.Compression, emptyList())));

            CompletableFuture <ProtocolStack> protocolStackCompletableFuture = _client.initiate(_channel, _applicationProtocolRepository, repo);

            _client.handle(InitialMagicMessage.Instance());
            _client.handle(new ApplicationProtocolResponse(StatusCode.Success, _applicationProtocolIdentifier.canonicalName(), _raftVersion));
            _client.handle(new ModifierProtocolResponse(StatusCode.Success, SNAPPY.category(), SNAPPY.implementation()));

            // when
            _client.handle(new SwitchOverResponse(StatusCode.Success));

            // then
            ProtocolStack protocolStack = protocolStackCompletableFuture.getNow(null);

            assertThat(protocolStack, equalTo(new ProtocolStack(_expectedApplicationProtocol, singletonList(SNAPPY))));
        }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotIncludeModifierProtocolInSwitchOverRequestIfNotSuccessful()
        public virtual void ShouldNotIncludeModifierProtocolInSwitchOverRequestIfNotSuccessful()
        {
            // 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(), SNAPPY.implementation()));
            _client.handle(new ModifierProtocolResponse(StatusCode.Failure, ModifierProtocolCategory.GRATUITOUS_OBFUSCATION.canonicalName(), ROT13.implementation()));

            // then
            IList <Pair <string, string> > switchOverModifierProtocols = new IList <Pair <string, string> > {
                Pair.of(ModifierProtocolCategory.COMPRESSION.canonicalName(), SNAPPY.implementation())
            };

            verify(_channel).writeAndFlush(new SwitchOverRequest(_applicationProtocolIdentifier.canonicalName(), _raftVersion, switchOverModifierProtocols));
            assertFalse(protocolStackCompletableFuture.Done);
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Parameterized.Parameters public static java.util.Collection<Parameters> data()
        public static ICollection <Parameters> Data()
        {
            // Application protocols
            ApplicationSupportedProtocols allRaft          = new ApplicationSupportedProtocols(RAFT, TestProtocols_TestApplicationProtocols.listVersionsOf(RAFT));
            ApplicationSupportedProtocols raft1            = new ApplicationSupportedProtocols(RAFT, singletonList(RAFT_1.implementation()));
            ApplicationSupportedProtocols allRaftByDefault = new ApplicationSupportedProtocols(RAFT, emptyList());

            // Modifier protocols
            ICollection <ModifierSupportedProtocols> allModifiers = asList(new ModifierSupportedProtocols(COMPRESSION, TestProtocols_TestModifierProtocols.listVersionsOf(COMPRESSION)), new ModifierSupportedProtocols(GRATUITOUS_OBFUSCATION, TestProtocols_TestModifierProtocols.listVersionsOf(GRATUITOUS_OBFUSCATION))
                                                                           );
            ICollection <ModifierSupportedProtocols> allCompressionModifiers          = singletonList(new ModifierSupportedProtocols(COMPRESSION, TestProtocols_TestModifierProtocols.listVersionsOf(COMPRESSION)));
            ICollection <ModifierSupportedProtocols> allObfuscationModifiers          = singletonList(new ModifierSupportedProtocols(GRATUITOUS_OBFUSCATION, TestProtocols_TestModifierProtocols.listVersionsOf(GRATUITOUS_OBFUSCATION)));
            ICollection <ModifierSupportedProtocols> allCompressionModifiersByDefault = singletonList(new ModifierSupportedProtocols(COMPRESSION, emptyList()));

            IList <ModifierSupportedProtocols> onlyLzoCompressionModifiers    = singletonList(new ModifierSupportedProtocols(COMPRESSION, singletonList(LZO.implementation())));
            IList <ModifierSupportedProtocols> onlySnappyCompressionModifiers = singletonList(new ModifierSupportedProtocols(COMPRESSION, singletonList(SNAPPY.implementation())));

            ICollection <ModifierSupportedProtocols> noModifiers = emptyList();

            // Ordered modifier protocols
            ModifierProtocolRepository modifierProtocolRepository = new ModifierProtocolRepository(TestProtocols_TestModifierProtocols.values(), allModifiers);

            string[] lzoFirstVersions = new string[] { LZO.implementation(), LZ4.implementation(), SNAPPY.implementation() };
            IList <ModifierSupportedProtocols> lzoFirstCompressionModifiers = singletonList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                lzoFirstVersions
            }));
            Protocol_ModifierProtocol preferredLzoFirstCompressionModifier = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet(lzoFirstVersions)).get();

            string[] snappyFirstVersions = new string[] { SNAPPY.implementation(), LZ4.implementation(), LZO.implementation() };
            IList <ModifierSupportedProtocols> snappyFirstCompressionModifiers = singletonList(new ModifierSupportedProtocols(COMPRESSION, new IList <string> {
                snappyFirstVersions
            }));
            Protocol_ModifierProtocol preferredSnappyFirstCompressionModifier = modifierProtocolRepository.Select(COMPRESSION.canonicalName(), asSet(snappyFirstVersions)).get();

            return(asList(new Parameters(allRaft, allRaft, allModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaftByDefault, allModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaftByDefault, allRaft, allModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, raft1, allModifiers, allModifiers, RAFT_1, new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(raft1, allRaft, allModifiers, allModifiers, RAFT_1, new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION), TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaft, allModifiers, allCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allCompressionModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allModifiers, allCompressionModifiersByDefault, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allCompressionModifiersByDefault, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(COMPRESSION) }), new Parameters(allRaft, allRaft, allModifiers, allObfuscationModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaft, allObfuscationModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.latest(GRATUITOUS_OBFUSCATION) }), new Parameters(allRaft, allRaft, allModifiers, lzoFirstCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { LZO }), new Parameters(allRaft, allRaft, lzoFirstCompressionModifiers, allCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { preferredLzoFirstCompressionModifier }), new Parameters(allRaft, allRaft, allModifiers, snappyFirstCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { SNAPPY }), new Parameters(allRaft, allRaft, snappyFirstCompressionModifiers, allCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { preferredSnappyFirstCompressionModifier }), new Parameters(allRaft, allRaft, allModifiers, onlyLzoCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.LZO }), new Parameters(allRaft, allRaft, onlyLzoCompressionModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] { TestProtocols_TestModifierProtocols.LZO }), new Parameters(allRaft, allRaft, onlySnappyCompressionModifiers, onlyLzoCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {}), new Parameters(allRaft, allRaft, onlyLzoCompressionModifiers, onlySnappyCompressionModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {}), new Parameters(allRaft, allRaft, allModifiers, noModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {}), new Parameters(allRaft, allRaft, noModifiers, allModifiers, TestProtocols_TestApplicationProtocols.latest(RAFT), new Protocol_ModifierProtocol[] {})
                          ));
        }
Exemplo n.º 11
0
//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();
        }
Exemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverDiffersByVersionFromNegotiatedModifierProtocol()
        public void shouldSendFailureIfSwitchOverDiffersByVersionFromNegotiatedModifierProtocol()
        {
            // 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
            InOrder inOrder = Mockito.inOrder(_channel);

            inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE));
            inOrder.verify(_channel).dispose();
        }
Exemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackIfSwitchOverChangesOrderOfModifierProtocols()
        public void shouldExceptionallyCompleteProtocolStackIfSwitchOverChangesOrderOfModifierProtocols()
        {
            // 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())));
            _server.handle(new ModifierProtocolRequest(GRATUITOUS_OBFUSCATION.canonicalName(), asSet(ROT13.implementation())));

            // when
            _server.handle(new SwitchOverRequest(RAFT.canonicalName(), version, new IList <Pair <string, string> > {
                Pair.of(GRATUITOUS_OBFUSCATION.canonicalName(), ROT13.implementation()), Pair.of(COMPRESSION.canonicalName(), SNAPPY.implementation())
            }));

            // then
            AssertExceptionallyCompletedProtocolStackFuture();
        }
Exemplo n.º 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverChangesOrderOfModifierProtocols()
        public void shouldSendFailureIfSwitchOverChangesOrderOfModifierProtocols()
        {
            // 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())));
            _server.handle(new ModifierProtocolRequest(GRATUITOUS_OBFUSCATION.canonicalName(), asSet(ROT13.implementation())));

            // when
            _server.handle(new SwitchOverRequest(RAFT.canonicalName(), version, new IList <Pair <string, string> > {
                Pair.of(GRATUITOUS_OBFUSCATION.canonicalName(), ROT13.implementation()), Pair.of(COMPRESSION.canonicalName(), SNAPPY.implementation())
            }));

            // then
            InOrder inOrder = Mockito.inOrder(_channel);

            inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE));
            inOrder.verify(_channel).dispose();
        }
Exemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotIncludeModifierProtocolInSwitchOverRequestIfUnsupportedVersion()
        public virtual void ShouldNotIncludeModifierProtocolInSwitchOverRequestIfUnsupportedVersion()
        {
            // 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(), SNAPPY.implementation()));
            _client.handle(new ModifierProtocolResponse(StatusCode.Success, Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocolCategory.GratuitousObfuscation.canonicalName(), "Rearrange the bytes at random"));

            // then
            IList <Pair <string, string> > switchOverModifierProtocols = new IList <Pair <string, string> > {
                Pair.of(Org.Neo4j.causalclustering.protocol.Protocol_ModifierProtocolCategory.Compression.canonicalName(), SNAPPY.implementation())
            };

            verify(_channel).writeAndFlush(new SwitchOverRequest(_applicationProtocolIdentifier.canonicalName(), _raftVersion, switchOverModifierProtocols));
            assertFalse(protocolStackCompletableFuture.Done);
        }
Exemplo n.º 16
0
//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);
        }