コード例 #1
0
            public void Run(RegressionEnvironment env)
            {
                string epl = "@public @buseventtype create json schema JsonEvent(local " +
                             typeof(MyLocalEventCollectionBuiltinType).FullName +
                             ");\n" +
                             "@Name('s0') select * from JsonEvent#keepall;\n";

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

                string jsonFilled = "{ \"local\" : { " +
                                    "\"c0\": [\"abc\", \"def\"],\n" +
                                    "\"c1\": [\"x\", \"y\"],\n" +
                                    "\"c2\": [true, false],\n" +
                                    "\"c3\": [10, 11],\n" +
                                    "\"c4\": [20, 21],\n" +
                                    "\"c5\": [30, 31],\n" +
                                    "\"c6\": [40, 41],\n" +
                                    "\"c7\": [50.0, 51.0],\n" +
                                    "\"c8\": [60.0, 61.0],\n" +
                                    "\"c9\": [70, 71],\n" +
                                    "\"c10\": [80, 81]\n" +
                                    "}}\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" +
                                   "\"c1\": [],\n" +
                                   "\"c2\": [],\n" +
                                   "\"c3\": [],\n" +
                                   "\"c4\": [],\n" +
                                   "\"c5\": [],\n" +
                                   "\"c6\": [],\n" +
                                   "\"c7\": [],\n" +
                                   "\"c8\": [],\n" +
                                   "\"c9\": [],\n" +
                                   "\"c10\": []\n" +
                                   "}}\n";

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

                string jsonNull = "{ \"local\" : { " +
                                  "\"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" +
                                  "}}\n";

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

                string jsonPartiallyFilled = "{ \"local\" : { " +
                                             "\"c0\": [\"abc\", null],\n" +
                                             "\"c1\": [\"x\", null],\n" +
                                             "\"c2\": [true, null],\n" +
                                             "\"c3\": [10, null],\n" +
                                             "\"c4\": [20, null],\n" +
                                             "\"c5\": [30, null],\n" +
                                             "\"c6\": [40, null],\n" +
                                             "\"c7\": [50.0, null],\n" +
                                             "\"c8\": [60.0, null],\n" +
                                             "\"c9\": [70, null],\n" +
                                             "\"c10\": [80, null]\n" +
                                             "}}\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();
            }
コード例 #2
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("@Name('v0') create variable Object varobject = null", path);
                env.CompileDeploy(
                    "@Name('v1') create variable " + typeof(SupportBean_A).FullName + " varbean = null",
                    path);
                env.CompileDeploy("@Name('v2') create variable SupportBean_S0 vartype = null", path);
                var depIdVarobject = env.DeploymentId("v0");
                var depIdVarbean = env.DeploymentId("v1");
                var depIdVartype = env.DeploymentId("v2");

                var fields = new [] { "varobject","varbean","varbean.Id","vartype","vartype.Id" };
                env.CompileDeploy(
                    "@Name('s0') select varobject, varbean, varbean.Id, vartype, vartype.Id from SupportBean",
                    path);
                env.AddListener("s0");

                // test null
                env.SendEventBean(new SupportBean());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {null, null, null, null, null});

                env.Milestone(0);

                // test objects
                var a1objectOne = new SupportBean_A("A1");
                var s0objectOne = new SupportBean_S0(1);
                env.Runtime.VariableService.SetVariableValue(depIdVarobject, "varobject", "abc");
                env.Runtime.VariableService.SetVariableValue(depIdVarbean, "varbean", a1objectOne);
                env.Runtime.VariableService.SetVariableValue(depIdVartype, "vartype", s0objectOne);

                env.Milestone(1);

                env.SendEventBean(new SupportBean());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"abc", a1objectOne, a1objectOne.Id, s0objectOne, s0objectOne.Id});

                // test on-set for Object and EventType
                var fieldsTop = new [] { "varobject","vartype","varbean" };
                env.CompileDeploy(
                    "@Name('set') on SupportBean_S0(P00='X') arrival set varobject=1, vartype=arrival, varbean=null",
                    path);
                env.AddListener("set");

                var s0objectTwo = new SupportBean_S0(2, "X");
                env.SendEventBean(s0objectTwo);
                Assert.AreEqual(1, env.Runtime.VariableService.GetVariableValue(depIdVarobject, "varobject"));
                Assert.AreEqual(s0objectTwo, env.Runtime.VariableService.GetVariableValue(depIdVartype, "vartype"));
                Assert.AreEqual(
                    s0objectTwo,
                    env.Runtime
                        .VariableService.GetVariableValue(
                            Collections.SingletonSet(new DeploymentIdNamePair(depIdVartype, "vartype")))
                        .Get(new DeploymentIdNamePair(depIdVartype, "vartype")));
                EPAssertionUtil.AssertProps(
                    env.Listener("set").AssertOneGetNewAndReset(),
                    fieldsTop,
                    new object[] {1, s0objectTwo, null});
                EPAssertionUtil.AssertProps(
                    env.GetEnumerator("set").Advance(),
                    fieldsTop,
                    new object[] {1, s0objectTwo, null});

                // set via API to null
                IDictionary<DeploymentIdNamePair, object> newValues = new Dictionary<DeploymentIdNamePair, object>();
                newValues.Put(new DeploymentIdNamePair(depIdVarobject, "varobject"), null);
                newValues.Put(new DeploymentIdNamePair(depIdVartype, "vartype"), null);
                newValues.Put(new DeploymentIdNamePair(depIdVarbean, "varbean"), null);
                env.Runtime.VariableService.SetVariableValue(newValues);
                env.SendEventBean(new SupportBean());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {null, null, null, null, null});

                // set via API to values
                newValues.Put(new DeploymentIdNamePair(depIdVarobject, "varobject"), 10L);
                newValues.Put(new DeploymentIdNamePair(depIdVartype, "vartype"), s0objectTwo);
                newValues.Put(new DeploymentIdNamePair(depIdVarbean, "varbean"), a1objectOne);
                env.Runtime.VariableService.SetVariableValue(newValues);
                env.SendEventBean(new SupportBean());
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {10L, a1objectOne, a1objectOne.Id, s0objectTwo, s0objectTwo.Id});

                // test on-set for Bean class
                env.CompileDeploy(
                    "@Name('set-two') on SupportBean_A(Id='Y') arrival set varobject=null, vartype=null, varbean=arrival",
                    path);
                env.AddListener("set-two");
                var a1objectTwo = new SupportBean_A("Y");
                env.SendEventBean(new SupportBean_A("Y"));
                Assert.AreEqual(null, env.Runtime.VariableService.GetVariableValue(depIdVarobject, "varobject"));
                Assert.AreEqual(null, env.Runtime.VariableService.GetVariableValue(depIdVartype, "vartype"));
                Assert.AreEqual(
                    a1objectTwo,
                    env.Runtime
                        .VariableService.GetVariableValue(
                            Collections.SingletonSet(new DeploymentIdNamePair(depIdVarbean, "varbean")))
                        .Get(new DeploymentIdNamePair(depIdVarbean, "varbean")));
                EPAssertionUtil.AssertProps(
                    env.Listener("set-two").AssertOneGetNewAndReset(),
                    fieldsTop,
                    new object[] {null, null, a1objectTwo});
                EPAssertionUtil.AssertProps(
                    env.GetEnumerator("set-two").Advance(),
                    fieldsTop,
                    new object[] {null, null, a1objectTwo});

                env.UndeployAll();
            }
コード例 #3
0
            public void Run(RegressionEnvironment env)
            {
                var compat = typeof(CompatExtensions).FullName;

                // Test of the various coercion user cases.
                var epl = "@Name('s0') select case IntPrimitive" +
                          $" when 1 then {compat}.RenderAny(BoolPrimitive) " +
                          $" when 2 then {compat}.RenderAny(BoolBoxed) " +
                          $" when 3 then {compat}.RenderAny(IntPrimitive) " +
                          $" when 4 then {compat}.RenderAny(IntBoxed)" +
                          $" when 5 then {compat}.RenderAny(LongPrimitive) " +
                          $" when 6 then {compat}.RenderAny(LongBoxed) " +
                          $" when 7 then {compat}.RenderAny(CharPrimitive) " +
                          $" when 8 then {compat}.RenderAny(CharBoxed) " +
                          $" when 9 then {compat}.RenderAny(ShortPrimitive) " +
                          $" when 10 then {compat}.RenderAny(ShortBoxed) " +
                          $" when 11 then {compat}.RenderAny(BytePrimitive) " +
                          $" when 12 then {compat}.RenderAny(ByteBoxed) " +
                          $" when 13 then {compat}.RenderAny(FloatPrimitive) " +
                          $" when 14 then {compat}.RenderAny(FloatBoxed) " +
                          $" when 15 then {compat}.RenderAny(DoublePrimitive) " +
                          $" when 16 then {compat}.RenderAny(DoubleBoxed) " +
                          $" when 17 then TheString " +
                          " else 'x' end as p1 " +
                          " from SupportBean#length(1)";

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

                Assert.AreEqual(typeof(string), env.Statement("s0").EventType.GetPropertyType("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    1,
                    0,
                    0L,
                    0L,
                    '0',
                    'a',
                    0,
                    0,
                    0,
                    0,
                    0.0f,
                    0.0f,
                    0.0,
                    0.0,
                    null,
                    SupportEnum.ENUM_VALUE_1);
                var theEvent = env.Listener("s0").GetAndResetLastNewData()[0];

                Assert.AreEqual("true", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    2,
                    0,
                    0L,
                    0L,
                    '0',
                    'a',
                    0,
                    0,
                    0,
                    0,
                    0.0f,
                    0.0f,
                    0.0d,
                    0.0d,
                    null,
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("false", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    3,
                    0,
                    0L,
                    0L,
                    '0',
                    'a',
                    0,
                    0,
                    0,
                    0,
                    0.0f,
                    0,
                    0.0,
                    0.0,
                    null,
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("3", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    4,
                    4,
                    0L,
                    0L,
                    '0',
                    'a',
                    0,
                    0,
                    0,
                    0,
                    0.0f,
                    0,
                    0.0,
                    0.0,
                    null,
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("4", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    5,
                    0,
                    5L,
                    0L,
                    '0',
                    'a',
                    0,
                    0,
                    0,
                    0,
                    0.0f,
                    0,
                    0.0,
                    0.0,
                    null,
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("5L", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    6,
                    0,
                    0L,
                    6L,
                    '0',
                    'a',
                    0,
                    0,
                    0,
                    0,
                    0.0f,
                    0,
                    0.0,
                    0.0,
                    null,
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("6L", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    7,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    0,
                    0,
                    0,
                    0,
                    0.0f,
                    0,
                    0.0,
                    0.0,
                    null,
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("'A'", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    8,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    0,
                    0,
                    0,
                    0,
                    0.0f,
                    0,
                    0.0,
                    0.0,
                    null,
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("'a'", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    9,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    0,
                    0,
                    0,
                    0.0f,
                    0,
                    0.0,
                    0.0,
                    null,
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("9", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    10,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    10,
                    11,
                    12,
                    13.0f,
                    14,
                    15.0,
                    16.0,
                    "testCoercion",
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("10", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    11,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    10,
                    11,
                    12,
                    13.0f,
                    14,
                    15.0,
                    16.0,
                    "testCoercion",
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("11", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    12,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    10,
                    11,
                    12,
                    13.0f,
                    14,
                    15.0,
                    16.0,
                    "testCoercion",
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("12", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    13,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    10,
                    11,
                    12,
                    13.0f,
                    14,
                    15.0,
                    16.0,
                    "testCoercion",
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("13.0f", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    14,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    10,
                    11,
                    12,
                    13.0f,
                    14,
                    15.0,
                    16.0,
                    "testCoercion",
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("14.0f", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    15,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    10,
                    11,
                    12,
                    13.0f,
                    14,
                    15.0,
                    16.0,
                    "testCoercion",
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("15.0d", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    16,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    10,
                    11,
                    12,
                    13.0f,
                    14,
                    15.0,
                    16.0,
                    "testCoercion",
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("16.0d", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    17,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    10,
                    11,
                    12,
                    13.0f,
                    14,
                    15.0,
                    16.0,
                    "testCoercion",
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("testCoercion", theEvent.Get("p1"));

                SendSupportBeanEvent(
                    env,
                    true,
                    false,
                    -1,
                    0,
                    0L,
                    0L,
                    'A',
                    'a',
                    9,
                    10,
                    11,
                    12,
                    13.0f,
                    14,
                    15.0,
                    16.0,
                    "testCoercion",
                    SupportEnum.ENUM_VALUE_1);
                theEvent = env.Listener("s0").GetAndResetLastNewData()[0];
                Assert.AreEqual("x", theEvent.Get("p1"));

                env.UndeployAll();
            }
コード例 #4
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"c0", "c1"};
                var epl = "create window ABCWin.win:keepall() as SupportBean;\n" +
                          "insert into ABCWin select * from SupportBean;\n" +
                          "on SupportBean_A delete from ABCWin where TheString = Id;\n" +
                          "@Name('s0') select irstream TheString as c0, window(IntPrimitive) as c1 from ABCWin;\n";
                env.CompileDeploy(epl).AddListener("s0");

                env.Milestone(0);

                SendSupportBean(env, "E1", 10);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", new[] {10}});

                env.Milestone(1);

                SendSupportBean(env, "E2", 100);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2", new[] {10, 100}});

                env.Milestone(2);

                SendSupportBean_A(env, "E2"); // delete E2
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetOldAndReset(),
                    fields,
                    new object[] {"E2", new[] {10}});

                env.Milestone(3);

                SendSupportBean(env, "E3", 50);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E3", new[] {10, 50}});

                env.Milestone(4);

                env.Milestone(5); // no change

                SendSupportBean_A(env, "E1"); // delete E1
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetOldAndReset(),
                    fields,
                    new object[] {"E1", new[] {50}});

                env.Milestone(6);

                SendSupportBean(env, "E4", -1);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E4", new[] {50, -1}});

                env.UndeployAll();
            }
コード例 #5
0
 public void Run(RegressionEnvironment env)
 {
     TryDeployAndAssertionSB(env, "@Name('s0') select * from SupportBean(TheString = 'a' || 'x')", EQUAL);
     TryDeployAndAssertionSB(env, "@Name('s0') select * from SupportBean('a' || 'x' is TheString)", IS);
 }
コード例 #6
0
 private static void SendEvent(
     RegressionEnvironment env,
     long longBoxed)
 {
     SendEvent(env, longBoxed, 0, 0);
 }
コード例 #7
0
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"c0", "c1", "c2"};

                var epl = "@Name('s0') select irstream TheString as c0, sum(IntPrimitive) as c1," +
                          "window(*) as c2 from SupportBean.win:length(2)";
                env.CompileDeploy(epl).AddListener("s0");

                env.Milestone(0);

                object e1 = SendSupportBean(env, "E1", 10);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "E1", 10,
                        new[] {e1}
                    });

                env.Milestone(1);

                object e2 = SendSupportBean(env, "E2", 100);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {
                        "E2", 10 + 100,
                        new[] {e1, e2}
                    });

                env.Milestone(2);

                object e3 = SendSupportBean(env, "E3", 11);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {
                        "E3", 100 + 11,
                        new[] {e2, e3}
                    },
                    new object[] {
                        "E1", 100 + 11,
                        new[] {e2, e3}
                    });

                env.Milestone(3);

                env.Milestone(4);

                object e4 = SendSupportBean(env, "E4", 9);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {
                        "E4", 11 + 9,
                        new[] {e3, e4}
                    },
                    new object[] {
                        "E2", 11 + 9,
                        new[] {e3, e4}
                    });

                env.UndeployAll();
            }
コード例 #8
0
ファイル: ViewRank.cs プロジェクト: lanicon/nesper
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"TheString", "IntPrimitive", "LongPrimitive"};
                var epl =
                    "@Name('create') create window MyWindow#rank(TheString, 3, IntPrimitive asc) as SupportBean;\n" +
                    "insert into MyWindow select * from SupportBean;\n" +
                    "@Name('s0') select irstream * from MyWindow;\n" +
                    "on SupportBean_A delete from MyWindow mw where TheString = Id;\n";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(MakeEvent("E1", 10, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 10, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 10, 0L}});

                env.SendEventBean(MakeEvent("E2", 50, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2", 50, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 10, 0L}, new object[] {"E2", 50, 0L}});

                env.SendEventBean(MakeEvent("E3", 5, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E3", 5, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3", 5, 0L}, new object[] {"E1", 10, 0L}, new object[] {"E2", 50, 0L}});

                env.SendEventBean(MakeEvent("E4", 5, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E4", 5, 0L},
                    new object[] {"E2", 50, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3", 5, 0L}, new object[] {"E4", 5, 0L}, new object[] {"E1", 10, 0L}});

                env.SendEventBean(new SupportBean_A("E3"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetOldAndReset(),
                    fields,
                    new object[] {"E3", 5, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E4", 5, 0L}, new object[] {"E1", 10, 0L}});

                env.SendEventBean(new SupportBean_A("E4"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetOldAndReset(),
                    fields,
                    new object[] {"E4", 5, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 10, 0L}});

                env.SendEventBean(new SupportBean_A("E1"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetOldAndReset(),
                    fields,
                    new object[] {"E1", 10, 0L});
                EPAssertionUtil.AssertPropsPerRow(env.Statement("create").GetEnumerator(), fields, new object[0][]);

                env.SendEventBean(MakeEvent("E3", 100, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E3", 100, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3", 100, 0L}});

                env.SendEventBean(MakeEvent("E3", 101, 1L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E3", 101, 1L},
                    new object[] {"E3", 100, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("create").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3", 101, 1L}});

                env.SendEventBean(new SupportBean_A("E3"));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetOldAndReset(),
                    fields,
                    new object[] {"E3", 101, 1L});
                EPAssertionUtil.AssertPropsPerRow(env.Statement("create").GetEnumerator(), fields, new object[0][]);

                env.UndeployAll();
            }
コード例 #9
0
ファイル: ViewRank.cs プロジェクト: lanicon/nesper
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"TheString", "IntPrimitive", "LongPrimitive"};
                var epl = "@Name('s0') select irstream * from SupportBean.ext:rank(TheString, 3, IntPrimitive)";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                EPAssertionUtil.AssertPropsPerRow(env.GetEnumerator("s0"), fields, null);

                SendSupportBean(env, "A", 10, 100L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"A", 10, 100L});

                env.Milestone(1);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 10, 100L}});
                SendSupportBean(env, "B", 20, 101L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"B", 20, 101L});

                env.Milestone(2);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 10, 100L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "A", 8, 102L); // replace A
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"A", 8, 102L},
                    new object[] {"A", 10, 100L});

                env.Milestone(3);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 8, 102L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "C", 15, 103L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"C", 15, 103L});

                env.Milestone(4);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 8, 102L}, new object[] {"C", 15, 103L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "D", 21, 104L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"D", 21, 104L},
                    new object[] {"D", 21, 104L});

                env.Milestone(5);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 8, 102L}, new object[] {"C", 15, 103L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "A", 16, 105L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"A", 16, 105L},
                    new object[] {"A", 8, 102L});

                env.Milestone(6);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"C", 15, 103L}, new object[] {"A", 16, 105L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "C", 16, 106L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"C", 16, 106L},
                    new object[] {"C", 15, 103L});

                env.Milestone(7);

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 16, 105L}, new object[] {"C", 16, 106L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "C", 16, 107L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"C", 16, 107L},
                    new object[] {"C", 16, 106L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"A", 16, 105L}, new object[] {"C", 16, 107L}, new object[] {"B", 20, 101L}});
                SendSupportBean(env, "E", 1, 108L);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertGetAndResetIRPair(),
                    fields,
                    new object[] {"E", 1, 108L},
                    new object[] {"B", 20, 101L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("s0"),
                    fields,
                    new[] {new object[] {"E", 1, 108L}, new object[] {"A", 16, 105L}, new object[] {"C", 16, 107L}});

                env.UndeployAll();
            }
コード例 #10
0
ファイル: ViewRank.cs プロジェクト: lanicon/nesper
            public void Run(RegressionEnvironment env)
            {
                var epl =
                    "@Name('s0') select prevwindow(ev) as win, prev(0, ev) as prev0, prev(1, ev) as prev1, prev(2, ev) as prev2, prev(3, ev) as prev3, prev(4, ev) as prev4 " +
                    "from SupportBean#rank(TheString, 3, IntPrimitive) as ev";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(MakeEvent("E1", 100, 0L));
                AssertWindowAggAndPrev(
                    env,
                    new[] {new object[] {"E1", 100, 0L}});

                env.SendEventBean(MakeEvent("E2", 99, 0L));
                AssertWindowAggAndPrev(
                    env,
                    new[] {new object[] {"E2", 99, 0L}, new object[] {"E1", 100, 0L}});

                env.SendEventBean(MakeEvent("E1", 98, 1L));
                AssertWindowAggAndPrev(
                    env,
                    new[] {new object[] {"E1", 98, 1L}, new object[] {"E2", 99, 0L}});

                env.SendEventBean(MakeEvent("E3", 98, 0L));
                AssertWindowAggAndPrev(
                    env,
                    new[] {new object[] {"E1", 98, 1L}, new object[] {"E3", 98, 0L}, new object[] {"E2", 99, 0L}});

                env.SendEventBean(MakeEvent("E2", 97, 1L));
                AssertWindowAggAndPrev(
                    env,
                    new[] {new object[] {"E2", 97, 1L}, new object[] {"E1", 98, 1L}, new object[] {"E3", 98, 0L}});
                env.UndeployAll();

                epl =
                    "@Name('s0') select irstream * from SupportBean#groupwin(TheString)#rank(IntPrimitive, 2, DoublePrimitive) as ev";
                env.CompileDeployAddListenerMile(epl, "s0", 1);

                var fields = new[] {"TheString", "IntPrimitive", "LongPrimitive", "DoublePrimitive"};
                env.SendEventBean(MakeEvent("E1", 100, 0L, 1d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 100, 0L, 1d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 100, 0L, 1d}});

                env.SendEventBean(MakeEvent("E2", 100, 0L, 2d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2", 100, 0L, 2d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 100, 0L, 1d}, new object[] {"E2", 100, 0L, 2d}});

                env.SendEventBean(MakeEvent("E1", 200, 0L, 0.5d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 200, 0L, 0.5d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E1", 200, 0L, 0.5d}, new object[] {"E1", 100, 0L, 1d},
                        new object[] {"E2", 100, 0L, 2d}
                    });

                env.SendEventBean(MakeEvent("E2", 200, 0L, 2.5d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2", 200, 0L, 2.5d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E1", 200, 0L, 0.5d}, new object[] {"E1", 100, 0L, 1d},
                        new object[] {"E2", 100, 0L, 2d}, new object[] {"E2", 200, 0L, 2.5d}
                    });

                env.SendEventBean(MakeEvent("E1", 300, 0L, 0.1d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E1", 300, 0L, 0.1d},
                    new object[] {"E1", 100, 0L, 1d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E1", 300, 0L, 0.1d}, new object[] {"E1", 200, 0L, 0.5d},
                        new object[] {"E2", 100, 0L, 2d}, new object[] {"E2", 200, 0L, 2.5d}
                    });

                env.UndeployAll();
            }
コード例 #11
0
ファイル: ViewRank.cs プロジェクト: lanicon/nesper
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"TheString", "IntPrimitive", "LongPrimitive", "DoublePrimitive"};
                var epl =
                    "@Name('s0') select irstream * from SupportBean#rank(TheString, IntPrimitive, 3, LongPrimitive, DoublePrimitive)";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.SendEventBean(MakeEvent("E1", 100, 1L, 10d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 100, 1L, 10d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 100, 1L, 10d}});

                env.SendEventBean(MakeEvent("E1", 200, 1L, 9d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 200, 1L, 9d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 200, 1L, 9d}, new object[] {"E1", 100, 1L, 10d}});

                env.Milestone(1);

                env.SendEventBean(MakeEvent("E1", 150, 1L, 11d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 150, 1L, 11d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E1", 200, 1L, 9d}, new object[] {"E1", 100, 1L, 10d},
                        new object[] {"E1", 150, 1L, 11d}
                    });

                env.SendEventBean(MakeEvent("E1", 100, 1L, 8d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E1", 100, 1L, 8d},
                    new object[] {"E1", 100, 1L, 10d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E1", 100, 1L, 8d}, new object[] {"E1", 200, 1L, 9d},
                        new object[] {"E1", 150, 1L, 11d}
                    });

                env.Milestone(2);

                env.SendEventBean(MakeEvent("E2", 300, 2L, 7d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E2", 300, 2L, 7d},
                    new object[] {"E2", 300, 2L, 7d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E1", 100, 1L, 8d}, new object[] {"E1", 200, 1L, 9d},
                        new object[] {"E1", 150, 1L, 11d}
                    });

                env.SendEventBean(MakeEvent("E3", 300, 1L, 8.5d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E3", 300, 1L, 8.5d},
                    new object[] {"E1", 150, 1L, 11d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E1", 100, 1L, 8d}, new object[] {"E3", 300, 1L, 8.5d},
                        new object[] {"E1", 200, 1L, 9d}
                    });

                env.Milestone(3);

                env.SendEventBean(MakeEvent("E4", 400, 1L, 9d));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E4", 400, 1L, 9d},
                    new object[] {"E1", 200, 1L, 9d});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E1", 100, 1L, 8d}, new object[] {"E3", 300, 1L, 8.5d},
                        new object[] {"E4", 400, 1L, 9d}
                    });

                env.UndeployAll();
            }
コード例 #12
0
 public void Run(RegressionEnvironment env)
 {
     var sql = "select mydouble from mytesttable ${$ESPER-SAMPLE-WHERE} where ${IntPrimitive} = myint";
     RunAssertion(env, sql);
 }
コード例 #13
0
 public void Run(RegressionEnvironment env)
 {
     var sql =
         "select mydouble, sum(myint) from mytesttable where ${IntPrimitive} = myint group by mydouble";
     RunAssertion(env, sql);
 }
コード例 #14
0
            public void Run(RegressionEnvironment env)
            {
                EPStage        stage = env.StageService.GetStage("ST");
                RegressionPath path  = new RegressionPath();

                // Bean
                RunAssertion(
                    env,
                    path,
                    stage,
                    "SupportBean",
                    new SupportBean(),
                    svc => svc.SendEventBean(new SupportBean(), "SupportBean"));

                // Map
                RunAssertion(
                    env,
                    path,
                    stage,
                    MAP_TYPENAME,
                    new Dictionary <string, object>(),
                    svc => svc.SendEventMap(new Dictionary <string, object>(), MAP_TYPENAME));

                // Object-Array
                RunAssertion(
                    env,
                    path,
                    stage,
                    OA_TYPENAME,
                    new object[0],
                    svc => svc.SendEventObjectArray(new object[0], OA_TYPENAME));

                // XML
                var node = SupportXML.GetDocument("<myevent/>").DocumentElement;

                RunAssertion(
                    env,
                    path,
                    stage,
                    XML_TYPENAME,
                    node,
                    svc => svc.SendEventXMLDOM(node, XML_TYPENAME));

                // Avro
                var schema = AvroSchemaUtil.ResolveAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured(AVRO_TYPENAME));
                var record = new GenericRecord(schema.AsRecordSchema());

                RunAssertion(
                    env,
                    path,
                    stage,
                    AVRO_TYPENAME,
                    record,
                    svc => svc.SendEventAvro(record, AVRO_TYPENAME));

                // Json
                RunAssertion(
                    env,
                    path,
                    stage,
                    JSON_TYPENAME,
                    "{}",
                    svc => svc.SendEventJson("{}", JSON_TYPENAME));

                env.UndeployAll();
            }
コード例 #15
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create window MyWindow#keepall as SupportSpatialPoint", path);

                // invalid number of columns
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow(Px pointregionquadtree(0, 0, 100, 100))",
                    "Index of type 'pointregionquadtree' requires 2 expressions as index columns but received 1");

                // invalid column type
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Id, Py) pointregionquadtree(0, 0, 100, 100))",
                    "Index of type 'pointregionquadtree' for column 0 that is providing X-values expecting type System.Object but received type System.String");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Id) pointregionquadtree(0, 0, 100, 100))",
                    "Index of type 'pointregionquadtree' for column 1 that is providing Y-values expecting type System.Object but received type System.String");

                // invalid expressions for column or parameter
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((dummy, dummy2) pointregionquadtree(0, 0, 100, 100))",
                    "Failed to validate create-index index-column expression 'dummy': Property named 'dummy' is not valid in any stream");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree(dummy, 0, 100, 100))",
                    "Failed to validate create-index index-parameter expression 'dummy': Property named 'dummy' is not valid in any stream");

                // invalid property use in parameter
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree(Px, 0, 100, 100))",
                    "Index parameters may not refer to event properties");

                // invalid number of parameters
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree)",
                    "Index of type 'pointregionquadtree' requires at least 4 parameters but received 0");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree('a'))",
                    "Index of type 'pointregionquadtree' requires at least 4 parameters but received 1");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree(0, 0, 0, 0, 0, 0, 0))",
                    "Index of type 'pointregionquadtree' requires at least 4 parameters but received 7");

                // invalid parameter type
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree('a', 0, 100, 100))",
                    "Index of type 'pointregionquadtree' for parameter 0 that is providing XMin-values expecting type System.Object but received type System.String");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree(0, 'a', 100, 100))",
                    "Index of type 'pointregionquadtree' for parameter 1 that is providing YMin-values expecting type System.Object but received type System.String");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree(0, 0, 'a', 100))",
                    "Index of type 'pointregionquadtree' for parameter 2 that is providing Width-values expecting type System.Object but received type System.String");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree(0, 0, 100, 'a'))",
                    "Index of type 'pointregionquadtree' for parameter 3 that is providing Height-values expecting type System.Object but received type System.String");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree(0, 0, 100, 100, 'a'))",
                    "Index of type 'pointregionquadtree' for parameter 4 that is providing LeafCapacity-values expecting type System.Nullable<System.Int32> but received type System.String");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree(0, 0, 100, 100, 1, 'a'))",
                    "Index of type 'pointregionquadtree' for parameter 5 that is providing MaxTreeHeight-values expecting type System.Nullable<System.Int32> but received type System.String");

                // invalid parameter value
                SupportMessageAssertUtil.TryInvalidDeploy(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Px, Py) pointregionquadtree(cast(null, double), 0, 0, 0))",
                    "Failed to deploy: Invalid value for index 'MyIndex' parameter 'XMin' received null and expected non-null");
                SupportMessageAssertUtil.TryInvalidDeploy(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Py, Px) pointregionquadtree(0, 0, -100, 0))",
                    "Failed to deploy: Invalid value for index 'MyIndex' parameter 'Width' received -100.0d and expected value>0");
                SupportMessageAssertUtil.TryInvalidDeploy(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Py, Px) pointregionquadtree(0, 0, 1, -200))",
                    "Failed to deploy: Invalid value for index 'MyIndex' parameter 'Height' received -200.0d and expected value>0");
                SupportMessageAssertUtil.TryInvalidDeploy(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Py, Px) pointregionquadtree(0, 0, 1, 1, -1))",
                    "Failed to deploy: Invalid value for index 'MyIndex' parameter 'LeafCapacity' received -1 and expected value>=1");
                SupportMessageAssertUtil.TryInvalidDeploy(
                    env,
                    path,
                    "create index MyIndex on MyWindow((Py, Px) pointregionquadtree(0, 0, 1, 1, 10, -1))",
                    "Failed to deploy: Invalid value for index 'MyIndex' parameter 'MaxTreeHeight' received -1 and expected value>=2");

                // same index twice, by-name and by-columns
                env.CompileDeploy("create window SomeWindow#keepall as SupportSpatialPoint", path);
                env.CompileDeploy(
                    "create index SomeWindowIdx1 on SomeWindow((Px, Py) pointregionquadtree(0, 0, 1, 1))",
                    path);
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index SomeWindowIdx2 on SomeWindow((Px, Py) pointregionquadtree(0, 0, 1, 1))",
                    "An index for the same columns already exists");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index SomeWindowIdx1 on SomeWindow((Py, Px) pointregionquadtree(0, 0, 1, 1))",
                    "An index by name 'SomeWindowIdx1' already exists");

                // non-plain column or parameter expressions
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndexInv on MyWindow((sum(Px), Py) pointregionquadtree(0, 0, 1, 1))",
                    "Invalid create-index index-column expression 'sum(Px)': Aggregation, sub-select, previous or prior functions are not supported in this context");
                SupportMessageAssertUtil.TryInvalidCompile(
                    env,
                    path,
                    "create index MyIndexInv on MyWindow((Px, Py) pointregionquadtree(count(*), 0, 1, 1))",
                    "Invalid create-index index-parameter expression 'count(*)': Aggregation, sub-select, previous or prior functions are not supported in this context");

                env.UndeployAll();
            }
コード例 #16
0
ファイル: ViewRank.cs プロジェクト: lanicon/nesper
            public void Run(RegressionEnvironment env)
            {
                var fields = new[] {"TheString", "IntPrimitive", "LongPrimitive"};
                var epl = "@Name('s0') select irstream * from SupportBean#rank(TheString, 4, IntPrimitive desc)";
                env.CompileDeploy(epl).AddListener("s0");

                env.SendEventBean(MakeEvent("E1", 10, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", 10, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 10, 0L}});

                env.Milestone(0);

                env.SendEventBean(MakeEvent("E2", 30, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2", 30, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E2", 30, 0L}, new object[] {"E1", 10, 0L}});

                env.SendEventBean(MakeEvent("E1", 50, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E1", 50, 0L},
                    new object[] {"E1", 10, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 50, 0L}, new object[] {"E2", 30, 0L}});

                env.Milestone(1);

                env.SendEventBean(MakeEvent("E3", 40, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E3", 40, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 50, 0L}, new object[] {"E3", 40, 0L}, new object[] {"E2", 30, 0L}});

                env.SendEventBean(MakeEvent("E2", 45, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E2", 45, 0L},
                    new object[] {"E2", 30, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1", 50, 0L}, new object[] {"E2", 45, 0L}, new object[] {"E3", 40, 0L}});

                env.Milestone(2);

                env.SendEventBean(MakeEvent("E1", 43, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E1", 43, 0L},
                    new object[] {"E1", 50, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E2", 45, 0L}, new object[] {"E1", 43, 0L}, new object[] {"E3", 40, 0L}});

                env.SendEventBean(MakeEvent("E3", 50, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E3", 50, 0L},
                    new object[] {"E3", 40, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3", 50, 0L}, new object[] {"E2", 45, 0L}, new object[] {"E1", 43, 0L}});

                env.Milestone(3);

                env.SendEventBean(MakeEvent("E3", 10, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E3", 10, 0L},
                    new object[] {"E3", 50, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E2", 45, 0L}, new object[] {"E1", 43, 0L}, new object[] {"E3", 10, 0L}});

                env.SendEventBean(MakeEvent("E4", 43, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E4", 43, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E2", 45, 0L}, new object[] {"E1", 43, 0L}, new object[] {"E4", 43, 0L},
                        new object[] {"E3", 10, 0L}
                    });

                env.Milestone(4);

                // in-place replacement
                env.SendEventBean(MakeEvent("E4", 43, 1L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E4", 43, 1L},
                    new object[] {"E4", 43, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E2", 45, 0L}, new object[] {"E1", 43, 0L}, new object[] {"E4", 43, 1L},
                        new object[] {"E3", 10, 0L}
                    });

                env.SendEventBean(MakeEvent("E2", 45, 1L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E2", 45, 1L},
                    new object[] {"E2", 45, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E2", 45, 1L}, new object[] {"E1", 43, 0L}, new object[] {"E4", 43, 1L},
                        new object[] {"E3", 10, 0L}
                    });

                env.Milestone(5);

                env.SendEventBean(MakeEvent("E1", 43, 1L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E1", 43, 1L},
                    new object[] {"E1", 43, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E2", 45, 1L}, new object[] {"E4", 43, 1L}, new object[] {"E1", 43, 1L},
                        new object[] {"E3", 10, 0L}
                    });

                // out-of-space: pushing out the back end
                env.SendEventBean(MakeEvent("E5", 10, 2L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E5", 10, 2L},
                    new object[] {"E3", 10, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E2", 45, 1L}, new object[] {"E4", 43, 1L}, new object[] {"E1", 43, 1L},
                        new object[] {"E5", 10, 2L}
                    });

                env.Milestone(6);

                env.SendEventBean(MakeEvent("E5", 11, 3L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E5", 11, 3L},
                    new object[] {"E5", 10, 2L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E2", 45, 1L}, new object[] {"E4", 43, 1L}, new object[] {"E1", 43, 1L},
                        new object[] {"E5", 11, 3L}
                    });

                env.SendEventBean(MakeEvent("E6", 43, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E6", 43, 0L},
                    new object[] {"E5", 11, 3L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E2", 45, 1L}, new object[] {"E4", 43, 1L}, new object[] {"E1", 43, 1L},
                        new object[] {"E6", 43, 0L}
                    });

                env.Milestone(7);

                env.SendEventBean(MakeEvent("E7", 50, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E7", 50, 0L},
                    new object[] {"E4", 43, 1L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E7", 50, 0L}, new object[] {"E2", 45, 1L}, new object[] {"E1", 43, 1L},
                        new object[] {"E6", 43, 0L}
                    });

                env.SendEventBean(MakeEvent("E8", 45, 0L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E8", 45, 0L},
                    new object[] {"E1", 43, 1L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E7", 50, 0L}, new object[] {"E2", 45, 1L}, new object[] {"E8", 45, 0L},
                        new object[] {"E6", 43, 0L}
                    });

                env.Milestone(8);

                env.SendEventBean(MakeEvent("E8", 46, 1L));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertPairGetIRAndReset(),
                    fields,
                    new object[] {"E8", 46, 1L},
                    new object[] {"E8", 45, 0L});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {
                        new object[] {"E7", 50, 0L}, new object[] {"E8", 46, 1L}, new object[] {"E2", 45, 1L},
                        new object[] {"E6", 43, 0L}
                    });

                env.UndeployAll();
            }
コード例 #17
0
 private static void SendSupportBean_A(
     RegressionEnvironment env,
     string id)
 {
     env.SendEventBean(new SupportBean_A(id));
 }
コード例 #18
0
            public void Run(RegressionEnvironment env)
            {
                foreach (var rep in new[] {EventRepresentationChoice.AVRO}) {
                    RunAssertionFields(env, rep, true);
                    RunAssertionFields(env, rep, false);
                }

                // test doc samples
                var epl = "@Name('flow') create dataflow MyDataFlow\n" +
                          "  create schema SampleSchema(tagId string, locX double, locY double)," +
                          "  " +
                          "  // BeaconSource that produces empty object-array events without delay or interval\n" +
                          "  // until cancelled.\n" +
                          "  BeaconSource -> stream.one {}\n" +
                          "  \n" +
                          "  // BeaconSource that produces one RFIDSchema event populating event properties\n" +
                          "  // from a user-defined function \"generateTagId\" and values.\n" +
                          "  BeaconSource -> stream.two<SampleSchema> {\n" +
                          "    iterations : 1,\n" +
                          "    tagId : generateTagId(),\n" +
                          "    locX : 10,\n" +
                          "    locY : 20 \n" +
                          "  }\n" +
                          "  \n" +
                          "  // BeaconSource that produces 10 object-array events populating the Price property \n" +
                          "  // with a random value.\n" +
                          "  BeaconSource -> stream.three {\n" +
                          "    iterations : 1,\n" +
                          "    interval : 10, // every 10 seconds\n" +
                          "    initialDelay : 5, // start after 5 seconds\n" +
                          "    price : Randomizer.Random() * 100,\n" +
                          "  }";
                env.CompileDeploy(epl);
                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlow");
                env.UndeployAll();

                // test options-provided beacon field
                var eplMinimal = "@Name('flow') create dataflow MyGraph " +
                                 "BeaconSource -> outstream<SupportBean> {iterations:1} " +
                                 "EventBusSink(outstream) {}";
                env.CompileDeploy(eplMinimal);

                var options = new EPDataFlowInstantiationOptions();
                options.AddParameterURI("BeaconSource/TheString", "E1");
                var instance = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyGraph", options);

                env.CompileDeploy("@Name('s0') select * from SupportBean").AddListener("s0");
                instance.Run();
                Sleep(200);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "TheString" },
                    new object[] {"E1"});

                // invalid: no output stream
                TryInvalidCompile(
                    env,
                    "create dataflow DF1 BeaconSource {}",
                    "Failed to obtain operator 'BeaconSource': BeaconSource operator requires one output stream but produces 0 streams");

                env.UndeployAll();
            }
コード例 #19
0
 private static void SendTimerEvent(
     RegressionEnvironment env,
     long msec)
 {
     env.AdvanceTime(msec);
 }
コード例 #20
0
            public void Run(RegressionEnvironment env)
            {
                EPDataFlowInstantiationOptions options;
                object[] output;

                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowOne " +
                    "BeaconSource -> BeaconStream {}" +
                    "DefaultSupportCaptureOp(BeaconStream) {}");

                var countExpected = 10;
                var futureAtLeast = new DefaultSupportCaptureOp(countExpected, env.Container.LockManager());
                options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProvider(futureAtLeast));
                var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);
                df.Start();
                try {
                    output = futureAtLeast.GetValue(1, TimeUnit.SECONDS);
                }
                catch (Exception e) {
                    throw new EPException(e);
                }

                Assert.IsTrue(countExpected <= output.Length);
                df.Cancel();
                env.UndeployAll();

                // BeaconSource with given number of iterations
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowTwo " +
                    "BeaconSource -> BeaconStream {" +
                    "  iterations: 5" +
                    "}" +
                    "DefaultSupportCaptureOp(BeaconStream) {}");

                var futureExactTwo = new DefaultSupportCaptureOp(5, env.Container.LockManager());
                options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProvider(futureExactTwo));
                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowTwo", options).Start();
                try {
                    output = futureExactTwo.GetValue(1, TimeUnit.SECONDS);
                }
                catch (Exception t) {
                    throw new EPException(t);
                }

                Assert.AreEqual(5, output.Length);
                env.UndeployAll();

                // BeaconSource with delay
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowThree " +
                    "BeaconSource -> BeaconStream {" +
                    "  iterations: 2," +
                    "  initialDelay: 0.5" +
                    "}" +
                    "DefaultSupportCaptureOp(BeaconStream) {}");

                var futureExactThree = new DefaultSupportCaptureOp(2, env.Container.LockManager());
                options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProvider(futureExactThree));
                var start = PerformanceObserver.MilliTime;
                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowThree", options).Start();
                try {
                    output = futureExactThree.GetValue(1, TimeUnit.SECONDS);
                }
                catch (Exception e) {
                    throw new EPException(e);
                }

                var end = PerformanceObserver.MilliTime;
                Assert.AreEqual(2, output.Length);
                Assert.IsTrue(end - start > 490, "delta=" + (end - start));
                env.UndeployAll();

                // BeaconSource with period
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowFour " +
                    "BeaconSource -> BeaconStream {" +
                    "  interval: 0.5" +
                    "}" +
                    "DefaultSupportCaptureOp(BeaconStream) {}");
                var futureFour = new DefaultSupportCaptureOp(2, env.Container.LockManager());
                options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProvider(futureFour));
                var instance = env.Runtime.DataFlowService.Instantiate(
                    env.DeploymentId("flow"),
                    "MyDataFlowFour",
                    options);
                instance.Start();
                try {
                    output = futureFour.GetValue(2, TimeUnit.SECONDS);
                }
                catch (Exception t) {
                    throw new EPException(t);
                }

                Assert.AreEqual(2, output.Length);
                instance.Cancel();
                env.UndeployAll();

                // test Beacon with define typed
                var path = new RegressionPath();
                env.CompileDeploy("create objectarray schema MyTestOAType(p1 string)", path);
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowFive " +
                    "BeaconSource -> BeaconStream<MyTestOAType> {" +
                    "  interval: 0.5," +
                    "  p1 : 'abc'" +
                    "}",
                    path);
                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowFive");
                env.UndeployAll();
            }
コード例 #21
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('s0') select irstream " +
                          "avg(Price) as avgPrice," +
                          "sum(Price) as sumPrice," +
                          "min(Price) as minPrice," +
                          "max(Price) as maxPrice," +
                          "median(Price) as medianPrice," +
                          "stddev(Price) as stddevPrice," +
                          "avedev(Price) as avedevPrice," +
                          "count(*) as datacount, " +
                          "count(distinct Price) as countDistinctPrice " +
                          "from SupportMarketDataBean";
                env.CompileDeploy(epl).AddListener("s0");

                env.Milestone(0);

                env.SendEventBean(MakeMarketDataEvent(100));

                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"avgPrice", 100d},
                            new object[] {"sumPrice", 100d},
                            new object[] {"minPrice", 100d},
                            new object[] {"maxPrice", 100d},
                            new object[] {"medianPrice", 100d},
                            new object[] {"stddevPrice", null},
                            new object[] {"avedevPrice", 0.0},
                            new object[] {"datacount", 1L},
                            new object[] {"countDistinctPrice", 1L}
                        }, // new data
                        new[] {
                            new object[] {"avgPrice", null},
                            new object[] {"sumPrice", null},
                            new object[] {"minPrice", null},
                            new object[] {"maxPrice", null},
                            new object[] {"medianPrice", null},
                            new object[] {"stddevPrice", null},
                            new object[] {"avedevPrice", null},
                            new object[] {"datacount", 0L},
                            new object[] {"countDistinctPrice", 0L}
                        } // old data
                    );

                env.Milestone(1);

                env.SendEventBean(MakeMarketDataEvent(200));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"avgPrice", (100 + 200) / 2.0},
                            new object[] {"sumPrice", 100 + 200d},
                            new object[] {"minPrice", 100d},
                            new object[] {"maxPrice", 200d},
                            new object[] {"medianPrice", 150d},
                            new object[] {"stddevPrice", 70.71067811865476},
                            new object[] {"avedevPrice", 50d},
                            new object[] {"datacount", 2L},
                            new object[] {"countDistinctPrice", 2L}
                        }, // new data
                        new[] {
                            new object[] {"avgPrice", 100d},
                            new object[] {"sumPrice", 100d},
                            new object[] {"minPrice", 100d},
                            new object[] {"maxPrice", 100d},
                            new object[] {"medianPrice", 100d},
                            new object[] {"stddevPrice", null},
                            new object[] {"avedevPrice", 0.0},
                            new object[] {"datacount", 1L},
                            new object[] {"countDistinctPrice", 1L}
                        } // old data
                    );

                env.Milestone(2);

                env.SendEventBean(MakeMarketDataEvent(150));
                env.Listener("s0")
                    .AssertNewOldData(
                        new[] {
                            new object[] {"avgPrice", (150 + 100 + 200) / 3.0},
                            new object[] {"sumPrice", 150 + 100 + 200d},
                            new object[] {"minPrice", 100d},
                            new object[] {"maxPrice", 200d},
                            new object[] {"medianPrice", 150d},
                            new object[] {"stddevPrice", 50d},
                            new object[] {"avedevPrice", 33 + 1 / 3d},
                            new object[] {"datacount", 3L},
                            new object[] {"countDistinctPrice", 3L}
                        }, // new data
                        new[] {
                            new object[] {"avgPrice", (100 + 200) / 2.0},
                            new object[] {"sumPrice", 100 + 200d},
                            new object[] {"minPrice", 100d},
                            new object[] {"maxPrice", 200d},
                            new object[] {"medianPrice", 150d},
                            new object[] {"stddevPrice", 70.71067811865476},
                            new object[] {"avedevPrice", 50d},
                            new object[] {"datacount", 2L},
                            new object[] {"countDistinctPrice", 2L}
                        } // old data
                    );

                env.UndeployAll();
            }
コード例 #22
0
        private static void RunAssertionFields(
            RegressionEnvironment env,
            EventRepresentationChoice representationEnum,
            bool eventbean)
        {
            EPDataFlowInstantiationOptions options;

            var path = new RegressionPath();
            var streamType = eventbean ? "EventBean<MyEvent>" : "MyEvent";
            
            env.CompileDeploy(
                representationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedMyEvent>() +
                "create schema MyEvent(p0 string, p1 long, p2 double)", path);
            
            env.CompileDeploy(
                "@Name('flow') create dataflow MyDataFlowOne " +
                "" +
                "BeaconSource -> BeaconStream<" + streamType + "> " +
                "{" +
                "  iterations : 3," +
                "  p0 : 'abc'," +
                "  p1 : cast(Math.Round(Randomizer.Random() * 10) + 1, long)," +
                "  p2 : 1d," +
                "}" +
                "DefaultSupportCaptureOp(BeaconStream) {}",
                path);

            var future = new DefaultSupportCaptureOp(3, env.Container.LockManager());
            options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(future));
            var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);
            df.Start();
            object[] output;
            try {
                output = future.GetValue(2, TimeUnit.SECONDS);
            }
            catch (Exception t) {
                throw new EPException(t);
            }

            Assert.AreEqual(3, output.Length);
            for (var i = 0; i < 3; i++) {
                if (!eventbean) {
                    if (representationEnum.IsObjectArrayEvent()) {
                        var row = (object[]) output[i];
                        Assert.AreEqual("abc", row[0]);
                        var val = row[1].AsInt64();
                        Assert.IsTrue(val >= 0 && val <= 11, "val=" + val);
                        Assert.AreEqual(1d, row[2]);
                    }
                    else if (representationEnum.IsMapEvent()) {
                        var row = (IDictionary<string, object>) output[i];
                        Assert.AreEqual("abc", row.Get("p0"));
                        var val = row.Get("p1").AsInt64();
                        Assert.IsTrue(val >= 0 && val <= 11, "val=" + val);
                        Assert.AreEqual(1d, row.Get("p2"));
                    }
                    else {
                        var row = (GenericRecord) output[i];
                        Assert.AreEqual("abc", row.Get("p0"));
                        var val = row.Get("p1").AsInt64();
                        Assert.IsTrue(val >= 0 && val <= 11, "val=" + val);
                        Assert.AreEqual(1d, row.Get("p2"));
                    }
                }
                else {
                    var row = (EventBean) output[i];
                    Assert.AreEqual("abc", row.Get("p0"));
                }
            }

            env.UndeployAll();
        }
コード例 #23
0
 public void Run(RegressionEnvironment env)
 {
     string variable = "create constant variable string MYCONST = 'a';\n";
     TryDeployAndAssertionSB(env, variable + "@Name('s0') select * from SupportBean(TheString = MYCONST || 'x')", EQUAL);
     TryDeployAndAssertionSB(env, variable + "@Name('s0') select * from SupportBean(MYCONST || 'x' = TheString)", EQUAL);
 }
コード例 #24
0
 private static void SendCurrentTime(
     RegressionEnvironment env,
     string time)
 {
     env.AdvanceTime(DateTimeParsingFunctions.ParseDefaultMSecWZone(time));
 }
コード例 #25
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("@Name('create') create variable SupportBean varbean", path);

                var fields = new [] { "varbean.TheString","varbean.IntPrimitive","varbean.GetTheString()" };
                env.CompileDeploy(
                    "@Name('s0') select varbean.TheString,varbean.IntPrimitive,varbean.GetTheString() from SupportBean_S0",
                    path);
                env.AddListener("s0");

                env.SendEventBean(new SupportBean_S0(1));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {null, null, null});

                env.CompileDeploy(
                    "@Name('set') on SupportBean_A set varbean.TheString = 'A', varbean.IntPrimitive = 1",
                    path);
                env.AddListener("set");
                env.SendEventBean(new SupportBean_A("E1"));
                env.Listener("set").Reset();

                env.Milestone(0);

                env.SendEventBean(new SupportBean_S0(2));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {null, null, null});

                var setBean = new SupportBean();
                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("create"), "varbean", setBean);
                env.SendEventBean(new SupportBean_A("E2"));
                EPAssertionUtil.AssertProps(
                    env.Listener("set").AssertOneGetNewAndReset(),
                    new [] { "varbean.TheString","varbean.IntPrimitive" },
                    new object[] {"A", 1});
                EPAssertionUtil.AssertProps(
                    env.GetEnumerator("set").Advance(),
                    new [] { "varbean.TheString","varbean.IntPrimitive" },
                    new object[] {"A", 1});

                env.Milestone(1);

                env.SendEventBean(new SupportBean_S0(3));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"A", 1, "A"});
                Assert.AreNotSame(
                    setBean,
                    env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "varbean"));
                Assert.AreEqual(
                    1,
                    ((SupportBean) env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "varbean"))
                    .IntPrimitive);

                // test self evaluate
                env.UndeployModuleContaining("set");
                env.CompileDeploy(
                    "@Name('set') on SupportBean_A set varbean.TheString = SupportBean_A.Id, varbean.TheString = '>'||varbean.TheString||'<'",
                    path);
                env.AddListener("set");
                env.SendEventBean(new SupportBean_A("E3"));
                Assert.AreEqual(
                    ">E3<",
                    ((SupportBean) env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "varbean"))
                    .TheString);
                env.UndeployModuleContaining("set");

                // test widen
                env.CompileDeploy("@Name('set') on SupportBean_A set varbean.LongPrimitive = 1", path);
                env.AddListener("set");
                env.SendEventBean(new SupportBean_A("E4"));
                Assert.AreEqual(
                    1,
                    ((SupportBean) env.Runtime.VariableService.GetVariableValue(env.DeploymentId("create"), "varbean"))
                    .LongPrimitive);

                env.UndeployAll();
            }
コード例 #26
0
 private void SendMyEvent(
     RegressionEnvironment env,
     string c1)
 {
     env.SendEventMap(Collections.SingletonDataMap("cId", c1), "MyEvent");
 }
コード例 #27
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var vars = "@Name('vars') create variable " +
                           typeof(SupportBean).Name +
                           " varbeannull;\n" +
                           "create variable " +
                           typeof(SupportBean).Name +
                           " varbean;\n" +
                           "create variable SupportBean_S0 vars0;\n" +
                           "create variable long varobj;\n" +
                           "create variable long varobjnull;\n";
                env.CompileDeploy(vars, path);
                var deploymentId = env.DeploymentId("vars");

                var fields = new [] { "c0", "c1", "c2", "c3", "c4", "c5", "c6" };
                var stmtSelectText =
                    "@Name('select') select varbean.TheString as c0,varbean.IntPrimitive as c1,vars0.Id as c2,vars0.P00 as c3,varobj as c4,varbeannull.TheString as c5, varobjnull as c6 from SupportBean_A";
                env.CompileDeploy(stmtSelectText, path).AddListener("select");

                env.SendEventBean(new SupportBean_A("A1"));
                EPAssertionUtil.AssertProps(
                    env.Listener("select").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {null, null, null, null, null, null, null});

                // update via API
                env.Runtime.VariableService.SetVariableValue(deploymentId, "varobj", 101L);
                env.Runtime.VariableService.SetVariableValue(deploymentId, "vars0", new SupportBean_S0(1, "S01"));
                env.Runtime.VariableService.SetVariableValue(deploymentId, "varbean", new SupportBean("E1", -1));

                env.Milestone(0);

                env.SendEventBean(new SupportBean_A("A2"));
                EPAssertionUtil.AssertProps(
                    env.Listener("select").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E1", -1, 1, "S01", 101L, null, null});

                env.Milestone(1);

                // update properties via on-set
                var stmtUpdateText =
                    "@Name('update') on SupportBean_B set varbean.TheString = 'EX', varbean.IntPrimitive = -999";
                env.CompileDeploy(stmtUpdateText, path);
                Assert.AreEqual(
                    StatementType.ON_SET,
                    env.Statement("update").GetProperty(StatementProperty.STATEMENTTYPE));
                env.SendEventBean(new SupportBean_B("B1"));

                env.Milestone(2);

                env.SendEventBean(new SupportBean_A("A3"));
                EPAssertionUtil.AssertProps(
                    env.Listener("select").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"EX", -999, 1, "S01", 101L, null, null});

                // update full bean via on-set
                stmtUpdateText = "@Name('update2') on SupportBean(IntPrimitive = 0) as sb set varbean = sb";
                env.CompileDeploy(stmtUpdateText, path);

                var bean = new SupportBean("E2", 0);
                env.SendEventBean(bean);

                env.Milestone(3);

                env.SendEventBean(new SupportBean_A("A4"));
                EPAssertionUtil.AssertProps(
                    env.Listener("select").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E2", 0, 1, "S01", 101L, null, null});

                env.UndeployAll();
            }
コード例 #28
0
 private static void AdvanceTime(
     RegressionEnvironment env,
     string time)
 {
     AdvanceTime(env, null, time);
 }
コード例 #29
0
            public void Run(RegressionEnvironment env)
            {
                RegressionPath path = new RegressionPath();

                env.CompileDeploy("@public create json schema Book(BookId string, price decimal);\n", path);
                env.CompileDeploy("@public create json schema Shelf(shelfId string, books Book[]);\n", path);
                env.CompileDeploy("@public create json schema Isle(isleId string, shelfs Shelf[]);\n", path);
                env.CompileDeploy("@public @buseventtype create json schema Library(libraryId string, isles Isle[]);\n", path);
                env.CompileDeploy("@Name('s0') select * from Library#keepall;\n", path).AddListener("s0");

                string jsonOne = "{\n" +
                                 "  \"libraryId\": \"L1\",\n" +
                                 "  \"isles\": [\n" +
                                 "    {\n" +
                                 "      \"isleId\": \"I1\",\n" +
                                 "      \"shelfs\": [\n" +
                                 "        {\n" +
                                 "          \"shelfId\": \"S1\",\n" +
                                 "          \"books\": [\n" +
                                 "            {\n" +
                                 "              \"BookId\": \"B1\",\n" +
                                 "              \"price\": 10\n" +
                                 "            }\n" +
                                 "          ]\n" +
                                 "        }\n" +
                                 "      ]\n" +
                                 "    }\n" +
                                 "  ]\n" +
                                 "}";

                env.SendEventJson(jsonOne, "Library");
                AssertJsonWrite(jsonOne, env.Listener("s0").AssertOneGetNewAndReset());

                JObject book111    = BuildBook("B111", 20);
                JObject shelf11    = BuildShelf("S11", book111);
                JObject isle1      = BuildIsle("I1", shelf11);
                JObject libraryOne = BuildLibrary("L1", isle1);
                string  jsonTwo    = libraryOne.ToString();

                env.SendEventJson(jsonTwo, "Library");
                AssertJsonWrite(jsonTwo, env.Listener("s0").AssertOneGetNewAndReset());

                JObject book112 = BuildBook("B112", 21);

                ((JArray)shelf11.Get("books")).Add(book112);
                JObject shelf12    = BuildShelf("S12", book111, book112);
                JObject isle2      = BuildIsle("I2", shelf11, shelf12);
                JObject libraryTwo = BuildLibrary("L", isle1, isle2);
                string  jsonThree  = libraryTwo.ToString();

                env.SendEventJson(jsonThree, "Library");
                AssertJsonWrite(jsonThree, env.Listener("s0").AssertOneGetNewAndReset());

                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();
            }
コード例 #30
0
            private void RunAssertion(
                RegressionEnvironment env,
                Type localType,
                Type fieldType,
                string jsonText,
                object expected,
                JValue invalidJson,
                AtomicLong milestone)
            {
                string epl = "@public @buseventtype create json schema JsonEvent(local " +
                             localType.FullName +
                             ");\n" +
                             "@Name('s0') select * from JsonEvent#keepall;\n";

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

                JObject localFilled = new JObject(
                    new JProperty("c0", jsonText),
                    new JProperty("c0Arr", new JArray(jsonText)),
                    new JProperty("c0Arr2Dim", new JArray(new JArray(jsonText))),
                    new JProperty("c0Coll", new JArray(jsonText)));
                JObject jsonFilledObject = new JObject(
                    new JProperty("local", localFilled));
                string jsonFilled = jsonFilledObject.ToString();

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

                JObject localNull = new JObject(
                    new JProperty("c0", NULL_VALUE),
                    new JProperty("c0Arr", new JArray(NULL_VALUE)),
                    new JProperty("c0Arr2Dim", new JArray(new JArray(NULL_VALUE))),
                    new JProperty("c0Coll", new JArray(NULL_VALUE)));
                JObject jsonNullObject = new JObject(
                    new JProperty("local", localNull));
                string jsonNull = jsonNullObject.ToString();

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

                try {
                    JObject localInvalid = new JObject(
                        new JProperty("c0", invalidJson));
                    JObject jsonInvalidObject = new JObject(
                        new JProperty("local", localInvalid));
                    env.SendEventJson(jsonInvalidObject.ToString(), "JsonEvent");
                    Assert.Fail();
                }
                catch (EPException ex) {
                    string value = invalidJson.ToString();
                    AssertMessage(ex, "Failed to parse json member name 'c0' as a " + fieldType.Name + "-type from value '" + value + "'");
                }

                env.MilestoneInc(milestone);

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

                AssertEvent(env, it.Advance(), jsonFilled, expected);
                AssertEvent(env, it.Advance(), jsonNull, null);

                env.UndeployAll();
            }