public void Run(Configuration config) { config.Runtime.Threading.IsInternalTimerEnabled = true; config.Common.TimeSource.TimeUnit = TimeUnit.MICROSECONDS; try { EPRuntimeProvider.GetRuntime(GetType().Name, config).Initialize(); Assert.Fail(); } catch (ConfigurationException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Internal timer requires millisecond time resolution"); } config.Runtime.Threading.IsInternalTimerEnabled = false; var runtime = EPRuntimeProvider.GetRuntime(GetType().Name, config); try { runtime.EventService.ClockInternal(); Assert.Fail(); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Internal timer requires millisecond time resolution"); } runtime.Destroy(); }
public void Run(RegressionEnvironment env) { var epl = "@Name('mywindow') create window PointWindow#keepall as SupportSpatialPoint;\n" + "insert into PointWindow select * from SupportSpatialPoint;\n" + "create index MyIndex on PointWindow((Px, Py) pointregionquadtree(0, 0, 100, 100));\n"; env.CompileDeploy(epl); try { env.SendEventBean(new SupportSpatialPoint("E1", null, null)); } catch (Exception ex) { SupportMessageAssertUtil.AssertMessage( ex, "Unexpected exception in statement 'mywindow': Invalid value for index 'MyIndex' column 'x' received null and expected non-null"); } try { env.SendEventBean(new SupportSpatialPoint("E1", 200d, 200d)); } catch (Exception ex) { SupportMessageAssertUtil.AssertMessage( ex, "Unexpected exception in statement 'mywindow': Invalid value for index 'MyIndex' column '(X,Y)' received (200.0d,200.0d) and expected a value within index bounding box (range-end-non-inclusive) {MinX=0.0d, MinY=0.0d, MaxX=100.0d, MaxY=100.0d}"); } env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var epl = "@Name('mywindow') create window RectangleWindow#keepall as SupportSpatialEventRectangle;\n" + "insert into RectangleWindow select * from SupportSpatialEventRectangle;\n" + "create index MyIndex on RectangleWindow((X, Y, Width, Height) mxcifquadtree(0, 0, 100, 100));\n"; env.CompileDeploy(epl); try { env.SendEventBean(new SupportSpatialEventRectangle("E1", null, null, null, null, "category")); } catch (Exception ex) { SupportMessageAssertUtil.AssertMessage( ex, "Unexpected exception in statement 'mywindow': Invalid value for index 'MyIndex' column 'X' received null and expected non-null"); } try { env.SendEventBean(new SupportSpatialEventRectangle("E1", 200d, 200d, 1, 1)); } catch (Exception ex) { SupportMessageAssertUtil.AssertMessage( ex, "Unexpected exception in statement 'mywindow': Invalid value for index 'MyIndex' column '(X,Y,Width,Height)' received (200.0d,200.0d,1.0d,1.0d) and expected a value intersecting index bounding box (range-end-inclusive) {MinX=0.0d, MinY=0.0d, MaxX=100.0d, MaxY=100.0d}"); } env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var eplCreate = namedWindow ? "create window MyInfraIS#keepall as SupportBean" : "create table MyInfraIS(TheString string)"; env.CompileDeploy(eplCreate, path); try { env.CompileWCheckedEx("select (select TheString from MyInfraIS#lastevent) from MyInfraIS", path); Assert.Fail(); } catch (EPCompileException ex) { if (namedWindow) { StringAssert.StartsWith( "Error during compilation: " + "Failed to plan subquery number 1 querying MyInfraIS: " + "Consuming statements to a named window cannot declare a data window view onto the named window " + "[select (select TheString from MyInfraIS#lastevent) from MyInfraIS]", ex.Message); } else { SupportMessageAssertUtil.AssertMessage(ex, "Views are not supported with tables"); } } env.UndeployAll(); }
public void TestAssertionWildcardRecast() { // bean to OA/Map/bean EnumHelper.ForEach <EventRepresentationChoice>( rep => RunAssertionWildcardRecast(true, null, false, rep)); try { RunAssertionWildcardRecast(true, null, true, null); Assert.Fail(); } catch (EPStatementException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Error starting statement: Expression-returned event type 'SourceSchema' with underlying type '" + Name.Of <MyP0P1EventSource>() + "' cannot be converted to target event type 'TargetSchema' with underlying type "); } // OA RunAssertionWildcardRecast(false, EventRepresentationChoice.ARRAY, false, EventRepresentationChoice.ARRAY); RunAssertionWildcardRecast(false, EventRepresentationChoice.ARRAY, false, EventRepresentationChoice.MAP); RunAssertionWildcardRecast(false, EventRepresentationChoice.ARRAY, false, EventRepresentationChoice.AVRO); RunAssertionWildcardRecast(false, EventRepresentationChoice.ARRAY, true, null); // Map RunAssertionWildcardRecast(false, EventRepresentationChoice.MAP, false, EventRepresentationChoice.ARRAY); RunAssertionWildcardRecast(false, EventRepresentationChoice.MAP, false, EventRepresentationChoice.MAP); RunAssertionWildcardRecast(false, EventRepresentationChoice.MAP, false, EventRepresentationChoice.AVRO); RunAssertionWildcardRecast(false, EventRepresentationChoice.MAP, true, null); // Avro RunAssertionWildcardRecast(false, EventRepresentationChoice.AVRO, false, EventRepresentationChoice.ARRAY); RunAssertionWildcardRecast(false, EventRepresentationChoice.AVRO, false, EventRepresentationChoice.MAP); RunAssertionWildcardRecast(false, EventRepresentationChoice.AVRO, false, EventRepresentationChoice.AVRO); RunAssertionWildcardRecast(false, EventRepresentationChoice.AVRO, true, null); }
public void TestInvalidExceptionList() { var moduleOne = MakeModule("mymodule.one", "create schema MySchemaOne (col1 Wrong)", "create schema MySchemaOne (col2 WrongTwo)"); try { var options = new DeploymentOptions(); options.IsFailFast = false; _deploymentAdmin.Deploy(moduleOne, options); Assert.Fail(); } catch (DeploymentActionException ex) { Assert.AreEqual("Deployment failed in module 'mymodule.one' in expression 'create schema MySchemaOne (col1 Wrong)' : Error starting statement: Nestable type configuration encountered an unexpected property type name 'Wrong' for property 'col1', expected Type or DataMap or the name of a previously-declared Map or ObjectArray type [create schema MySchemaOne (col1 Wrong)]", ex.Message); Assert.AreEqual(2, ex.Exceptions.Count); Assert.AreEqual("create schema MySchemaOne (col1 Wrong)", ex.Exceptions[0].Expression); Assert.AreEqual("Error starting statement: Nestable type configuration encountered an unexpected property type name 'Wrong' for property 'col1', expected Type or DataMap or the name of a previously-declared Map or ObjectArray type [create schema MySchemaOne (col1 Wrong)]", ex.Exceptions[0].Inner.Message); Assert.AreEqual("create schema MySchemaOne (col2 WrongTwo)", ex.Exceptions[1].Expression); Assert.AreEqual("Error starting statement: Nestable type configuration encountered an unexpected property type name 'WrongTwo' for property 'col2', expected Type or DataMap or the name of a previously-declared Map or ObjectArray type [create schema MySchemaOne (col2 WrongTwo)]", ex.Exceptions[1].Inner.Message); } // test newline as part of the failing expression - replaced by space try { _deploymentAdmin.ParseDeploy("XX\nX"); Assert.Fail(); } catch (DeploymentException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Compilation failed in expression 'XX X' : Incorrect syntax near 'XX' ["); } }
public void TestInvalidSyntax() { // keyword in select clause EPStatementException exception = GetSyntaxExceptionView("select inner from MyStream"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'inner' (a reserved keyword) at line 1 column 7, please check the select clause [select inner from MyStream]"); // keyword in from clause exception = GetSyntaxExceptionView("select something from Outer"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'Outer' (a reserved keyword) at line 1 column 22, please check the from clause [select something from Outer]"); // keyword used in package exception = GetSyntaxExceptionView("select * from com.true.mycompany.MyEvent"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'true' (a reserved keyword) expecting an identifier but found 'true' at line 1 column 18, please check the view specifications within the from clause [select * from com.true.mycompany.MyEvent]"); // keyword as part of identifier exception = GetSyntaxExceptionView("select * from MyEvent, MyEvent2 where a.day=b.day"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'day' (a reserved keyword) at line 1 column 40, please check the where clause [select * from MyEvent, MyEvent2 where a.day=b.day]"); exception = GetSyntaxExceptionView("select * * from " + EVENT_NUM); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near '*' at line 1 column 9 near reserved keyword 'from' [select * * from " + Name.Of <SupportBean_N>() + "]"); // keyword in select clause exception = GetSyntaxExceptionView("select day from MyEvent, MyEvent2"); SupportMessageAssertUtil.AssertMessage(exception, "Incorrect syntax near 'day' (a reserved keyword) at line 1 column 7, please check the select clause [select day from MyEvent, MyEvent2]"); }
public void Run(RegressionEnvironment env) { var epl = "@Name('win') create window MyRectWindow#keepall as (Id string, rx double, ry double, rw double, rh double);\n" + "@Name('insert') insert into MyRectWindow select Id, X as rx, Y as ry, Width as rw, Height as rh from SupportSpatialEventRectangle;\n" + "@Name('Idx') create unique index Idx on MyRectWindow( (rx, ry, rw, rh) mxcifquadtree(0, 0, 100, 100));\n" + IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "@Name('out') on SupportSpatialAABB select mpw.Id as c0 from MyRectWindow as mpw where rectangle(rx, ry, rw, rh).intersects(rectangle(X, Y, Width, Height));\n"; env.CompileDeploy(epl).AddListener("out"); SupportQueryPlanIndexHook.AssertOnExprTableAndReset( "Idx", "unique hash={} btree={} advanced={mxcifquadtree(rx,ry,rw,rh)}"); SendEventRectangle(env, "P1", 10, 15, 1, 2); try { SendEventRectangle(env, "P1", 10, 15, 1, 2); Assert.Fail(); } catch (Exception ex) { // we have a handler SupportMessageAssertUtil.AssertMessage( ex, "Unexpected exception in statement 'win': Unique index violation, index 'Idx' is a unique index and key '(10.0d,15.0d,1.0d,2.0d)' already exists"); } env.UndeployAll(); }
private static void TryInvalidDeploy( RegressionEnvironment env, EPCompiled compiled, string text, string moduleName) { var message = "A precondition is not satisfied: " + text + " has already been created for module '" + moduleName + "'"; try { env.Runtime.DeploymentService.Deploy(compiled); Assert.Fail(); } catch (EPDeployPreconditionException ex) { Assert.That(ex.RolloutItemNumber, Is.EqualTo(-1)); if (!message.Equals("skip")) { SupportMessageAssertUtil.AssertMessage(ex.Message, message); } } catch (EPDeployException) { Assert.Fail(); } }
public void RunAssertionInvalidSubquery(bool namedWindow) { string eplCreate = namedWindow ? "create window MyInfra.win:keepall() as " + typeof(SupportBean).FullName : "create table MyInfra(TheString string)"; epService.EPAdministrator.CreateEPL(eplCreate); try { epService.EPAdministrator.CreateEPL("select (select TheString from MyInfra.std:lastevent()) from MyInfra"); Assert.Fail(); } catch (EPException ex) { if (namedWindow) { Assert.AreEqual("Error starting statement: Failed to plan subquery number 1 querying MyInfra: Consuming statements to a named window cannot declare a data window view onto the named window [select (select TheString from MyInfra.std:lastevent()) from MyInfra]", ex.Message); } else { SupportMessageAssertUtil.AssertMessage(ex, "Views are not supported with tables"); } } epService.EPAdministrator.DestroyAllStatements(); epService.EPAdministrator.Configuration.RemoveEventType("MyInfra", false); }
public override void Run(EPServiceProvider defaultEPService) { Configuration config = SupportConfigFactory.GetConfiguration(); config.EngineDefaults.Threading.IsInternalTimerEnabled = true; config.EngineDefaults.TimeSource.TimeUnit = TimeUnit.MICROSECONDS; try { EPServiceProviderManager .GetProvider(SupportContainer.Instance, this.GetType().Name, config) .Initialize(); Assert.Fail(); } catch (ConfigurationException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Internal timer requires millisecond time resolution"); } config.EngineDefaults.Threading.IsInternalTimerEnabled = false; EPServiceProvider epService = EPServiceProviderManager .GetProvider(SupportContainer.Instance, this.GetType().Name, config); try { epService.EPRuntime.SendEvent(new TimerControlEvent(TimerControlEvent.ClockTypeEnum.CLOCK_INTERNAL)); Assert.Fail(); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Internal timer requires millisecond time resolution"); } epService.Dispose(); }
private void RunAssertionAssertionWildcardRecast(EPServiceProvider epService) { // bean to OA/Map/bean foreach (EventRepresentationChoice rep in EnumHelper.GetValues <EventRepresentationChoice>()) { TryAssertionWildcardRecast(epService, true, null, false, rep); } try { TryAssertionWildcardRecast(epService, true, null, true, null); Assert.Fail(); } catch (EPStatementException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Error starting statement: Expression-returned event type 'SourceSchema' with underlying type 'com.espertech.esper.regression.epl.insertinto.ExecInsertInto+MyP0P1EventSource' cannot be converted to target event type 'TargetSchema' with underlying type "); } // OA TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.ARRAY, false, EventRepresentationChoice.ARRAY); TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.ARRAY, false, EventRepresentationChoice.MAP); TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.ARRAY, false, EventRepresentationChoice.AVRO); TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.ARRAY, true, null); // Map TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.MAP, false, EventRepresentationChoice.ARRAY); TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.MAP, false, EventRepresentationChoice.MAP); TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.MAP, false, EventRepresentationChoice.AVRO); TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.MAP, true, null); // Avro TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.AVRO, false, EventRepresentationChoice.ARRAY); TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.AVRO, false, EventRepresentationChoice.MAP); TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.AVRO, false, EventRepresentationChoice.AVRO); TryAssertionWildcardRecast(epService, false, EventRepresentationChoice.AVRO, true, null); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); env.CompileDeploy( "@Name('create') create table MyTableLUIV as (" + "pKey0 string primary key, " + "pkey1 int primary key, " + "col0 int, " + "thecnt count(*))", path); env.CompileDeploy( "into table MyTableLUIV select count(*) as thecnt from SupportBean group by TheString, IntPrimitive", path); env.SendEventBean(new SupportBean("E1", 10)); env.SendEventBean(new SupportBean("E2", 20)); // On-merge exists before creating a unique index env.CompileDeploy( "@Name('on-merge') on SupportBean_S1 merge MyTableLUIV " + "when matched then update set col0 = 0", path); try { var compiled = env.Compile("create unique index MyUniqueSecondary on MyTableLUIV (col0)", path); path.Compileds.Remove(compiled); env.Runtime.DeploymentService.Deploy(compiled); Assert.Fail(); } catch (EPDeployException ex) { SupportMessageAssertUtil.AssertMessage( ex, "Failed to deploy: Create-index adds a unique key on columns that are updated by one or more on-merge statements"); } env.UndeployModuleContaining("on-merge"); // on-update exists before creating a unique index env.CompileDeploy("@Name('on-update') on SupportBean_S1 update MyTableLUIV set pkey1 = 0", path); env.CompileDeploy("create unique index MyUniqueSecondary on MyTableLUIV (pkey1)", path); try { env.SendEventBean(new SupportBean_S1(0)); Assert.Fail(); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessage( ex, "Unexpected exception in statement 'on-update': Unique index violation, index 'MyUniqueSecondary' is a unique index and key '0' already exists"); // assert events are unchanged - no update actually performed EPAssertionUtil.AssertPropsPerRowAnyOrder( env.GetEnumerator("create"), new[] {"pKey0", "pkey1"}, new[] {new object[] {"E1", 10}, new object[] {"E2", 20}}); } // unregister env.UndeployModuleContaining("on-update"); env.UndeployAll(); }
private void RunAssertionFailedValidation(EPServiceProvider epService) { try { string text = "select concat(1) from " + typeof(SupportBean).FullName; epService.EPAdministrator.CreateEPL(text); } catch (EPStatementException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Error starting statement: Failed to validate select-clause expression 'concat(1)': Plug-in aggregation function 'concat' failed validation: Invalid parameter type '" + Name.Clean <int>() + "', expecting string ["); } }
private void TryInvalidControlCharacter(EventBean eventBean) { try { eventBean.Get("a\u008F"); Assert.Fail(); } catch (PropertyAccessException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Property named 'a\u008F' is not a valid property name for this type"); } }
private void RunAssertionInvalidGroupByNoChild(EPServiceProvider epService) { string stmtText = "select avg(price), symbol from " + typeof(SupportMarketDataBean).FullName + "#length(100)#groupwin(symbol)"; try { epService.EPAdministrator.CreateEPL(stmtText); } catch (EPStatementException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Error starting statement: Invalid use of the 'groupwin' view, the view requires one or more child views to group, or consider using the group-by clause ["); } }
private void RunAssertionInvalidViewParameter(EPServiceProvider epService) { string stmt = "select * from " + typeof(SupportBean).FullName + "#length(?)"; try { epService.EPAdministrator.PrepareEPL(stmt); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Incorrect syntax near '?' expecting a closing parenthesis ')' but found a questionmark '?' at line 1 column 70, please check the view specifications within the from clause ["); } }
private void RunAssertionInvalidCreateEPL(EPServiceProvider epService) { string stmt = "select * from " + typeof(SupportBean).FullName + "(TheString=?)"; try { epService.EPAdministrator.CreateEPL(stmt); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Failed to validate filter expression 'TheString=?': Invalid use of substitution parameters marked by '?' in statement, use the prepare method to prepare statements with substitution parameters"); } }
private void TryInvalid(string epl, string message) { try { _epService.EPAdministrator.CreateEPL(epl); Assert.Fail(); } catch (EPStatementException ex) { SupportMessageAssertUtil.AssertMessage(ex, message); } }
private void TryInvalidControlCharacters(EPServiceProvider epService) { string epl = "select * \u008F from " + typeof(SupportBean).FullName; try { epService.EPAdministrator.CreateEPL(epl); Assert.Fail(); } catch (EPStatementException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Unrecognized control characters found in text at line 1 column 8 ["); } }
private void TryInvalidControlCharacters(EPServiceProvider epService) { string epl = "select * \u008F from " + typeof(SupportBean).FullName; try { epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl); Assert.Fail(); } catch (ParseException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Unrecognized control characters found in text, failed to parse text "); } }
private void TryInvalid(String stmtText, String expectedMsg) { try { _epService.EPAdministrator.CreateEPL(stmtText); Assert.Fail(); } catch (EPStatementException ex) { SupportMessageAssertUtil.AssertMessage(ex, expectedMsg); } }
private void TryCompile(String expression, String expectedMsg) { try { _epService.EPAdministrator.CreateEPL(expression); Assert.Fail(); } catch (EPStatementSyntaxException ex) { SupportMessageAssertUtil.AssertMessage(ex, expectedMsg); } }
private void TryInvalid(EPServiceProvider epService, string clause, string message) { try { epService.EPAdministrator.CreateEPL(clause); Assert.Fail(); } catch (EPStatementException ex) { if (message != null) { SupportMessageAssertUtil.AssertMessage(ex, message); } } }
private void TryInvalidControlCharacter(EventBean eventBean) { try { eventBean.Get("a\u008F"); Assert.Fail(); } catch (PropertyAccessException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Unrecognized control characters found in text"); } }
private void TryInvalidControlCharacters() { String epl = string.Format("select * \u008F from {0}", typeof(SupportBean).FullName); try { Assert.That(epl[9], Is.EqualTo('\u008F')); _epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl); Assert.Fail(); } catch (ParseException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Unrecognized control characters found in text, failed to parse text "); } }
private void RunAssertionInvalid(string typename, object incorrectUnderlying, string message) { var sender = _epService.EPRuntime.GetEventSender(typename); try { sender.SendEvent(incorrectUnderlying); Assert.Fail(); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessage(ex, message); } }
private static void TryInvalid( RegressionEnvironment env, string json, string message) { try { env.Runtime.EventService.SendEventJson(json, "JsonEvent"); Assert.Fail(); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessage(message, ex.Message); } }
private void RunAssertionInvalidParameterType(EPServiceProvider epService) { string stmt = "select * from " + typeof(SupportBean).FullName + "(TheString=?)"; EPPreparedStatement prepared = epService.EPAdministrator.PrepareEPL(stmt); try { prepared.SetObject(1, -1); epService.EPAdministrator.Create(prepared); Assert.Fail(); } catch (EPException ex) { SupportMessageAssertUtil.AssertMessage(ex, "Failed to validate filter expression 'TheString=-1': Implicit conversion from datatype '" + Name.Clean <int>() + "' to '" + Name.Clean <string>() + "' is not allowed ["); } }
public void TestInvalidSelectWildcardProperty() { try { var stmtOneText = "select simpleProperty.* as a from " + typeof(SupportBeanComplexProps).FullName + " as s0"; _epService.EPAdministrator.CreateEPL(stmtOneText); Assert.Fail(); } catch (Exception ex) { SupportMessageAssertUtil.AssertMessage(ex, "Error starting statement: The property wildcard syntax must be used without column name"); } }