예제 #1
0
        public void TestDropNoJoin()
        {
            var stmtHande       = new EPStatementHandle(1, "id", null, StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler());
            var stmtAgentHandle = new EPStatementAgentInstanceHandle(stmtHande, ReaderWriterLockManager.CreateDefaultLock(), -1, null, null);

            _streams    = new EventStream[4];
            _streams[0] = _streamFactoryService.CreateStream(1, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;
            _streams[1] = _streamFactoryService.CreateStream(2, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;
            _streams[2] = _streamFactoryService.CreateStream(3, _filterSpecs[1], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;
            _streams[3] = _streamFactoryService.CreateStream(4, _filterSpecs[2], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;

            _streamFactoryService.DropStream(_filterSpecs[0], _supportFilterService, false, false, false, false);
            _streamFactoryService.DropStream(_filterSpecs[1], _supportFilterService, false, false, false, false);
            Assert.AreEqual(0, _supportFilterService.Removed.Count);

            // Filter removed
            _streamFactoryService.DropStream(_filterSpecs[0], _supportFilterService, false, false, false, false);
            Assert.AreEqual(1, _supportFilterService.Removed.Count);

            _streamFactoryService.DropStream(_filterSpecs[2], _supportFilterService, false, false, false, false);
            Assert.AreEqual(2, _supportFilterService.Removed.Count);

            // Something already removed
            try
            {
                _streamFactoryService.DropStream(_filterSpecs[2], _supportFilterService, false, false, false, false);
                Assert.Fail();
            }
            catch (IllegalStateException)
            {
                // Expected
            }
        }
예제 #2
0
        public void TestNodeMatching()
        {
            SupportBeanSimple eventObject = new SupportBeanSimple("DepositEvent_1", 1);
            EventBean         eventBean   = SupportEventBeanFactory.CreateObject(eventObject);

            FilterHandle expr = new SupportFilterHandle();

            _testNode.Add(expr);

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

            _testNode.MatchEvent(eventBean, matches);
            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), ReaderWriterLockManager.CreateDefaultLock());

            _testNode.Add(index);
            index["DepositEvent_1"] = _testEvaluator;

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

            Assert.IsTrue(_testEvaluator.GetAndResetCountInvoked() == 1);
            Assert.IsTrue(_testEvaluator.GetLastEvent() == eventBean);
            Assert.AreEqual(1, matches.Count);
            Assert.AreEqual(expr, matches[0]);
        }
예제 #3
0
        public void TestMultithreaded()
        {
            var topNode = new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock());

            PerformMultithreadedTest(topNode, 2, 1000, 1);
            PerformMultithreadedTest(topNode, 3, 1000, 1);
            PerformMultithreadedTest(topNode, 4, 1000, 1);

            PerformMultithreadedTest(new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock()), 2, 1000, 1);
            PerformMultithreadedTest(new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock()), 3, 1000, 1);
            PerformMultithreadedTest(new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock()), 4, 1000, 1);
        }
예제 #4
0
        public void SetUp()
        {
            _eventType       = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean));
            _topNode         = new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock());
            _filterCallbacks = new List <FilterHandle>();
            _pathsAddedTo    = new List <ArrayDeque <EventTypeIndexBuilderIndexLookupablePair> >();

            _testFilterSpecs = new List <FilterSpecCompiled>();
            _matchedEvents   = new List <EventBean>();
            _unmatchedEvents = new List <EventBean>();

            // Any int and double value specified here must match only the current filter spec not any other filter spec
            _testFilterSpecs.Add(MakeSpec(new Object[] { "IntPrimitive", FilterOperator.GREATER_OR_EQUAL, 100000 }));
            _matchedEvents.Add(MakeEvent(9999999, -1));
            _unmatchedEvents.Add(MakeEvent(0, -1));

            _testFilterSpecs.Add(MakeSpec(new Object[] { "IntPrimitive", FilterOperator.GREATER_OR_EQUAL, 10,
                                                         "DoublePrimitive", FilterOperator.EQUAL, 0.5 }));
            _matchedEvents.Add(MakeEvent(10, 0.5));
            _unmatchedEvents.Add(MakeEvent(0, 0.5));

            _testFilterSpecs.Add(MakeSpec(new Object[] { "DoublePrimitive", FilterOperator.EQUAL, 0.8 }));
            _matchedEvents.Add(MakeEvent(-1, 0.8));
            _unmatchedEvents.Add(MakeEvent(-1, 0.1));

            _testFilterSpecs.Add(MakeSpec(new Object[] { "DoublePrimitive", FilterOperator.EQUAL, 99.99,
                                                         "IntPrimitive", FilterOperator.LESS, 1 }));
            _matchedEvents.Add(MakeEvent(0, 99.99));

            _testFilterSpecs.Add(MakeSpec(new Object[] { "DoublePrimitive", FilterOperator.GREATER, .99,
                                                         "IntPrimitive", FilterOperator.EQUAL, 5001 }));
            _matchedEvents.Add(MakeEvent(5001, 1.1));
            _unmatchedEvents.Add(MakeEvent(5002, 0.98));

            _testFilterSpecs.Add(MakeSpec(new Object[] { "IntPrimitive", FilterOperator.LESS, -99000 }));
            _matchedEvents.Add(MakeEvent(-99001, -1));
            _unmatchedEvents.Add(MakeEvent(-98999, -1));

            _testFilterSpecs.Add(MakeSpec(new Object[] { "IntPrimitive", FilterOperator.GREATER_OR_EQUAL, 11,
                                                         "DoublePrimitive", FilterOperator.GREATER, 888.0 }));
            _matchedEvents.Add(MakeEvent(11, 888.001));
            _unmatchedEvents.Add(MakeEvent(10, 888));

            _testFilterSpecs.Add(MakeSpec(new Object[] { "IntPrimitive", FilterOperator.EQUAL, 973,
                                                         "DoublePrimitive", FilterOperator.EQUAL, 709.0 }));
            _matchedEvents.Add(MakeEvent(973, 709));
            _unmatchedEvents.Add(MakeEvent(0, 0.5));

            _testFilterSpecs.Add(MakeSpec(new Object[] { "IntPrimitive", FilterOperator.EQUAL, 973,
                                                         "DoublePrimitive", FilterOperator.EQUAL, 655.0 }));
            _matchedEvents.Add(MakeEvent(973, 655));
            _unmatchedEvents.Add(MakeEvent(33838, 655.5));
        }
예제 #5
0
        public void SetUp()
        {
            SupportBean testBean = new SupportBean();

            _testEventBean = SupportEventBeanFactory.CreateObject(testBean);
            _testEventType = _testEventBean.EventType;

            _handleSetNode  = new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock());
            _filterCallback = new SupportFilterHandle();
            _handleSetNode.Add(_filterCallback);

            _testIndex = new EventTypeIndex(new FilterServiceGranularLockFactoryReentrant());
            _testIndex.Add(_testEventType, _handleSetNode);
        }
예제 #6
0
        public IReaderWriterLock GetStatementLock(String statementName, Attribute[] annotations, bool stateless)
        {
            bool foundNoLock = AnnotationUtil.FindAttribute(annotations, typeof(NoLockAttribute)) != null;

            if (_disableLocking || foundNoLock || stateless)
            {
                return(ReaderWriterLockManager.VoidLock());
            }

            if (_fairlocks)
            {
                return(ReaderWriterLockManager.FairLock());
            }

            return(ReaderWriterLockManager.CreateDefaultLock());
        }
예제 #7
0
        public void TestCreateNoJoin()
        {
            var stmtHande       = new EPStatementHandle(1, "id", null, StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler());
            var stmtAgentHandle = new EPStatementAgentInstanceHandle(stmtHande, ReaderWriterLockManager.CreateDefaultLock(), -1, null, null);

            _streams    = new EventStream[4];
            _streams[0] = _streamFactoryService.CreateStream(1, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;
            _streams[1] = _streamFactoryService.CreateStream(2, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;
            _streams[2] = _streamFactoryService.CreateStream(3, _filterSpecs[1], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;
            _streams[3] = _streamFactoryService.CreateStream(4, _filterSpecs[2], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First;

            // Streams are reused
            Assert.AreSame(_streams[0], _streams[1]);
            Assert.AreSame(_streams[0], _streams[2]);
            Assert.AreNotSame(_streams[0], _streams[3]);

            // Type is ok
            Assert.AreEqual(typeof(SupportBean), _streams[0].EventType.UnderlyingType);

            // 2 filters are active now
            Assert.AreEqual(2, _supportFilterService.Added.Count);
        }
예제 #8
0
 public void SetUp()
 {
     _testEvaluator = new SupportEventEvaluator();
     _testNode      = new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock());
 }
예제 #9
0
        public static StatementContext MakeContext(SchedulingService stub)
        {
            var variableService = new VariableServiceImpl(1000, null, SupportEventAdapterService.Service, null);
            var config          = new Configuration();

            config.EngineDefaults.ViewResourcesConfig.IsAllowMultipleExpiryPolicies = true;

            var stmtEngineServices = new StatementContextEngineServices(
                "engURI",
                SupportEventAdapterService.Service,
                new NamedWindowServiceImpl(null, variableService, new TableServiceImpl(), false, ReaderWriterLockManager.CreateDefaultLock(), new ExceptionHandlingService("engURI", Collections.GetEmptyList <ExceptionHandler>(), Collections.GetEmptyList <ConditionHandler>()), false, null),
                null, new TableServiceImpl(),
                new EngineSettingsService(new Configuration().EngineDefaults, new Uri[0]),
                new ValueAddEventServiceImpl(),
                config,
                null,
                null,
                null,
                null,
                new StatementEventTypeRefImpl(),
                null,
                null,
                null,
                null);

            return(new StatementContext(
                       stmtEngineServices,
                       null,
                       stub,
                       new ScheduleBucket(1),
                       new EPStatementHandle("id1", "name1", "epl1", StatementType.SELECT, "epl1", false, null, 0, false, false, MultiMatchHandlerFactory.DefaultHandler),
                       new ViewResolutionServiceImpl(new PluggableObjectRegistryImpl(new PluggableObjectCollection[] { ViewEnumHelper.BuiltinViews }), null, null),
                       new PatternObjectResolutionServiceImpl(null),
                       null,
                       null,
                       new MethodResolutionServiceImpl(SupportEngineImportServiceFactory.Make(), null),
                       null,
                       null,
                       new StatementResultServiceImpl("name", null, null, new ThreadingServiceImpl(new ConfigurationEngineDefaults.Threading())),  // statement result svc
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       null,
                       false,
                       null,
                       null,
                       AggregationServiceFactoryServiceImpl.DEFAULT_FACTORY,
                       null,
                       false,
                       null));
        }
예제 #10
0
 private FilterParamIndexDoubleRangeInverted MakeOne(String field, FilterOperator notRangeHalfClosed, EventType testEventType)
 {
     return(new FilterParamIndexDoubleRangeInverted(MakeLookupable(field), ReaderWriterLockManager.CreateDefaultLock(), notRangeHalfClosed));
 }
예제 #11
0
        public void TestBuildWithMatch()
        {
            var topNode = new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock());

            // Add some parameter-less expression
            var filterSpec = MakeFilterValues();

            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[0], topNode, _lockFactory);
            Assert.IsTrue(topNode.Contains(_testFilterCallback[0]));

            // Attempt a match
            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 1);
            _matches.Clear();

            // Add a filter that won't match, with a single parameter matching against an int
            filterSpec = MakeFilterValues("IntPrimitive", FilterOperator.EQUAL, 100);
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[1], topNode, _lockFactory);
            Assert.IsTrue(topNode.Indizes.Count == 1);
            Assert.IsTrue(topNode.Indizes[0].Count == 1);

            // Match again
            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 1);
            _matches.Clear();

            // Add a filter that will match
            filterSpec = MakeFilterValues("IntPrimitive", FilterOperator.EQUAL, 50);
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[2], topNode, _lockFactory);
            Assert.IsTrue(topNode.Indizes.Count == 1);
            Assert.IsTrue(topNode.Indizes[0].Count == 2);

            // match
            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 2);
            _matches.Clear();

            // Add some filter against a double
            filterSpec = MakeFilterValues("DoublePrimitive", FilterOperator.LESS, 1.1);
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[3], topNode, _lockFactory);
            Assert.IsTrue(topNode.Indizes.Count == 2);
            Assert.IsTrue(topNode.Indizes[0].Count == 2);
            Assert.IsTrue(topNode.Indizes[1].Count == 1);

            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 3);
            _matches.Clear();

            filterSpec = MakeFilterValues("DoublePrimitive", FilterOperator.LESS_OR_EQUAL, 0.5);
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[4], topNode, _lockFactory);
            Assert.IsTrue(topNode.Indizes.Count == 3);
            Assert.IsTrue(topNode.Indizes[0].Count == 2);
            Assert.IsTrue(topNode.Indizes[1].Count == 1);
            Assert.IsTrue(topNode.Indizes[2].Count == 1);

            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 4);
            _matches.Clear();

            // Add an filterSpec against double and string
            filterSpec = MakeFilterValues("DoublePrimitive", FilterOperator.LESS, 1.1,
                                          "TheString", FilterOperator.EQUAL, "jack");
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[5], topNode, _lockFactory);
            Assert.IsTrue(topNode.Indizes.Count == 3);
            Assert.IsTrue(topNode.Indizes[0].Count == 2);
            Assert.IsTrue(topNode.Indizes[1].Count == 1);
            Assert.IsTrue(topNode.Indizes[2].Count == 1);
            var nextLevelSetNode = (FilterHandleSetNode)topNode.Indizes[1][1.1d];

            Assert.IsTrue(nextLevelSetNode != null);
            Assert.IsTrue(nextLevelSetNode.Indizes.Count == 1);

            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 5);
            _matches.Clear();

            filterSpec = MakeFilterValues("DoublePrimitive", FilterOperator.LESS, 1.1,
                                          "TheString", FilterOperator.EQUAL, "beta");
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[6], topNode, _lockFactory);

            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 5);
            _matches.Clear();

            filterSpec = MakeFilterValues("DoublePrimitive", FilterOperator.LESS, 1.1,
                                          "TheString", FilterOperator.EQUAL, "jack");
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[7], topNode, _lockFactory);
            Assert.IsTrue(nextLevelSetNode.Indizes.Count == 1);
            var nodeTwo = (FilterHandleSetNode)nextLevelSetNode.Indizes[0]["jack"];

            Assert.IsTrue(nodeTwo.FilterCallbackCount == 2);

            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 6);
            _matches.Clear();

            // Try depth first
            filterSpec = MakeFilterValues("TheString", FilterOperator.EQUAL, "jack",
                                          "LongPrimitive", FilterOperator.EQUAL, 10L,
                                          "ShortPrimitive", FilterOperator.EQUAL, (short)20);
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[8], topNode, _lockFactory);

            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 7);
            _matches.Clear();

            // Add an filterSpec in the middle
            filterSpec = MakeFilterValues("LongPrimitive", FilterOperator.EQUAL, 10L,
                                          "TheString", FilterOperator.EQUAL, "jack");
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[9], topNode, _lockFactory);

            filterSpec = MakeFilterValues("LongPrimitive", FilterOperator.EQUAL, 10L,
                                          "TheString", FilterOperator.EQUAL, "jim");
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[10], topNode, _lockFactory);

            filterSpec = MakeFilterValues("LongPrimitive", FilterOperator.EQUAL, 10L,
                                          "TheString", FilterOperator.EQUAL, "joe");
            IndexTreeBuilder.Add(filterSpec, _testFilterCallback[11], topNode, _lockFactory);

            topNode.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 8);
            _matches.Clear();
        }
예제 #12
0
 private FilterParamIndexDoubleRange MakeOne(String fieldName, FilterOperator operatorType, EventType testEventType)
 {
     return(new FilterParamIndexDoubleRange(MakeLookupable(fieldName), ReaderWriterLockManager.CreateDefaultLock(), operatorType));
 }
예제 #13
0
 public TestStreamFactorySvcImpl()
 {
     _handle      = new EPStatementHandle(1, "name", "text", StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler());
     _agentHandle = new EPStatementAgentInstanceHandle(_handle, ReaderWriterLockManager.CreateDefaultLock(), -1, null, null);
 }
예제 #14
0
        /// <summary>Register an adapter. </summary>
        /// <param name="epService">engine</param>
        public void RegisterAdapter(EPServiceProvider epService)
        {
            var spi       = (EPServiceProviderSPI)epService;
            var eventType = spi.EventAdapterService.GetEventTypeByName(EventTypeName);
            var fvs       = new FilterSpecCompiled(eventType, null, new IList <FilterSpecParam> [0], null).GetValueSet(null, null, null);

            var name            = "subscription:" + SubscriptionName;
            var metricsHandle   = spi.MetricReportingService.GetStatementHandle(name, name);
            var statementHandle = new EPStatementHandle(name, name, name, StatementType.ESPERIO, name, false, metricsHandle, 0, false, false, MultiMatchHandlerFactory.DefaultHandler);
            var agentHandle     = new EPStatementAgentInstanceHandle(statementHandle, ReaderWriterLockManager.CreateDefaultLock(), -1, new StatementAgentInstanceFilterVersion());
            var registerHandle  = new EPStatementHandleCallback(agentHandle, this);

            spi.FilterService.Add(fvs, registerHandle);
        }
예제 #15
0
 private FilterParamIndexEquals MakeOne(String property, EventType testEventType)
 {
     return(new FilterParamIndexEquals(MakeLookupable(property), ReaderWriterLockManager.CreateDefaultLock()));
 }
예제 #16
0
 private FilterParamIndexCompare MakeOne(String field, FilterOperator op)
 {
     return(new FilterParamIndexCompare(MakeLookupable(field), ReaderWriterLockManager.CreateDefaultLock(), op));
 }
 public IReaderWriterLock ObtainNew()
 {
     return(ReaderWriterLockManager.CreateDefaultLock());
     //return new SlimReaderWriterLock();
 }
        public void TestIndex()
        {
            FilterParamIndexNotIn index = new FilterParamIndexNotIn(MakeLookupable("LongBoxed"), ReaderWriterLockManager.CreateDefaultLock());

            Assert.AreEqual(FilterOperator.NOT_IN_LIST_OF_VALUES, index.FilterOperator);

            index.Put(new MultiKeyUntyped(new Object[] { 2L, 5L }), _testEvaluators[0]);
            index.Put(new MultiKeyUntyped(new Object[] { 3L, 4L, 5L }), _testEvaluators[1]);
            index.Put(new MultiKeyUntyped(new Object[] { 1L, 4L, 5L }), _testEvaluators[2]);
            index.Put(new MultiKeyUntyped(new Object[] { 2L, 5L }), _testEvaluators[3]);

            Verify(index, 0L, new bool[] { true, true, true, true });
            Verify(index, 1L, new bool[] { true, true, false, true });
            Verify(index, 2L, new bool[] { false, true, true, false });
            Verify(index, 3L, new bool[] { true, false, true, true });
            Verify(index, 4L, new bool[] { true, false, false, true });
            Verify(index, 5L, new bool[] { false, false, false, false });
            Verify(index, 6L, new bool[] { true, true, true, true });

            MultiKeyUntyped inList = new MultiKeyUntyped(new Object[] { 3L, 4L, 5L });

            Assert.AreEqual(_testEvaluators[1], index.Get(inList));
            Assert.IsTrue(index.ReadWriteLock != null);
            Assert.IsTrue(index.Remove(inList));
            Assert.IsFalse(index.Remove(inList));
            Assert.AreEqual(null, index.Get(inList));

            // now that {3,4,5} is removed, verify results again
            Verify(index, 0L, new bool[] { true, false, true, true });
            Verify(index, 1L, new bool[] { true, false, false, true });
            Verify(index, 2L, new bool[] { false, false, true, false });
            Verify(index, 3L, new bool[] { true, false, true, true });
            Verify(index, 4L, new bool[] { true, false, false, true });
            Verify(index, 5L, new bool[] { false, false, false, false });
            Verify(index, 6L, new bool[] { true, false, true, true });

            try
            {
                index["a"] = _testEvaluators[0];
                Assert.IsTrue(false);
            }
            catch (Exception ex)
            {
                // Expected
            }
        }
예제 #19
0
        public void TestIndex()
        {
            FilterParamIndexIn index = new FilterParamIndexIn(MakeLookupable("LongBoxed"), ReaderWriterLockManager.CreateDefaultLock());

            Assert.AreEqual(FilterOperator.IN_LIST_OF_VALUES, index.FilterOperator);

            MultiKeyUntyped inList = new MultiKeyUntyped(new Object[] { 2L, 5L });

            index.Put(inList, _testEvaluator);
            inList = new MultiKeyUntyped(new Object[] { 10L, 5L });
            index.Put(inList, _testEvaluator);

            Verify(index, 1L, 0);
            Verify(index, 2L, 1);
            Verify(index, 5L, 2);
            Verify(index, 10L, 1);
            Verify(index, 999L, 0);
            Verify(index, null, 0);

            Assert.AreEqual(_testEvaluator, index.Get(inList));
            Assert.IsTrue(index.ReadWriteLock != null);
            Assert.IsTrue(index.Remove(inList));
            Assert.IsFalse(index.Remove(inList));
            Assert.AreEqual(null, index.Get(inList));

            try
            {
                index["a"] = _testEvaluator;
                Assert.IsTrue(false);
            }
            catch (Exception ex)
            {
                // Expected
            }
        }
예제 #20
0
        public void TestBuildMatchRemove()
        {
            var top = new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock());

            // Add a parameter-less filter
            var filterSpecNoParams = MakeFilterValues();
            var pathAddedTo        = IndexTreeBuilder.Add(filterSpecNoParams, _testFilterCallback[0], top, _lockFactory);

            // Try a match
            top.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 1);
            _matches.Clear();

            // Remove filter
            IndexTreeBuilder.Remove(_eventType, _testFilterCallback[0], ToArrayPath(pathAddedTo[0]), top);

            // Match should not be found
            top.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 0);
            _matches.Clear();

            // Add a depth-first filterSpec
            var filterSpecOne = MakeFilterValues(
                "TheString", FilterOperator.EQUAL, "jack",
                "LongPrimitive", FilterOperator.EQUAL, 10L,
                "ShortPrimitive", FilterOperator.EQUAL, (short)20);
            var pathAddedToOne = IndexTreeBuilder.Add(filterSpecOne, _testFilterCallback[1], top, _lockFactory);

            var filterSpecTwo = MakeFilterValues(
                "TheString", FilterOperator.EQUAL, "jack",
                "LongPrimitive", FilterOperator.EQUAL, 10L,
                "ShortPrimitive", FilterOperator.EQUAL, (short)20);
            var pathAddedToTwo = IndexTreeBuilder.Add(filterSpecTwo, _testFilterCallback[2], top, _lockFactory);

            var filterSpecThree = MakeFilterValues(
                "TheString", FilterOperator.EQUAL, "jack",
                "LongPrimitive", FilterOperator.EQUAL, 10L);
            var pathAddedToThree = IndexTreeBuilder.Add(filterSpecThree, _testFilterCallback[3], top, _lockFactory);

            var filterSpecFour = MakeFilterValues(
                "TheString", FilterOperator.EQUAL, "jack");
            var pathAddedToFour = IndexTreeBuilder.Add(filterSpecFour, _testFilterCallback[4], top, _lockFactory);

            var filterSpecFive = MakeFilterValues(
                "LongPrimitive", FilterOperator.EQUAL, 10L);
            var pathAddedToFive = IndexTreeBuilder.Add(filterSpecFive, _testFilterCallback[5], top, _lockFactory);

            top.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 5);
            _matches.Clear();

            // Remove some of the nodes
            IndexTreeBuilder.Remove(_eventType, _testFilterCallback[2], ToArrayPath(pathAddedToTwo[0]), top);

            top.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 4);
            _matches.Clear();

            // Remove some of the nodes
            IndexTreeBuilder.Remove(_eventType, _testFilterCallback[4], ToArrayPath(pathAddedToFour[0]), top);

            top.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 3);
            _matches.Clear();

            // Remove some of the nodes
            IndexTreeBuilder.Remove(_eventType, _testFilterCallback[5], ToArrayPath(pathAddedToFive[0]), top);

            top.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 2);
            _matches.Clear();

            // Remove some of the nodes
            IndexTreeBuilder.Remove(_eventType, _testFilterCallback[1], ToArrayPath(pathAddedToOne[0]), top);

            top.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 1);
            _matches.Clear();

            // Remove some of the nodes
            IndexTreeBuilder.Remove(_eventType, _testFilterCallback[3], ToArrayPath(pathAddedToThree[0]), top);

            top.MatchEvent(_eventBean, _matches);
            Assert.IsTrue(_matches.Count == 0);
            _matches.Clear();
        }