Ejemplo n.º 1
0
        public void TestUserObjectAndStatementNameResolver()
        {
            var module  = _deploymentAdmin.Parse("select * from System.Object where 1=2; select * from System.Object where 3=4;");
            var options = new DeploymentOptions();

            options.StatementNameResolver = new ProxyStatementNameResolver
            {
                ProcGetStatementName = context => context.Epl.Contains("1=2") ? "StmtOne" : "StmtTwo"
            };
            options.StatementUserObjectResolver = new ProxyStatementUserObjectResolver
            {
                ProcGetUserObject = context => context.Epl.Contains("1=2") ? 100 : 200
            };

            _deploymentAdmin.Deploy(module, options);

            Assert.AreEqual(100, _epService.EPAdministrator.GetStatement("StmtOne").UserObject);
            Assert.AreEqual(200, _epService.EPAdministrator.GetStatement("StmtTwo").UserObject);
        }
Ejemplo n.º 2
0
        public void TestParse()
        {
            Module module = _deploySvc.Read("regression/test_module_4.epl");

            AssertModule(module, null, "abd", null, new String[] {
                "select * from ABC",
                "/* Final comment */"
            }, new bool[] { false, true },
                         new int[] { 3, 8 },
                         new int[] { 12, 0 },
                         new int[] { 37, 0 }
                         );

            module = _deploySvc.Read("regression/test_module_1.epl");
            AssertModule(module, "abc", "def,jlk", null, new String[] {
                "select * from A",
                "select * from B" + newline +
                "where C=d",
                "/* Test ; Comment */" + newline +
                "update ';' where B=C",
                "update D"
            }
                         );

            module = _deploySvc.Read("regression/test_module_2.epl");
            AssertModule(module, "abc.def.hij", "def.hik,jlk.aja", null, new String[] {
                "// Note 4 white spaces after * and before from" + newline + "select * from A",
                "select * from B",
                "select *    " + newline + "    from C",
            }
                         );

            module = _deploySvc.Read("regression/test_module_3.epl");
            AssertModule(module, null, null, null, new String[] {
                "create window ABC",
                "select * from ABC"
            }
                         );

            module = _deploySvc.Read("regression/test_module_5.epl");
            AssertModule(module, "abd.def", null, null, new String[0]);

            module = _deploySvc.Read("regression/test_module_6.epl");
            AssertModule(module, null, null, null, new String[0]);

            module = _deploySvc.Read("regression/test_module_7.epl");
            AssertModule(module, null, null, null, new String[0]);

            module = _deploySvc.Read("regression/test_module_8.epl");
            AssertModule(module, "def.jfk", null, null, new String[0]);

            module = _deploySvc.Parse("module mymodule; uses mymodule2; import abc; select * from MyEvent;");
            AssertModule(module, "mymodule", "mymodule2", "abc", new String[] {
                "select * from MyEvent"
            });

            module = _deploySvc.Read("regression/test_module_11.epl");
            AssertModule(module, null, null, "com.mycompany.pck1", new String[0]);

            module = _deploySvc.Read("regression/test_module_10.epl");
            AssertModule(module, "abd.def", "one.use,two.use", "com.mycompany.pck1,com.mycompany.*", new String[] {
                "select * from A",
            }
                         );

            Assert.AreEqual("org.mycompany.events", _deploySvc.Parse("module org.mycompany.events; select * from System.Object;").Name);
            Assert.AreEqual("glob.Update.me", _deploySvc.Parse("module glob.Update.me; select * from System.Object;").Name);
            Assert.AreEqual("seconds.until.every.where", _deploySvc.Parse("uses seconds.until.every.where; select * from System.Object;").Uses.ToArray()[0]);
            Assert.AreEqual("seconds.until.every.where", _deploySvc.Parse("import seconds.until.every.where; select * from System.Object;").Imports.ToArray()[0]);

            // Test script square brackets
            module = _deploySvc.Read("regression/test_module_13.epl");
            Assert.AreEqual(1, module.Items.Count);

            module = _deploySvc.Read("regression/test_module_14.epl");
            Assert.AreEqual(4, module.Items.Count);

            module = _deploySvc.Read("regression/test_module_15.epl");
            Assert.AreEqual(1, module.Items.Count);
        }