Esempio n. 1
0
        private static void RunAssertion(RegressionEnvironment env)
        {
            var future = new DefaultSupportCaptureOp(1, env.Container.LockManager());
            var source = new MyObjectArrayGraphSource(
                Arrays.AsList(
                        new object[] {"trade", "GE", 100d, 1000L, null, null}, // vwap = 100, minPrice=100
                        new object[] {"quote", "GE", null, null, 99.5d, 2000L} //
                    )
                    .GetEnumerator());

            var options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(future, source));

            env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "VWAPSample", options).Start();

            object[] received;
            try {
                received = future.GetValue(5, TimeUnit.SECONDS);
            }
            catch (Exception t) {
                throw new EPException(t);
            }

            Assert.AreEqual(1, received.Length);

            var receivedArray = received[0].UnwrapIntoArray<object>();
            EPAssertionUtil.AssertProps(
                env.Container,
                receivedArray,
                new string[] { "index" },
                new object[] { 2000 * Math.Exp(100 - 99.5) });

            env.UndeployAll();
        }
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                var schemaEPL =
                    "create objectarray schema MyEventOne(type string, p0 int, p1 string);\n" +
                    "create objectarray schema MyEventTwo(type string, f0 string, f1 int);\n";
                env.CompileDeployWBusPublicType(schemaEPL, path);

                env.CompileDeploy("@Name('s0') select * from MyEventOne", path).AddListener("s0");
                env.CompileDeploy("@Name('s1') select * from MyEventTwo", path).AddListener("s1");

                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlow " +
                    "MyObjectArrayGraphSource -> OutStream<?> {}" +
                    "EventBusSink(OutStream) {" +
                    "  collector : {" +
                    "    class: '" +
                    typeof(MyTransformToEventBus).FullName +
                    "'" +
                    "  }" +
                    "}");

                var source = new MyObjectArrayGraphSource(
                    Arrays.AsList(
                            new object[] {"type1", 100, "abc"},
                            new object[] {"type2", "GE", -1}
                        )
                        .GetEnumerator());
                var options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProvider(source));
                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlow", options).Start();

                env.Listener("s0").WaitForInvocation(3000, 1);
                env.Listener("s1").WaitForInvocation(3000, 1);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    new [] { "p0","p1" },
                    new object[] {100, "abc"});
                EPAssertionUtil.AssertProps(
                    env.Listener("s1").AssertOneGetNewAndReset(),
                    new [] { "f0","f1" },
                    new object[] {"GE", -1});

                env.UndeployAll();
            }