public void Run(RegressionEnvironment env) { var @namespace = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " using com.espertech.esper.common.client.hook.singlerowfunc;\n" + " namespace " + @namespace + " {\n" + " [ExtensionSingleRowFunction(Name=\"multiply\", MethodName=\"MultiplyIt\")]\n" + " public class MultiplyHelper {\n" + " public static int MultiplyIt(int a, int b) {\n" + " return a*b;\n" + " }\n" + " public static int MultiplyIt(int a, int b, int c) {\n" + " return a*b*c;\n" + " }\n" + " }\n" + " }\n" + "\"\"\" " + "select multiply(IntPrimitive,IntPrimitive) as c0, multiply(IntPrimitive,IntPrimitive,IntPrimitive) as c1 \n" + " from SupportBean"; env.CompileDeploy(epl).AddListener("s0"); env.SendEventBean(new SupportBean("E1", 4)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), "c0,c1".SplitCsv(), new object[] { 16, 64 }); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var eplWindow = "create window MyWindow#keepall as (TheString string);\n" + "on SupportBean merge MyWindow insert select TheString;\n"; env.CompileDeploy(eplWindow, path); env.SendEventBean(new SupportBean("E1", 1)); var eplFAF = "inlined_class \"\"\"\n" + "namespace ${NAMESPACE} {\n" + " public class MyClass {\n" + " public static string DoIt(string parameter) {\n" + " return '>' + parameter + '<';\n" + " }\n" + " }\n" + "}\n" + "\"\"\"\n select ${NAMESPACE}.MyClass.DoIt(TheString) as c0 from MyWindow"; var result = env.CompileExecuteFAF( eplFAF.Replace("${NAMESPACE}", NamespaceGenerator.Create()), path); Assert.AreEqual(">E1<", result.Array[0].Get("c0")); env.Milestone(0); result = env.CompileExecuteFAF( eplFAF.Replace("${NAMESPACE}", NamespaceGenerator.Create()), path); Assert.AreEqual(">E1<", result.Array[0].Get("c0")); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var prefix = INLINEDCLASS_PREFIXMAP.Replace("${NAMESPACE}", ns); var eplCreateInlined = "@Name('clazz') @public create " + prefix + ";\n"; var path = new RegressionPath(); env.Compile(eplCreateInlined, path); var epl = "@public @buseventtype create schema PersonEvent(name string, id string);" + "@Name('table') create table TableWithTrie(nameTrie trieState(string));\n" + "into table TableWithTrie select trieEnter(name) as nameTrie from PersonEvent;\n"; var compiledTable = env.Compile(epl, path); env.CompileDeploy(eplCreateInlined); env.Deploy(compiledTable); MakeSendPerson(env, "Andreas", "P1"); MakeSendPerson(env, "Andras", "P2"); MakeSendPerson(env, "Andras", "P3"); MakeSendPerson(env, "And", "P4"); var trie = (SupportTrie <string, IList <object> >)env.GetEnumerator("table").Advance().Get("nameTrie"); Assert.AreEqual(3, trie.PrefixMap("And").Count); // assert dependencies SupportDeploymentDependencies.AssertSingle(env, "table", "clazz", EPObjectType.CLASSPROVIDED, ns + ".TrieAggForge"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var @namespace = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " namespace " + @namespace + " {\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(\n" + " Name=\"multiply\", MethodName=\"MultiplyIfPositive\",\n" + " ValueCache=" + typeof(ConfigurationCompilerPlugInSingleRowFunction.ValueCacheEnum).FullName.CodeInclusionTypeName() + ".DISABLED,\n" + " FilterOptimizable=" + typeof(ConfigurationCompilerPlugInSingleRowFunction.FilterOptimizableEnum).FullName.CodeInclusionTypeName() + ".DISABLED,\n" + " RethrowExceptions=false,\n" + " EventTypeName=\"abc\"\n" + " )]\n" + " public class MultiplyHelper {\n" + " public static int MultiplyIfPositive(int a, int b) {\n" + " return a*b;\n" + " }\n" + " }\n" + " }\n" + "\"\"\" " + "select multiply(IntPrimitive,IntPrimitive) as c0 from SupportBean"; env.CompileDeploy(epl).AddListener("s0"); SendAssertIntMultiply(env, 5, 25); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var @namespace = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " namespace " + @namespace + " {\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(Name=\"multiply\", MethodName=\"Multiply\")]\n" + " public class MultiplyHelper {\n" + " public static int Multiply(int a, int b) {\n" + " return a*b;\n" + " }\n" + " }\n" + " }\n" + "\"\"\" " + "select multiply(IntPrimitive,IntPrimitive) as c0 from SupportBean"; env.CompileDeploy(soda, epl).AddListener("s0"); SendAssertIntMultiply(env, 5, 25); env.Milestone(0); SendAssertIntMultiply(env, 6, 36); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); var eplCreateInlined = "@Name('clazz') @public create " + inlined + ";\n"; var path = new RegressionPath(); env.Compile(eplCreateInlined.Replace("builder.ToString()", "null"), path); var eplSelect = "@Name('s0') select concat(TheString) as c0 from SupportBean"; var compiledSelect = env.Compile(eplSelect, path); env.CompileDeploy(eplCreateInlined); env.Deploy(compiledSelect).AddListener("s0"); SendAssertConcat(env, "A", "A"); env.Milestone(0); SendAssertConcat(env, "B", "A,B"); // assert dependencies SupportDeploymentDependencies.AssertSingle(env, "s0", "clazz", EPObjectType.CLASSPROVIDED, "ConcatAggForge"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var createEPL = CREATE_EPL .Replace("${PREFIX}", "@private") .Replace("${NAMESPACE}", namespc); var userEPL = USER_EPL.Replace("${NAMESPACE}", namespc); var epl = createEPL + userEPL; var compiled = env.Compile(epl); TryInvalidNotVisible(env, compiled); }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var createEPL = CREATE_EPL .Replace("${PREFIX}", "@public") .Replace("${NAMESPACE}", namespc); var epl = "module a.b.c;\n" + createEPL.Replace("${PREFIX}", "@public"); var compiled = env.Compile(epl); var userEPL = USER_EPL.Replace("${NAMESPACE}", namespc); var path = new RegressionPath(); path.Add(compiled); env.Compile("module x;\n" + userEPL, path); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); var epl = "@Name('s0')\n" + inlined + "select concat(TheString) as c0 from SupportBean"; env.CompileDeploy(epl).AddListener("s0"); SendAssertConcat(env, "A", "A"); SendAssertConcat(env, "B", "A,B"); env.Milestone(0); SendAssertConcat(env, "C", "A,B,C"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var createEPL = CREATE_EPL .Replace("${PREFIX}", "@protected") .Replace("${NAMESPACE}", namespc); var epl = "module a.b.c;\n" + createEPL; var compiled = env.Compile(epl); TryInvalidNotVisible(env, compiled); var userEPL = USER_EPL.Replace("${NAMESPACE}", namespc); var path = new RegressionPath(); path.Add(compiled); env.Compile("module a.b.c;\n" + userEPL, path); TryInvalidCompile(env, path, "module a.b.d;\n" + userEPL, FIRST_MESSAGE); }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " using com.espertech.esper.common.client.hook.singlerowfunc;\n" + " namespace " + namespc + " {\n" + " [ExtensionSingleRowFunction(Name=\"toArray\", MethodName=\"ToArray\")]\n" + " public class Helper {\n" + " public static int[] ToArray(int a, int b) {\n" + " return new int[] {a, b};\n" + " }\n" + " }\n" + " }\n" + "\"\"\" " + "select " + typeof(ExprCoreArrayAtElement).FullName + ".GetIntArray()[IntPrimitive] as c0, " + typeof(ExprCoreArrayAtElement).FullName + ".GetIntArray2Dim()[IntPrimitive][IntPrimitive] as c1, " + "toArray(3,30)[IntPrimitive] as c2 " + "from SupportBean"; env.CompileDeploy(soda, epl).AddListener("s0"); var fields = "c0,c1,c2".SplitCsv(); var eventType = env.Statement("s0").EventType; foreach (var field in fields) { Assert.AreEqual(typeof(int?), eventType.GetPropertyType(field)); } env.SendEventBean(new SupportBean("E1", 1)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, 10, 20, 30); env.SendEventBean(new SupportBean("E2", 0)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, 1, 1, 3); env.SendEventBean(new SupportBean("E3", 2)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, null, null, null); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var eplCreateInlined = "@Name('clazz') @public create inlined_class \"\"\"\n" + " namespace %NAMESPACE% {\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(Name=\"multiply\", MethodName=\"Multiply\")]\n" + " public class MultiplyHelper {\n" + " public static int Multiply(int a, int b) {\n" + " %BEHAVIOR%\n" + " }\n" + " }\n" + " }\n" + "\"\"\"\n;"; var path = new RegressionPath(); var ns1 = NamespaceGenerator.Create(); env.Compile( eplCreateInlined .Replace("%NAMESPACE%", ns1) .Replace("%BEHAVIOR%", "return -1;"), path); var eplSelect = "@Name('s0') select multiply(IntPrimitive,IntPrimitive) as c0 from SupportBean"; var compiledSelect = env.Compile(eplSelect, path); var ns2 = NamespaceGenerator.Create(); env.CompileDeploy( eplCreateInlined .Replace("%NAMESPACE%", ns2) .Replace("%BEHAVIOR%", "return a*b;")); env.Deploy(compiledSelect).AddListener("s0"); SendAssertIntMultiply(env, 3, 9); env.Milestone(0); SendAssertIntMultiply(env, 13, 13 * 13); // assert dependencies SupportDeploymentDependencies.AssertSingle(env, "s0", "clazz", EPObjectType.CLASSPROVIDED, "MultiplyHelper"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var nsp = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + $"namespace {nsp} {{\n" + " public class MyClass {\n" + " public static string DoIt(string parameter) {\n" + " return \"|\" + parameter + \"|\";\n" + " }\n" + " }\n" + "}\n" + "\"\"\" " + $"select {nsp}.MyClass.DoIt(TheString) as c0 from SupportBean\n"; env.CompileDeploy(_soda, epl).AddListener("s0"); SendSBAssert(env, "E1", 0, "|E1|"); env.Milestone(0); SendSBAssert(env, "E2", 0, "|E2|"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var namespc = NamespaceGenerator.Create(); env.CompileDeploy( "@Name('clazz') create inlined_class \"\"\" " + "namespace " + namespc + " {" + " public class MyClass {" + " public static string DoIt() {" + " return \"def\";" + " }" + " }" + "}\"\"\"", path); var text = "Application-inlined class 'MyClass'"; TryDeployInvalidUndeploy(env, path, "clazz", $"@Name('A') select {namespc}.MyClass.DoIt() as col from SupportBean", "A", text); env.UndeployModuleContaining("clazz"); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var ns = NamespaceGenerator.Create(); var prefix = INLINEDCLASS_PREFIXMAP.Replace("${NAMESPACE}", ns); var epl = "@public @buseventtype create schema PersonEvent(name string, id string);" + "create " + prefix + ";\n" + "@Name('table') create table TableWithTrie(nameTrie trieState(string));\n" + "@Priority(1) into table TableWithTrie select trieEnter(name) as nameTrie from PersonEvent;\n" + "@Priority(0) @name('s0') select TableWithTrie.nameTrie.triePrefixMap(name) as c0 from PersonEvent;\n"; env.CompileDeploy(epl, path).AddListener("s0"); var p1 = MakeSendPerson(env, "Andreas", "P1"); AssertReceived(env, CollectionUtil.BuildMap("Andreas", SingletonList(p1))); var p2 = MakeSendPerson(env, "Andras", "P2"); AssertReceived(env, CollectionUtil.BuildMap("Andras", SingletonList(p2))); var p3 = MakeSendPerson(env, "Andras", "P3"); AssertReceived(env, CollectionUtil.BuildMap("Andras", Arrays.AsList(p2, p3))); var p4 = MakeSendPerson(env, "And", "P4"); AssertReceived(env, CollectionUtil.BuildMap("Andreas", SingletonList(p1), "Andras", Arrays.AsList(p2, p3), "And", SingletonList(p4))); var eplFAF = "select nameTrie as c0 from TableWithTrie"; var result = env.CompileExecuteFAF(eplFAF, path); var trie = (SupportTrie <string, IList <object> >)result.Array[0].Get("c0"); Assert.AreEqual(3, trie.PrefixMap("And").Count); trie = (SupportTrie <string, IList <object> >)env.GetEnumerator("table").Advance().Get("nameTrie"); Assert.AreEqual(3, trie.PrefixMap("And").Count); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); var path = new RegressionPath(); var eplWindow = "create window MyWindow#keepall as (TheString string);\n" + "on SupportBean merge MyWindow insert select TheString;\n"; env.CompileDeploy(eplWindow, path); env.SendEventBean(new SupportBean("E1", 1)); env.SendEventBean(new SupportBean("E2", 1)); var eplFAF = inlined + "select concat(TheString) as c0 from MyWindow"; var result = env.CompileExecuteFAF(eplFAF, path); Assert.AreEqual("E1,E2", result.Array[0].Get("c0")); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { RegressionPath path = new RegressionPath(); string namespc = NamespaceGenerator.Create(); string objects = "@public create variable string MYVARIABLE_NONCONSTANT = 'abc';\n" + "@public create table MyTable(tablecol string);\n" + "@public create window MyWindow#keepall as SupportBean;\n" + "@public create inlined_class \"\"\"\n" + "namespace " + namespc + " {\n" + " public class Helper {\n" + " public static string Doit(object param) {\n" + " return null;\n" + " }\n" + " }\n" + "}\n" + "\"\"\";\n" + "@public create expression MyDeclaredExpr { (select TheString from MyWindow) };\n" + "@public create expression MyHandThrough {v => v};\n" + "@public create expression string js:MyJavaScript(param) [\"a\"];\n"; env.Compile(objects, path); AssertDisqualified(env, path, "SupportBean", "TheString=Convert.ToString(IntPrimitive)"); AssertDisqualified(env, path, "SupportBean", "TheString=MYVARIABLE_NONCONSTANT"); AssertDisqualified(env, path, "SupportBean", "TheString=MyTable.tablecol"); AssertDisqualified(env, path, "SupportBean", "TheString=(select TheString from MyWindow)"); AssertDisqualified(env, path, "SupportBeanArrayCollMap", "Id = SetOfString.where(v => v=Id).firstOf()"); AssertDisqualified(env, path, "SupportBean", $"TheString={namespc}.Helper.Doit(*)"); AssertDisqualified(env, path, "SupportBean", $"TheString={namespc}.Helper.Doit(me)"); AssertDisqualified(env, path, "SupportBean", "BoolPrimitive=event_identity_equals(me, me)"); AssertDisqualified(env, path, "SupportBean", "TheString=MyDeclaredExpr()"); AssertDisqualified(env, path, "SupportBean", "IntPrimitive=me.TheString.Length"); AssertDisqualified(env, path, "SupportBean", "IntPrimitive = funcOne('hello')"); AssertDisqualified(env, path, "SupportBean", "BoolPrimitive = exists(TheString)"); AssertDisqualified(env, path, "SupportBean", "TheString = MyJavaScript('a')"); AssertDisqualified(env, path, "SupportBean", "TheString = MyHandThrough('a')"); }
public void Run(RegressionEnvironment env) { var @namespace = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " namespace " + @namespace + " {\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(Name=\"multiply\", MethodName=\"Multiply\")]\n" + " public class MultiplyHelperOne {\n" + " public static int Multiply(int a, int b) { return 0; }\n" + " }\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(Name=\"multiply\", MethodName=\"Multiply\")]\n" + " public class MultiplyHelperTwo {\n" + " public static int Multiply(int a, int b, int c) { return 0; }\n" + " }\n" + " }\n" + "\"\"\" " + "select multiply(IntPrimitive,IntPrimitive) as c0 from SupportBean"; TryInvalidCompile( env, epl, "The plug-in single-row function 'multiply' occurs multiple times"); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); var eplTwiceLocal = inlined.Replace("ConcatAggForge", "ConcatAggForgeOne") + inlined.Replace("ConcatAggForge", "ConcatAggForgeTwo") + "select concat(TheString) from SupportBean"; TryInvalidCompile( env, eplTwiceLocal, "The plug-in aggregation function 'concat' occurs multiple times"); var eplTwiceCreate = "create " + inlined.Replace("ConcatAggForge", "ConcatAggForgeOne") + ";\n" + "create " + inlined.Replace("ConcatAggForge", "ConcatAggForgeTwo") + ";\n" + "select concat(TheString) from SupportBean"; TryInvalidCompile( env, eplTwiceCreate, "The plug-in aggregation function 'concat' occurs multiple times"); var path = new RegressionPath(); env.Compile("@public create " + inlined.Replace("ConcatAggForge", "ConcatAggForgeOne"), path); env.Compile("@public create " + inlined.Replace("ConcatAggForge", "ConcatAggForgeTwo"), path); var eplTwiceInPath = "select concat(TheString) from SupportBean"; TryInvalidCompile( env, path, eplTwiceInPath, "The plug-in aggregation function 'concat' occurs multiple times"); }
public void Run(RegressionEnvironment env) { var eplTemplate = "@public create inlined_class \"\"\"\n" + "namespace ${NAMESPACE} {\n" + " public class MyClass {\n" + " public static int DoIt(int parameter) {\n" + " return ${REPLACE};\n" + " }\n" + " }\n" + "}\n" + "\"\"\"\n"; var ns1 = NamespaceGenerator.Create(); var ns2 = NamespaceGenerator.Create(); var compiledReturnZero = env.Compile( eplTemplate .Replace("${REPLACE}", "0") .Replace("${NAMESPACE}", ns1)); var compiledReturnPlusOne = env.Compile( eplTemplate .Replace("${REPLACE}", "parameter+1") .Replace("${NAMESPACE}", ns2)); var path = new RegressionPath(); path.Add(compiledReturnZero); var compiledQuery = env.Compile($"@Name('s0') select {ns2}.MyClass.DoIt(IntPrimitive) as c0 from SupportBean;\n", path); env.Deploy(compiledReturnPlusOne); env.Deploy(compiledQuery).AddListener("s0"); SendSBAssert(env, "E1", 10, 11); env.Milestone(0); SendSBAssert(env, "E2", 20, 21); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); foreach (var module in new string[] { "XXX", "YYY", "ZZZ" }) { var epl = "module " + module + "; " + "@public create " + inlined .Replace("ConcatAggForge", $"ConcatAggForge{module}") .Replace("builder.ToString()", $"\"{module}\""); env.CompileDeploy(epl, path); } var eplSelect = "uses YYY; @Name('s0') select concat(TheString) as c0 from SupportBean"; env.CompileDeploy(eplSelect, path).AddListener("s0"); SendAssertConcat(env, "A", "YYY"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var eplWindow = "create window MyWindow#keepall as (TheString string);\n" + "on SupportBean merge MyWindow insert select TheString;\n"; env.CompileDeploy(eplWindow, path); env.SendEventBean(new SupportBean("E1", 1)); var eplFAF = "inlined_class \"\"\"\n" + " namespace %NAMESPACE% {\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(Name=\"appendDelimiters\", MethodName=\"DoIt\")]\n" + " public class MyClass {\n" + " public static string DoIt(string parameter) {\n" + " return '>' + parameter + '<';\n" + " }\n" + " }\n" + " }\n" + "\"\"\"\n select appendDelimiters(TheString) as c0 from MyWindow"; var ns1 = NamespaceGenerator.Create(); var result = env.CompileExecuteFAF(eplFAF.Replace("%NAMESPACE%", ns1), path); Assert.AreEqual(">E1<", result.Array[0].Get("c0")); env.Milestone(0); var ns2 = NamespaceGenerator.Create(); result = env.CompileExecuteFAF(eplFAF.Replace("%NAMESPACE%", ns2), path); Assert.AreEqual(">E1<", result.Array[0].Get("c0")); env.UndeployAll(); }