public void SetUp() { var configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType("SupportBean", typeof(SupportBean)); configuration.AddEventType("SupportBean_S0", typeof(SupportBean_S0)); configuration.AddEventType("SupportBean_S1", typeof(SupportBean_S1)); configuration.EngineDefaults.LoggingConfig.IsEnableExecutionDebug = true; _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _listenerSelect = new SupportUpdateListener(); _listenerNamedWindow = new SupportUpdateListener(); }
public void SetUp() { Configuration config = SupportConfigFactory.GetConfiguration(); config.AddEventType("SupportBean", typeof(SupportBean)); epService = EPServiceProviderManager.GetDefaultProvider(config); epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, this.GetType(), GetType().FullName); } listeners = new SupportUpdateListener[10]; for (int i = 0; i < listeners.Length; i++) { listeners[i] = new SupportUpdateListener(); } }
public void TestFailedValidation() { var configuration = SupportConfigFactory.GetConfiguration(); configuration.AddPlugInSingleRowFunction("singlerow", typeof(MySingleRowFunctionTwo).FullName, "TestSingleRow"); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); try { var text = "select Singlerow('a', 'b') from " + typeof(SupportBean).FullName; _epService.EPAdministrator.CreateEPL(text); } catch (EPStatementException ex) { Assert.AreEqual("Error starting statement: Failed to validate select-clause expression 'Singlerow(\"a\",\"b\")': Could not find static method named 'TestSingleRow' in class 'com.espertech.esper.regression.client.MySingleRowFunctionTwo' with matching parameter number and expected parameter type(s) 'System.String, System.String' (nearest match found was 'TestSingleRow' taking type(s) 'System.String, System.Int32') [select Singlerow('a', 'b') from com.espertech.esper.support.bean.SupportBean]", ex.Message); } }
public void SetUp() { Configuration config = SupportConfigFactory.GetConfiguration(); config.EngineDefaults.LoggingConfig.IsEnableQueryPlan = true; epService = EPServiceProviderManager.GetDefaultProvider(config); epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, this.GetType(), GetType().FullName); } epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); epService.EPAdministrator.Configuration.AddEventType("ABean", typeof(SupportBean_S0)); listenerWindow = new SupportUpdateListener(); listenerStmtOne = new SupportUpdateListener(); listenerStmtTwo = new SupportUpdateListener(); listenerStmtDelete = new SupportUpdateListener(); }
public void SetUp() { Configuration config = SupportConfigFactory.GetConfiguration(); config.AddEventType("Sensor", typeof(SupportSensorEvent)); config.AddEventType("MyEvent", typeof(SupportBean)); config.AddEventType <SupportBean>(); config.AddEventType("S0", typeof(SupportBean_S0)); config.AddEventType("S1", typeof(SupportBean_S1)); config.AddEventType("S2", typeof(SupportBean_S2)); config.AddEventType("S3", typeof(SupportBean_S3)); config.AddEventType("S4", typeof(SupportBean_S4)); config.AddEventType("S5", typeof(SupportBean_S5)); config.AddEventType("SupportBeanRange", typeof(SupportBeanRange)); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); _listener = new SupportUpdateListener(); }
public void SetUp() { Configuration config = SupportConfigFactory.GetConfiguration(); config.AddEventType <SupportBean>(); config.AddEventType("SupportBean_ST0", typeof(SupportBean_ST0)); config.AddEventType("SupportBean_ST0_Container", typeof(SupportBean_ST0_Container)); config.AddEventType("SupportBeanComplexProps", typeof(SupportBeanComplexProps)); config.AddEventType("SupportCollection", typeof(SupportCollection)); config.AddImport(typeof(SupportBean_ST0_Container)); config.AddPlugInSingleRowFunction("makeTest", typeof(SupportBean_ST0_Container).FullName, "MakeTest"); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, this.GetType(), GetType().FullName); } }
public void SetUp() { _listener = new SupportUpdateListener(); Configuration configuration = SupportConfigFactory.GetConfiguration(); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _events = new SupportMarketDataBean[100]; for (int i = 0; i < _events.Length; i++) { _events[i] = new SupportMarketDataBean("S" + Convert.ToString(i), "id_" + Convert.ToString(i), i); } }
public void SetUp() { var configuration = SupportConfigFactory.GetConfiguration(); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); AddMapEventTypes(); AddOAEventTypes(); AddAvroEventTypes(); AddBeanTypes(); _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportMarkerInterface)); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName); } }
public void TestRegexpFilterWithDanglingMetaCharacter() { Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType <SupportBean>(); EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(configuration); epService.Initialize(); EPStatement stmt = epService.EPAdministrator.CreateEPL("select * from SupportBean where TheString regexp \"*any*\""); stmt.Events += _testListener.Update; epService.EPRuntime.SendEvent(new SupportBean()); Assert.IsFalse(_testListener.IsInvoked); stmt.Dispose(); }
public void TestFailedValidation() { var configuration = SupportConfigFactory.GetConfiguration(); configuration.AddPlugInAggregationFunctionFactory("concat", typeof(SupportPluginAggregationMethodTwoFactory).FullName); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); try { var 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.Of <int>() + "', expecting string ["); } }
public void SetUp() { Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType("SupportBean", typeof(SupportBean)); configuration.AddEventType("SupportBean_S0", typeof(SupportBean_S0)); configuration.EngineDefaults.LoggingConfig.IsEnableExecutionDebug = true; configuration.AddPlugInAggregationFunctionFactory("concat", typeof(MyConcatAggregationFunctionFactory).FullName); configuration.AddPlugInSingleRowFunction("toArray", GetType().FullName, "ToArray"); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _listener = new SupportUpdateListener(); }
public void SetUp() { var config = SupportConfigFactory.GetConfiguration(); config.AddEventType("S0", typeof(SupportBean_S0)); config.AddEventType("S1", typeof(SupportBean_S1)); config.AddEventType("S2", typeof(SupportBean_S2)); config.AddEventType("S3", typeof(SupportBean_S3)); config.AddEventType("S4", typeof(SupportBean_S4)); config.AddEventType("S5", typeof(SupportBean_S5)); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _listener = new SupportUpdateListener(); }
public void SetUp() { var configuration = SupportConfigFactory.GetConfiguration(); configuration.EngineDefaults.EventMeta.AvroSettings.TypeRepresentationMapperClass = typeof(MyTypeRepresentationMapper).FullName; configuration.EngineDefaults.EventMeta.AvroSettings.ObjectValueTypeWidenerFactoryClass = typeof(MyObjectValueTypeWidenerFactory).FullName; _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); _listener = new SupportUpdateListener(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName); } foreach (var clazz in Collections.List(typeof(SupportBean), typeof(SupportBean_S0))) { _epService.EPAdministrator.Configuration.AddEventType(clazz); } }
public void SetUp() { Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType <SupportBean>(); configuration.AddEventType <SupportBean_S0>(); configuration.AddEventType <SupportBean_S1>(); configuration.EngineDefaults.Logging.IsEnableExecutionDebug = true; epService = EPServiceProviderManager.GetDefaultProvider(configuration); epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, this.GetType(), GetType().FullName); } listenerSelect = new SupportUpdateListener(); listenerNamedWindow = new SupportUpdateListener(); }
public void SetUp() { var config = SupportConfigFactory.GetConfiguration(); config.EngineDefaults.LoggingConfig.IsEnableQueryPlan = true; _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, this.GetType(), GetType().FullName); } _epRuntime = _epService.EPRuntime; _epService.EPAdministrator.Configuration.AddEventType("SupportBean", typeof(SupportBean)); _epService.EPAdministrator.Configuration.AddEventType("ABean", typeof(SupportBean_S0)); _epService.EPAdministrator.Configuration.AddEventType("SB2", typeof(SupportBeanTwo)); _listenerStmtOne = new SupportUpdateListener(); SupportQueryPlanIndexHook.Reset(); }
private void Init(bool isAllowMultipleDataWindows) { _listener = new SupportUpdateListener(); var config = SupportConfigFactory.GetConfiguration(); config.EngineDefaults.ViewResources.IsAllowMultipleExpiryPolicies = isAllowMultipleDataWindows; _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); _epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>(); _epService.EPAdministrator.Configuration.AddEventType <SupportBean_S1>(); }
public void TestNoSchemaDOMGetter() { var configuration = SupportConfigFactory.GetConfiguration(); var desc = new ConfigurationEventTypeXMLDOM(); desc.RootElementName = "simpleEvent"; configuration.AddEventType("MyEvent", desc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName); } var stmtText = "select type?,dyn[1]?,nested.nes2?,map('a')? from MyEvent"; var stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.AddListener(_listener); EPAssertionUtil.AssertEqualsAnyOrder( new EventPropertyDescriptor[] { new EventPropertyDescriptor("type?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("dyn[1]?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("nested.nes2?", typeof(XmlNode), null, false, false, false, false, false), new EventPropertyDescriptor("map('a')?", typeof(XmlNode), null, false, false, false, false, false), }, stmt.EventType.PropertyDescriptors); SupportEventTypeAssertionUtil.AssertConsistency(stmt.EventType); var root = SupportXML.SendEvent(_epService.EPRuntime, NOSCHEMA_XML); var theEvent = _listener.AssertOneGetNewAndReset(); Assert.AreSame(root.DocumentElement.ChildNodes.Item(0), theEvent.Get("type?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(2), theEvent.Get("dyn[1]?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(3).ChildNodes.Item(0), theEvent.Get("nested.nes2?")); Assert.AreSame(root.DocumentElement.ChildNodes.Item(4), theEvent.Get("map('a')?")); SupportEventTypeAssertionUtil.AssertConsistency(theEvent); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestInvalid() { Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType("SupportBean", typeof(SupportBean)); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } try { _epService.EPRuntime.GetEventSender("ABC"); Assert.Fail(); } catch (EventTypeException ex) { Assert.AreEqual("Event type named 'ABC' could not be found", ex.Message); } EPStatement stmt = _epService.EPAdministrator.CreateEPL("insert into ABC select *, TheString as value from SupportBean"); stmt.Events += _listener.Update; try { _epService.EPRuntime.GetEventSender("ABC"); Assert.Fail("Event type named 'ABC' could not be found"); } catch (EventTypeException ex) { Assert.AreEqual( "An event sender for event type named 'ABC' could not be created as the type is internal", ex.Message); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestSenderMap() { Configuration configuration = SupportConfigFactory.GetConfiguration(); IDictionary <String, Object> myMapType = MakeMap(new[] { new Object[] { "f1", typeof(int) } }); configuration.AddEventType("MyMap", myMapType); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } // type resolved for each by the first event representation picking both up, i.e. the one with "r2" since that is the most specific URI EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from MyMap"); stmt.Events += _listener.Update; // send right event EventSender sender = _epService.EPRuntime.GetEventSender("MyMap"); IDictionary <String, Object> myMap = MakeMap(new[] { new Object[] { "f1", 10 } }); sender.SendEvent(myMap); Assert.AreEqual(10, _listener.AssertOneGetNewAndReset().Get("f1")); // send wrong event try { sender.SendEvent(new SupportBean()); Assert.Fail(); } catch (EPException ex) { Assert.AreEqual( "Unexpected event object of type com.espertech.esper.support.bean.SupportBean, expected " + typeof(IDictionary <string, object>).FullName, ex.Message); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestElementNode() { // test for Esper-129 var configuration = SupportConfigFactory.GetConfiguration(); var desc = new ConfigurationEventTypeXMLDOM(); desc.AddXPathProperty("event.type", "//event/@type", XPathResultType.String); desc.AddXPathProperty("event.uid", "//event/@uid", XPathResultType.String); desc.RootElementName = "batch-event"; configuration.AddEventType("MyEvent", desc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName); } _updateListener = new SupportUpdateListener(); var stmt = "select event.type as type, event.uid as uid from MyEvent"; var joinView = _epService.EPAdministrator.CreateEPL(stmt); joinView.AddListener(_updateListener); var xml = "<batch-event>" + "<event type=\"a-f-G\" uid=\"terminal.55\" time=\"2007-04-19T13:05:20.22Z\" version=\"2.0\"/>" + "</batch-event>"; var doc = new XmlDocument(); doc.LoadXml(xml); var topElement = doc.DocumentElement; _epService.EPRuntime.SendEvent(topElement); var theEvent = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual("a-f-G", theEvent.Get("type")); Assert.AreEqual("terminal.55", theEvent.Get("uid")); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TryNativeBeanAccessor(CodeGenerationEnum codeGeneration) { var config = SupportConfigFactory.GetConfiguration(); var legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = AccessorStyleEnum.NATIVE; legacyDef.CodeGeneration = codeGeneration; legacyDef.AddFieldProperty("explicitFInt", "fieldIntPrimitive"); legacyDef.AddMethodProperty("explicitMGetInt", "GetIntPrimitive"); legacyDef.AddMethodProperty("explicitMReadInt", "ReadIntPrimitive"); config.AddEventType("MyLegacyEvent", typeof(SupportLegacyBeanInt).FullName, legacyDef); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } var statementText = "select IntPrimitive, explicitFInt, explicitMGetInt, explicitMReadInt " + " from MyLegacyEvent#length(5)"; var statement = _epService.EPAdministrator.CreateEPL(statementText); var listener = new SupportUpdateListener(); statement.Events += listener.Update; var eventType = statement.EventType; var theEvent = new SupportLegacyBeanInt(10); _epService.EPRuntime.SendEvent(theEvent); foreach (var name in new String[] { "IntPrimitive", "explicitFInt", "explicitMGetInt", "explicitMReadInt" }) { Assert.AreEqual(typeof(int), eventType.GetPropertyType(name)); Assert.AreEqual(10, listener.LastNewData[0].Get(name)); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } _epService.Dispose(); }
public void TestSchemaXMLWSchemaWithRestriction() { var config = SupportConfigFactory.GetConfiguration(); var eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "order"; var schemaStream = ResourceManager.GetResourceAsStream(CLASSLOADER_SCHEMA_WITH_RESTRICTION_URI); Assert.IsNotNull(schemaStream); var schemaReader = new StreamReader(schemaStream); var schemaText = schemaReader.ReadToEnd(); schemaReader.Close(); schemaStream.Close(); eventTypeMeta.SchemaText = schemaText; config.AddEventType("OrderEvent", eventTypeMeta); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName); } _updateListener = new SupportUpdateListener(); var text = "select order_amount from OrderEvent"; var stmt = _epService.EPAdministrator.CreateEPL(text); stmt.AddListener(_updateListener); SupportXML.SendEvent(_epService.EPRuntime, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<order>\n" + "<order_amount>202.1</order_amount>" + "</order>"); var theEvent = _updateListener.LastNewData[0]; Assert.AreEqual(typeof(double), theEvent.Get("order_amount").GetType()); Assert.AreEqual(202.1d, theEvent.Get("order_amount")); _updateListener.Reset(); }
public void TestObjectArrayInheritanceInitTime() { var configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType("RootEvent", new String[] { "base" }, new Object[] { typeof(String) }); configuration.AddEventType("Sub1Event", new String[] { "sub1" }, new Object[] { typeof(String) }); configuration.AddEventType("Sub2Event", new String[] { "sub2" }, new Object[] { typeof(String) }); configuration.AddEventType("SubAEvent", new String[] { "suba" }, new Object[] { typeof(String) }); configuration.AddEventType("SubBEvent", new String[] { "subb" }, new Object[] { typeof(String) }); configuration.AddObjectArraySuperType("Sub1Event", "RootEvent"); configuration.AddObjectArraySuperType("Sub2Event", "RootEvent"); configuration.AddObjectArraySuperType("SubAEvent", "Sub1Event"); configuration.AddObjectArraySuperType("SubBEvent", "SubAEvent"); try { configuration.AddObjectArraySuperType("SubBEvent", "Sub2Event"); Assert.Fail(); } catch (ConfigurationException ex) { Assert.AreEqual("Object-array event types may not have multiple supertypes", ex.Message); } var epService = EPServiceProviderManager.GetDefaultProvider(configuration); epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, GetType(), GetType().FullName); } EPAssertionUtil.AssertEqualsExactOrder(new [] { new EventPropertyDescriptor("base", typeof(string), typeof(char), false, false, true, false, false), new EventPropertyDescriptor("sub1", typeof(string), typeof(char), false, false, true, false, false), new EventPropertyDescriptor("suba", typeof(string), typeof(char), false, false, true, false, false), }, ((EPServiceProviderSPI)epService).EventAdapterService.GetEventTypeByName("SubAEvent").PropertyDescriptors); RunObjectArrInheritanceAssertion(epService); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestNonOverlappingSubqueryAndInvalid() { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } // using a separate engine instance Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.EngineDefaults.ExecutionConfig.IsPrioritized = true; _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _epService.EPAdministrator.Configuration.AddEventType <Event>(); SendTimeEvent("2002-05-1T10:00:00.000"); String epl = "\n @Name('ctx') create context RuleActivityTime as start (0, 9, *, *, *) end (0, 17, *, *, *);" + "\n @Name('window') context RuleActivityTime create window EventsWindow.std:firstunique(productID) as Event;" + "\n @Name('variable') create variable boolean IsOutputTriggered_2 = false;" + "\n @Name('A') context RuleActivityTime insert into EventsWindow select * from Event(not exists (select * from EventsWindow));" + "\n @Name('B') context RuleActivityTime insert into EventsWindow select * from Event(not exists (select * from EventsWindow));" + "\n @Name('C') context RuleActivityTime insert into EventsWindow select * from Event(not exists (select * from EventsWindow));" + "\n @Name('D') context RuleActivityTime insert into EventsWindow select * from Event(not exists (select * from EventsWindow));" + "\n @Name('out') context RuleActivityTime select * from EventsWindow"; _epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl); _epService.EPAdministrator.GetStatement("out").AddListener(new SupportUpdateListener()); _epService.EPRuntime.SendEvent(new Event("A1")); // invalid - subquery not the same context SupportMessageAssertUtil.TryInvalid(_epService, "insert into EventsWindow select * from Event(not exists (select * from EventsWindow))", "Failed to validate subquery number 1 querying EventsWindow: Named window by name 'EventsWindow' has been declared for context 'RuleActivityTime' and can only be used within the same context"); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
private void RunAssertionInvalid(EPServiceProvider epService) { try { Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType("MyInvalidEvent", new[] { "p00" }, new object[] { typeof(int), typeof(string) }); Assert.Fail(); } catch (ConfigurationException ex) { Assert.AreEqual("Number of property names and property types do not match, found 1 property names and 2 property types", ex.Message); } TryInvalid(epService, "select XXX from MyObjectArrayEvent#length(5)"); TryInvalid(epService, "select myString * 2 from MyObjectArrayEvent#length(5)"); TryInvalid(epService, "select String.Trim(myInt) from MyObjectArrayEvent#length(5)"); var invalidOAConfig = new ConfigurationEventTypeObjectArray(); invalidOAConfig.SuperTypes = new HashSet <string>(Collections.List("A", "B")); var invalidOANames = new[] { "p00" }; var invalidOATypes = new object[] { typeof(int) }; try { Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType("MyInvalidEventTwo", invalidOANames, invalidOATypes, invalidOAConfig); Assert.Fail(); } catch (ConfigurationException ex) { Assert.AreEqual("Object-array event types only allow a single supertype", ex.Message); } try { epService.EPAdministrator.Configuration.AddEventType("MyInvalidOA", invalidOANames, invalidOATypes, invalidOAConfig); Assert.Fail(); } catch (ConfigurationException ex) { Assert.AreEqual("Object-array event types only allow a single supertype", ex.Message); } try { epService.EPAdministrator.CreateEPL("create objectarray schema InvalidOA () inherits A, B"); Assert.Fail(); } catch (EPStatementException ex) { Assert.AreEqual("Error starting statement: Object-array event types only allow a single supertype [create objectarray schema InvalidOA () inherits A, B]", ex.Message); } epService.EPAdministrator.DestroyAllStatements(); }
public void TestNestedXMLDOMGetter() { Configuration configuration = SupportConfigFactory.GetConfiguration(); ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "a"; xmlDOMEventTypeDesc.AddXPathProperty("element1", "/a/b/c", XPathResultType.String); configuration.AddEventType("AEvent", xmlDOMEventTypeDesc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _updateListener = new SupportUpdateListener(); String stmt = "select b.c as type, element1, result1 from AEvent"; EPStatement joinView = _epService.EPAdministrator.CreateEPL(stmt); joinView.Events += _updateListener.Update; SendXMLEvent("<a><b><c></c></b></a>"); EventBean theEvent = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual("", theEvent.Get("type")); Assert.AreEqual("", theEvent.Get("element1")); SendXMLEvent("<a><b></b></a>"); theEvent = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual(null, theEvent.Get("type")); Assert.AreEqual(null, theEvent.Get("element1")); SendXMLEvent("<a><b><c>text</c></b></a>"); theEvent = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual("text", theEvent.Get("type")); Assert.AreEqual("text", theEvent.Get("element1")); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestNamespaceXPathRelative() { Configuration configuration = SupportConfigFactory.GetConfiguration(); ConfigurationEventTypeXMLDOM desc = new ConfigurationEventTypeXMLDOM(); desc.RootElementName = "getQuote"; desc.DefaultNamespace = "http://services.samples/xsd"; desc.RootElementNamespace = "http://services.samples/xsd"; desc.AddNamespacePrefix("m0", "http://services.samples/xsd"); desc.IsXPathResolvePropertiesAbsolute = false; desc.IsXPathPropertyExpr = true; configuration.AddEventType("StockQuote", desc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _updateListener = new SupportUpdateListener(); String stmt = "select request.symbol as symbol_a, symbol as symbol_b from StockQuote"; EPStatement joinView = _epService.EPAdministrator.CreateEPL(stmt); joinView.Events += _updateListener.Update; String xml = "<m0:getQuote xmlns:m0=\"http://services.samples/xsd\"><m0:request><m0:symbol>IBM</m0:symbol></m0:request></m0:getQuote>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); _epService.EPRuntime.SendEvent(doc); EventBean theEvent = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual("IBM", theEvent.Get("symbol_a")); Assert.AreEqual("IBM", theEvent.Get("symbol_b")); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestPrimitivesTypes() { _properties = new Properties(); _properties["MyInt"] = typeof(int).FullName; _properties["byteArr"] = typeof(byte[]).FullName; _properties["MyInt2"] = "int"; _properties["double"] = "double"; _properties["boolean"] = "boolean"; _properties["long"] = "long"; _properties["astring"] = "string"; Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType("MyPrimMapEvent", _properties); _epService = EPServiceProviderManager.GetProvider("testPrimitivesTypes", configuration); _epService.Dispose(); }
public void TestSimpleXMLXPathGetter() { Configuration configuration = SupportConfigFactory.GetConfiguration(); ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myevent"; xmlDOMEventTypeDesc.IsXPathPropertyExpr = true; // <== XPath getter configuration.AddEventType("TestXMLNoSchemaType", xmlDOMEventTypeDesc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _updateListener = new SupportUpdateListener(); String stmt = "select element1, invalidelement, " + "element4.element41 as nestedElement," + "element2.element21('e21_2') as mappedElement," + "element2.element21[1] as indexedElement," + "element3.myattribute as invalidattribute " + "from TestXMLNoSchemaType.win:length(100)"; EPStatement joinView = _epService.EPAdministrator.CreateEPL(stmt); joinView.Events += _updateListener.Update; // Generate document with the specified in element1 to confirm we have independent events SendEvent("EventA"); AssertDataGetter("EventA", false); SendEvent("EventB"); AssertDataGetter("EventB", false); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void SetUp() { Configuration config = SupportConfigFactory.GetConfiguration(); config.EngineDefaults.LoggingConfig.IsEnableQueryPlan = true; config.AddEventType(typeof(SupportBeanInt)); config.AddImport(typeof(SupportJoinMethods).FullName); config.AddVariable("var1", typeof(int?), 0); config.AddVariable("var2", typeof(int?), 0); config.AddVariable("var3", typeof(int?), 0); config.AddVariable("var4", typeof(int?), 0); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _listener = new SupportUpdateListener(); }