Пример #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)));
        }
Пример #2
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();
        }
Пример #3
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();
        }
Пример #4
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();
        }
Пример #5
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();
        }