Beispiel #1
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)));
        }
Beispiel #2
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)));
        }
Beispiel #3
0
//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();
        }
Beispiel #4
0
//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()));
        }
Beispiel #5
0
//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();
        }
Beispiel #6
0
//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();
        }
Beispiel #7
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();
        }
Beispiel #8
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();
        }
Beispiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithNoModifierProtocols()
        public void shouldCompleteProtocolStackOnSuccessfulSwitchOverWithNoModifierProtocols()
        {
            // 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, emptyList()));

            // then
            verify(_channel).writeAndFlush(InitialMagicMessage.Instance());
            verify(_channel).writeAndFlush(new SwitchOverResponse(SUCCESS));
            ProtocolStack protocolStack = _server.protocolStackFuture().getNow(null);

            assertThat(protocolStack, equalTo(new ProtocolStack(RAFT_1, emptyList())));
        }
Beispiel #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersByNameFromNegotiatedModifiedProtocol()
        public void shouldExceptionallyCompleteProtocolStackIfSwitchOverDiffersByNameFromNegotiatedModifiedProtocol()
        {
            // given
            string modifierVersion    = ROT13.implementation();
            int    applicationVersion = 1;

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(applicationVersion)));
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(modifierVersion)));

            // when
            _server.handle(new SwitchOverRequest(RAFT.canonicalName(), applicationVersion, new IList <Pair <string, string> > {
                Pair.of(GRATUITOUS_OBFUSCATION.canonicalName(), modifierVersion)
            }));

            // then
            AssertExceptionallyCompletedProtocolStackFuture();
        }
Beispiel #11
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();
        }
Beispiel #12
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();
        }
Beispiel #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSendFailureIfSwitchOverDiffersByNameFromNegotiatedModifierProtocol()
        public void shouldSendFailureIfSwitchOverDiffersByNameFromNegotiatedModifierProtocol()
        {
            // given
            string modifierVersion    = ROT13.implementation();
            int    applicationVersion = 1;

            _server.handle(InitialMagicMessage.Instance());
            _server.handle(new ApplicationProtocolRequest(RAFT.canonicalName(), asSet(applicationVersion)));
            _server.handle(new ModifierProtocolRequest(COMPRESSION.canonicalName(), asSet(modifierVersion)));

            // when
            _server.handle(new SwitchOverRequest(RAFT.canonicalName(), applicationVersion, new IList <Pair <string, string> > {
                Pair.of(GRATUITOUS_OBFUSCATION.canonicalName(), modifierVersion)
            }));

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

            inOrder.verify(_channel).writeAndFlush(new SwitchOverResponse(FAILURE));
            inOrder.verify(_channel).dispose();
        }
Beispiel #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSuccessfullySwitchOverWhenServerHasConfiguredRaftVersions()
        public void shouldSuccessfullySwitchOverWhenServerHasConfiguredRaftVersions()
        {
            // given
            ISet <int> requestedVersions         = asSet(TestProtocols_TestApplicationProtocols.allVersionsOf(RAFT));
            int?       expectedNegotiatedVersion = 1;
            ApplicationProtocolRepository applicationProtocolRepository = new ApplicationProtocolRepository(TestProtocols_TestApplicationProtocols.values(), new ApplicationSupportedProtocols(RAFT, singletonList(expectedNegotiatedVersion)));

            HandshakeServer server = new HandshakeServer(applicationProtocolRepository, _modifierProtocolRepository, _channel);

            server.Handle(InitialMagicMessage.Instance());
            server.Handle(new ApplicationProtocolRequest(RAFT.canonicalName(), requestedVersions));

            // when
            server.Handle(new SwitchOverRequest(RAFT_1.category(), expectedNegotiatedVersion.Value, emptyList()));

            // then
            verify(_channel).writeAndFlush(InitialMagicMessage.Instance());
            verify(_channel).writeAndFlush(new SwitchOverResponse(SUCCESS));
            ProtocolStack protocolStack         = server.ProtocolStackFuture().getNow(null);
            ProtocolStack expectedProtocolStack = new ProtocolStack(applicationProtocolRepository.Select(RAFT.canonicalName(), expectedNegotiatedVersion.Value).get(), emptyList());

            assertThat(protocolStack, equalTo(expectedProtocolStack));
        }
Beispiel #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSeeOutboundInstalledProtocolsOnLeader() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSeeOutboundInstalledProtocolsOnLeader()
        {
            string modifiers = (new StringJoiner(",", "[", "]")).add(COMPRESSION_SNAPPY.implementation()).ToString();

//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            ProtocolInfo[] expectedProtocolInfos = _cluster.coreMembers().Where(member => !member.Equals(_leader)).Select(member => new ProtocolInfo(OUTBOUND, Localhost(member.raftListenAddress()), RAFT.canonicalName(), 2, modifiers)).ToArray(ProtocolInfo[] ::new);

            assertEventually("should see outbound installed protocols on core " + _leader.serverId(), () => InstalledProtocols(_leader.database(), OUTBOUND), hasItems(expectedProtocolInfos), 60, SECONDS);
        }
Beispiel #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnKnownProtocolVersionWhenFirstGivenVersionNotKnown()
        public virtual void ShouldReturnKnownProtocolVersionWhenFirstGivenVersionNotKnown()
        {
            // when
            Optional <Org.Neo4j.causalclustering.protocol.Protocol_ApplicationProtocol> applicationProtocol = _applicationProtocolRepository.select(RAFT.canonicalName(), asSet(-1, 1));

            // then
            assertThat(applicationProtocol, OptionalMatchers.contains(TestProtocols_TestApplicationProtocols.RAFT_1));
        }
Beispiel #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnEmptyIfNoVersions()
        public virtual void ShouldReturnEmptyIfNoVersions()
        {
            // when
            Optional <Org.Neo4j.causalclustering.protocol.Protocol_ApplicationProtocol> applicationProtocol = _applicationProtocolRepository.select(RAFT.canonicalName(), emptySet());

            // then
            assertThat(applicationProtocol, OptionalMatchers.empty());
        }
Beispiel #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnApplicationProtocolOfHighestVersionNumberRequestedAndSupported()
        public virtual void ShouldReturnApplicationProtocolOfHighestVersionNumberRequestedAndSupported()
        {
            // when
            Optional <Org.Neo4j.causalclustering.protocol.Protocol_ApplicationProtocol> applicationProtocol = _applicationProtocolRepository.select(RAFT.canonicalName(), asSet(389432, 1, 3, 2, 71234));

            // then
            assertThat(applicationProtocol, OptionalMatchers.contains(TestProtocols_TestApplicationProtocols.RAFT_3));
        }