private void RunAssertionAddRemoveFilter(FilterService service) { var eventType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); var spec = SupportFilterSpecBuilder.Build(eventType, new Object[] { "TheString", FilterOperator.EQUAL, "HELLO" }); var filterValues = spec.GetValueSet(null, null, null); var callables = new Func <bool> [5]; for (int ii = 0; ii < callables.Length; ii++) { callables[ii] = () => { var handle = new SupportFilterHandle(); for (int jj = 0; jj < 10000; jj++) { var entry = service.Add(filterValues, handle); service.Remove(handle, entry); } return(true); }; } Object[] result = TryMT(callables); EPAssertionUtil.AssertAllBooleanTrue(result); }
public void TestEquals() { Object[][] paramList = { new Object[] { "IntPrimitive", FilterOperator.EQUAL, 2, "IntBoxed", FilterOperator.EQUAL, 3 }, new Object[] { "IntPrimitive", FilterOperator.EQUAL, 3, "IntBoxed", FilterOperator.EQUAL, 3 }, new Object[] { "IntPrimitive", FilterOperator.EQUAL, 2 }, new Object[] { "IntPrimitive", FilterOperator.RANGE_CLOSED, 1, 10 }, new Object[] { "IntPrimitive", FilterOperator.EQUAL, 2, "IntBoxed", FilterOperator.EQUAL, 3 }, new Object[] { }, new Object[] { }, }; var specVec = new List <FilterSpecCompiled>(); foreach (Object[] param in paramList) { FilterSpecCompiled spec = SupportFilterSpecBuilder.Build(_eventType, param); specVec.Add(spec); } Assert.IsFalse(specVec[0].Equals(specVec[1])); Assert.IsFalse(specVec[0].Equals(specVec[2])); Assert.IsFalse(specVec[0].Equals(specVec[3])); Assert.AreEqual(specVec[0], specVec[4]); Assert.IsFalse(specVec[0].Equals(specVec[5])); Assert.AreEqual(specVec[5], specVec[6]); Assert.IsFalse(specVec[2].Equals(specVec[4])); }
public void TestGetValueSet() { IList <FilterSpecParam> parameters = SupportFilterSpecBuilder.BuildList(_eventType, new Object[] { "IntPrimitive", FilterOperator.EQUAL, 2 }); var numberCoercer = CoercerFactory.GetCoercer(typeof(int), typeof(double)); parameters.Add(new FilterSpecParamEventProp(MakeLookupable("DoubleBoxed"), FilterOperator.EQUAL, "asName", "DoublePrimitive", false, numberCoercer, typeof(double?), "Test")); FilterSpecCompiled filterSpec = new FilterSpecCompiled(_eventType, "SupportBean", new IList <FilterSpecParam>[] { parameters }, null); SupportBean eventBean = new SupportBean(); eventBean.DoublePrimitive = 999.999; EventBean theEvent = SupportEventBeanFactory.CreateObject(eventBean); MatchedEventMap matchedEvents = new MatchedEventMapImpl(new MatchedEventMapMeta(new String[] { "asName" }, false)); matchedEvents.Add(0, theEvent); FilterValueSet valueSet = filterSpec.GetValueSet(matchedEvents, null, null); // Assert the generated filter value container Assert.AreSame(_eventType, valueSet.EventType); Assert.AreEqual(2, valueSet.Parameters[0].Length); // Assert the first param var param = valueSet.Parameters[0][0]; Assert.AreEqual("IntPrimitive", param.Lookupable.Expression); Assert.AreEqual(FilterOperator.EQUAL, param.FilterOperator); Assert.AreEqual(2, param.FilterForValue); // Assert the second param param = (FilterValueSetParam)valueSet.Parameters[0][1]; Assert.AreEqual("DoubleBoxed", param.Lookupable.Expression); Assert.AreEqual(FilterOperator.EQUAL, param.FilterOperator); Assert.AreEqual(999.999, param.FilterForValue); }
private FilterValueSet MakeFilterValues(params object[] filterSpecArgs) { var spec = SupportFilterSpecBuilder.Build(_eventType, filterSpecArgs); var filterValues = spec.GetValueSet(null, null, null); return(filterValues); }
public void SetUp() { _supportFilterService = new SupportFilterServiceImpl(); _streamFactoryService = new StreamFactorySvcImpl("default", true); var eventType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); _filterSpecs = new FilterSpecCompiled[3]; _filterSpecs[0] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "a" }); _filterSpecs[1] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "a" }); _filterSpecs[2] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "b" }); }
public void SetUp() { _eventTypeIndex = new EventTypeIndex(_lockFactory); _indexBuilder = new EventTypeIndexBuilder(_eventTypeIndex, true); _typeOne = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); _typeTwo = SupportEventTypeFactory.CreateBeanType(typeof(SupportBeanSimple)); _valueSetOne = SupportFilterSpecBuilder.Build(_typeOne, new Object[0]).GetValueSet(null, null, null); _valueSetTwo = SupportFilterSpecBuilder.Build(_typeTwo, new Object[0]).GetValueSet(null, null, null); _callbackOne = new SupportFilterHandle(); _callbackTwo = new SupportFilterHandle(); }
public void SetUp() { _container = SupportContainer.Reset(); _handle = new EPStatementHandle(1, "name", "text", StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler()); _agentHandle = new EPStatementAgentInstanceHandle(_handle, _container.RWLockManager().CreateDefaultLock(), -1, null, null); _supportFilterService = new SupportFilterServiceImpl(); _streamFactoryService = new StreamFactorySvcImpl("default", true); var eventType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); _filterSpecs = new FilterSpecCompiled[3]; _filterSpecs[0] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "a" }); _filterSpecs[1] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "a" }); _filterSpecs[2] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "b" }); }
public void SetUp() { _container = SupportContainer.Reset(); _lockFactory = new FilterServiceGranularLockFactoryReentrant(_container.RWLockManager()); _eventTypeIndex = new EventTypeIndex(_lockFactory); _indexBuilder = new EventTypeIndexBuilder(_container.LockManager(), _eventTypeIndex, true); _typeOne = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); _typeTwo = SupportEventTypeFactory.CreateBeanType(typeof(SupportBeanSimple)); _valueSetOne = SupportFilterSpecBuilder.Build(_typeOne, new Object[0]).GetValueSet(null, null, null); _valueSetTwo = SupportFilterSpecBuilder.Build(_typeTwo, new Object[0]).GetValueSet(null, null, null); _callbackOne = new SupportFilterHandle(); _callbackTwo = new SupportFilterHandle(); }
public void TestActiveCallbackRemove() { var spec = SupportFilterSpecBuilder.Build(_eventTypeOne, new Object[0]).GetValueSet(null, null, null); var callbackTwo = new SupportFilterHandle(); // callback that removes another matching filter spec callback Atomic <FilterServiceEntry> filterServiceEntryOne = new Atomic <FilterServiceEntry>(); FilterHandleCallback callbackOne = new ProxyFilterHandleCallback { ProcStatementId = () => "", ProcIsSubselect = () => false, ProcMatchFound = (e, allStmtMatches) => { Log.Debug(".matchFound Removing callbackTwo"); _filterService.Remove(callbackTwo, filterServiceEntryOne.Value); } }; FilterServiceEntry filterServiceEntry = _filterService.Add(spec, callbackOne); filterServiceEntryOne.Set(filterServiceEntry); _filterService.Add(spec, callbackTwo); // send event var theEvent = MakeTypeOneEvent(1, "HELLO", false, 1); var matches = new List <FilterHandle>(); _filterService.Evaluate(theEvent, matches); foreach (FilterHandle match in matches) { var handle = (FilterHandleCallback)match; handle.MatchFound(theEvent, null); } // Callback two MUST be invoked, was removed by callback one, but since the // callback invocation order should not matter, the second one MUST also execute Assert.AreEqual(1, callbackTwo.GetAndResetCountInvoked()); }
private FilterSpecCompiled MakeFilterValues(params object[] filterSpecArgs) { return(SupportFilterSpecBuilder.Build(_eventType, filterSpecArgs)); }
private FilterSpecCompiled MakeSpec(Object[] args) { return(SupportFilterSpecBuilder.Build(_eventType, args)); }
public void SetUp() { _filterService = new FilterServiceLockCoarse(false); _eventTypeOne = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); _eventTypeTwo = SupportEventTypeFactory.CreateBeanType(typeof(SupportBeanSimple)); _filterSpecs = new List <FilterValueSet>(); _filterSpecs.Add(SupportFilterSpecBuilder.Build(_eventTypeOne, new Object[0]).GetValueSet(null, null, null)); _filterSpecs.Add(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)); _filterSpecs.Add(SupportFilterSpecBuilder.Build(_eventTypeTwo, new Object[0]).GetValueSet(null, null, null)); _filterSpecs.Add(SupportFilterSpecBuilder.Build(_eventTypeTwo, new Object[] { "MyInt", FilterOperator.RANGE_HALF_CLOSED, 1, 10, "MyString", FilterOperator.EQUAL, "Hello" }).GetValueSet(null, null, null)); // Create callbacks and add _filterCallbacks = new List <SupportFilterHandle>(); for (int i = 0; i < _filterSpecs.Count; i++) { _filterCallbacks.Add(new SupportFilterHandle()); _filterService.Add(_filterSpecs[i], _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 }); }