Пример #1
0
        private void RunAssertionUserDefined(EPServiceProvider epService)
        {
            var listener      = new SupportUpdateListener();
            var className     = typeof(SupportStaticMethodLib).FullName;
            var statementText = "select " + className + ".StaticMethod(2)" + STREAM_MDB_LEN5;
            var stmt          = epService.EPAdministrator.CreateEPL(statementText);

            stmt.Events += listener.Update;
            Assert.AreEqual(2, AssertStatementAndGetProperty(epService, listener, true, className + ".StaticMethod(2)")[0]);
            stmt.Dispose();

            // try context passed
            SupportStaticMethodLib.GetMethodInvocationContexts().Clear();
            statementText = "@Name('S0') select " + className + ".StaticMethodWithContext(2)" + STREAM_MDB_LEN5;
            stmt          = epService.EPAdministrator.CreateEPL(statementText);
            stmt.Events  += listener.Update;
            Assert.AreEqual(2, AssertStatementAndGetProperty(epService, listener, true, className + ".StaticMethodWithContext(2)")[0]);
            EPLMethodInvocationContext first = SupportStaticMethodLib.GetMethodInvocationContexts()[0];

            Assert.AreEqual("S0", first.StatementName);
            Assert.AreEqual(epService.URI, first.EngineURI);
            Assert.AreEqual(-1, first.ContextPartitionId);
            Assert.AreEqual("StaticMethodWithContext", first.FunctionName);
            stmt.Dispose();
        }
Пример #2
0
        private static void TryOptimizableEquals(
            RegressionEnvironment env,
            RegressionPath path,
            string epl,
            int numStatements)
        {
            // test function returns lookup value and "Equals"
            for (int i = 0; i < numStatements; i++) {
                string text = "@Name('s" + i + "') " + epl.Replace("!NUM!", i.ToString());
                env.CompileDeploy(text, path).AddListener("s" + i);
            }

            env.Milestone(0);

            var loops = 1000;
            var delta = PerformanceObserver.TimeMillis(
                () => {
                    SupportStaticMethodLib.ResetCountInvoked();
                    for (int i = 0; i < loops; i++) {
                        env.SendEventBean(new SupportBean("E_" + i % numStatements, 0));
                        SupportListener listener = env.Listener("s" + i % numStatements);
                        Assert.IsTrue(listener.GetAndClearIsInvoked());
                    }
                });

            Assert.AreEqual(loops, SupportStaticMethodLib.CountInvoked);

            Assert.IsTrue(delta < 1000, "Delta is " + delta);
            env.UndeployAll();
        }
        private void RunAssertionType(bool isCheckStatic)
        {
            var fields = "f1,f2,w1,l1".Split(',');

            var beanOne  = SendEvent(_epService, "E1", 10d, 100);
            var expected = new object[] { 110d, 100, new object[] { beanOne }, beanOne };

            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, expected);
            if (isCheckStatic)
            {
                object[] parameters = SupportStaticMethodLib.GetInvocations()[0];
                SupportStaticMethodLib.GetInvocations().Clear();
                EPAssertionUtil.AssertEqualsExactOrder(expected, parameters);
            }
        }
Пример #4
0
        private static void TryOptimizableBoolean(
            RegressionEnvironment env,
            RegressionPath path,
            string epl)
        {
            // test function returns lookup value and "Equals"
            int count = 10;
            for (int i = 0; i < count; i++) {
                EPCompiled compiled = env.Compile("@Name('s" + i + "')" + epl, path);
                EPDeploymentService admin = env.Runtime.DeploymentService;
                try {
                    admin.Deploy(compiled);
                }
                catch (EPDeployException) {
                    Assert.Fail();
                }
            }

            env.Milestone(0);

            SupportUpdateListener listener = new SupportUpdateListener();
            for (int i = 0; i < 10; i++) {
                env.Statement("s" + i).AddListener(listener);
            }

            var loops = 10000;
            var delta = PerformanceObserver.TimeMillis(
                () => {
                    SupportStaticMethodLib.ResetCountInvoked();
                    for (int i = 0; i < loops; i++) {
                        string key = "E_" + i % 100;
                        env.SendEventBean(new SupportBean(key, 0));
                        if (key.Equals("E_1")) {
                            Assert.AreEqual(count, listener.NewDataList.Count);
                            listener.Reset();
                        }
                        else {
                            Assert.IsFalse(listener.IsInvoked);
                        }
                    }
                });
            Assert.AreEqual(loops, SupportStaticMethodLib.CountInvoked);

            Assert.IsTrue(delta < 1000, "Delta is " + delta);
            env.UndeployAll();
        }
Пример #5
0
        public void TestUserDefined()
        {
            var className = typeof(SupportStaticMethodLib).FullName;

            _statementText = "select " + className + ".StaticMethod(2)" + _stream;
            Assert.AreEqual(2, CreateStatementAndGetProperty(true, className + ".StaticMethod(2)")[0]);

            // try context passed
            SupportStaticMethodLib.GetMethodInvocationContexts().Clear();
            _statementText = "@Name('S0') select " + className + ".StaticMethodWithContext(2)" + _stream;
            Assert.AreEqual(2, CreateStatementAndGetProperty(true, className + ".StaticMethodWithContext(2)")[0]);
            var first = SupportStaticMethodLib.GetMethodInvocationContexts()[0];

            Assert.AreEqual("S0", first.StatementName);
            Assert.AreEqual(_epService.URI, first.EngineURI);
            Assert.AreEqual(-1, first.ContextPartitionId);
            Assert.AreEqual("StaticMethodWithContext", first.FunctionName);
        }