private void RunAssertionWithTime(EPServiceProvider epService, long startTime, long flipTime) { EPServiceProviderIsolated isolated = epService.GetEPServiceIsolated("isolated"); isolated.EPRuntime.SendEvent(new CurrentTimeEvent(startTime)); string text = "select * from SupportBean " + "match_recognize (" + " measures A as a" + " pattern (A*)" + " interval 10 seconds" + ")"; EPStatement stmt = isolated.EPAdministrator.CreateEPL(text, "s0", null); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; isolated.EPRuntime.SendEvent(new SupportBean("E1", 1)); isolated.EPRuntime.SendEvent(new CurrentTimeEvent(flipTime - 1)); Assert.IsFalse(listener.IsInvokedAndReset()); isolated.EPRuntime.SendEvent(new CurrentTimeEvent(flipTime)); Assert.IsTrue(listener.IsInvokedAndReset()); isolated.Dispose(); }
private void RunAssertionRecurringAnchoring(EPServiceProvider epService) { EPServiceProviderIsolated iso = epService.GetEPServiceIsolated("E1"); // Repeat unlimited number of times, reference-dated to "1980-01-01T00:00:00Z" (UTC), period of 1 second SendCurrentTime(iso, "2012-01-01T00:0:00.000GMT-0:00"); string epl = "select * from pattern[every timer:schedule(iso: 'R/PT10S')]"; var listener = new SupportUpdateListener(); iso.EPAdministrator.CreateEPL(epl, null, null).Events += listener.Update; SendCurrentTime(iso, "2012-01-01T00:0:15.000GMT-0:00"); Assert.IsTrue(listener.IsInvokedAndReset()); SendCurrentTime(iso, "2012-01-01T00:0:20.000GMT-0:00"); Assert.IsTrue(listener.IsInvokedAndReset()); AssertReceivedAtTime(listener, iso, "2012-01-01T00:0:30.000GMT-0:00"); SendCurrentTime(iso, "2012-01-01T00:0:55.000GMT-0:00"); Assert.IsTrue(listener.IsInvokedAndReset()); AssertReceivedAtTime(listener, iso, "2012-01-01T00:1:00.000GMT-0:00"); epService.EPAdministrator.DestroyAllStatements(); iso.Dispose(); }
private void RunAssertionOutputLimit(EPServiceProvider epService, long startTime, string size, long flipTime, long repeatTime) { EPServiceProviderIsolated isolated = epService.GetEPServiceIsolated("isolated"); isolated.EPRuntime.SendEvent(new CurrentTimeEvent(startTime)); var listener = new SupportUpdateListener(); EPStatement stmt = isolated.EPAdministrator.CreateEPL("select * from SupportBean output every " + size + " seconds", "s0", null); stmt.Events += listener.Update; isolated.EPRuntime.SendEvent(new SupportBean("E1", 10)); isolated.EPRuntime.SendEvent(new CurrentTimeEvent(flipTime - 1)); Assert.IsFalse(listener.IsInvoked); isolated.EPRuntime.SendEvent(new CurrentTimeEvent(flipTime)); Assert.IsTrue(listener.IsInvokedAndReset()); isolated.EPRuntime.SendEvent(new SupportBean("E2", 10)); isolated.EPRuntime.SendEvent(new CurrentTimeEvent(repeatTime + flipTime - 1)); Assert.IsFalse(listener.IsInvoked); isolated.EPRuntime.SendEvent(new CurrentTimeEvent(repeatTime + flipTime)); Assert.IsTrue(listener.IsInvokedAndReset()); isolated.Dispose(); }
private void AssertSendNoMoreCallback(SupportUpdateListener listener, EPServiceProviderIsolated iso, string time) { SendCurrentTime(iso, time); Assert.IsFalse(listener.IsInvokedAndReset()); SendCurrentTime(iso, "2999-01-01T00:0:00.000GMT-0:00"); Assert.IsFalse(listener.IsInvokedAndReset()); }
private void AssertReceivedAtTime(SupportUpdateListener listener, EPServiceProviderIsolated iso, string time) { long msec = DateTimeParser.ParseDefaultMSecWZone(time); iso.EPRuntime.SendEvent(new CurrentTimeEvent(msec - 1)); Assert.IsFalse(listener.IsInvokedAndReset()); iso.EPRuntime.SendEvent(new CurrentTimeEvent(msec)); Assert.IsTrue(listener.IsInvokedAndReset(), "expected but not received at " + time); }
private void RunAssertionFollowedBy(EPServiceProvider epService) { EPServiceProviderIsolated iso = epService.GetEPServiceIsolated("E1"); SendCurrentTime(iso, "2012-10-01T05:51:07.000GMT-0:00"); string epl = "select * from pattern[every sb=SupportBean -> timer:schedule(iso: 'R/1980-01-01T00:00:00Z/PT15S')]"; var listener = new SupportUpdateListener(); iso.EPAdministrator.CreateEPL(epl, null, null).Events += listener.Update; SupportBean b1 = MakeSendEvent(iso, "E1"); SendCurrentTime(iso, "2012-10-01T05:51:14.999GMT-0:00"); Assert.IsFalse(listener.IsInvokedAndReset()); SendCurrentTime(iso, "2012-10-01T05:51:15.000GMT-0:00"); Assert.AreEqual(b1, listener.AssertOneGetNewAndReset().Get("sb")); SendCurrentTime(iso, "2012-10-01T05:51:16.000GMT-0:00"); SupportBean b2 = MakeSendEvent(iso, "E2"); SendCurrentTime(iso, "2012-10-01T05:51:18.000GMT-0:00"); SupportBean b3 = MakeSendEvent(iso, "E3"); SendCurrentTime(iso, "2012-10-01T05:51:30.000GMT-0:00"); EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), "sb".Split(','), new object[][] { new object[] { b2 }, new object[] { b3 } }); epService.EPAdministrator.DestroyAllStatements(); iso.Dispose(); }
private void RunAssertionPatternTypeCacheForRepeat(EPServiceProvider epService) { // UEJ-229-28464 bug fix for type reuse for dissimilar types string epl = "create objectarray schema TypeOne(symbol string, price double);\n" + "create objectarray schema TypeTwo(symbol string, market string, price double);\n" + "\n" + "@Name('Out2') select a[0].symbol from pattern [ [2] a=TypeOne ]\n;" + "@Name('Out3') select a[0].market from pattern [ [2] a=TypeTwo ];"; DeploymentResult result = epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl); var listenerOut2 = new SupportUpdateListener(); epService.EPAdministrator.GetStatement("Out2").Events += listenerOut2.Update; var listenerOut3 = new SupportUpdateListener(); epService.EPAdministrator.GetStatement("Out3").Events += listenerOut3.Update; epService.EPRuntime.SendEvent(new object[] { "GE", 10 }, "TypeOne"); epService.EPRuntime.SendEvent(new object[] { "GE", 10 }, "TypeOne"); Assert.IsTrue(listenerOut2.IsInvokedAndReset()); epService.EPRuntime.SendEvent(new object[] { "GE", 10, 5 }, "TypeTwo"); epService.EPRuntime.SendEvent(new object[] { "GE", 10, 5 }, "TypeTwo"); Assert.IsTrue(listenerOut3.IsInvokedAndReset()); epService.EPAdministrator.DeploymentAdmin.UndeployRemove(result.DeploymentId); }
public void TestContextPartition() { String epl = "create expression the_expr alias for {theString='a' and intPrimitive=1};\n" + "create context the_context start @now end after 10 minutes;\n" + "@Name('s0') context the_context select * from SupportBean(the_expr)\n"; epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl); epService.EPAdministrator.GetStatement("s0").AddListener(listener); epService.EPRuntime.SendEvent(new SupportBean("a", 1)); Assert.IsTrue(listener.IsInvokedAndReset()); epService.EPRuntime.SendEvent(new SupportBean("b", 1)); Assert.False(listener.IsInvokedAndReset()); }
private void RunAssertionContextPartition(EPServiceProvider epService) { string epl = "create expression the_expr alias for {TheString='a' and IntPrimitive=1};\n" + "create context the_context start @now end after 10 minutes;\n" + "@Name('s0') context the_context select * from SupportBean(the_expr)\n"; DeploymentResult result = epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl); var listener = new SupportUpdateListener(); epService.EPAdministrator.GetStatement("s0").Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean("a", 1)); Assert.IsTrue(listener.IsInvokedAndReset()); epService.EPRuntime.SendEvent(new SupportBean("b", 1)); Assert.IsFalse(listener.IsInvokedAndReset()); epService.EPAdministrator.DeploymentAdmin.UndeployRemove(result.DeploymentId); }
public void TestMovePattern() { EPServiceProviderIsolated isolatedService = _epService.GetEPServiceIsolated("Isolated"); EPStatement stmt = isolatedService.EPAdministrator.CreateEPL("select * from pattern [every (a=SupportBean -> b=SupportBean(theString=a.theString)) where timer:within(1 day)]", "TestStatement", null); isolatedService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeHelper.CurrentTimeMillis + 1000)); isolatedService.EPRuntime.SendEvent(new SupportBean("E1", 1)); stmt.AddListener(_listener); isolatedService.EPAdministrator.RemoveStatement(stmt); _epService.EPRuntime.SendEvent(new SupportBean("E1", 2)); Assert.IsTrue(_listener.IsInvokedAndReset()); }
private static void RunAssertionEventTime(EPServiceProvider epService, long tsB, long flipTimeEndtsA) { EPServiceProviderIsolated isolated = epService.GetEPServiceIsolated("isolated"); isolated.EPRuntime.SendEvent(new CurrentTimeEvent(0)); EPStatement stmt = isolated.EPAdministrator.CreateEPL("select * from MyEvent(id='A') as a unidirectional, MyEvent(id='B')#lastevent as b where a.withDate(2002, 5, 30).before(b)", "s0", null); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; isolated.EPRuntime.SendEvent(new object[] { "B", tsB, tsB }, "MyEvent"); isolated.EPRuntime.SendEvent(new object[] { "A", flipTimeEndtsA - 1, flipTimeEndtsA - 1 }, "MyEvent"); Assert.IsTrue(listener.IsInvokedAndReset()); isolated.EPRuntime.SendEvent(new object[] { "A", flipTimeEndtsA, flipTimeEndtsA }, "MyEvent"); Assert.IsFalse(listener.IsInvokedAndReset()); isolated.Dispose(); }
public void TestCurrentTimeWTime() { EPServiceProviderIsolated iso = _epService.GetEPServiceIsolated("E1"); SendCurrentTime(iso, "2012-10-01T8:59:00.000GMT-04:00"); string epl = "select * from pattern[timer:schedule(date: current_timestamp.withTime(9, 0, 0, 0))]"; iso.EPAdministrator.CreateEPL(epl, null, null).AddListener(_listener); SendCurrentTime(iso, "2012-10-01T8:59:59.999GMT-4:00"); Assert.IsFalse(_listener.IsInvokedAndReset()); SendCurrentTime(iso, "2012-10-01T9:00:00.000GMT-4:00"); Assert.IsTrue(_listener.IsInvokedAndReset()); SendCurrentTime(iso, "2012-10-03T9:00:00.000GMT-4:00"); Assert.IsFalse(_listener.IsInvokedAndReset()); _epService.EPAdministrator.DestroyAllStatements(); iso.Dispose(); }
public override void Run(EPServiceProvider epService) { EPServiceProviderIsolated iso = epService.GetEPServiceIsolated("E1"); SendCurrentTime(iso, "2012-10-01T08:59:00.000GMT-04:00"); string epl = "select * from pattern[timer:schedule(date: current_timestamp.WithTime(9, 0, 0, 0))]"; var listener = new SupportUpdateListener(); iso.EPAdministrator.CreateEPL(epl, null, null).Events += listener.Update; SendCurrentTime(iso, "2012-10-01T08:59:59.999GMT-4:00"); Assert.IsFalse(listener.IsInvokedAndReset()); SendCurrentTime(iso, "2012-10-01T09:00:00.000GMT-4:00"); Assert.IsTrue(listener.IsInvokedAndReset()); SendCurrentTime(iso, "2012-10-03T09:00:00.000GMT-4:00"); Assert.IsFalse(listener.IsInvokedAndReset()); epService.EPAdministrator.DestroyAllStatements(); iso.Dispose(); }
private void RunAssertionMovePattern(EPServiceProvider epService) { EPServiceProviderIsolated isolatedService = epService.GetEPServiceIsolated("Isolated"); EPStatement stmt = isolatedService.EPAdministrator.CreateEPL("select * from pattern [every (a=SupportBean -> b=SupportBean(TheString=a.TheString)) where timer:within(1 day)]", "TestStatement", null); isolatedService.EPRuntime.SendEvent(new CurrentTimeEvent(DateTimeHelper.CurrentTimeMillis + 1000)); isolatedService.EPRuntime.SendEvent(new SupportBean("E1", 1)); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; isolatedService.EPAdministrator.RemoveStatement(stmt); epService.EPRuntime.SendEvent(new SupportBean("E1", 2)); Assert.IsTrue(listener.IsInvokedAndReset()); stmt.Dispose(); isolatedService.Dispose(); }
private void RunAssertionFollowedByDynamicallyComputed(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("computeISO8601String", GetType(), "ComputeISO8601String"); EPServiceProviderIsolated iso = epService.GetEPServiceIsolated("E1"); SendCurrentTime(iso, "2012-10-01T05:51:07.000GMT-0:00"); string epl = "select * from pattern[every sb=SupportBean -> timer:schedule(iso: computeISO8601String(sb))]"; var listener = new SupportUpdateListener(); iso.EPAdministrator.CreateEPL(epl, null, null).Events += listener.Update; SupportBean b1 = MakeSendEvent(iso, "E1", 5); SendCurrentTime(iso, "2012-10-01T05:51:9.999GMT-0:00"); Assert.IsFalse(listener.IsInvokedAndReset()); SendCurrentTime(iso, "2012-10-01T05:51:10.000GMT-0:00"); Assert.AreEqual(b1, listener.AssertOneGetNewAndReset().Get("sb")); epService.EPAdministrator.DestroyAllStatements(); iso.Dispose(); }
public void TestComparableProperties() { var admin = _epService.EPAdministrator; var runtime = _epService.EPRuntime; using (admin .CreateEPL("select * from SupportVersionObject where VersionA > VersionB") .AddListener(_listener)) { Assert.That(_listener.IsInvoked, Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 0), new SupportVersion(2, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(2, 0, 0), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.True); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 1), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.True); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 0), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.False); } using (admin .CreateEPL("select * from SupportVersionObject where VersionA >= VersionB") .AddListener(_listener)) { Assert.That(_listener.IsInvoked, Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 0), new SupportVersion(2, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(2, 0, 0), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.True); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 1), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.True); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 0), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.True); } using (admin .CreateEPL("select * from SupportVersionObject where VersionA < VersionB") .AddListener(_listener)) { Assert.That(_listener.IsInvoked, Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 0), new SupportVersion(2, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.True); runtime.SendEvent(new SupportVersionObject(new SupportVersion(2, 0, 0), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 1), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 0), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.False); } using (admin .CreateEPL("select * from SupportVersionObject where VersionA <= VersionB") .AddListener(_listener)) { Assert.That(_listener.IsInvoked, Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 0), new SupportVersion(2, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.True); runtime.SendEvent(new SupportVersionObject(new SupportVersion(2, 0, 0), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 1), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.False); runtime.SendEvent(new SupportVersionObject(new SupportVersion(1, 0, 0), new SupportVersion(1, 0, 0))); Assert.That(_listener.IsInvokedAndReset(), Is.True); } }
private void SendAndAssert(String metaOne, String metaTwo, bool expected) { _epService.EPRuntime.SendEvent(new Object[] { metaOne.SplitCsv(), metaTwo.SplitCsv() }, "Event"); Assert.AreEqual(expected, _listener.IsInvokedAndReset()); }
private void SendAndAssert(EPServiceProvider epService, SupportUpdateListener listener, string metaOne, string metaTwo, bool expected) { epService.EPRuntime.SendEvent(new object[] { metaOne.Split(','), metaTwo.Split(',') }, "Event"); Assert.AreEqual(expected, listener.IsInvokedAndReset()); }
internal static void SendAssertEventRectangle(EPServiceProvider epService, SupportUpdateListener listener, double x, double y, double width, double height, bool expected) { epService.EPRuntime.SendEvent(new SupportSpatialEventRectangle(null, x, y, width, height)); Assert.AreEqual(expected, listener.IsInvokedAndReset()); }