Beispiel #1
0
 /// <summary>
 /// Report back that a message has been sent through the console.
 /// </summary>
 /// <param name="message"></param>
 protected void SendRunMessage(string message)
 {
     lock (this)
     {
         RunMessage?.Invoke(message);
     }
 }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void testPermutation(byte[] unfragmented, io.netty.buffer.ByteBuf[] fragments) throws Exception
        private void TestPermutation(sbyte[] unfragmented, ByteBuf[] fragments)
        {
            // Given
            _channel = new EmbeddedChannel();
            BoltChannel boltChannel = NewBoltChannel(_channel);

            BoltStateMachine          machine        = mock(typeof(BoltStateMachine));
            SynchronousBoltConnection boltConnection = new SynchronousBoltConnection(machine);
            NullLogService            logging        = NullLogService.Instance;
            BoltProtocol boltProtocol = new BoltProtocolV1(boltChannel, (ch, s) => boltConnection, (v, ch) => machine, logging);

            boltProtocol.Install();

            // When data arrives split up according to the current permutation
            foreach (ByteBuf fragment in fragments)
            {
                _channel.writeInbound(fragment.readerIndex(0).retain());
            }

            // Then the session should've received the specified messages, and the protocol should be in a nice clean state
            try
            {
                RequestMessage run = new RunMessage("Mjölnir", EMPTY_MAP);
                verify(machine).process(eq(run), any(typeof(BoltResponseHandler)));
            }
            catch (AssertionError e)
            {
                throw new AssertionError("Failed to handle fragmented delivery.\n" + "Messages: " + Arrays.ToString(_messages) + "\n" + "Chunk size: " + _chunkSize + "\n" + "Serialized data delivered in fragments: " + DescribeFragments(fragments) + "\n" + "Unfragmented data: " + HexPrinter.hex(unfragmented) + "\n", e);
            }
        }
Beispiel #3
0
 /// <summary>
 /// 接收事件
 /// </summary>
 /// <param name="m"></param>
 static void Log_Event(RunMessage m)
 {
     Console.WriteLine(m.TimeString + " " + m.SenderMessage);
     if (m.Type == RunMessage.RunType.WAIT)
     {
         string str = Console.ReadLine();
     }
 }
Beispiel #4
0
 //传递事件
 private void TransferEvent(RunMessage runmsg)
 {
     if (ManageEvent != null)
     {
         runmsg.PutMessageSender(this);
         ManageEvent(runmsg);
     }
 }
Beispiel #5
0
 public bool ThrowWaitEvent(string eMsg, ISrcUrl eSrcUrl)
 {
     if (RunEvent != null)
     {
         RunMessage rm = new RunMessage(RunMessage.RunType.WAIT, eMsg, this);
         rm.AttachObject = (eSrcUrl as IMakeParam).PL;
         RunEvent(rm);
         return(true);
     }
     return(false);
 }
Beispiel #6
0
 //抛出事件
 public bool ThrowEvent(RunMessage eRunMessage)
 {
     if (ManageEvent != null)
     {
         ManageEvent(eRunMessage);
         return(true);
     }
     else
     {
         return(false);
     }
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleParameterizedStatements() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleParameterizedStatements()
        {
            // Given
            MapValue parameters = ValueUtils.asMapValue(map("n", 12L));

            // When
            RunMessage msg = SerializeAndDeserialize(new RunMessage("asd", parameters));

            // Then
            MapValue @params = msg.Params();

            assertThat(@params, equalTo(parameters));
        }
            public async Task ShouldSendAllMessagesAsync()
            {
                // Given
                var writerMock = new Mock <IMessageWriter>();

                var m1       = new RunMessage("Run message 1");
                var m2       = new RunMessage("Run message 2");
                var messages = new IRequestMessage[] { m1, m2 };
                var client   = new SocketClient(null, writerMock.Object);

                // When
                await client.SendAsync(messages);

                // Then
                writerMock.Verify(x => x.Write(m1), Times.Once);
                writerMock.Verify(x => x.Write(m2), Times.Once);
                writerMock.Verify(x => x.FlushAsync(), Times.Once);
            }
Beispiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldMoveToFailedStateOnRun_fail() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldMoveToFailedStateOnRunFail()
        {
            // Given
            BoltStateMachineV3 machine = NewStateMachine();

            machine.Process(NewHelloMessage(), nullResponseHandler());

            // When
            BoltResponseRecorder recorder   = new BoltResponseRecorder();
            RunMessage           runMessage = mock(typeof(RunMessage));

            when(runMessage.Statement()).thenThrow(new Exception("Fail"));
            machine.Process(runMessage, recorder);

            // Then
            assertThat(recorder.NextResponse(), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError));
            assertThat(machine.State(), instanceOf(typeof(FailedState)));
        }
Beispiel #10
0
        public void Log_RunMessage(RunMessage msg)
        {
            switch (msg.Type)
            {
            case RunMessage.RunType.OK:
                this.log.Debug(msg.MessageString);
                break;

            case RunMessage.RunType.TIP:
                this.log.Debug(msg.MessageString);
                break;

            case RunMessage.RunType.ERR:
                this.log.Error(msg.MessageString);
                break;

            case RunMessage.RunType.WAIT:
                this.log.Error(msg.MessageString);
                break;
            }
        }
            public void ShouldSendAllMessages()
            {
                // Given
                var protocolMock = new Mock <IBoltProtocol>();
                var writerMock   = new Mock <IBoltWriter>();

                protocolMock.Setup(x => x.Writer).Returns(writerMock.Object);

                var m1       = new RunMessage("Run message 1");
                var m2       = new RunMessage("Run message 2");
                var messages = new IRequestMessage[] { m1, m2 };
                var client   = new SocketClient(protocolMock.Object);

                // When
                client.Send(messages);

                // Then
                writerMock.Verify(x => x.Write(m1), Times.Once);
                writerMock.Verify(x => x.Write(m2), Times.Once);
                writerMock.Verify(x => x.Flush(), Times.Once);
            }
Beispiel #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.bolt.runtime.StatementMetadata processRunMessage(org.neo4j.bolt.v1.messaging.request.RunMessage message, org.neo4j.bolt.runtime.StatementProcessor statementProcessor) throws Exception
        private static StatementMetadata ProcessRunMessage(RunMessage message, StatementProcessor statementProcessor)
        {
            if (isBegin(message))
            {
                Bookmark bookmark = Bookmark.fromParamsOrNull(message.Params());
                statementProcessor.BeginTransaction(bookmark);
                return(StatementMetadata.EMPTY);
            }
            else if (isCommit(message))
            {
                statementProcessor.CommitTransaction();
                return(StatementMetadata.EMPTY);
            }
            else if (isRollback(message))
            {
                statementProcessor.RollbackTransaction();
                return(StatementMetadata.EMPTY);
            }
            else
            {
                return(statementProcessor.Run(message.Statement(), message.Params()));
            }
        }
Beispiel #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.bolt.runtime.BoltStateMachineState processRunMessage(org.neo4j.bolt.v1.messaging.request.RunMessage message, org.neo4j.bolt.runtime.StateMachineContext context) throws org.neo4j.bolt.runtime.BoltConnectionFatality
        private BoltStateMachineState ProcessRunMessage(RunMessage message, StateMachineContext context)
        {
            try
            {
                long start = context.Clock().millis();
                StatementMetadata statementMetadata = ProcessRunMessage(message, context.ConnectionState().StatementProcessor);
                long end = context.Clock().millis();

                context.ConnectionState().onMetadata("fields", stringArray(statementMetadata.FieldNames()));
                context.ConnectionState().onMetadata("result_available_after", Values.longValue(end - start));

                return(_streamingState);
            }
            catch (AuthorizationExpiredException e)
            {
                context.HandleFailure(e, true);
                return(_failedState);
            }
            catch (Exception t)
            {
                context.HandleFailure(t, false);
                return(_failedState);
            }
        }
 /// <remarks/>
 public void BeginRunQueryAsync(RunMessage message, object userState) {
     if ((this.BeginRunQueryOperationCompleted == null)) {
         this.BeginRunQueryOperationCompleted = new System.Threading.SendOrPostCallback(this.OnBeginRunQueryOperationCompleted);
     }
     this.InvokeAsync("BeginRunQuery", new object[] {
                 message}, this.BeginRunQueryOperationCompleted, userState);
 }
 /// <remarks/>
 public void BeginRunQueryAsync(RunMessage message) {
     this.BeginRunQueryAsync(message, null);
 }
 /// <remarks/>
 public System.IAsyncResult BeginBeginRunQuery(RunMessage message, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("BeginRunQuery", new object[] {
                 message}, callback, asyncState);
 }
        public void Run(ResultBuilder resultBuilder, string statement, IDictionary <string, object> paramters = null)
        {
            var runMessage = new RunMessage(statement, paramters);

            Enqueue(runMessage, resultBuilder);
        }
Beispiel #18
0
 private void aqiRunner_RunEvent(RunMessage m)
 {
     this.TransferEvent(m);
     Remind.Log_RunMessage(m);
 }
Beispiel #19
0
 private void aqiRunner_RunEvent(RunMessage m)
 {
     TransferEvent(m);
 }
Beispiel #20
0
 private void node_RunEvent(RunMessage m)
 {
     AqiManage.Remind.Log_RunMessage(m);
 }