Esempio n. 1
0
        public void TestNodeMatching()
        {
            var eventObject = new SupportBeanSimple("DepositEvent_1", 1);
            var eventBean   = SupportEventBeanFactory
                              .GetInstance(container)
                              .CreateObject(eventObject);

            FilterHandle expr = new SupportFilterHandle();

            testNode.Add(expr);

            // Check matching without an index node
            IList <FilterHandle> matches = new List <FilterHandle>();

            testNode.MatchEvent(eventBean, matches, null);
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(expr, matches[0]);
            matches.Clear();

            // Create, add and populate an index node
            FilterParamIndexBase index = new FilterParamIndexEquals(
                MakeLookupable("MyString", eventBean.EventType),
                new SlimReaderWriterLock());

            testNode.Add(index);
            index.Put("DepositEvent_1", testEvaluator);

            // Verify matcher instance stored in index is called
            testNode.MatchEvent(eventBean, matches, null);

            Assert.IsTrue(testEvaluator.GetAndResetCountInvoked() == 1);
            Assert.IsTrue(testEvaluator.LastEvent == eventBean);
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(expr, matches[0]);
        }
Esempio n. 2
0
        public void SetUp()
        {
            lockFactory = new FilterServiceGranularLockFactoryReentrant(
                container.RWLockManager());

            var testBean = new SupportBean();

            testBean.IntPrimitive    = 50;
            testBean.DoublePrimitive = 0.5;
            testBean.TheString       = "jack";
            testBean.LongPrimitive   = 10;
            testBean.ShortPrimitive  = (short)20;

            eventBean = SupportEventBeanFactory
                        .GetInstance(container)
                        .CreateObject(testBean);
            eventType = eventBean.EventType;

            matches = new List <FilterHandle>();

            // Allocate a couple of callbacks
            testFilterCallback = new SupportFilterHandle[20];
            for (var i = 0; i < testFilterCallback.Length; i++)
            {
                testFilterCallback[i] = new SupportFilterHandle();
            }
        }
Esempio n. 3
0
 public void SetUp()
 {
     testEvaluator = new SupportEventEvaluator();
     testBean      = new SupportBean();
     testEventBean = SupportEventBeanFactory
                     .GetInstance(container)
                     .CreateObject(testBean);
     testEventType = testEventBean.EventType;
     matchesList   = new List <FilterHandle>();
 }
        private EventBean MakeEvent(
            int aInt,
            double aDouble)
        {
            var bean = new SupportBean();

            bean.IntPrimitive    = aInt;
            bean.DoublePrimitive = aDouble;
            return(SupportEventBeanFactory
                   .GetInstance(container)
                   .CreateObject(bean));
        }
Esempio n. 5
0
        public void SetUp()
        {
            lockFactory = new FilterServiceGranularLockFactoryReentrant(container.RWLockManager());

            testEvaluator = new SupportEventEvaluator();
            testBean      = new SupportBean();
            testEventBean = SupportEventBeanFactory
                            .GetInstance(container)
                            .CreateObject(testBean);
            testEventType = testEventBean.EventType;
            matchesList   = new List <FilterHandle>();
        }
        public void SetUp()
        {
            testEvaluators = new SupportEventEvaluator[4];
            for (int i = 0; i < testEvaluators.Length; i++)
            {
                testEvaluators[i] = new SupportEventEvaluator();
            }

            testBean      = new SupportBean();
            testEventBean = SupportEventBeanFactory
                            .GetInstance(container)
                            .CreateObject(testBean);
            testEventType = testEventBean.EventType;
            matchesList   = new List <FilterHandle>();
        }
Esempio n. 7
0
        public void SetUp()
        {
            SupportBean testBean = new SupportBean();

            testEventBean = SupportEventBeanFactory
                            .GetInstance(container)
                            .CreateObject(testBean);
            testEventType = testEventBean.EventType;

            handleSetNode  = new FilterHandleSetNode(new SlimReaderWriterLock());
            filterCallback = new SupportFilterHandle();
            handleSetNode.Add(filterCallback);

            testIndex = new EventTypeIndex(new FilterServiceGranularLockFactoryReentrant(
                                               container.RWLockManager()));
            testIndex.Add(testEventType, handleSetNode);
        }
Esempio n. 8
0
        public void SetUp()
        {
            supportEventBeanFactory = SupportEventBeanFactory.GetInstance(container);

            filterService = new FilterServiceLockCoarse(container.RWLockManager(), -1);

            eventTypeOne = supportEventTypeFactory.CreateBeanType(typeof(SupportBean));
            eventTypeTwo = supportEventTypeFactory.CreateBeanType(typeof(SupportBeanSimple));

            filterSpecs = new List <Pair <EventType, FilterValueSetParam[][]> >();
            filterSpecs.Add(
                new Pair <EventType, FilterValueSetParam[][]>(
                    eventTypeOne,
                    SupportFilterSpecBuilder.Build(eventTypeOne, new object[0]).GetValueSet(null, null, null, null)));
            filterSpecs.Add(
                new Pair <EventType, FilterValueSetParam[][]>(
                    eventTypeOne,
                    SupportFilterSpecBuilder.Build(
                        eventTypeOne,
                        new object[] {
                "IntPrimitive", FilterOperator.RANGE_CLOSED, 10, 20,
                "TheString", FilterOperator.EQUAL, "HELLO",
                "BoolPrimitive", FilterOperator.EQUAL, false,
                "DoubleBoxed", FilterOperator.GREATER, 100d
            })
                    .GetValueSet(null, null, null, null)));
            filterSpecs.Add(
                new Pair <EventType, FilterValueSetParam[][]>(
                    eventTypeTwo,
                    SupportFilterSpecBuilder.Build(eventTypeTwo, new object[0]).GetValueSet(null, null, null, null)));
            filterSpecs.Add(
                new Pair <EventType, FilterValueSetParam[][]>(
                    eventTypeTwo,
                    SupportFilterSpecBuilder.Build(
                        eventTypeTwo,
                        new object[] {
                "MyInt", FilterOperator.RANGE_HALF_CLOSED, 1, 10,
                "MyString", FilterOperator.EQUAL, "Hello"
            })
                    .GetValueSet(null, null, null, null)));

            // Create callbacks and add
            filterCallbacks = new List <SupportFilterHandle>();
            for (var i = 0; i < filterSpecs.Count; i++)
            {
                filterCallbacks.Add(new SupportFilterHandle());
                filterService.Add(filterSpecs[i].First, filterSpecs[i].Second, filterCallbacks[i]);
            }

            // Create events
            matchesExpected = new List <int[]>();
            events          = new List <EventBean>();

            events.Add(MakeTypeOneEvent(15, "HELLO", false, 101));
            matchesExpected.Add(new[] { 1, 1, 0, 0 });

            events.Add(MakeTypeTwoEvent("Hello", 100));
            matchesExpected.Add(new[] { 0, 0, 1, 0 });

            events.Add(MakeTypeTwoEvent("Hello", 1)); // eventNumber = 2
            matchesExpected.Add(new[] { 0, 0, 1, 0 });

            events.Add(MakeTypeTwoEvent("Hello", 2));
            matchesExpected.Add(new[] { 0, 0, 1, 1 });

            events.Add(MakeTypeOneEvent(15, "HELLO", true, 100));
            matchesExpected.Add(new[] { 1, 0, 0, 0 });

            events.Add(MakeTypeOneEvent(15, "HELLO", false, 99));
            matchesExpected.Add(new[] { 1, 0, 0, 0 });

            events.Add(MakeTypeOneEvent(9, "HELLO", false, 100));
            matchesExpected.Add(new[] { 1, 0, 0, 0 });

            events.Add(MakeTypeOneEvent(10, "no", false, 100));
            matchesExpected.Add(new[] { 1, 0, 0, 0 });

            events.Add(MakeTypeOneEvent(15, "HELLO", false, 999999)); // number 8
            matchesExpected.Add(new[] { 1, 1, 0, 0 });

            events.Add(MakeTypeTwoEvent("Hello", 10));
            matchesExpected.Add(new[] { 0, 0, 1, 1 });

            events.Add(MakeTypeTwoEvent("Hello", 11));
            matchesExpected.Add(new[] { 0, 0, 1, 0 });
        }