Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.bolt.v1.messaging.BoltRequestMessageWriter write(org.neo4j.bolt.messaging.RequestMessage message) throws java.io.IOException
        public override BoltRequestMessageWriter Write(RequestMessage message)
        {
            if (message is HelloMessage)
            {
                WriteHello(( HelloMessage )message);
            }
            else if (message is BeginMessage)
            {
                WriteBegin(( BeginMessage )message);
            }
            else if (message is CommitMessage)
            {
                WriteCommit();
            }
            else if (message is RollbackMessage)
            {
                WriteRollback();
            }
            else if (message is RunMessage)
            {
                WriteRun(( RunMessage )message);
            }
            else
            {
                base.Write(message);
            }
            return(this);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldDecodeAckFailure() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldDecodeAckFailure()
        {
            RequestMessage message = _decoder.decode(mock(typeof(Neo4jPack_Unpacker)));

            assertEquals(ResetMessage.INSTANCE, message);
            verify(_connection).interrupt();
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.bolt.runtime.BoltStateMachineState process(org.neo4j.bolt.messaging.RequestMessage message, org.neo4j.bolt.runtime.StateMachineContext context) throws org.neo4j.bolt.runtime.BoltConnectionFatality
        public override BoltStateMachineState Process(RequestMessage message, StateMachineContext context)
        {
            AssertInitialized();
            if (message is InterruptSignal)
            {
                return(this);
            }
            else if (message is ResetMessage)
            {
                if (context.ConnectionState().decrementInterruptCounter() > 0)
                {
                    context.ConnectionState().markIgnored();
                    return(this);
                }

                if (context.ResetMachine())
                {
                    context.ConnectionState().resetPendingFailedAndIgnored();
                    return(_readyState);
                }
                return(_failedState);
            }
            else
            {
                context.ConnectionState().markIgnored();
                return(this);
            }
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.bolt.runtime.BoltStateMachineState processUnsafe(org.neo4j.bolt.messaging.RequestMessage message, org.neo4j.bolt.runtime.StateMachineContext context) throws Throwable
        public override BoltStateMachineState ProcessUnsafe(RequestMessage message, StateMachineContext context)
        {
            if (message is PullAllMessage)
            {
                return(ProcessStreamResultMessage(true, context));
            }
            if (message is DiscardAllMessage)
            {
                return(ProcessStreamResultMessage(false, context));
            }
            return(null);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.bolt.runtime.BoltStateMachineState processUnsafe(org.neo4j.bolt.messaging.RequestMessage message, org.neo4j.bolt.runtime.StateMachineContext context) throws Exception
        public override BoltStateMachineState ProcessUnsafe(RequestMessage message, StateMachineContext context)
        {
            if (message is RunMessage)
            {
                return(ProcessRunMessage(( RunMessage )message, context));
            }
            if (message is BeginMessage)
            {
                return(ProcessBeginMessage(( BeginMessage )message, context));
            }
            return(null);
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void shouldCloseConnectionOnIllegalMessages(org.neo4j.bolt.messaging.RequestMessage message) throws InterruptedException, org.neo4j.bolt.runtime.BoltConnectionFatality
        private void ShouldCloseConnectionOnIllegalMessages(RequestMessage message)
        {
            // Given
            BoltStateMachineV3 machine = BoltStateMachineInInterruptedState;

            // when
            BoltResponseRecorder recorder = new BoltResponseRecorder();

            machine.Process(message, recorder);

            // then
            assertThat(recorder.NextResponse(), wasIgnored());
            assertThat(machine.State(), instanceOf(typeof(InterruptedState)));
        }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void shouldCloseConnectionOnIllegalMessages(org.neo4j.bolt.messaging.RequestMessage message) throws InterruptedException
        private void ShouldCloseConnectionOnIllegalMessages(RequestMessage message)
        {
            // Given
            BoltStateMachineV3 machine = NewStateMachine();

            // when
            BoltResponseRecorder recorder = new BoltResponseRecorder();

            verifyKillsConnection(() => machine.process(message, recorder));

            // then
            assertThat(recorder.NextResponse(), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid));
            assertNull(machine.State());
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.bolt.runtime.BoltStateMachineState process(org.neo4j.bolt.messaging.RequestMessage message, org.neo4j.bolt.runtime.StateMachineContext context) throws org.neo4j.bolt.runtime.BoltConnectionFatality
        public override BoltStateMachineState Process(RequestMessage message, StateMachineContext context)
        {
            AssertInitialized();
            if (ShouldIgnore(message))
            {
                context.ConnectionState().markIgnored();
                return(this);
            }
            if (message is InterruptSignal)
            {
                return(_interruptedState);
            }
            return(null);
        }
//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());
        }
Ejemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldDecodeAckFailure() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldDecodeAckFailure()
        {
            Neo4jPackV1 neo4jPack       = new Neo4jPackV1();
            RunMessage  originalMessage = new RunMessage("UNWIND range(1, 10) AS x RETURN x, $y", map(new string[] { "y" }, new AnyValue[] { longValue(42) }));

            PackedInputArray   innput   = new PackedInputArray(serialize(neo4jPack, originalMessage));
            Neo4jPack_Unpacker unpacker = neo4jPack.NewUnpacker(innput);

            // these two steps are executed before decoding in order to select a correct decoder
            unpacker.UnpackStructHeader();
            unpacker.UnpackStructSignature();

            RequestMessage deserializedMessage = _decoder.decode(unpacker);

            assertEquals(originalMessage, deserializedMessage);
        }
Ejemplo n.º 11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.bolt.runtime.BoltStateMachineState process(org.neo4j.bolt.messaging.RequestMessage message, org.neo4j.bolt.runtime.StateMachineContext context) throws org.neo4j.bolt.runtime.BoltConnectionFatality
        public override BoltStateMachineState Process(RequestMessage message, StateMachineContext context)
        {
            AssertInitialized();
            if (ShouldIgnore(message))
            {
                context.ConnectionState().markIgnored();
                return(this);
            }
            if (message is AckFailureMessage)
            {
                context.ConnectionState().resetPendingFailedAndIgnored();
                return(_readyState);
            }
            if (message is ResetMessage)
            {
                return(ProcessResetMessage(context));
            }
            if (message is InterruptSignal)
            {
                return(_interruptedState);
            }
            return(null);
        }
Ejemplo n.º 12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public BoltRequestMessageWriter write(org.neo4j.bolt.messaging.RequestMessage message) throws java.io.IOException
        public virtual BoltRequestMessageWriter Write(RequestMessage message)
        {
            if (message is InitMessage)
            {
                WriteInit(( InitMessage )message);
            }
            else if (message is AckFailureMessage)
            {
                WriteAckFailure();
            }
            else if (message is ResetMessage)
            {
                WriteReset();
            }
            else if (message is RunMessage)
            {
                WriteRun(( RunMessage )message);
            }
            else if (message is DiscardAllMessage)
            {
                WriteDiscardAll();
            }
            else if (message is PullAllMessage)
            {
                WritePullAll();
            }
            else if (message is GoodbyeMessage)
            {
                WriteGoodbye();
            }
            else
            {
                throw new System.ArgumentException("Unknown message: " + message);
            }
            return(this);
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ParameterizedTest @MethodSource("illegalV3Messages") void shouldCloseConnectionOnIllegalV3Messages(org.neo4j.bolt.messaging.RequestMessage message) throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldCloseConnectionOnIllegalV3Messages(RequestMessage message)
        {
            ShouldCloseConnectionOnIllegalMessages(message);
        }
Ejemplo n.º 14
0
 private static bool ShouldIgnore(RequestMessage message)
 {
     return(message is RunMessage || message is PullAllMessage || message is DiscardAllMessage);
 }