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 TestPropertyAssignment()
        {
            EventDrivenConsumer endpoint           = (EventDrivenConsumer)_ctx.GetObject("completelyDefinedAggregator");
            ICompletionStrategy completionStrategy = (ICompletionStrategy)_ctx.GetObject("completionStrategy");
            IMessageChannel     outputChannel      = (IMessageChannel)_ctx.GetObject("outputChannel");
            IMessageChannel     discardChannel     = (IMessageChannel)_ctx.GetObject("discardChannel");

            object consumer =
                endpoint.GetType().GetField("_handler", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(
                    endpoint);

            Assert.That(typeof(MethodInvokingAggregator), Is.EqualTo(consumer.GetType()));

            //DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
            MethodInfo expectedMethod = typeof(TestAggregatorObject).GetMethod("CreateSingleMessageFromGroup");

            Assert.That(TestUtils.GetFieldValue(TestUtils.GetFieldValue(consumer, "_methodInvoker"), "_method"),
                        Is.EqualTo(expectedMethod),
                        "The MethodInvokingAggregator is not injected with the appropriate aggregation method");
            Assert.That(TestUtils.GetFieldValue(consumer, "_completionStrategy"), Is.EqualTo(completionStrategy),
                        "The AggregatorEndpoint is not injected with the appropriate CompletionStrategy instance");
            Assert.That(TestUtils.GetFieldValue(consumer, "_outputChannel"), Is.EqualTo(outputChannel),
                        "The AggregatorEndpoint is not injected with the appropriate output channel");
            Assert.That(TestUtils.GetFieldValue(consumer, "_discardChannel"), Is.EqualTo(discardChannel),
                        "The AggregatorEndpoint is not injected with the appropriate discard channel");
            Assert.That(TestUtils.GetFieldValue(TestUtils.GetFieldValue(consumer, "_channelTemplate"), "_sendTimeout"),
                        Is.EqualTo(TimeSpan.FromMilliseconds(86420000l)),
                        "The AggregatorEndpoint is not set with the appropriate timeout value");
            Assert.That(TestUtils.GetFieldValue(consumer, "_sendPartialResultOnTimeout"), Is.True,
                        "The AggregatorEndpoint is not configured with the appropriate 'send partial results on timeout' flag");
            Assert.That(TestUtils.GetFieldValue(consumer, "_reaperInterval"),
                        Is.EqualTo(TimeSpan.FromMilliseconds(135l)),
                        "The AggregatorEndpoint is not configured with the appropriate reaper interval");
            Assert.That(TestUtils.GetFieldValue(consumer, "_trackedCorrelationIdCapacity"), Is.EqualTo(99),
                        "The AggregatorEndpoint is not configured with the appropriate tracked correlationId capacity");
            Assert.That(TestUtils.GetFieldValue(consumer, "_timeout"), Is.EqualTo(TimeSpan.FromMilliseconds(42l)),
                        "The AggregatorEndpoint is not configured with the appropriate timeout");
        }
 public StatefulRealtimeResultEntryAggregator(IRealtimeResultEntryFilter realtimeResultEntryFilter, QueryConfiguration queryConfiguration)
 {
     this.realtimeResultEntryFilter = realtimeResultEntryFilter;
     completionStrategy             = new ResultEntryCompletionStrategy(queryConfiguration.PermittedGap);
     concatenator = new ResultEntryConcatenator();
 }
Esempio n. 4
0
 public void SetUp()
 {
     strategy = new ResultEntryCompletionStrategy(PermittedGap);
 }