Exemplo n.º 1
0
        private void RunAssertionOrderByProps(EPServiceProvider epService)
        {
            var         fields   = new string[] { "symbol", "volume" };
            string      stmtText = "select symbol, volume from " + typeof(SupportMarketDataBean).FullName + "#length(3) order by symbol, volume";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(stmtText);

            Assert.IsFalse(stmt.HasFirst());

            SendEvent(epService, "SYM", 1);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "SYM", 1L } });

            SendEvent(epService, "OCC", 2);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "OCC", 2L }, new object[] { "SYM", 1L } });

            SendEvent(epService, "SYM", 0);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "OCC", 2L }, new object[] { "SYM", 0L }, new object[] { "SYM", 1L } });

            SendEvent(epService, "OCC", 3);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { "OCC", 2L }, new object[] { "OCC", 3L }, new object[] { "SYM", 0L } });

            stmt.Dispose();
        }
Exemplo n.º 2
0
        private void TryAssertionTimeWinUnique(EPServiceProvider epService, SupportUpdateListener listener, EPStatement stmt)
        {
            var fields = new string[] { "TheString" };

            SendTimer(epService, 1000);
            SendEvent(epService, "E1", 1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E1"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1" });

            SendTimer(epService, 2000);
            SendEvent(epService, "E2", 2);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E1", "E2"));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2" });

            SendTimer(epService, 3000);
            SendEvent(epService, "E3", 1);
            EPAssertionUtil.AssertProps(listener.AssertOneGetOld(), fields, new object[] { "E1" });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNew(), fields, new object[] { "E3" });
            listener.Reset();
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E2", "E3"));

            SendTimer(epService, 4000);
            SendEvent(epService, "E4", 3);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E4" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E2", "E3", "E4"));
            SendEvent(epService, "E5", 3);
            EPAssertionUtil.AssertProps(listener.AssertOneGetOld(), fields, new object[] { "E4" });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNew(), fields, new object[] { "E5" });
            listener.Reset();
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E2", "E3", "E5"));

            SendTimer(epService, 11999);
            Assert.IsFalse(listener.IsInvoked);
            SendTimer(epService, 12000);
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E2" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E3", "E5"));

            SendTimer(epService, 12999);
            Assert.IsFalse(listener.IsInvoked);
            SendTimer(epService, 13000);
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E3" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E5"));

            SendTimer(epService, 13999);
            Assert.IsFalse(listener.IsInvoked);
            SendTimer(epService, 14000);
            EPAssertionUtil.AssertProps(listener.AssertOneGetOldAndReset(), fields, new object[] { "E5" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr());
        }
Exemplo n.º 3
0
        private void RunAssertionNamedWindowMergeInsertIntoTable(EPServiceProvider epService)
        {
            EPStatement stmtCreate = epService.EPAdministrator.CreateEPL("create table MyTableNWM(pkey string)");

            epService.EPAdministrator.CreateEPL("create window MyWindow#keepall as SupportBean");
            epService.EPAdministrator.CreateEPL("on SupportBean as sb merge MyWindow when not matched " +
                                                "then insert into MyTableNWM select sb.TheString as pkey");

            epService.EPRuntime.SendEvent(new SupportBean("E1", 0));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), "pkey".Split(','), new object[][] { new object[] { "E1" } });

            epService.EPAdministrator.DestroyAllStatements();
        }
Exemplo n.º 4
0
        public void TestNamedWindowDelete()
        {
            _epService.EPAdministrator.Configuration.AddEventType <SupportBean_A>();

            String[]    fields = { "TheString" };
            EPStatement stmt   = _epService.EPAdministrator.CreateEPL("create window NW.win:expr(true) as SupportBean");

            stmt.Events += _listener.Update;

            _epService.EPAdministrator.CreateEPL("insert into NW select * from SupportBean");

            _epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            _epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            _listener.Reset();
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1" }, new Object[] { "E2" }, new Object[] { "E3" } });

            _epService.EPAdministrator.CreateEPL("on SupportBean_A delete from NW where TheString = id");
            _epService.EPRuntime.SendEvent(new SupportBean_A("E2"));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new Object[][] { new Object[] { "E1" }, new Object[] { "E3" } });
            EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), fields, new Object[] { "E2" });
        }
        private void TryAssertionTwo(EPServiceProvider epService, string expression)
        {
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(expression);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            string[] fields = "id,valh0,valh1".Split(',');
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendBeanInt(epService, "E1", 0, 0, 0, 0, 1, 1);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendBeanInt(epService, "E2", 1, 1, 1, 1, 1, 1);
            var resultTwo = new object[][] { new object[] { "E2", "H01_0", "H11_0" } };

            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultTwo);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultTwo));

            SendBeanInt(epService, "E3", 5, 5, 3, 4, 1, 1);
            var resultThree = new object[][] { new object[] { "E3", "H03_0", "H14_0" } };

            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultThree);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultTwo, resultThree));

            SendBeanInt(epService, "E4", 0, 5, 3, 4, 1, 1);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultTwo, resultThree));

            SendBeanInt(epService, "E5", 2, 0, 2, 1, 1, 1);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultTwo, resultThree));

            // set 2 rows for H0
            SendBeanInt(epService, "E6", 2, 2, 2, 2, 2, 1);
            var resultSix = new object[][] { new object[] { "E6", "H02_0", "H12_0" }, new object[] { "E6", "H02_1", "H12_0" } };

            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultSix);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultTwo, resultThree, resultSix));

            SendBeanInt(epService, "E7", 10, 10, 4, 5, 1, 2);
            var resultSeven = new object[][] { new object[] { "E7", "H04_0", "H15_0" }, new object[] { "E7", "H04_0", "H15_1" } };

            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultSeven);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultTwo, resultThree, resultSix, resultSeven));

            stmt.Dispose();
        }
Exemplo n.º 6
0
        public void TestRowForAllHaving()
        {
            var    fields   = new[] { "sumVol" };
            String stmtText = "select sum(Volume) as sumVol " +
                              "from " + typeof(SupportMarketDataBean).FullName + ".win:length(3) having sum(Volume) > 100";

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            Assert.IsFalse(stmt.HasFirst());

            SendEvent(100);
            Assert.IsFalse(stmt.HasFirst());

            SendEvent(50);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new Object[] { 150L } });

            SendEvent(25);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new Object[] { 175L } });

            SendEvent(10);
            Assert.IsFalse(stmt.HasFirst());
        }
        private void RunAssertionAggregateGroupedPropsPerGroup(EPServiceProvider epService)
        {
            // test for ESPER-185
            string[] fields = "mycount".Split(',');
            string   epl    = "select irstream count(price) as mycount " +
                              "from " + typeof(SupportMarketDataBean).FullName + "#length(5) " +
                              "group by symbol, price";

            EPStatement stmt     = epService.EPAdministrator.CreateEPL(epl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SendEvent(epService, SYMBOL_DELL, 10);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 1L });
            EPAssertionUtil.AssertProps(listener.LastOldData[0], fields, new object[] { 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1L } });
            listener.Reset();

            SendEvent(epService, SYMBOL_DELL, 11);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 1L });
            EPAssertionUtil.AssertProps(listener.LastOldData[0], fields, new object[] { 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1L }, new object[] { 1L } });
            listener.Reset();

            SendEvent(epService, SYMBOL_DELL, 10);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 2L });
            EPAssertionUtil.AssertProps(listener.LastOldData[0], fields, new object[] { 1L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 2L }, new object[] { 1L } });
            listener.Reset();

            SendEvent(epService, SYMBOL_IBM, 10);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 1L });
            EPAssertionUtil.AssertProps(listener.LastOldData[0], fields, new object[] { 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 2L }, new object[] { 1L }, new object[] { 1L } });
            listener.Reset();

            stmt.Dispose();
        }
Exemplo n.º 8
0
        private void RunAssertionFAFInsert(EPServiceProvider epService)
        {
            string[]    propertyNames = "p0,p1".Split(',');
            EPStatement stmt          = epService.EPAdministrator.CreateEPL("create table MyTableINS as (p0 string, p1 int)");

            string eplInsertInto            = "insert into MyTableINS (p0, p1) select 'a', 1";
            EPOnDemandQueryResult resultOne = epService.EPRuntime.ExecuteQuery(eplInsertInto);

            AssertFAFInsertResult(resultOne, propertyNames, stmt);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), propertyNames, new object[][] { new object[] { "a", 1 } });

            epService.EPAdministrator.DestroyAllStatements();
        }
Exemplo n.º 9
0
        private void RunAssertionLengthBatchSize2(EPServiceProvider epService, SupportBean[] events)
        {
            EPStatement stmt = epService.EPAdministrator.CreateEPL(
                "select irstream * from " + typeof(SupportBean).FullName + "#length_batch(2)");
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SendEvent(events[0], epService);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(new SupportBean[] { events[0] }, stmt.GetEnumerator());

            SendEvent(events[1], epService);
            EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(),
                                                   new SupportBean[] { events[0], events[1] }, null);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(events[2], epService);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(new SupportBean[] { events[2] }, stmt.GetEnumerator());

            SendEvent(events[3], epService);
            EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(),
                                                   new SupportBean[] { events[2], events[3] },
                                                   new SupportBean[] { events[0], events[1] });
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            SendEvent(events[4], epService);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(new SupportBean[] { events[4] }, stmt.GetEnumerator());

            SendEvent(events[5], epService);
            EPAssertionUtil.AssertUnderlyingPerRow(listener.AssertInvokedAndReset(),
                                                   new SupportBean[] { events[4], events[5] },
                                                   new SupportBean[] { events[2], events[3] });
            EPAssertionUtil.AssertEqualsExactOrderUnderlying(null, stmt.GetEnumerator());

            stmt.Dispose();
        }
        private void RunAssertionSeven(String expression)
        {
            EPStatement stmt = epService.EPAdministrator.CreateEPL(expression);

            listener     = new SupportUpdateListener();
            stmt.Events += listener.Update;

            String[]   fields    = "s0id,valh0,valh1".Split(',');
            Object[][] resultOne = new Object[][]
            {
                new Object[] { null, "H01", null },
                new Object[] { null, "H02", null },
                new Object[] { null, null, "H11" },
                new Object[] { null, null, "H12" }
            };
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, resultOne);

            SendBeanInt("E1", 0);
            Assert.IsFalse(listener.IsInvoked);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, resultOne);

            SendBeanInt("E2", 2);
            Object[][] resultTwo = new Object[][] { new Object[] { "E2", "H02", "H12" } };
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultTwo);
            Object[][] resultIt = new Object[][] { new Object[] { null, "H01", null }, new Object[] { null, null, "H11" }, new Object[] { "E2", "H02", "H12" } };
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, resultIt);

            SendBeanInt("E3", 1);
            resultTwo = new Object[][] { new Object[] { "E3", "H01", "H11" } };
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultTwo);
            resultIt = new Object[][] { new Object[] { "E3", "H01", "H11" }, new Object[] { "E2", "H02", "H12" } };
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, resultIt);

            SendBeanInt("E4", 1);
            resultTwo = new Object[][] { new Object[] { "E4", "H01", "H11" } };
            EPAssertionUtil.AssertPropsPerRow(listener.GetAndResetLastNewData(), fields, resultTwo);
            resultIt = new Object[][] { new Object[] { "E3", "H01", "H11" }, new Object[] { "E4", "H01", "H11" }, new Object[] { "E2", "H02", "H12" } };
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, resultIt);
        }
Exemplo n.º 11
0
        private void RunAssertion2JoinHistoricalIndependentOuter(EPServiceProvider epService)
        {
            string[] fields    = "valueOne,valueTwo".Split(',');
            string   className = typeof(SupportStaticMethodLib).FullName;
            string   stmtText;

            // fetchBetween must execute first, fetchIdDelimited is dependent on the result of fetchBetween
            stmtText = "select s0.value as valueOne, s1.value as valueTwo from method:" + className + ".FetchResult12(0) as s0 " +
                       "left outer join " +
                       "method:" + className + ".FetchResult23(0) as s1 on s0.value = s1.value";
            EPStatement stmt = epService.EPAdministrator.CreateEPL(stmtText);

            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1, null }, new object[] { 2, 2 } });
            stmt.Dispose();

            stmtText = "select s0.value as valueOne, s1.value as valueTwo from " +
                       "method:" + className + ".FetchResult23(0) as s1 " +
                       "right outer join " +
                       "method:" + className + ".FetchResult12(0) as s0 on s0.value = s1.value";
            stmt = epService.EPAdministrator.CreateEPL(stmtText);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1, null }, new object[] { 2, 2 } });
            stmt.Dispose();

            stmtText = "select s0.value as valueOne, s1.value as valueTwo from " +
                       "method:" + className + ".FetchResult23(0) as s1 " +
                       "full outer join " +
                       "method:" + className + ".FetchResult12(0) as s0 on s0.value = s1.value";
            stmt = epService.EPAdministrator.CreateEPL(stmtText);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1, null }, new object[] { 2, 2 }, new object[] { null, 3 } });
            stmt.Dispose();

            stmtText = "select s0.value as valueOne, s1.value as valueTwo from " +
                       "method:" + className + ".FetchResult12(0) as s0 " +
                       "full outer join " +
                       "method:" + className + ".FetchResult23(0) as s1 on s0.value = s1.value";
            stmt = epService.EPAdministrator.CreateEPL(stmtText);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1, null }, new object[] { 2, 2 }, new object[] { null, 3 } });
            stmt.Dispose();
        }
Exemplo n.º 12
0
        private void RunAssertionTimeWindow(EPServiceProvider epService)
        {
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));

            var         fields   = new[] { "TheString" };
            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select irstream * from SupportBean#expr(oldest_timestamp > newest_timestamp - 2000)");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1000));
            epService.EPRuntime.SendEvent(new SupportBean("E1", 1));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E1" } });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1" });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(1500));
            epService.EPRuntime.SendEvent(new SupportBean("E2", 2));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2" });

            epService.EPRuntime.SendEvent(new SupportBean("E3", 3));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E1" }, new object[] { "E2" }, new object[] { "E3" } });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E3" });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(2500));
            epService.EPRuntime.SendEvent(new SupportBean("E4", 4));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E1" }, new object[] { "E2" }, new object[] { "E3" }, new object[] { "E4" } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(3000));
            epService.EPRuntime.SendEvent(new SupportBean("E5", 5));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E2" }, new object[] { "E3" }, new object[] { "E4" }, new object[] { "E5" } });
            EPAssertionUtil.AssertPropsPerRow(listener.LastNewData, fields, new[] { new object[] { "E5" } });
            EPAssertionUtil.AssertPropsPerRow(listener.LastOldData, fields, new[] { new object[] { "E1" } });
            listener.Reset();

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(3499));
            epService.EPRuntime.SendEvent(new SupportBean("E6", 6));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E2" }, new object[] { "E3" }, new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(3500));
            epService.EPRuntime.SendEvent(new SupportBean("E7", 7));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" }, new object[] { "E7" } });
            EPAssertionUtil.AssertPropsPerRow(listener.LastNewData, fields, new[] { new object[] { "E7" } });
            EPAssertionUtil.AssertPropsPerRow(listener.LastOldData, fields, new[] { new object[] { "E2" }, new object[] { "E3" } });
            listener.Reset();

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(10000));
            epService.EPRuntime.SendEvent(new SupportBean("E8", 8));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "E8" } });
            EPAssertionUtil.AssertPropsPerRow(listener.LastNewData, fields, new[] { new object[] { "E8" } });
            EPAssertionUtil.AssertPropsPerRow(listener.LastOldData, fields, new[] { new object[] { "E4" }, new object[] { "E5" }, new object[] { "E6" }, new object[] { "E7" } });
            listener.Reset();

            stmt.Dispose();
        }
Exemplo n.º 13
0
        private void RunAssertionTimeWinUnique(EPStatement stmt)
        {
            var fields = new String[] { "TheString" };

            SendTimer(1000);
            SendEvent("E1", 1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E1"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E1" });

            SendTimer(2000);
            SendEvent("E2", 2);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E1", "E2"));
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E2" });

            SendTimer(3000);
            SendEvent("E3", 1);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetOld(), fields, new Object[] { "E1" });
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNew(), fields, new Object[] { "E3" });
            _listener.Reset();
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E2", "E3"));

            SendTimer(4000);
            SendEvent("E4", 3);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { "E4" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E2", "E3", "E4"));
            SendEvent("E5", 3);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetOld(), fields, new Object[] { "E4" });
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNew(), fields, new Object[] { "E5" });
            _listener.Reset();
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E2", "E3", "E5"));

            SendTimer(11999);
            Assert.IsFalse(_listener.IsInvoked);
            SendTimer(12000);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), fields, new Object[] { "E2" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E3", "E5"));

            SendTimer(12999);
            Assert.IsFalse(_listener.IsInvoked);
            SendTimer(13000);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), fields, new Object[] { "E3" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr("E5"));

            SendTimer(13999);
            Assert.IsFalse(_listener.IsInvoked);
            SendTimer(14000);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetOldAndReset(), fields, new Object[] { "E5" });
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr());
        }
Exemplo n.º 14
0
        private void RunAssertionFirstUniqueAndLengthOnDelete(EPServiceProvider epService)
        {
            EPStatement nwstmt = epService.EPAdministrator.CreateEPL("create window MyWindowOne#firstunique(TheString)#firstlength(3) retain-union as SupportBean");

            epService.EPAdministrator.CreateEPL("insert into MyWindowOne select * from SupportBean");
            epService.EPAdministrator.CreateEPL("on SupportBean_S0 delete from MyWindowOne where TheString = p00");

            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select irstream * from MyWindowOne");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            var fields = new string[] { "TheString", "IntPrimitive" };

            SendEvent(epService, "E1", 1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 } });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 1 });

            SendEvent(epService, "E1", 99);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E1", 99 } });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 99 });

            SendEvent(epService, "E2", 2);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 1 }, new object[] { "E1", 99 }, new object[] { "E2", 2 } });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E2", 2 });

            epService.EPRuntime.SendEvent(new SupportBean_S0(1, "E1"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E2", 2 } });
            EPAssertionUtil.AssertProps(listener.LastOldData[0], "TheString".Split(','), new object[] { "E1" });
            EPAssertionUtil.AssertProps(listener.LastOldData[1], "TheString".Split(','), new object[] { "E1" });
            listener.Reset();

            SendEvent(epService, "E1", 3);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(nwstmt.GetEnumerator(), fields, new object[][] { new object[] { "E1", 3 }, new object[] { "E2", 2 } });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { "E1", 3 });

            epService.EPAdministrator.DestroyAllStatements();
        }
Exemplo n.º 15
0
        private void RunAssertionIteratorAggregateRowPerEvent(EPServiceProvider epService)
        {
            var    fields          = new string[] { "symbol", "sumPrice" };
            string statementString = "select symbol, sum(price) as sumPrice from " +
                                     typeof(SupportMarketDataBean).FullName + "#length(10) as one, " +
                                     typeof(SupportBeanString).FullName + "#length(100) as two " +
                                     "where one.symbol = two.TheString " +
                                     "order by symbol";
            EPStatement statement = epService.EPAdministrator.CreateEPL(statementString);

            epService.EPRuntime.SendEvent(new SupportBeanString("CAT"));
            epService.EPRuntime.SendEvent(new SupportBeanString("IBM"));
            epService.EPRuntime.SendEvent(new SupportBeanString("KGB"));

            SendEvent(epService, "CAT", 50);
            SendEvent(epService, "IBM", 49);
            SendEvent(epService, "CAT", 15);
            SendEvent(epService, "IBM", 100);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), fields,
                                              new object[][] {
                new object[] { "CAT", 214d },
                new object[] { "CAT", 214d },
                new object[] { "IBM", 214d },
                new object[] { "IBM", 214d },
            });

            SendEvent(epService, "KGB", 75);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), fields,
                                              new object[][] {
                new object[] { "CAT", 289d },
                new object[] { "CAT", 289d },
                new object[] { "IBM", 289d },
                new object[] { "IBM", 289d },
                new object[] { "KGB", 289d },
            });

            statement.Dispose();
        }
Exemplo n.º 16
0
        public void TestGroupByRowPerEventOrdered()
        {
            var    fields   = new[] { "Symbol", "Price", "sumVol" };
            String stmtText = "select Symbol, Price, sum(Volume) as sumVol " +
                              "from " + typeof(SupportMarketDataBean).FullName + "#length(5) " +
                              "group by Symbol " +
                              "order by Symbol";

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            Assert.IsFalse(stmt.HasFirst());

            SendEvent("SYM", -1, 100);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[] { new object[] { "SYM", -1d, 100L } });

            SendEvent("TAC", -2, 12);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[]
                                              { new object[] { "SYM", -1d, 100L }, new object[] { "TAC", -2d, 12L } });

            SendEvent("TAC", -3, 13);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[]
            {
                new object[] { "SYM", -1d, 100L }, new object[] { "TAC", -2d, 25L },
                new object[] { "TAC", -3d, 25L }
            });

            SendEvent("SYM", -4, 1);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[]
            {
                new object[] { "SYM", -1d, 101L },
                new object[] { "SYM", -4d, 101L },
                new object[] { "TAC", -2d, 25L },
                new object[] { "TAC", -3d, 25L }
            });

            SendEvent("OCC", -5, 99);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[]
            {
                new object[] { "OCC", -5d, 99L },
                new object[] { "SYM", -1d, 101L },
                new object[] { "SYM", -4d, 101L },
                new object[] { "TAC", -2d, 25L }, new object[] { "TAC", -3d, 25L }
            });

            SendEvent("TAC", -6, 2);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[]
            {
                new object[] { "OCC", -5d, 99L }, new object[] { "SYM", -4d, 1L },
                new object[] { "TAC", -2d, 27L },
                new object[] { "TAC", -3d, 27L }, new object[] { "TAC", -6d, 27L }
            });
        }
Exemplo n.º 17
0
        private void RunAssertionAggregationOverGroupedProps(EPServiceProvider epService)
        {
            // test for ESPER-185
            string[] fields = "volume,symbol,price,mycount".Split(',');
            string   epl    = "select irstream volume,symbol,price,count(price) as mycount " +
                              "from " + typeof(SupportMarketDataBean).FullName + "#length(5) " +
                              "group by symbol, price";

            EPStatement stmt     = epService.EPAdministrator.CreateEPL(epl);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SendEvent(epService, SYMBOL_DELL, 1000, 10);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 1000L, "DELL", 10.0, 1L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1000L, "DELL", 10.0, 1L } });

            SendEvent(epService, SYMBOL_DELL, 900, 11);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 900L, "DELL", 11.0, 1L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1000L, "DELL", 10.0, 1L }, new object[] { 900L, "DELL", 11.0, 1L } });
            listener.Reset();

            SendEvent(epService, SYMBOL_DELL, 1500, 10);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 1500L, "DELL", 10.0, 2L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1000L, "DELL", 10.0, 2L }, new object[] { 900L, "DELL", 11.0, 1L }, new object[] { 1500L, "DELL", 10.0, 2L } });
            listener.Reset();

            SendEvent(epService, SYMBOL_IBM, 500, 5);
            Assert.AreEqual(1, listener.NewDataList.Count);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 500L, "IBM", 5.0, 1L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1000L, "DELL", 10.0, 2L }, new object[] { 900L, "DELL", 11.0, 1L }, new object[] { 1500L, "DELL", 10.0, 2L }, new object[] { 500L, "IBM", 5.0, 1L } });
            listener.Reset();

            SendEvent(epService, SYMBOL_IBM, 600, 5);
            Assert.AreEqual(1, listener.LastNewData.Length);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 600L, "IBM", 5.0, 2L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1000L, "DELL", 10.0, 2L }, new object[] { 900L, "DELL", 11.0, 1L }, new object[] { 1500L, "DELL", 10.0, 2L }, new object[] { 500L, "IBM", 5.0, 2L }, new object[] { 600L, "IBM", 5.0, 2L } });
            listener.Reset();

            SendEvent(epService, SYMBOL_IBM, 500, 5);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 500L, "IBM", 5.0, 3L });
            EPAssertionUtil.AssertProps(listener.LastOldData[0], fields, new object[] { 1000L, "DELL", 10.0, 1L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 900L, "DELL", 11.0, 1L }, new object[] { 1500L, "DELL", 10.0, 1L }, new object[] { 500L, "IBM", 5.0, 3L }, new object[] { 600L, "IBM", 5.0, 3L }, new object[] { 500L, "IBM", 5.0, 3L } });
            listener.Reset();

            SendEvent(epService, SYMBOL_IBM, 600, 5);
            EPAssertionUtil.AssertProps(listener.LastNewData[0], fields, new object[] { 600L, "IBM", 5.0, 4L });
            EPAssertionUtil.AssertProps(listener.LastOldData[0], fields, new object[] { 900L, "DELL", 11.0, 0L });
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1500L, "DELL", 10.0, 1L }, new object[] { 500L, "IBM", 5.0, 4L }, new object[] { 600L, "IBM", 5.0, 4L }, new object[] { 500L, "IBM", 5.0, 4L }, new object[] { 600L, "IBM", 5.0, 4L } });
            listener.Reset();

            stmt.Dispose();
        }
Exemplo n.º 18
0
        private void RunInsertIntoKeyed(EPServiceProvider epService)
        {
            string[]    fields     = "pkey,thesum".Split(',');
            EPStatement stmtCreate = epService.EPAdministrator.CreateEPL("create table MyTableIIK(" +
                                                                         "pkey string primary key," +
                                                                         "thesum sum(int))");

            epService.EPAdministrator.CreateEPL("insert into MyTableIIK select TheString as pkey from SupportBean");
            epService.EPAdministrator.CreateEPL("into table MyTableIIK select sum(id) as thesum from SupportBean_S0 group by p00");
            epService.EPAdministrator.CreateEPL("on SupportBean_S1 insert into MyTableIIK select p10 as pkey");
            epService.EPAdministrator.CreateEPL("on SupportBean_S2 merge MyTableIIK where p20 = pkey when not matched then insert into MyTableIIK select p20 as pkey");

            epService.EPRuntime.SendEvent(new SupportBean("E1", 0));
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", null } });

            epService.EPRuntime.SendEvent(new SupportBean_S0(10, "E1"));
            EPAssertionUtil.AssertPropsPerRow(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 10 } });

            epService.EPRuntime.SendEvent(new SupportBean("E2", 0));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 10 }, new object[] { "E2", null } });

            epService.EPRuntime.SendEvent(new SupportBean_S0(20, "E2"));
            epService.EPRuntime.SendEvent(new SupportBean_S0(11, "E1"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 21 }, new object[] { "E2", 20 } });

            // assert on-insert and on-merge
            epService.EPRuntime.SendEvent(new SupportBean_S1(0, "E3"));
            epService.EPRuntime.SendEvent(new SupportBean_S2(0, "E4"));
            epService.EPRuntime.SendEvent(new SupportBean_S0(3, "E3"));
            epService.EPRuntime.SendEvent(new SupportBean_S0(4, "E4"));
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmtCreate.GetEnumerator(), fields, new object[][] { new object[] { "E1", 21 }, new object[] { "E2", 20 }, new object[] { "E3", 3 }, new object[] { "E4", 4 } });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("table_MyTableIIK__internal", false);
            epService.EPAdministrator.Configuration.RemoveEventType("table_MyTableIIK__public", false);

            epService.EPAdministrator.DestroyAllStatements();
        }
Exemplo n.º 19
0
        private void RunAssertionLeftOuterJoinOnFilter(EPServiceProvider epService)
        {
            string[] fields   = "MyInt,myint".Split(',');
            string   stmtText = "@IterableUnbound select s0.IntPrimitive as MyInt, " + ExecDatabase2StreamOuterJoin.ALL_FIELDS + " from " +
                                typeof(SupportBean).FullName + " as s0 " +
                                " left outer join " +
                                " sql:MyDB ['select " + ExecDatabase2StreamOuterJoin.ALL_FIELDS + " from mytesttable where ${s0.IntPrimitive} = mytesttable.mybigint'] as s1 " +
                                "on TheString = myvarchar";

            EPStatement statement = epService.EPAdministrator.CreateEPL(stmtText);
            var         listener  = new SupportUpdateListener();

            statement.Events += listener.Update;
            EPAssertionUtil.AssertPropsPerRowAnyOrder(statement.GetEnumerator(), fields, null);

            // Result as the SQL query returns 1 row and therefore the on-clause filters it out, but because of left out still getting a row
            SendEvent(epService, 1, "xxx");
            EventBean received = listener.AssertOneGetNewAndReset();

            Assert.AreEqual(1, received.Get("MyInt"));
            AssertReceived(received, null, null, null, null, null, null, null, null, null);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), fields, new object[][] { new object[] { 1, null } });

            // Result as the SQL query returns 0 rows
            SendEvent(epService, -1, "xxx");
            received = listener.AssertOneGetNewAndReset();
            Assert.AreEqual(-1, received.Get("MyInt"));
            AssertReceived(received, null, null, null, null, null, null, null, null, null);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), fields, new object[][] { new object[] { -1, null } });

            SendEvent(epService, 2, "B");
            received = listener.AssertOneGetNewAndReset();
            Assert.AreEqual(2, received.Get("MyInt"));
            AssertReceived(received, 2L, 20, "B", "Y", false, 100.0m, 200.0m, 2.2d, 2.3f);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), fields, new object[][] { new object[] { 2, 20 } });

            statement.Dispose();
        }
Exemplo n.º 20
0
        public void TestSimpleSelectUpdateOnly()
        {
            MySubscriberRowByRowSpecific subscriber = new MySubscriberRowByRowSpecific();
            EPStatement stmt = _epService.EPAdministrator.CreateEPL("select TheString, IntPrimitive from " + typeof(SupportBean).FullName + ".std:lastevent()");

            stmt.Subscriber = subscriber;

            // get statement, attach listener
            SupportUpdateListener listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            // send event
            _epService.EPRuntime.SendEvent(new SupportBean("E1", 100));
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E1", 100 } }, subscriber.GetAndResetIndicate());
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), _fields, new Object[][] { new Object[] { "E1", 100 } });
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), _fields, new Object[] { "E1", 100 });

            // remove listener
            stmt.RemoveAllEventHandlers();

            // send event
            _epService.EPRuntime.SendEvent(new SupportBean("E2", 200));
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E2", 200 } }, subscriber.GetAndResetIndicate());
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), _fields, new Object[][] { new Object[] { "E2", 200 } });
            Assert.IsFalse(listener.IsInvoked);

            // add listener
            SupportStmtAwareUpdateListener stmtAwareListener = new SupportStmtAwareUpdateListener();

            stmt.Events += stmtAwareListener.Update;

            // send event
            _epService.EPRuntime.SendEvent(new SupportBean("E3", 300));
            EPAssertionUtil.AssertEqualsExactOrder(new Object[][] { new Object[] { "E3", 300 } }, subscriber.GetAndResetIndicate());
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), _fields, new Object[][] { new Object[] { "E3", 300 } });
            EPAssertionUtil.AssertProps(stmtAwareListener.AssertOneGetNewAndReset(), _fields, new Object[] { "E3", 300 });
        }
Exemplo n.º 21
0
        public void TestIterator()
        {
            String      viewExpr  = "select Symbol, Price from " + typeof(SupportMarketDataBean).FullName + ".win:keepall()";
            EPStatement statement = _epService.EPAdministrator.CreateEPL(viewExpr);

            statement.Events += _listener.Update;

            SendEvent("ABC", 20);
            SendEvent("DEF", 100);

            // check iterator results
            IEnumerator <EventBean> events = statement.GetEnumerator();
            EventBean theEvent             = events.Advance();

            Assert.AreEqual("ABC", theEvent.Get("Symbol"));
            Assert.AreEqual(20d, theEvent.Get("Price"));

            theEvent = events.Advance();
            Assert.AreEqual("DEF", theEvent.Get("Symbol"));
            Assert.AreEqual(100d, theEvent.Get("Price"));
            Assert.IsFalse(events.MoveNext());

            SendEvent("EFG", 50);

            // check iterator results
            events   = statement.GetEnumerator();
            theEvent = events.Advance();
            Assert.AreEqual("ABC", theEvent.Get("Symbol"));
            Assert.AreEqual(20d, theEvent.Get("Price"));

            theEvent = events.Advance();
            Assert.AreEqual("DEF", theEvent.Get("Symbol"));
            Assert.AreEqual(100d, theEvent.Get("Price"));

            theEvent = events.Advance();
            Assert.AreEqual("EFG", theEvent.Get("Symbol"));
            Assert.AreEqual(50d, theEvent.Get("Price"));
        }
Exemplo n.º 22
0
        private void AssertJoinHistoricalOnlyIndependent(EPServiceProvider epService, string expression)
        {
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(expression);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            string[] fields = "valueOne,valueTwo".Split(',');
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            SendSupportBeanEvent(epService, 5, 5);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { 5, "5" } });

            SendSupportBeanEvent(epService, 1, 2);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, new object[][] { new object[] { 1, "1" }, new object[] { 1, "2" }, new object[] { 2, "1" }, new object[] { 2, "2" } });

            SendSupportBeanEvent(epService, 0, -1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);

            stmt.Dispose();
            SendSupportBeanEvent(epService, 0, -1);
            Assert.IsFalse(listener.IsInvoked);
        }
Exemplo n.º 23
0
        public void TestVariantStream()
        {
            epService.EPAdministrator.Configuration.AddEventType("SupportBean_A", typeof(SupportBean_A));
            epService.EPAdministrator.Configuration.AddEventType("SupportBean_B", typeof(SupportBean_B));

            ConfigurationVariantStream config = new ConfigurationVariantStream();

            //config.setTypeVariance(ConfigurationVariantStream.TypeVariance.ANY);
            config.AddEventTypeName("SupportBean_A");
            config.AddEventTypeName("SupportBean_B");
            epService.EPAdministrator.Configuration.AddVariantStream("VarStream", config);
            epService.EPAdministrator.CreateEPL("create window MyWindow.win:keepall() as select * from VarStream");
            EPStatement stmt = epService.EPAdministrator.CreateEPL("create window MyWindowTwo.win:keepall() as MyWindow");

            epService.EPAdministrator.CreateEPL("insert into VarStream select * from SupportBean_A");
            epService.EPAdministrator.CreateEPL("insert into VarStream select * from SupportBean_B");
            epService.EPAdministrator.CreateEPL("insert into MyWindowTwo select * from VarStream");
            epService.EPRuntime.SendEvent(new SupportBean_A("A1"));
            epService.EPRuntime.SendEvent(new SupportBean_B("B1"));
            EventBean[] events = EPAssertionUtil.EnumeratorToArray(stmt.GetEnumerator());
            Assert.AreEqual("A1", events[0].Get("id?"));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), "id?".Split(','), new object[][] { new object[] { "A1" }, new object[] { "B1" } });
        }
        private void CheckValue(EPStatement weightedAvgView, double avgE)
        {
            IEnumerator <EventBean> iterator = weightedAvgView.GetEnumerator();

            CheckValue(iterator.Advance(), avgE);
            Assert.IsTrue(iterator.MoveNext() == false);

            Assert.IsTrue(_testListener.LastNewData.Length == 1);
            EventBean listenerValues = _testListener.LastNewData[0];

            CheckValue(listenerValues, avgE);

            _testListener.Reset();
        }
Exemplo n.º 25
0
        private void CheckNew(EPStatement statement, long countE, double sumE, double avgE, double stdevpaE, double stdevE, double varianceE)
        {
            var iterator = new LookaheadEnumerator <EventBean>(statement.GetEnumerator());

            CheckValues(iterator.Next(), false, false, countE, sumE, avgE, stdevpaE, stdevE, varianceE);
            Assert.IsTrue(iterator.HasNext() == false);

            Assert.IsTrue(_testListener.LastNewData.Length == 1);
            EventBean childViewValues = _testListener.LastNewData[0];

            CheckValues(childViewValues, false, false, countE, sumE, avgE, stdevpaE, stdevE, varianceE);

            _testListener.Reset();
        }
Exemplo n.º 26
0
        private void RunAssertionVariantStream(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType("SupportBean_A", typeof(SupportBean_A));
            epService.EPAdministrator.Configuration.AddEventType("SupportBean_B", typeof(SupportBean_B));

            var config = new ConfigurationVariantStream();

            //config.TypeVariance = TypeVarianceEnum.ANY;
            config.AddEventTypeName("SupportBean_A");
            config.AddEventTypeName("SupportBean_B");
            epService.EPAdministrator.Configuration.AddVariantStream("VarStream", config);
            epService.EPAdministrator.CreateEPL("create window MyWindowVS#keepall as select * from VarStream");
            EPStatement stmt = epService.EPAdministrator.CreateEPL("create window MyWindowVSTwo#keepall as MyWindowVS");

            epService.EPAdministrator.CreateEPL("insert into VarStream select * from SupportBean_A");
            epService.EPAdministrator.CreateEPL("insert into VarStream select * from SupportBean_B");
            epService.EPAdministrator.CreateEPL("insert into MyWindowVSTwo select * from VarStream");
            epService.EPRuntime.SendEvent(new SupportBean_A("A1"));
            epService.EPRuntime.SendEvent(new SupportBean_B("B1"));
            EventBean[] events = EPAssertionUtil.EnumeratorToArray(stmt.GetEnumerator());
            Assert.AreEqual("A1", events[0].Get("id?"));
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), "id?".Split(','), new[] { new object[] { "A1" }, new object[] { "B1" } });
        }
Exemplo n.º 27
0
        private void RunAssertionUnionAndDerivedValue(EPServiceProvider epService)
        {
            var fields = new string[] { "total" };

            EPStatement stmt     = epService.EPAdministrator.CreateEPL("select * from SupportBean#unique(IntPrimitive)#unique(IntBoxed)#uni(DoublePrimitive) retain-union");
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SendEvent(epService, "E1", 1, 10, 100d);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr(100d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 100d });

            SendEvent(epService, "E2", 2, 20, 50d);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr(150d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 150d });

            SendEvent(epService, "E3", 1, 20, 20d);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, ToArr(170d));
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 170d });

            stmt.Dispose();
        }
Exemplo n.º 28
0
        public void TestLeftOuterJoinOnFilter()
        {
            String[] fields   = "MyInt,myint".Split(',');
            String   stmtText = string.Format(
                "@IterableUnbound select s0.IntPrimitive as MyInt, {0} from {1} as s0 " +
                " left outer join " +
                " sql:MyDB ['select {0} from mytesttable where ${{s0.IntPrimitive}} = mytesttable.mybigint'] as s1 " +
                "on TheString = myvarchar",
                ALL_FIELDS, typeof(SupportBean).FullName);

            EPStatement statement = _epService.EPAdministrator.CreateEPL(stmtText);

            _listener         = new SupportUpdateListener();
            statement.Events += _listener.Update;
            EPAssertionUtil.AssertPropsPerRowAnyOrder(statement.GetEnumerator(), fields, null);

            // Result as the SQL query returns 1 row and therefore the on-clause filters it out, but because of left out still getting a row
            SendEvent(1, "xxx");
            EventBean received = _listener.AssertOneGetNewAndReset();

            Assert.AreEqual(1, received.Get("MyInt"));
            AssertReceived(received, null, null, null, null, null, null, null, null, null);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), fields, new [] { new Object[] { 1, null } });

            // Result as the SQL query returns 0 rows
            SendEvent(-1, "xxx");
            received = _listener.AssertOneGetNewAndReset();
            Assert.AreEqual(-1, received.Get("MyInt"));
            AssertReceived(received, null, null, null, null, null, null, null, null, null);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), fields, new [] { new Object[] { -1, null } });

            SendEvent(2, "B");
            received = _listener.AssertOneGetNewAndReset();
            Assert.AreEqual(2, received.Get("MyInt"));
            AssertReceived(received, 2l, 20, "B", "Y", false, 100m, 200m, 2.2d, 2.3d);
            EPAssertionUtil.AssertPropsPerRow(statement.GetEnumerator(), fields, new [] { new Object[] { 2, 20 } });
        }
Exemplo n.º 29
0
        public void Test3Stream1HistSubordinate()
        {
            String expression;

            expression = "select s0.Id as ids0, s1.Id as ids1, s2.Id as ids2, h0.val as valh0 " +
                         "from SupportBeanInt(id like 'S0%').win:keepall() as s0, " +
                         "SupportBeanInt(id like 'S1%').std:lastevent() as s1, " +
                         "SupportBeanInt(id like 'S2%').std:lastevent() as s2, " +
                         "method:SupportJoinMethods.FetchVal(s1.Id||s2.Id||'H1', s0.P00) as h0 " +
                         "order by s0.Id, s1.Id, s2.Id, h0.val";

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(expression);

            _listener    = new SupportUpdateListener();
            stmt.Events += _listener.Update;

            String[] fields = "ids0,ids1,ids2,valh0".Split(',');
            SendBeanInt("S00", 2);
            SendBeanInt("S10", 1);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, null);
            Assert.IsFalse(_listener.IsInvoked);

            SendBeanInt("S20", 1);
            Object[][] resultOne = new Object[][] { new Object[] { "S00", "S10", "S20", "S10S20H11" }, new Object[] { "S00", "S10", "S20", "S10S20H12" } };
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, resultOne);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, resultOne);

            SendBeanInt("S01", 1);
            Object[][] resultTwo = new Object[][] { new Object[] { "S01", "S10", "S20", "S10S20H11" } };
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, resultTwo);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultOne, resultTwo));

            SendBeanInt("S21", 1);
            Object[][] resultThree = new Object[][] { new Object[] { "S00", "S10", "S21", "S10S21H11" }, new Object[] { "S00", "S10", "S21", "S10S21H12" }, new Object[] { "S01", "S10", "S21", "S10S21H11" } };
            EPAssertionUtil.AssertPropsPerRow(_listener.GetAndResetLastNewData(), fields, resultThree);
            EPAssertionUtil.AssertPropsPerRowAnyOrder(stmt.GetEnumerator(), fields, EPAssertionUtil.ConcatenateArray2Dim(resultThree));
        }
Exemplo n.º 30
0
        public void TestFilter()
        {
            var    fields   = new[] { "Symbol", "vol" };
            String stmtText = "select Symbol, Volume * 10 as vol from " + typeof(SupportMarketDataBean).FullName +
                              "#length(5)" +
                              " where Volume < 0";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText);

            Assert.IsFalse(stmt.HasFirst());

            SendEvent("SYM", 100);
            Assert.IsFalse(stmt.HasFirst());
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, null);

            SendEvent("SYM", -1);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "SYM", -10L } });

            SendEvent("SYM", -6);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[] { new object[] { "SYM", -10L }, new object[] { "SYM", -60L } });

            SendEvent("SYM", 1);
            SendEvent("SYM", 16);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[] { new object[] { "SYM", -10L }, new object[] { "SYM", -60L } });

            SendEvent("SYM", -9);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[]
            {
                new object[] { "SYM", -10L }, new object[] { "SYM", -60L },
                new object[] { "SYM", -90L }
            });

            SendEvent("SYM", 2);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields,
                                              new[] { new object[] { "SYM", -60L }, new object[] { "SYM", -90L } });

            SendEvent("SYM", 3);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "SYM", -90L } });

            SendEvent("SYM", 4);
            SendEvent("SYM", 5);
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), fields, new[] { new object[] { "SYM", -90L } });
            SendEvent("SYM", 6);
            Assert.IsFalse(stmt.HasFirst());
        }