Example #1
0
			public void Run(RegressionEnvironment env)
			{
				env.CompileDeploy(
						"@JsonSchema(Dynamic=true) @public @buseventtype create json schema JsonEvent();\n" +
						"@Name('s0') select a_array? as c0 from JsonEvent#keepall")
					.AddListener("s0");
				string json;

				json = "{\n" +
				       "  \"a_array\": [\n" +
				       "    [1,2],\n" +
				       "    [[3,4], 5]" +
				       "  ]\n" +
				       "}";
				env.SendEventJson(json, "JsonEvent");
				AssertFillOne(env.Listener("s0").AssertOneGetNewAndReset());

				json = "{\n" +
				       "  \"a_array\": [\n" +
				       "    [6, [ [7,8], [9], []]]\n" +
				       "  ]\n" +
				       "}";
				env.SendEventJson(json, "JsonEvent");
				AssertFillTwo(env.Listener("s0").AssertOneGetNewAndReset());

				env.Milestone(0);

				IEnumerator<EventBean> it = env.Statement("s0").GetEnumerator();
				AssertFillOne(it.Advance());
				AssertFillTwo(it.Advance());

				env.UndeployAll();
			}
Example #2
0
			public void Run(RegressionEnvironment env)
			{
				string epl = "@public @buseventtype create json schema JsonEvent (c0 Map);\n" +
				             "@Name('s0') select * from JsonEvent#keepall;\n";
				env.CompileDeploy(epl).AddListener("s0");
				object[][] namesAndTypes = new object[][] {
					new object[] {"c0", typeof(IDictionary<string, object>)}
				};
				SupportEventTypeAssertionUtil.AssertEventTypeProperties(
					namesAndTypes,
					env.Statement("s0").EventType,
					SupportEventTypeAssertionEnum.NAME,
					SupportEventTypeAssertionEnum.TYPE);

				SendAssertColumn(env, "{}", null);
				SendAssertColumn(env, "{\"c0\": {\"c1\" : 10}}", Collections.SingletonMap("c1", 10));
				SendAssertColumn(env, "{\"c0\": {\"c1\": {\"c2\": 20}}}", Collections.SingletonMap("c1", Collections.SingletonMap("c2", 20)));
				Consumer<object> assertionOne = result => {
					object[] oa = (object[]) (result.AsStringDictionary()).Get("c1");
					EPAssertionUtil.AssertEqualsExactOrder(new object[] {"c2", 20}, oa);
				};
				SendAssert(env, "{\"c0\": {\"c1\": [\"c2\", 20]}}", assertionOne);

				env.Milestone(0);

				IEnumerator<EventBean> it = env.Statement("s0").GetEnumerator();
				AssertColumn(it.Advance(), null);
				AssertColumn(it.Advance(), Collections.SingletonMap("c1", 10));
				AssertColumn(it.Advance(), Collections.SingletonMap("c1", Collections.SingletonMap("c2", 20)));
				JustAssert(it.Advance(), assertionOne);

				env.UndeployAll();
			}
Example #3
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@public @buseventtype create json schema JsonEvent(a int);\n" +
                    "@Name('s0') select *  from JsonEvent#keepall")
                .AddListener("s0");

                IDictionary <string, object> actualOne   = SendJsonGetUnderlying(env, "{\"a\" : 1, \"b\": 2, \"c\": 3}\n");
                IDictionary <string, object> expectedOne = new LinkedHashMap <string, object>();

                expectedOne.Put("a", 1);
                CompareDictionaries(expectedOne, actualOne);

                IDictionary <string, object> actualTwo   = SendJsonGetUnderlying(env, "{\"a\" : 10}\n");
                IDictionary <string, object> expectedTwo = new LinkedHashMap <string, object>();

                expectedTwo.Put("a", 10);
                CompareDictionaries(expectedTwo, actualTwo);

                IDictionary <string, object> actualThree   = SendJsonGetUnderlying(env, "{}\n");
                IDictionary <string, object> expectedThree = new LinkedHashMap <string, object>();

                expectedThree.Put("a", null);
                CompareDictionaries(expectedThree, actualThree);

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    CompareMapWBean(expectedOne, it.Advance());
                    CompareMapWBean(expectedTwo, it.Advance());
                    CompareMapWBean(expectedThree, it.Advance());
                }

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                string epl = "@public @buseventtype create json schema JsonEvent (c0 SupportEnum, c1 SupportEnum[], c2 SupportEnum[][]);\n" +
                             "@Name('s0') select * from JsonEvent#keepall;\n";

                env.CompileDeploy(epl).AddListener("s0");

                string jsonOne =
                    "{\"c0\": \"ENUM_VALUE_2\", \"c1\": [\"ENUM_VALUE_2\", \"ENUM_VALUE_1\"], \"c2\": [[\"ENUM_VALUE_2\"], [\"ENUM_VALUE_1\", \"ENUM_VALUE_3\"]]}";

                AssertJsonWrite(jsonOne, SendGet(env, jsonOne));

                string jsonTwo = "{\"c0\": null, \"c1\": null, \"c2\": null}";

                AssertJsonWrite(jsonTwo, SendGet(env, jsonTwo));

                string jsonThree = "{\"c0\": null, \"c1\": [], \"c2\": [[]]}";

                AssertJsonWrite(jsonThree, SendGet(env, jsonThree));

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    AssertJsonWrite(jsonOne, it.Advance());
                    AssertJsonWrite(jsonTwo, it.Advance());
                    AssertJsonWrite(jsonThree, it.Advance());
                }

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@JsonSchema(Dynamic=true) @public @buseventtype create json schema JsonEvent();\n" +
                    "@Name('s0') select * from JsonEvent#keepall")
                .AddListener("s0");

                string jsonOne = "{\n" +
                                 "  \"a_array\": [\n" +
                                 "    [1,2],\n" +
                                 "    [[3,4], 5]" +
                                 "  ]\n" +
                                 "}";

                SendAssert(env, jsonOne);

                string jsonTwo = "{\n" +
                                 "  \"a_array\": [\n" +
                                 "    [6, [ [7,8], [9], []]]\n" +
                                 "  ]\n" +
                                 "}";

                SendAssert(env, jsonTwo);

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    AssertJsonWrite(jsonOne, it.Advance());
                    AssertJsonWrite(jsonTwo, it.Advance());
                }

                env.UndeployAll();
            }
Example #6
0
        public void TestFlow()
        {
            var lookupEvents = SupportEventBeanFactory.MakeMarketDataEvents(new String[] { "a2" });
            var result       = new List <EventBean[]>();
            var prefill      = new EventBean[] { lookupEvents[0], null };

            // Test lookup on empty index, expect 1 row
            _exec.Process(lookupEvents[0], prefill, result, null);
            Assert.AreEqual(1, result.Count);
            var events = result.FirstOrDefault();

            Assert.IsNull(events[1]);
            Assert.AreSame(lookupEvents[0], events[0]);
            result.Clear();

            // Test lookup on filled index, expect row2
            var indexEvents = SupportEventBeanFactory.MakeEvents(new String[] { "a1", "a2" });

            _index.Add(indexEvents);
            _exec.Process(lookupEvents[0], prefill, result, null);
            Assert.AreEqual(2, result.Count);

            IEnumerator <EventBean[]> it = result.GetEnumerator();

            events = it.Advance();
            Assert.AreSame(lookupEvents[0], events[0]);
            Assert.IsTrue((indexEvents[0] == events[1]) || (indexEvents[1] == events[1]));

            events = it.Advance();
            Assert.AreSame(lookupEvents[0], events[0]);
            Assert.IsTrue((indexEvents[0] == events[1]) || (indexEvents[1] == events[1]));
        }
Example #7
0
            public void Run(RegressionEnvironment env)
            {
                string epl = "@public @buseventtype create json schema JsonEvent(local " +
                             typeof(MyLocalEventNestedRecursive).FullName +
                             ");\n" +
                             "@Name('s0') select * from JsonEvent#keepall;\n";

                env.CompileDeploy(epl).AddListener("s0");

                JObject depthTwo = new JObject(
                    new JProperty("local", MakeNested("a,b")));

                env.SendEventJson(depthTwo.ToString(), "JsonEvent");
                AssertDepthTwo(env, env.Listener("s0").AssertOneGetNewAndReset(), depthTwo);

                JObject depthThree = new JObject(
                    new JProperty("local", MakeNested("a,b,c")));

                env.SendEventJson(depthThree.ToString(), "JsonEvent");
                AssertDepthThree(env, env.Listener("s0").AssertOneGetNewAndReset(), depthThree);

                env.Milestone(0);

                IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator();

                AssertDepthTwo(env, it.Advance(), depthTwo);
                AssertDepthThree(env, it.Advance(), depthThree);

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                string epl = "@public @buseventtype create json schema JsonEvent (" +
                             "c0 string, c1 char, c2 character, c3 bool, c4 boolean, " +
                             "c5 byte, c6 short, c7 int, c8 integer, c9 long, c10 double, c11 float, c12 null);\n" +
                             "@Name('s0') select * from JsonEvent#keepall;\n";

                env.CompileDeploy(epl).AddListener("s0");

                string jsonOne = "{\n" +
                                 "  \"c0\": \"abc\",\n" +
                                 "  \"c1\": \"x\",\n" +
                                 "  \"c2\": \"z\",\n" +
                                 "  \"c3\": true,\n" +
                                 "  \"c4\": false,\n" +
                                 "  \"c5\": 1,\n" +
                                 "  \"c6\": 10,\n" +
                                 "  \"c7\": 11,\n" +
                                 "  \"c8\": 12,\n" +
                                 "  \"c9\": 13,\n" +
                                 "  \"c10\": 14.0,\n" +
                                 "  \"c11\": 1500.0,\n" +
                                 "  \"c12\": null\n" +
                                 "}";

                AssertJsonWrite(jsonOne, SendGet(env, jsonOne));

                string jsonTwo = "{\n" +
                                 "  \"c0\": null,\n" +
                                 "  \"c1\": null,\n" +
                                 "  \"c2\": null,\n" +
                                 "  \"c3\": null,\n" +
                                 "  \"c4\": null,\n" +
                                 "  \"c5\": null,\n" +
                                 "  \"c6\": null,\n" +
                                 "  \"c7\": null,\n" +
                                 "  \"c8\": null,\n" +
                                 "  \"c9\": null,\n" +
                                 "  \"c10\": null,\n" +
                                 "  \"c11\": null,\n" +
                                 "  \"c12\": null\n" +
                                 "}";

                AssertJsonWrite(jsonTwo, SendGet(env, jsonTwo));

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    AssertJsonWrite(jsonOne, it.Advance());
                    AssertJsonWrite(jsonTwo, it.Advance());
                }

                env.UndeployAll();
            }
Example #9
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@public @buseventtype create json schema JsonEvent(`p q` string, ABC string, abc string, AbC string);\n" +
                    "@Name('s0') select * from JsonEvent#keepall")
                .AddListener("s0");

                env.SendEventJson(
                    new JObject(
                        new JProperty("p q", "v1"),
                        new JProperty("ABC", "v2"),
                        new JProperty("abc", "v3"),
                        new JProperty("AbC", "v4"))
                    .ToString(),
                    "JsonEvent");
                AssertEvent(env.Listener("s0").AssertOneGetNewAndReset());

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    AssertEvent(it.Advance());
                }

                env.UndeployAll();
            }
Example #10
0
			public void Run(RegressionEnvironment env)
			{
				env.CompileDeploy(
						"@JsonSchema(Dynamic=true) @public @buseventtype create json schema JsonEvent();\n" +
						"@Name('s0') select a_array? as c0 from JsonEvent#keepall")
					.AddListener("s0");

				string json = "{\n" +
				              "  \"a_array\": [\n" +
				              "    \"a\",\n" +
				              "     1,\n" +
				              "    {\n" +
				              "      \"value\": \"def\"\n" +
				              "    },\n" +
				              "    false,\n" +
				              "    null\n" +
				              "  ]\n" +
				              "}";
				env.SendEventJson(json, "JsonEvent");
				AssertFilled(env.Listener("s0").AssertOneGetNewAndReset());

				env.Milestone(0);

				IEnumerator<EventBean> it = env.Statement("s0").GetEnumerator();
				AssertFilled(it.Advance());

				env.UndeployAll();
			}
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@JsonSchema(Dynamic=true) @public @buseventtype create json schema JsonEvent();\n" +
                    "@Name('s0') select * from JsonEvent#keepall")
                .AddListener("s0");

                string json = "{\n" +
                              "  \"a_array\": [\n" +
                              "    \"a\",\n" +
                              "     1,\n" +
                              "    {\n" +
                              "      \"value\": \"def\"\n" +
                              "    },\n" +
                              "    false,\n" +
                              "    null\n" +
                              "  ]\n" +
                              "}";

                SendAssert(env, json);

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    AssertJsonWrite(json, it.Advance());
                }

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                string epl = "@public @buseventtype create json schema JsonEvent (c0 Map);\n" +
                             "@Name('s0') select * from JsonEvent#keepall;\n";

                env.CompileDeploy(epl).AddListener("s0");
                object[][] namesAndTypes = new object[][] {
                    new object[] { "c0", typeof(IDictionary <string, object>) }
                };
                SupportEventTypeAssertionUtil.AssertEventTypeProperties(
                    namesAndTypes,
                    env.Statement("s0").EventType,
                    SupportEventTypeAssertionEnum.NAME,
                    SupportEventTypeAssertionEnum.TYPE);

                string[] jsons = new string[] {
                    "{\"c0\": {\"c1\" : 10}}",
                    "{\"c0\": {\"c1\": [\"c2\", 20]}}",
                };
                foreach (string json in jsons)
                {
                    SendAssert(env, json);
                }

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    foreach (string json in jsons)
                    {
                        AssertJsonWrite(json, it.Advance());
                    }
                }

                env.UndeployAll();
            }
Example #13
0
        public void TestSensorPerEvent()
        {
            String stmtString =
                "SELECT irstream * " +
                "FROM\n " +
                typeof(SupportSensorEvent).FullName + "#groupwin(type)#time(1 hour)#unique(device)#sort(1, measurement desc) as high ";

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

            stmt.Events += _testListener.Update;

            EPRuntime runtime = _epService.EPRuntime;

            SupportSensorEvent eventOne = new SupportSensorEvent(1, "Temperature", "Device1", 5.0, 96.5);

            runtime.SendEvent(eventOne);
            EPAssertionUtil.AssertUnderlyingPerRow(_testListener.AssertInvokedAndReset(), new Object[] { eventOne }, null);

            SupportSensorEvent eventTwo = new SupportSensorEvent(2, "Temperature", "Device2", 7.0, 98.5);

            runtime.SendEvent(eventTwo);
            EPAssertionUtil.AssertUnderlyingPerRow(_testListener.AssertInvokedAndReset(), new Object[] { eventTwo }, new Object[] { eventOne });

            SupportSensorEvent eventThree = new SupportSensorEvent(3, "Temperature", "Device2", 4.0, 99.5);

            runtime.SendEvent(eventThree);
            EPAssertionUtil.AssertUnderlyingPerRow(_testListener.AssertInvokedAndReset(), new Object[] { eventThree }, new Object[] { eventTwo });

            IEnumerator <EventBean> it       = stmt.GetEnumerator();
            SupportSensorEvent      theEvent = (SupportSensorEvent)it.Advance().Underlying;

            Assert.AreEqual(3, theEvent.Id);
        }
Example #14
0
        public void TestJoinSelect()
        {
            String eventA = typeof(SupportBean).FullName;
            String eventB = typeof(SupportBean).FullName;

            String joinStatement = "select s0.DoubleBoxed, s1.IntPrimitive*s1.IntBoxed/2.0 as div from " +
                                   eventA + "(TheString='s0').win:length(3) as s0," +
                                   eventB + "(TheString='s1').win:length(3) as s1" +
                                   " where s0.DoubleBoxed = s1.DoubleBoxed";

            EPStatement joinView = _epService.EPAdministrator.CreateEPL(joinStatement);

            joinView.Events += _updateListener.Update;

            EventType result = joinView.EventType;

            Assert.AreEqual(typeof(double?), result.GetPropertyType("s0.DoubleBoxed"));
            Assert.AreEqual(typeof(double?), result.GetPropertyType("div"));
            Assert.AreEqual(2, joinView.EventType.PropertyNames.Length);

            Assert.IsNull(_updateListener.LastNewData);

            SendEvent("s0", 1, 4, 5);
            SendEvent("s1", 1, 3, 2);

            EventBean[] newEvents = _updateListener.LastNewData;
            Assert.AreEqual(1d, newEvents[0].Get("s0.DoubleBoxed"));
            Assert.AreEqual(3d, newEvents[0].Get("div"));

            IEnumerator <EventBean> iterator = joinView.GetEnumerator();
            EventBean theEvent = iterator.Advance();

            Assert.AreEqual(1d, theEvent.Get("s0.DoubleBoxed"));
            Assert.AreEqual(3d, theEvent.Get("div"));
        }
Example #15
0
			public void Run(RegressionEnvironment env)
			{
				env.CompileDeploy(
						"@JsonSchema(Dynamic=true) @public @buseventtype create json schema JsonEvent();\n" +
						"@Name('s0') select a_string? as c0, exists(a_string?) as c1," +
						"a_number? as c2, exists(a_number?) as c3," +
						"a_boolean? as c4, exists(a_boolean?) as c5," +
						"a_null? as c6, exists(a_null?) as c7," +
						"a_object? as c8, exists(a_object?) as c9, " +
						"a_array? as c10, exists(a_array?) as c11 " +
						" from JsonEvent#keepall")
					.AddListener("s0");
				foreach (EventPropertyDescriptor prop in env.Statement("s0").EventType.PropertyDescriptors) {
					Assert.AreEqual("c1,c3,c5,c7,c9,c11".Contains(prop.PropertyName) ? typeof(bool?) : typeof(object), prop.PropertyType);
				}

				string json = "{\n" +
				              "  \"a_string\": \"abc\",\n" +
				              "  \"a_number\": 1,\n" +
				              "  \"a_boolean\": true,\n" +
				              "  \"a_null\": null,\n" +
				              "  \"a_object\": {\n" +
				              "    \"value\": \"def\"\n" +
				              "  },\n" +
				              "  \"a_array\": [\n" +
				              "    \"a\",\n" +
				              "    \"b\"\n" +
				              "  ]\n" +
				              "}";
				env.SendEventJson(json, "JsonEvent");
				AssertFilled(env.Listener("s0").AssertOneGetNewAndReset());

				env.SendEventJson("{}", "JsonEvent");
				AssertUnfilled(env.Listener("s0").AssertOneGetNewAndReset());

				env.SendEventJson("{\"a_boolean\": false}", "JsonEvent");
				AssertSomeFilled(env.Listener("s0").AssertOneGetNewAndReset());

				env.Milestone(0);

				IEnumerator<EventBean> it = env.Statement("s0").GetEnumerator();
				AssertFilled(it.Advance());
				AssertUnfilled(it.Advance());
				AssertSomeFilled(it.Advance());

				env.UndeployAll();
			}
Example #16
0
            public void Run(RegressionEnvironment env)
            {
                string epl = "@public @buseventtype create json schema JsonEvent(local " +
                             typeof(MyLocalEventCollectionEnumType).FullName +
                             ");\n" +
                             "@Name('s0') select * from JsonEvent#keepall;\n";

                env.CompileDeploy(epl).AddListener("s0");

                string jsonFilled = "{ \"local\" : { \"c0\": [\"ENUM_VALUE_1\", \"ENUM_VALUE_2\"] } }\n";

                env.SendEventJson(jsonFilled, "JsonEvent");
                AssertFilled(env, env.Listener("s0").AssertOneGetNewAndReset(), jsonFilled);

                string jsonUnfilled = "{ \"local\" : {}}";

                env.SendEventJson(jsonUnfilled, "JsonEvent");
                AssertUnfilled(env, env.Listener("s0").AssertOneGetNewAndReset());

                string jsonEmpty = "{ \"local\" : { \"c0\": []}}\n";

                env.SendEventJson(jsonEmpty, "JsonEvent");
                AssertEmpty(env, env.Listener("s0").AssertOneGetNewAndReset(), jsonEmpty);

                string jsonNull = "{ \"local\" : { \"c0\": null}}\n";

                env.SendEventJson(jsonNull, "JsonEvent");
                AssertUnfilled(env, env.Listener("s0").AssertOneGetNewAndReset());

                string jsonPartiallyFilled = "{ \"local\" : { \"c0\": [\"ENUM_VALUE_3\", null] }}\n";

                env.SendEventJson(jsonPartiallyFilled, "JsonEvent");
                AssertPartiallyFilled(env, env.Listener("s0").AssertOneGetNewAndReset(), jsonPartiallyFilled);

                env.Milestone(0);

                IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator();

                AssertFilled(env, it.Advance(), jsonFilled);
                AssertUnfilled(env, it.Advance());
                AssertEmpty(env, it.Advance(), jsonEmpty);
                AssertUnfilled(env, it.Advance());
                AssertPartiallyFilled(env, it.Advance(), jsonPartiallyFilled);

                env.UndeployAll();
            }
Example #17
0
			public void Run(RegressionEnvironment env)
			{
				string epl = "@public @buseventtype create json schema JsonEvent (c0 BigInteger, c1 BigDecimal," +
				             "c2 BigInteger[], c3 BigDecimal[], c4 BigInteger[][], c5 BigDecimal[][]);\n" +
				             "@Name('s0') select * from JsonEvent#keepall;\n";
				env.CompileDeploy(epl).AddListener("s0");
				object[][] namesAndTypes = new object[][] {
					new object[] {"c0", typeof(BigInteger?)},
					new object[] {"c1", typeof(decimal?)},
					new object[] {"c2", typeof(BigInteger?[])},
					new object[] {"c3", typeof(decimal?[])},
					new object[] {"c4", typeof(BigInteger?[][])},
					new object[] {"c5", typeof(decimal?[][])}
				};
				SupportEventTypeAssertionUtil.AssertEventTypeProperties(
					namesAndTypes,
					env.Statement("s0").EventType,
					SupportEventTypeAssertionEnum.NAME,
					SupportEventTypeAssertionEnum.TYPE);

				string json = "{\"c0\": 123456789123456789123456789, \"c1\": 123456789123456789123456789.1," +
				              "\"c2\": [123456789123456789123456789], \"c3\": [123456789123456789123456789.1]," +
				              "\"c4\": [[123456789123456789123456789]], \"c5\": [[123456789123456789123456789.1]]" +
				              "}";
				env.SendEventJson(json, "JsonEvent");
				AssertFilled(env.Listener("s0").AssertOneGetNewAndReset());

				json = "{}";
				env.SendEventJson(json, "JsonEvent");
				AssertUnfilled(env.Listener("s0").AssertOneGetNewAndReset());

				json = "{\"c0\": null, \"c1\": null, \"c2\": null, \"c3\": null, \"c4\": null, \"c5\": null}";
				env.SendEventJson(json, "JsonEvent");
				AssertUnfilled(env.Listener("s0").AssertOneGetNewAndReset());

				env.Milestone(0);

				IEnumerator<EventBean> it = env.Statement("s0").GetEnumerator();
				AssertFilled(it.Advance());
				AssertUnfilled(it.Advance());
				AssertUnfilled(it.Advance());

				env.UndeployAll();
			}
Example #18
0
			public void Run(RegressionEnvironment env)
			{
				string epl = "@public @buseventtype create json schema JsonEvent (c0 SupportEnum, c1 SupportEnum[], c2 SupportEnum[][]);\n" +
				             "@Name('s0') select * from JsonEvent#keepall;\n";
				env.CompileDeploy(epl).AddListener("s0");
				object[][] namesAndTypes = new object[][] {
					new object[] {"c0", typeof(SupportEnum)},
					new object[] {"c1", typeof(SupportEnum[])},
					new object[] {"c2", typeof(SupportEnum[][])}
				};
				SupportEventTypeAssertionUtil.AssertEventTypeProperties(
					namesAndTypes,
					env.Statement("s0").EventType,
					SupportEventTypeAssertionEnum.NAME,
					SupportEventTypeAssertionEnum.TYPE);

				string json =
					"{\"c0\": \"ENUM_VALUE_2\", \"c1\": [\"ENUM_VALUE_2\", \"ENUM_VALUE_1\"], \"c2\": [[\"ENUM_VALUE_2\"], [\"ENUM_VALUE_1\", \"ENUM_VALUE_3\"]]}";
				env.SendEventJson(json, "JsonEvent");
				AssertFilled(env.Listener("s0").AssertOneGetNewAndReset());

				json = "{}";
				env.SendEventJson(json, "JsonEvent");
				AssertUnfilled(env.Listener("s0").AssertOneGetNewAndReset());

				json = "{\"c0\": null, \"c1\": null, \"c2\": null}";
				env.SendEventJson(json, "JsonEvent");
				AssertUnfilled(env.Listener("s0").AssertOneGetNewAndReset());

				json = "{\"c1\": [], \"c2\": [[]]}";
				env.SendEventJson(json, "JsonEvent");
				AssertEmptyArray(env.Listener("s0").AssertOneGetNewAndReset());

				env.Milestone(0);

				IEnumerator<EventBean> it = env.Statement("s0").GetEnumerator();
				AssertFilled(it.Advance());
				AssertUnfilled(it.Advance());
				AssertUnfilled(it.Advance());
				AssertEmptyArray(it.Advance());

				env.UndeployAll();
			}
Example #19
0
        private static void RunAssertionSimple(RegressionEnvironment env)
        {
            string json = "{ \"fruit\": \"Apple\", \"size\": \"Large\", \"color\": \"Red\"}";

            env.SendEventJson(json, "SimpleJson");
            AssertFruitApple(env.Listener("s0").AssertOneGetNewAndReset());

            EventSender eventSender = env.Runtime.EventService.GetEventSender("SimpleJson");

            json = "{ \"fruit\": \"Peach\", \"size\": \"Small\", \"color\": \"Yellow\"}";
            eventSender.SendEvent(json);
            AssertFruitPeach(env.Listener("s0").AssertOneGetNewAndReset());

            env.Milestone(0);

            IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator();

            AssertFruitApple(it.Advance());
            AssertFruitPeach(it.Advance());
        }
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@JsonSchema(Dynamic=true) @public @buseventtype create json schema JsonEvent();\n" +
                    "@Name('s0') select * from JsonEvent#keepall")
                .AddListener("s0");

                string jsonOne = "{\n" +
                                 "  \"a_string\": \"abc\",\n" +
                                 "  \"a_number\": 1,\n" +
                                 "  \"a_boolean\": true,\n" +
                                 "  \"a_null\": null,\n" +
                                 "  \"a_object\": {\n" +
                                 "    \"value\": \"def\"\n" +
                                 "  },\n" +
                                 "  \"a_array\": [\n" +
                                 "    \"a\",\n" +
                                 "    \"b\"\n" +
                                 "  ]\n" +
                                 "}";

                SendAssert(env, jsonOne);

                string jsonTwo = "{}";

                SendAssert(env, jsonTwo);

                string jsonThree = "{\"a_boolean\": false}";

                SendAssert(env, jsonThree);

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    AssertJsonWrite(jsonOne, it.Advance());
                    AssertJsonWrite(jsonTwo, it.Advance());
                    AssertJsonWrite(jsonThree, it.Advance());
                }

                env.UndeployAll();
            }
Example #21
0
        private void CheckNew(double correlationE)
        {
            IEnumerator <EventBean> iterator = _myView.GetEnumerator();

            CheckValues(iterator.Advance(), correlationE);
            Assert.IsTrue(iterator.MoveNext() == false);

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

            CheckValues(childViewValues, correlationE);
        }
        private void CheckNew(long countE, double sumE, double avgE, double stdevpaE, double stdevE, double varianceE)
        {
            IEnumerator <EventBean> iterator = _myView.GetEnumerator();

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

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

            CheckValues(childViewValues, countE, sumE, avgE, stdevpaE, stdevE, varianceE);
        }
        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"));
        }
        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();
        }
            public void Run(RegressionEnvironment env)
            {
                string epl = "@public @buseventtype create json schema JsonEvent (" +
                             "c0 BigInteger, " +
                             "c1 decimal," +
                             "c2 BigInteger[], " +
                             "c3 decimal[], " +
                             "c4 BigInteger[][], " +
                             "c5 decimal[][]);\n" +
                             "@Name('s0') select * from JsonEvent#keepall;\n";

                env.CompileDeploy(epl).AddListener("s0");

                string jsonOne = "{" +
                                 "\"c0\": 123456789123456789123456789, " +
                                 "\"c1\": 123456789123456789123456789.1," +
                                 "\"c2\": [123456789123456789123456789], " +
                                 "\"c3\": [123456789123456789123456789.1]," +
                                 "\"c4\": [[123456789123456789123456789]], " +
                                 "\"c5\": [[123456789123456789123456789.1]]" +
                                 "}";

                AssertJsonWrite(jsonOne, SendGet(env, jsonOne));

                string jsonTwo = "{\"c0\": null, \"c1\": null, \"c2\": null, \"c3\": null, \"c4\": null, \"c5\": null}";

                AssertJsonWrite(jsonTwo, SendGet(env, jsonTwo));

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    AssertJsonWrite(jsonOne, it.Advance());
                    AssertJsonWrite(jsonTwo, it.Advance());
                }

                env.UndeployAll();
            }
Example #26
0
			public void Run(RegressionEnvironment env)
			{
				env.CompileDeploy(
						"@JsonSchema(Dynamic=true) @public @buseventtype create json schema JsonEvent();\n" +
						"@Name('s0') select num1? as c0, num2? as c1, num3? as c2 from JsonEvent#keepall")
					.AddListener("s0");

				string json = "{ \"num1\": 42, \"num2\": 42.0, \"num3\": 4.2E+1}";
				env.SendEventJson(json, "JsonEvent");
				AssertFill(env.Listener("s0").AssertOneGetNewAndReset());

				env.Milestone(0);

				IEnumerator<EventBean> it = env.Statement("s0").GetEnumerator();
				AssertFill(it.Advance());

				env.UndeployAll();
			}
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@JsonSchema(Dynamic=true) @public @buseventtype create json schema JsonEvent();\n" +
                    "@Name('s0') select * from JsonEvent#keepall")
                .AddListener("s0");

                string json = "{ \"num1\": 42, \"num2\": 42.0, \"num3\": 43.0}";

                SendAssert(env, json);

                env.Milestone(0);

                using (IEnumerator <EventBean> it = env.Statement("s0").GetEnumerator()) {
                    AssertJsonWrite(json, it.Advance());
                }

                env.UndeployAll();
            }
Example #28
0
        public override void ToPrecedenceFreeEPL(
            TextWriter writer,
            ExprNodeRenderableFlags flags)
        {
            IList<ExprNode> children = ChildNodes;
            using (IEnumerator<ExprNode> enumerator = children.GetEnumerator()) {
                if (IsLowEndpointIncluded && IsHighEndpointIncluded) {
                    enumerator.Advance().ToEPL(writer, Precedence, flags);
                    if (IsNotBetween) {
                        writer.Write(" not between ");
                    }
                    else {
                        writer.Write(" between ");
                    }

                    enumerator.Advance().ToEPL(writer, Precedence, flags);
                    writer.Write(" and ");
                    enumerator.Advance().ToEPL(writer, Precedence, flags);
                }
                else {
                    enumerator.Advance().ToEPL(writer, Precedence, flags);
                    writer.Write(" in ");
                    if (IsLowEndpointIncluded) {
                        writer.Write('[');
                    }
                    else {
                        writer.Write('(');
                    }

                    enumerator.Advance().ToEPL(writer, Precedence, flags);
                    writer.Write(':');
                    enumerator.Advance().ToEPL(writer, Precedence, flags);
                    if (IsHighEndpointIncluded) {
                        writer.Write(']');
                    }
                    else {
                        writer.Write(')');
                    }
                }
            }
        }
Example #29
0
			public void Run(RegressionEnvironment env)
			{
				string epl = "@public @buseventtype create json schema JsonEvent (" +
				             "c0 string, c1 char, c2 character, c3 bool, c4 boolean, " +
				             "c5 byte, c6 short, c7 int, c8 integer, c9 long, c10 double, c11 float, c12 null);\n" +
				             "@Name('s0') select * from JsonEvent#keepall;\n";
				env.CompileDeploy(epl).AddListener("s0");
				object[][] namesAndTypes = new object[][] {
					new object[] {"c0", typeof(string)},
					new object[] {"c1", typeof(char?)},
					new object[] {"c2", typeof(char?)},
					new object[] {"c3", typeof(bool?)},
					new object[] {"c4", typeof(bool?)},
					new object[] {"c5", typeof(byte?)},
					new object[] {"c6", typeof(short?)},
					new object[] {"c7", typeof(int?)},
					new object[] {"c8", typeof(int?)},
					new object[] {"c9", typeof(long?)},
					new object[] {"c10", typeof(double?)},
					new object[] {"c11", typeof(float?)},
					new object[] {"c12", null},
				};
				SupportEventTypeAssertionUtil.AssertEventTypeProperties(
					namesAndTypes,
					env.Statement("s0").EventType,
					SupportEventTypeAssertionEnum.NAME,
					SupportEventTypeAssertionEnum.TYPE);

				string json = "{\n" +
				              "  \"c0\": \"abc\",\n" +
				              "  \"c1\": \"xy\",\n" +
				              "  \"c2\": \"z\",\n" +
				              "  \"c3\": true,\n" +
				              "  \"c4\": false,\n" +
				              "  \"c5\": 1,\n" +
				              "  \"c6\": 10,\n" +
				              "  \"c7\": 11,\n" +
				              "  \"c8\": 12,\n" +
				              "  \"c9\": 13,\n" +
				              "  \"c10\": 14,\n" +
				              "  \"c11\": 15E2,\n" +
				              "  \"c12\": null\n" +
				              "}";
				env.SendEventJson(json, "JsonEvent");
				AssertEventFilled(env.Listener("s0").AssertOneGetNewAndReset());

				env.SendEventJson("{}", "JsonEvent");
				AssertEventNull(env.Listener("s0").AssertOneGetNewAndReset());

				json = "{\n" +
				       "  \"c0\": null,\n" +
				       "  \"c1\": null,\n" +
				       "  \"c2\": null,\n" +
				       "  \"c3\": null,\n" +
				       "  \"c4\": null,\n" +
				       "  \"c5\": null,\n" +
				       "  \"c6\": null,\n" +
				       "  \"c7\": null,\n" +
				       "  \"c8\": null,\n" +
				       "  \"c9\": null,\n" +
				       "  \"c10\": null,\n" +
				       "  \"c11\": null,\n" +
				       "  \"c12\": null\n" +
				       "}";
				env.SendEventJson(json, "JsonEvent");
				AssertEventNull(env.Listener("s0").AssertOneGetNewAndReset());

				env.Milestone(0);

				IEnumerator<EventBean> it = env.Statement("s0").GetEnumerator();
				AssertEventFilled(it.Advance());
				AssertEventNull(it.Advance());
				AssertEventNull(it.Advance());

				env.UndeployAll();
			}
Example #30
0
			public void Run(RegressionEnvironment env)
			{
				string epl = "@public @buseventtype create json schema JsonEvent (c0 Object[]);\n" +
				             "@Name('s0') select * from JsonEvent#keepall;\n";
				env.CompileDeploy(epl).AddListener("s0");
				object[][] namesAndTypes = new object[][] {
					new object[] {"c0", typeof(object[])}
				};
				SupportEventTypeAssertionUtil.AssertEventTypeProperties(
					namesAndTypes,
					env.Statement("s0").EventType,
					SupportEventTypeAssertionEnum.NAME,
					SupportEventTypeAssertionEnum.TYPE);

				SendAssertColumn(env, "{}", null);
				SendAssertColumn(env, "{\"c0\": []}", new object[0]);
				SendAssertColumn(env, "{\"c0\": [1.0]}", new object[] {1.0d});
				SendAssertColumn(env, "{\"c0\": [null]}", new object[] {null});
				SendAssertColumn(env, "{\"c0\": [true]}", new object[] {true});
				SendAssertColumn(env, "{\"c0\": [false]}", new object[] {false});
				SendAssertColumn(env, "{\"c0\": [\"abc\"]}", new object[] {"abc"});
				SendAssertColumn(env, "{\"c0\": [[\"abc\"]]}", new object[][] {new object[] {"abc"}});
				SendAssertColumn(env, "{\"c0\": [[]]}", new object[] {new object[0]});
				SendAssertColumn(env, "{\"c0\": [[\"abc\", 2]]}", new object[][] {new object[] {"abc", 2}});
				SendAssertColumn(env, "{\"c0\": [[[\"abc\"], [5.0]]]}", new object[][][] {new object[][] {new object[] {"abc"}, new object[] {5d}}});
				SendAssertColumn(env, "{\"c0\": [{\"c1\": 10}]}", new object[] {Collections.SingletonMap("c1", 10)});
				SendAssertColumn(env, "{\"c0\": [{\"c1\": 10, \"c2\": \"abc\"}]}", new object[] {CollectionUtil.BuildMap("c1", 10, "c2", "abc")});

				env.Milestone(0);

				IEnumerator<EventBean> it = env.Statement("s0").GetEnumerator();
				AssertColumn(it.Advance(), null);
				AssertColumn(it.Advance(), new object[0]);
				AssertColumn(it.Advance(), new object[] {1.0d});
				AssertColumn(it.Advance(), new object[] {null});
				AssertColumn(it.Advance(), new object[] {true});
				AssertColumn(it.Advance(), new object[] {false});
				AssertColumn(it.Advance(), new object[] {"abc"});
				AssertColumn(it.Advance(), new object[][] {new object[] {"abc"}});
				AssertColumn(it.Advance(), new object[] {new object[0]});
				AssertColumn(it.Advance(), new object[][] {new object[] {"abc", 2}});
				AssertColumn(it.Advance(), new object[][][] {new object[][] {new object[] {"abc"}, new object[] {5d}}});
				AssertColumn(it.Advance(), new object[] {Collections.SingletonMap("c1", 10)});
				AssertColumn(it.Advance(), new object[] {CollectionUtil.BuildMap("c1", 10, "c2", "abc")});

				env.UndeployAll();
			}