예제 #1
0
 public void SendMessage()
 {
     Expect.Call(_requestChannel.Send(_messageMock)).Return(true);
     _mocks.ReplayAll();
     _simpleMessagingGateway.Send(_messageMock);
     _mocks.VerifyAll();
 }
        public void TestAggregatorWithPojoCompletionStrategy()
        {
            IMessageChannel     input    = (IMessageChannel)_ctx.GetObject("aggregatorWithPojoCompletionStrategyInput");
            EventDrivenConsumer endpoint = (EventDrivenConsumer)_ctx.GetObject("aggregatorWithPojoCompletionStrategy");

            ICompletionStrategy completionStrategy =
                (ICompletionStrategy)
                TestUtils.GetFieldValue(TestUtils.GetFieldValue(endpoint, "_handler"), "_completionStrategy");

            Assert.IsTrue(completionStrategy is CompletionStrategyAdapter);

            //DirectFieldAccessor completionStrategyAccessor = new DirectFieldAccessor(completionStrategy);
            IMethodInvoker invoker = (IMethodInvoker)TestUtils.GetFieldValue(completionStrategy, "_invoker");

            Assert.IsTrue(TestUtils.GetFieldValue(invoker, "_obj") is MaxValueCompletionStrategy);
            Assert.IsTrue(
                ((MethodInfo)TestUtils.GetFieldValue(completionStrategy, "_method")).Name.Equals("CheckCompleteness"));
            input.Send(CreateMessage(1l, "id1", 0, 0, null));
            input.Send(CreateMessage(2l, "id1", 0, 0, null));
            input.Send(CreateMessage(3l, "id1", 0, 0, null));
            IPollableChannel outputChannel = (IPollableChannel)_ctx.GetObject("outputChannel");
            IMessage         reply         = outputChannel.Receive(TimeSpan.Zero);

            Assert.IsNull(reply);
            input.Send(CreateMessage(5l, "id1", 0, 0, null));
            reply = outputChannel.Receive(TimeSpan.Zero);
            Assert.IsNotNull(reply);
            Assert.That(reply.Payload, Is.EqualTo(11l));
        }
        public void TestDatatypeChannelWithAssignableSubTypes()
        {
            IApplicationContext ctx     = TestUtils.GetContext(@"Channel\Config\ChannelParserTests.xml");
            IMessageChannel     channel = (IMessageChannel)ctx.GetObject("numberChannel");

            Assert.IsTrue(channel.Send(new Message <int>(123)));
            Assert.IsTrue(channel.Send(new Message <double>(123.45)));
        }
        public void TestMultipleDatatypeChannelWithCorrectTypes()
        {
            IApplicationContext ctx     = TestUtils.GetContext(@"Channel\Config\ChannelParserTests.xml");
            IMessageChannel     channel = (IMessageChannel)ctx.GetObject("stringOrNumberChannel");

            Assert.IsTrue(channel.Send(new Message <double>(123.45)));
            Assert.IsTrue(channel.Send(new StringMessage("accepted type")));
        }
예제 #5
0
        public void MultipleTypes()
        {
            IMessageChannel channel = CreateChannel(typeof(string), typeof(int));

            Assert.True(channel.Send(Message.Create("test1")));
            Assert.True(channel.Send(Message.Create <int>(2)));
            Exception exception = null;

            try
            {
                channel.Send(Message.Create <DateTime>(default));
        public void TestChannelWithCapacity()
        {
            IApplicationContext ctx = TestUtils.GetContext(@"Channel\Config\ChannelParserTests.xml");

            IMessageChannel channel = (IMessageChannel)ctx.GetObject("capacityChannel");

            for (int i = 0; i < 10; i++)
            {
                bool result = channel.Send(new Message <string>("test"), TimeSpan.FromMilliseconds(10));
                Assert.IsTrue(result);
            }
            Assert.IsFalse(channel.Send(new Message <string>("test"), TimeSpan.FromMilliseconds(3)));
        }
        /// <summary>
        ///
        /// </summary>
        public virtual void Execute(ActivateProcessInstanceCmd cmd)
        {
            processEngine.Activate(cmd);
            ActivateProcessInstanceResults cmdResult = new ActivateProcessInstanceResults(cmd.Id);

            commandResults.Send(MessageBuilder <ActivateProcessInstanceResults> .WithPayload(cmdResult).Build());
        }
        public void TestDatatypeChannelWithIncorrectType()
        {
            IApplicationContext ctx     = TestUtils.GetContext(@"Channel\Config\ChannelParserTests.xml");
            IMessageChannel     channel = (IMessageChannel)ctx.GetObject("integerChannel");

            channel.Send(new StringMessage("incorrect type"));
        }
예제 #9
0
        public override void Display()
        {
            base.Display();

            var nodeId = Input.ReadInt("Enter node Id :", 1, 254);
            var dbNode = _unitOfWork.Nodes.Include(_ => _.Metadata).SingleOrDefault(_ => _.Id == nodeId);

            if (dbNode == null)
            {
                Output.WriteLine(ConsoleColor.Red, $"Node with id {nodeId} not found in database");
            }
            else
            {
                var confirm = Input.ReadString($"Will send restart to node {dbNode.Metadata.Name}. Confirm (Y/N)?");
                if (confirm != "Y")
                {
                    Output.WriteLine(ConsoleColor.Red, "Cancelled");
                }
                else
                {
                    _msgChannel.Send(new RestartCommand {
                        ToRfAddress = dbNode.RfAddress
                    });
                    Output.WriteLine(ConsoleColor.Blue, "Restart sent");
                }
            }

            Output.DisplayPrompt("Press any key");
            Console.ReadKey();
            Program.NavigateBack();
        }
예제 #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmd"></param>
        public virtual void Execute(ReleaseTaskCmd cmd)
        {
            processEngine.ReleaseTask(cmd);
            ReleaseTaskResults cmdResult = new ReleaseTaskResults(cmd.Id);

            commandResults.Send(MessageBuilder <ReleaseTaskResults> .WithPayload(cmdResult).Build());
        }
        public void TestMultipleDatatypeChannelWithIncorrectType()
        {
            IApplicationContext ctx     = TestUtils.GetContext(@"Channel\Config\ChannelParserTests.xml");
            IMessageChannel     channel = (IMessageChannel)ctx.GetObject("stringOrNumberChannel");

            channel.Send(new Message <bool>(true));
        }
예제 #12
0
 public void Enviar(IMessageChannel canal, string content, string[] names)
 {
     foreach (Contact item in this.Search(names))
     {
         canal.Send(canal.Mensajear(Owner, item, content));
     }
 }
예제 #13
0
        /// <summary>
        ///
        /// </summary>
        public virtual void Execute(CompleteTaskCmd cmd)
        {
            processEngine.CompleteTask(cmd);
            CompleteTaskResults cmdResult = new CompleteTaskResults(cmd.Id);

            commandResults.Send(MessageBuilder <CompleteTaskResults> .WithPayload(cmdResult).Build());
        }
        public void TestDatatypeChannelWithCorrectType()
        {
            IApplicationContext ctx     = TestUtils.GetContext(@"Channel\Config\ChannelParserTests.xml");
            IMessageChannel     channel = (IMessageChannel)ctx.GetObject("integerChannel");

            Assert.IsTrue(channel.Send(new Message <int>(123)));
        }
예제 #15
0
        public void exceptionThrowingFilterRejects()
        {
            IApplicationContext ctx            = TestUtils.GetContext(@"Config\FilterParserTests-context.xml");
            IMessageChannel     exceptionInput = (IMessageChannel)ctx.GetObject("exceptionInput");

            exceptionInput.Send(new StringMessage(""));
        }
예제 #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmd"></param>
        public virtual void Execute(SignalCmd cmd)
        {
            processEngine.Signal(cmd);
            SignalProcessInstancesResults cmdResult = new SignalProcessInstancesResults(cmd.Id);

            commandResults.Send(MessageBuilder <SignalProcessInstancesResults> .WithPayload(cmdResult).Build());
        }
예제 #17
0
파일: Phonebook.cs 프로젝트: Fiorella16/OCP
        public void Send(Contact contact, string text, IMessageChannel channel)
        {
            Message msg = new Message(this.Owner.Name, contact);

            msg.Text = text;
            channel.Send(msg);
        }
예제 #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmd"></param>
        public virtual void Execute(SetProcessVariablesCmd cmd)
        {
            processEngine.SetProcessVariables(cmd);
            SetProcessVariablesResults cmdResult = new SetProcessVariablesResults(cmd.Id);

            commandResults.Send(MessageBuilder <SetProcessVariablesResults> .WithPayload(cmdResult).Build());
        }
예제 #19
0
        public void SendMessage(ToStitchMessage message)
        {
            Assert.ArgNotNull(message, nameof(message));
            var messageBuffer = _serializer.Serialize(message);

            _messageChannel.Send(messageBuffer);
        }
 /// <summary>
 ///
 /// </summary>
 private void SendAuditEvent(IntegrationRequestEvent integrationRequestEvent)
 {
     if (runtimeBundleProperties.EventsProperties.IntegrationAuditEventsEnabled)
     {
         IntegrationRequestSentEventImpl @event = new IntegrationRequestSentEventImpl(runtimeBundleProperties.AppName, runtimeBundleProperties.AppVersion, runtimeBundleProperties.ServiceName, runtimeBundleProperties.ServiceFullName, runtimeBundleProperties.ServiceType, runtimeBundleProperties.ServiceVersion, integrationRequestEvent.ExecutionId, integrationRequestEvent.ProcessDefinitionId, integrationRequestEvent.ProcessInstanceId, integrationRequestEvent.IntegrationContextId, integrationRequestEvent.FlowNodeId);
         auditProducer.Send(MessageBuilder <IProcessEngineEvent[]> .WithPayload(new IProcessEngineEvent[] { @event }).Build());
     }
 }
예제 #21
0
        public void InvalidPayload()
        {
            IApplicationContext context =
                TestUtils.GetContext(@"Config\Xml\PayloadSerializingTransformerParserTests-context.xml");
            IMessageChannel directInput = (IMessageChannel)context.GetObject("directInput");

            directInput.Send(new Message <NonSerializableTestObject>(new NonSerializableTestObject()));
        }
예제 #22
0
        public void SendMessage(IMessageChannel channel, IMessage message, string[] names)
        {
            List <Contact> destinatarios = Search(names);

            foreach (Contact destinatario in destinatarios)
            {
                IMessage msg = new Message(this.Owner.Name, destinatario.Name);
                channel.Send(message, destinatario);
            }
        }
예제 #23
0
        public void ReturnAddressFallbackButNotAvailable()
        {
            IApplicationContext context  = TestUtils.GetContext(@"Endpoint\returnAddressTests.xml");
            IMessageChannel     channel3 = (IMessageChannel)context.GetObject("channel3");

            ((AbstractApplicationContext)context).Start();
            StringMessage message = new StringMessage("*");

            channel3.Send(message);
        }
예제 #24
0
        public void exceptionThrowingFilterAccepts()
        {
            IApplicationContext ctx            = TestUtils.GetContext(@"Config\FilterParserTests-context.xml");
            IMessageChannel     exceptionInput = (IMessageChannel)ctx.GetObject("exceptionInput");

            exceptionInput.Send(new StringMessage("test"));
            IPollableChannel implementationOutput = (IPollableChannel)ctx.GetObject("implementationOutput");
            IMessage         reply = implementationOutput.Receive(TimeSpan.Zero);

            Assert.IsNotNull(reply);
        }
예제 #25
0
 private static void StartResponder(IPollableChannel requestChannel, IMessageChannel replyChannel)
 {
     Executors.NewSingleThreadExecutor().Execute(delegate
     {
         IMessage request = requestChannel.Receive();
         IMessage reply   =
             MessageBuilder.FromMessage(request).SetCorrelationId
                 (request.Headers.Id).Build();
         replyChannel.Send(reply);
     });
 }
 private static void StartResponder(IPollableChannel requestChannel, IMessageChannel replyChannel)
 {
     Executors.NewSingleThreadExecutor().Execute(delegate
                                                     {
                                                         IMessage request = requestChannel.Receive();
                                                         IMessage reply =
                                                             MessageBuilder.FromMessage(request).SetCorrelationId
                                                                 (request.Headers.Id).Build();
                                                         replyChannel.Send(reply);
                                                     });
 }
예제 #27
0
        public void filterWithSelectorAdapterRejects()
        {
            IApplicationContext ctx          = TestUtils.GetContext(@"Config\FilterParserTests-context.xml");
            IMessageChannel     adapterInput = (IMessageChannel)ctx.GetObject("adapterInput");

            adapterInput.Send(new StringMessage(""));
            IPollableChannel adapterOutput = (IPollableChannel)ctx.GetObject("adapterOutput");
            IMessage         reply         = adapterOutput.Receive(TimeSpan.Zero);

            Assert.IsNull(reply);
        }
        public void SubscribableChannel()
        {
            IApplicationContext context             = TestUtils.GetContext(@"Config\Xml\BridgeParserTests-context.xml");
            IMessage            message             = new StringMessage("test2");
            IMessageChannel     subscribableChannel = (IMessageChannel)context.GetObject("subscribableChannel");

            subscribableChannel.Send(message);
            IPollableChannel output2 = (IPollableChannel)context.GetObject("output2");
            IMessage         reply   = output2.Receive(TimeSpan.Zero);

            Assert.That(reply, Is.EqualTo(message));
        }
예제 #29
0
        // Método para enviar mediante un canal, especificado por el usuario
        public void Send(String[] contactsList, IMessageChannel channelM, string textC)
        {
            Message        messageC;
            List <Contact> contactsM = this.Search(contactsList);

            foreach (Contact contactM in contactsM)
            {
                messageC      = channelM.createMessage(this.Owner, contactM, textC);
                messageC.Text = textC;
                channelM.Send(messageC);
            }
        }
        private bool DoSend(IMessage message, IMessageChannel channel)
        {
            AssertUtils.ArgumentNotNull(channel, "channel", "channel must not be null");
            TimeSpan timeout = _sendTimeout;
            bool     sent    = (timeout.TotalMilliseconds >= 0) ? channel.Send(message, timeout) : channel.Send(message);

            if (!sent && _logger.IsTraceEnabled)
            {
                _logger.Trace("failed to send message to channel '" + channel + "' within timeout: " + timeout);
            }
            return(sent);
        }
예제 #31
0
        public void filterWithSelectorImplementationAccepts()
        {
            IApplicationContext ctx = TestUtils.GetContext(@"Config\FilterParserTests-context.xml");
            IMessageChannel     implementationInput = (IMessageChannel)ctx.GetObject("implementationInput");

            implementationInput.Send(new StringMessage("test"));
            IPollableChannel implementationOutput = (IPollableChannel)ctx.GetObject("implementationOutput");
            IMessage         reply = implementationOutput.Receive(TimeSpan.Zero);

            Assert.IsNotNull(reply);
            Assert.That(reply.Payload, Is.EqualTo("test"));
        }
예제 #32
0
		public static void ReceiveTimeout(IMessageChannel channel)
		{
			var ts = new TimeSpan(0, 0, 0, 0, 500);

			channel.Open();
			channel.Clear();

			var m = new FakeMessage();
			var m2 = new FakeMessage();

			channel.Send(m);
			channel.Send(m2);

			var count = 0;
			foreach (var msg in channel.ReceiveMany(2, ts))
			{
				count++;
				Thread.Sleep(500);
			}

			Assert.AreEqual(1, count);
		}
예제 #33
0
		public static void SendAndReceiveSingleMessage(IMessageChannel channel)
		{
			channel.Open();
			channel.Clear();

			var m = GetNewMessage();

			channel.Send(m);

			var m2 = channel.ReceiveSingle(TimeSpan.MaxValue);

			Assert.NotNull(m2);

			Assert.AreEqual(m.Identifier, m2.Identifier);

			channel.Close();
		}
예제 #34
0
		public static void Clear(IMessageChannel channel)
		{
			channel.Open();

			for (var i = 0; i < 5; i++)
			{
				var m = new FakeMessage();
				channel.Send(m);
			}

			channel.Clear();

			var messages = channel.ReceiveMany(5, TimeSpan.MaxValue);

			Assert.AreEqual(0, messages.Count());

			channel.Close();
		}
예제 #35
0
		private static void SendMessages(IMessageChannel channel, int numberOfMessagesToCreate)
		{
			for (var i = 0; i < numberOfMessagesToCreate; i++)
			{
				var msg = GetNewMessage();
				channel.Send(msg);
			}
		}
예제 #36
0
		public static void TestSendingMessageOnClosedTransport(IMessageChannel channel)
		{
			channel.Open();
			channel.Close();

			var m = GetNewMessage();

			Assert.Throws(typeof(InvalidOperationException), () => channel.Send(m));
		}