public void TestObservationExamplePropertyExpression() { var typecfg = new ConfigurationEventTypeXMLDOM(); typecfg.RootElementName = "Sensor"; var schemaUri = ResourceManager.ResolveResourceURL(CLASSLOADER_SCHEMA_URI).ToString(); typecfg.SchemaResource = schemaUri; var configuration = SupportConfigFactory.GetConfiguration(); configuration.EngineDefaults.ViewResources.IsIterableUnbound = true; configuration.AddEventType("SensorEvent", typecfg); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName); } var stmtExampleOneText = "select ID, Observation.Command, Observation.ID,\n" + "Observation.Tag[0].ID, Observation.Tag[1].ID\n" + "from SensorEvent"; var stmtExampleOne = _epService.EPAdministrator.CreateEPL(stmtExampleOneText); var stmtExampleTwo_0 = _epService.EPAdministrator.CreateEPL("insert into ObservationStream\n" + "select ID, Observation from SensorEvent"); var stmtExampleTwo_1 = _epService.EPAdministrator.CreateEPL("select Observation.Command, Observation.Tag[0].ID from ObservationStream"); var stmtExampleThree_0 = _epService.EPAdministrator.CreateEPL("insert into TagListStream\n" + "select ID as sensorId, Observation.* from SensorEvent"); var stmtExampleThree_1 = _epService.EPAdministrator.CreateEPL("select sensorId, Command, Tag[0].ID from TagListStream"); var doc = SupportXML.GetDocument(XML); var sender = _epService.EPRuntime.GetEventSender("SensorEvent"); sender.SendEvent(doc); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleOne.First()); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_0.First()); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_1.First()); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleThree_0.First()); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleThree_1.First()); EPAssertionUtil.AssertProps(stmtExampleTwo_1.First(), "Observation.Command,Observation.Tag[0].ID".SplitCsv(), new object[] { "READ_PALLET_TAGS_ONLY", "urn:epc:1:2.24.400" }); EPAssertionUtil.AssertProps(stmtExampleThree_1.First(), "sensorId,Command,Tag[0].ID".SplitCsv(), new object[] { "urn:epc:1:4.16.36", "READ_PALLET_TAGS_ONLY", "urn:epc:1:2.24.400" }); try { _epService.EPAdministrator.CreateEPL("select Observation.Tag.ID from SensorEvent"); Assert.Fail(); } catch (EPStatementException ex) { Assert.AreEqual("Error starting statement: Failed to validate select-clause expression 'Observation.Tag.ID': Failed to resolve property 'Observation.Tag.ID' to a stream or nested property in a stream [select Observation.Tag.ID from SensorEvent]", ex.Message); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestNamespaceXPathRelative() { Configuration configuration = SupportConfigFactory.GetConfiguration(); var 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(); _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>"; var doc = XDocument.Parse(xml); _epService.EPRuntime.SendEvent(doc.Root); EventBean theEvent = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual("IBM", theEvent.Get("symbol_a")); Assert.AreEqual("IBM", theEvent.Get("symbol_b")); }
public void TestVariableAndDotMethodResolution() { // test for ESPER-341 Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddVariable("var", typeof(int), 0); ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myevent"; xmlDOMEventTypeDesc.AddXPathProperty("xpathAttrNum", "/myevent/@attrnum", XPathResultType.String, "long"); xmlDOMEventTypeDesc.AddXPathProperty("xpathAttrNumTwo", "/myevent/@attrnumtwo", XPathResultType.String, "long"); configuration.AddEventType("TestXMLNoSchemaType", xmlDOMEventTypeDesc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _updateListener = new SupportUpdateListener(); String stmtTextOne = "select var, xpathAttrNum.After(xpathAttrNumTwo) from TestXMLNoSchemaType.win:length(100)"; _epService.EPAdministrator.CreateEPL(stmtTextOne); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public override void Run(EPServiceProvider epService) { string xml = "<Event IsTriggering=\"True\">\n" + "<Field Name=\"A\" Value=\"987654321\"/>\n" + "<Field Name=\"B\" Value=\"2196958725202\"/>\n" + "<Field Name=\"C\" Value=\"1232363702\"/>\n" + "<Participants>\n" + "<Participant>\n" + "<Field Name=\"A\" Value=\"9876543210\"/>\n" + "<Field Name=\"B\" Value=\"966607340\"/>\n" + "<Field Name=\"D\" Value=\"353263010930650\"/>\n" + "</Participant>\n" + "</Participants>\n" + "</Event>"; var desc = new ConfigurationEventTypeXMLDOM(); desc.RootElementName = "Event"; desc.AddXPathProperty("A", "//Field[@Name='A']/@Value", XPathResultType.NodeSet, "string[]"); epService.EPAdministrator.Configuration.AddEventType("Event", desc); EPStatement stmt = epService.EPAdministrator.CreateEPL("select * from Event"); var updateListener = new SupportUpdateListener(); stmt.Events += updateListener.Update; XmlDocument doc = SupportXML.GetDocument(xml); epService.EPRuntime.SendEvent(doc); EventBean theEvent = updateListener.AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps(theEvent, "A".Split(','), new object[] { new object[] { "987654321", "9876543210" } }); }
public void TestNestedXMLXPathGetter() { Configuration configuration = SupportConfigFactory.GetConfiguration(); var xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "a"; xmlDOMEventTypeDesc.IsXPathPropertyExpr = true; xmlDOMEventTypeDesc.AddXPathProperty("element1", "/a/b/c", XPathResultType.String); configuration.AddEventType("AEvent", xmlDOMEventTypeDesc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); _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")); }
public override void Configure(Configuration configuration) { var xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myroot"; configuration.AddEventType("AEvent", xmlDOMEventTypeDesc); }
public void TestEventXML() { Configuration configuration = SupportConfigFactory.GetConfiguration(); ConfigurationEventTypeXMLDOM desc = new ConfigurationEventTypeXMLDOM(); desc.AddXPathProperty("event.type", "/event/@type", XPathResultType.String); desc.AddXPathProperty("event.uid", "/event/@uid", XPathResultType.String); desc.RootElementName = "event"; configuration.AddEventType("MyEvent", desc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _updateListener = new SupportUpdateListener(); String stmt = "select event.type as type, event.uid as uid from MyEvent"; EPStatement joinView = _epService.EPAdministrator.CreateEPL(stmt); joinView.Events += _updateListener.Update; SendXMLEvent("<event type=\"a-f-G\" uid=\"terminal.55\" time=\"2007-04-19T13:05:20.22Z\" version=\"2.0\"></event>"); EventBean theEvent = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual("a-f-G", theEvent.Get("type")); Assert.AreEqual("terminal.55", theEvent.Get("uid")); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public override void Run(EPServiceProvider epService) { // Note that XPath Node results when transposed must be queried by XPath that is also absolute. // For example: "nested1" => "/n0:simpleEvent/n0:nested1" results in a Node. // That result Node's "prop1" => "/n0:simpleEvent/n0:nested1/n0:prop1" and "/n0:nested1/n0:prop1" does NOT result in a value. // Therefore property transposal is disabled for Property-XPath expressions. var eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "simpleEvent"; string schemaUri = SupportContainer.Instance.ResourceManager().ResolveResourceURL(CLASSLOADER_SCHEMA_URI).ToString(); eventTypeMeta.SchemaResource = schemaUri; eventTypeMeta.IsXPathPropertyExpr = true; // <== note this eventTypeMeta.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); epService.EPAdministrator.Configuration.AddEventType("TestXMLSchemaType", eventTypeMeta); // note class not a fragment EPStatement stmtInsert = epService.EPAdministrator.CreateEPL("insert into MyNestedStream select nested1 from TestXMLSchemaType#lastevent"); EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] { new EventPropertyDescriptor("nested1", typeof(XmlNode), null, false, false, false, false, false), }, stmtInsert.EventType.PropertyDescriptors); SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.EventType); EventType type = ((EPServiceProviderSPI)epService).EventAdapterService.GetEventTypeByName("TestXMLSchemaType"); SupportEventTypeAssertionUtil.AssertConsistency(type); Assert.IsNull(type.GetFragmentType("nested1")); Assert.IsNull(type.GetFragmentType("nested1.nested2")); SupportXML.SendDefaultEvent(epService.EPRuntime, "ABC"); SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.First()); }
public override void Run(EPServiceProvider epService) { var container = SupportContainer.Instance; var config = new ConfigurationEventTypeXMLDOM(); string schemaUri = container.ResourceManager().ResolveResourceURL("regression/mediaOrderSchema.xsd").ToString(); config.SchemaResource = schemaUri; config.RootElementName = "mediaorder"; epService.EPAdministrator.Configuration.AddEventType("MediaOrder", config); epService.EPAdministrator.Configuration.AddEventType("Cancel", config); var xmlStreamOne = container.ResourceManager().GetResourceAsStream("regression/mediaOrderOne.xml"); var eventDocOne = SupportXML.GetDocument(xmlStreamOne); var xmlStreamTwo = container.ResourceManager().GetResourceAsStream("regression/mediaOrderTwo.xml"); var eventDocTwo = SupportXML.GetDocument(xmlStreamTwo); RunAssertionExample(epService, eventDocOne); RunAssertionJoinSelfJoin(epService, eventDocOne, eventDocTwo); RunAssertionJoinSelfLeftOuterJoin(epService, eventDocOne, eventDocTwo); RunAssertionJoinSelfFullOuterJoin(epService, eventDocOne, eventDocTwo); RunAssertionSolutionPattern(epService); }
public void TestExpressionSimpleXPathGetter() { var eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "simpleEvent"; var schemaUri = ResourceManager.ResolveResourceURL(CLASSLOADER_SCHEMA_URI).ToString(); eventTypeMeta.SchemaResource = schemaUri; eventTypeMeta.IsXPathPropertyExpr = true; // <== note this eventTypeMeta.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); _epService.EPAdministrator.Configuration.AddEventType("TestXMLSchemaType", eventTypeMeta); // note class not a fragment var stmtInsert = _epService.EPAdministrator.CreateEPL("insert into MyNestedStream select nested1 from TestXMLSchemaType#lastevent"); EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] { new EventPropertyDescriptor("nested1", typeof(XmlNode), null, false, false, false, false, false), }, stmtInsert.EventType.PropertyDescriptors); SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.EventType); EventType type = ((EPServiceProviderSPI)_epService).EventAdapterService.GetEventTypeByName("TestXMLSchemaType"); SupportEventTypeAssertionUtil.AssertConsistency(type); Assert.IsNull(type.GetFragmentType("nested1")); Assert.IsNull(type.GetFragmentType("nested1.nested2")); SupportXML.SendDefaultEvent(_epService.EPRuntime, "ABC"); SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.First()); }
public override void Run(EPServiceProvider epService) { var eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "simpleEvent"; // eventTypeMeta.IsXPathPropertyExpr = false; <== the default epService.EPAdministrator.Configuration.AddEventType("TestXMLSchemaType", eventTypeMeta); EPStatement stmtInsert = epService.EPAdministrator.CreateEPL("insert into MyNestedStream select nested1 from TestXMLSchemaType"); EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] { new EventPropertyDescriptor("nested1", typeof(string), typeof(char), false, false, true, false, false), }, stmtInsert.EventType.PropertyDescriptors); SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.EventType); EPStatement stmtSelectWildcard = epService.EPAdministrator.CreateEPL("select * from TestXMLSchemaType"); EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[0], stmtSelectWildcard.EventType.PropertyDescriptors); SupportEventTypeAssertionUtil.AssertConsistency(stmtSelectWildcard.EventType); SupportXML.SendDefaultEvent(epService.EPRuntime, "test"); EventBean stmtInsertWildcardBean = stmtInsert.First(); EventBean stmtSelectWildcardBean = stmtSelectWildcard.First(); Assert.IsNotNull(stmtInsertWildcardBean.Get("nested1")); SupportEventTypeAssertionUtil.AssertConsistency(stmtSelectWildcardBean); SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.First()); Assert.AreEqual(0, stmtSelectWildcardBean.EventType.PropertyNames.Length); }
public void SetUp() { _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration()); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } var config = new ConfigurationEventTypeXMLDOM(); var schemaUri = ResourceManager.ResolveResourceURL("regression/mediaOrderSchema.xsd").ToString(); config.SchemaResource = schemaUri; config.RootElementName = "mediaorder"; _epService.EPAdministrator.Configuration.AddEventType("MediaOrder", config); _epService.EPAdministrator.Configuration.AddEventType("Cancel", config); var xmlStreamOne = ResourceManager.GetResourceAsStream("regression/mediaOrderOne.xml"); _eventDocOne = SupportXML.GetDocument(xmlStreamOne); var xmlStreamTwo = ResourceManager.GetResourceAsStream("regression/mediaOrderTwo.xml"); _eventDocTwo = SupportXML.GetDocument(xmlStreamTwo); }
private void AddXMLEventType(Configuration configuration) { var eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "myevent"; string schema = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<xs:schema targetNamespace=\"http://www.espertech.com/schema/esper\" elementFormDefault=\"qualified\" xmlns:esper=\"http://www.espertech.com/schema/esper\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" + "\t<xs:element name=\"myevent\">\n" + "\t\t<xs:complexType>\n" + "\t\t\t<xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\n" + "\t\t\t\t<xs:choice>\n" + "\t\t\t\t\t<xs:element ref=\"esper:Nested\" minOccurs=\"1\" maxOccurs=\"1\"/>\n" + "\t\t\t\t</xs:choice>\n" + "\t\t\t</xs:sequence>\n" + "\t\t\t<xs:attribute name=\"MyInt\" type=\"xs:int\" use=\"required\"/>\n" + "\t\t\t<xs:attribute name=\"MyString\" type=\"xs:string\" use=\"required\"/>\n" + "\t\t</xs:complexType>\n" + "\t</xs:element>\n" + "\t<xs:element name=\"Nested\">\n" + "\t\t<xs:complexType>\n" + "\t\t\t<xs:attribute name=\"MyInsideInt\" type=\"xs:int\" use=\"required\"/>\n" + "\t\t</xs:complexType>\n" + "\t</xs:element>\n" + "</xs:schema>\n"; eventTypeMeta.SchemaText = schema; configuration.AddEventType(XML_TYPENAME, eventTypeMeta); }
public override void Configure(Configuration configuration) { var desc = new ConfigurationEventTypeXMLDOM(); desc.RootElementName = "simpleEvent"; configuration.AddEventType("MyEvent", desc); }
public void ReplaceXMLEventType(String xmlEventTypeName, ConfigurationEventTypeXMLDOM config) { SchemaModel schemaModel = null; if (config.SchemaResource != null || config.SchemaText != null) { try { schemaModel = XSDSchemaMapper.LoadAndMap(config.SchemaResource, config.SchemaText); } catch (Exception ex) { throw new ConfigurationException(ex.Message, ex); } } try { _eventAdapterService.ReplaceXMLEventType(xmlEventTypeName, config, schemaModel); } catch (EventAdapterException e) { throw new ConfigurationException("Error updating XML event type: " + e.Message, e); } }
public void TestSimpleXMLXPathGetter() { Configuration configuration = SupportConfigFactory.GetConfiguration(); var xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myevent"; xmlDOMEventTypeDesc.IsXPathPropertyExpr = true; // <== XPath getter configuration.AddEventType("TestXMLNoSchemaType", xmlDOMEventTypeDesc); _epService = EPServiceProviderManager.GetProvider("TestNoSchemaXML", configuration); _epService.Initialize(); _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#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); }
public void SetUp() { _container = SupportContainer.Reset(); var schemaUrl = _container.ResourceManager().ResolveResourceURL("regression/simpleSchema.xsd"); var configNoNS = new ConfigurationEventTypeXMLDOM(); configNoNS.IsXPathPropertyExpr = true; configNoNS.SchemaResource = schemaUrl.ToString(); configNoNS.RootElementName = "simpleEvent"; configNoNS.AddXPathProperty("customProp", "count(/ss:simpleEvent/ss:nested3/ss:nested4)", XPathResultType.Number); configNoNS.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); var model = XSDSchemaMapper.LoadAndMap( schemaUrl.ToString(), null, SupportEngineImportServiceFactory.Make(_container), _container.ResourceManager()); var eventTypeNoNS = new SchemaXMLEventType( null, 1, configNoNS, model, _container.Resolve <EventAdapterService>(), _container.LockManager()); var noNSDoc = new XmlDocument(); using (var stream = _container.ResourceManager().GetResourceAsStream("regression/simpleWithSchema.xml")) { noNSDoc.Load(stream); } _eventSchemaOne = new XMLEventBean(noNSDoc.DocumentElement, eventTypeNoNS); }
public override void Run(EPServiceProvider epService) { var tagcfg = new ConfigurationEventTypeXMLDOM(); tagcfg.RootElementName = "//Tag"; tagcfg.SchemaResource = _schemaUri; epService.EPAdministrator.Configuration.AddEventType("TagEvent", tagcfg); EPStatement stmtExampleOne = epService.EPAdministrator.CreateEPL("select countTags, countTagsInt, idarray, tagArray, tagOne from SensorEvent"); EPStatement stmtExampleTwo_0 = epService.EPAdministrator.CreateEPL("insert into TagOneStream select tagOne.* from SensorEvent"); EPStatement stmtExampleTwo_1 = epService.EPAdministrator.CreateEPL("select ID from TagOneStream"); EPStatement stmtExampleTwo_2 = epService.EPAdministrator.CreateEPL("insert into TagArrayStream select tagArray as mytags from SensorEvent"); EPStatement stmtExampleTwo_3 = epService.EPAdministrator.CreateEPL("select mytags[1].ID from TagArrayStream"); XmlDocument doc = SupportXML.GetDocument(OBSERVATION_XML); epService.EPRuntime.SendEvent(doc); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleOne.First()); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_0.First()); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_1.First()); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_2.First()); SupportEventTypeAssertionUtil.AssertConsistency(stmtExampleTwo_3.First()); Object resultArray = stmtExampleOne.First().Get("idarray"); EPAssertionUtil.AssertEqualsExactOrder((object[])resultArray, new string[] { "urn:epc:1:2.24.400", "urn:epc:1:2.24.401" }); EPAssertionUtil.AssertProps(stmtExampleOne.First(), "countTags,countTagsInt".Split(','), new object[] { 2d, 2 }); Assert.AreEqual("urn:epc:1:2.24.400", stmtExampleTwo_1.First().Get("ID")); Assert.AreEqual("urn:epc:1:2.24.401", stmtExampleTwo_3.First().Get("mytags[1].ID")); }
public void TestDotEscapeSyntax() { Configuration configuration = SupportConfigFactory.GetConfiguration(); ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myroot"; 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 a\\.b.c\\.d as val from AEvent"; EPStatement joinView = _epService.EPAdministrator.CreateEPL(stmt); joinView.Events += _updateListener.Update; SendXMLEvent("<myroot><a.b><c.d>value</c.d></a.b></myroot>"); EventBean theEvent = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual("value", theEvent.Get("val")); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestElementNode() { // test for Esper-129 Configuration 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(); _updateListener = new SupportUpdateListener(); const string stmt = "select event.type as type, event.uid as uid from MyEvent"; EPStatement joinView = _epService.EPAdministrator.CreateEPL(stmt); joinView.Events += _updateListener.Update; const string 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 = XDocument.Parse(xml); var topElement = doc.Root; _epService.EPRuntime.SendEvent(topElement); EventBean theEvent = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual("a-f-G", theEvent.Get("type")); Assert.AreEqual("terminal.55", theEvent.Get("uid")); }
private void RunAssertionConfiguredNotRemoved(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); epService.EPAdministrator.Configuration.AddEventType("MapType", new Dictionary <string, object>()); var xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myevent"; epService.EPAdministrator.Configuration.AddEventType("TestXMLNoSchemaType", xmlDOMEventTypeDesc); epService.EPAdministrator.CreateEPL("create schema ABCType(col1 int, col2 int)"); AssertTypeExists(epService, "ABCType", false); var moduleText = "select * from SupportBean;\n" + "select * from MapType;\n" + "select * from TestXMLNoSchemaType;\n"; var result = epService.EPAdministrator.DeploymentAdmin.ParseDeploy(moduleText, "uri", "arch", null); AssertTypeExists(epService, "SupportBean", true); AssertTypeExists(epService, "MapType", true); AssertTypeExists(epService, "TestXMLNoSchemaType", true); epService.EPAdministrator.DeploymentAdmin.UndeployRemove(result.DeploymentId); AssertTypeExists(epService, "SupportBean", true); AssertTypeExists(epService, "MapType", true); AssertTypeExists(epService, "TestXMLNoSchemaType", true); }
public void TestConfiguredNotRemoved() { _epService.EPAdministrator.Configuration.AddEventType("SupportBean", typeof(SupportBean)); _epService.EPAdministrator.Configuration.AddEventType("MapType", new Dictionary <String, Object>()); ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myevent"; _epService.EPAdministrator.Configuration.AddEventType("TestXMLNoSchemaType", xmlDOMEventTypeDesc); _epService.EPAdministrator.CreateEPL("create schema ABCType(col1 int, col2 int)"); AssertTypeExists(_epService, "ABCType", false); String moduleText = "select * from SupportBean;\n" + "select * from MapType;\n" + "select * from TestXMLNoSchemaType;\n"; DeploymentResult result = _epService.EPAdministrator.DeploymentAdmin.ParseDeploy(moduleText, "uri", "arch", null); AssertTypeExists(_epService, "SupportBean", true); AssertTypeExists(_epService, "MapType", true); AssertTypeExists(_epService, "TestXMLNoSchemaType", true); _epService.EPAdministrator.DeploymentAdmin.UndeployRemove(result.DeploymentId); AssertTypeExists(_epService, "SupportBean", true); AssertTypeExists(_epService, "MapType", true); AssertTypeExists(_epService, "TestXMLNoSchemaType", true); }
public void AddEventType(String eventTypeName, ConfigurationEventTypeXMLDOM xmlDOMEventTypeDesc) { SchemaModel schemaModel = null; CheckTableExists(eventTypeName); if ((xmlDOMEventTypeDesc.SchemaResource != null) || (xmlDOMEventTypeDesc.SchemaText != null)) { try { schemaModel = XSDSchemaMapper.LoadAndMap(xmlDOMEventTypeDesc.SchemaResource, xmlDOMEventTypeDesc.SchemaText); } catch (Exception ex) { throw new ConfigurationException(ex.Message, ex); } } try { _eventAdapterService.AddXMLDOMType(eventTypeName, xmlDOMEventTypeDesc, schemaModel, false); } catch (EventAdapterException t) { throw new ConfigurationException(t.Message, t); } }
public void TestSchemaReplace() { ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "simpleEvent"; String schemaUri = ResourceManager.ResolveResourceURL(CLASSLOADER_SCHEMA_URI).ToString(); eventTypeMeta.SchemaResource = schemaUri; eventTypeMeta.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); eventTypeMeta.AddXPathProperty("customProp", "count(/ss:simpleEvent/ss:nested3/ss:nested4)", XPathResultType.Number); Configuration configuration = SupportConfigFactory.GetConfiguration(); configuration.AddEventType("TestXMLSchemaType", eventTypeMeta); _epService = EPServiceProviderManager.GetProvider("TestSchemaXML", configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } String stmtSelectWild = "select * from TestXMLSchemaType"; EPStatement wildStmt = _epService.EPAdministrator.CreateEPL(stmtSelectWild); EventType type = wildStmt.EventType; EventTypeAssertionUtil.AssertConsistency(type); EPAssertionUtil.AssertEqualsAnyOrder(new [] { new EventPropertyDescriptor("nested1", typeof(XmlNode), null, false, false, false, false, true), new EventPropertyDescriptor("prop4", typeof(string), typeof(char), false, false, true, false, false), new EventPropertyDescriptor("nested3", typeof(XmlNode), null, false, false, false, false, true), new EventPropertyDescriptor("customProp", typeof(double?), null, false, false, false, false, false), }, type.PropertyDescriptors); // Update type and replace schemaUri = ResourceManager.ResolveResourceURL(CLASSLOADER_SCHEMA_VERSION2_URI).ToString(); eventTypeMeta.SchemaResource = schemaUri; eventTypeMeta.AddXPathProperty("countProp", "count(/ss:simpleEvent/ss:nested3/ss:nested4)", XPathResultType.Number); _epService.EPAdministrator.Configuration.ReplaceXMLEventType("TestXMLSchemaType", eventTypeMeta); wildStmt = _epService.EPAdministrator.CreateEPL(stmtSelectWild); type = wildStmt.EventType; EventTypeAssertionUtil.AssertConsistency(type); EPAssertionUtil.AssertEqualsAnyOrder(new [] { new EventPropertyDescriptor("nested1", typeof(XmlNode), null, false, false, false, false, true), new EventPropertyDescriptor("prop4", typeof(string), typeof(char), false, false, true, false, false), new EventPropertyDescriptor("prop5", typeof(string), typeof(char), false, false, true, false, false), new EventPropertyDescriptor("nested3", typeof(XmlNode), null, false, false, false, false, true), new EventPropertyDescriptor("customProp", typeof(double?), null, false, false, false, false, false), new EventPropertyDescriptor("countProp", typeof(double?), null, false, false, false, false, false), }, type.PropertyDescriptors); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
private static ConfigurationEventTypeXMLDOM GetXMLDOMConfig() { var config = new ConfigurationEventTypeXMLDOM(); config.RootElementName = "simpleEvent"; config.AddXPathProperty("nested1", "/simpleEvent/nested1", XPathResultType.String); return(config); }
public override void Configure(Configuration configuration) { var typeMeta = new ConfigurationEventTypeXMLDOM(); typeMeta.RootElementName = "a"; typeMeta.AddXPathProperty("element1", "/a/b/c", XPathResultType.String); configuration.AddEventType("AEvent", typeMeta); }
public override void Configure(Configuration configuration) { var xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myevent"; xmlDOMEventTypeDesc.IsXPathPropertyExpr = false; // <== DOM getter configuration.AddEventType("TestXMLNoSchemaType", xmlDOMEventTypeDesc); }
public override void Configure(Configuration configuration) { var xmlDOMEventTypeDesc = new ConfigurationEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "a"; xmlDOMEventTypeDesc.AddXPathProperty("element1", "/a/b/c", XPathResultType.String); configuration.AddEventType("AEvent", xmlDOMEventTypeDesc); }
private void RunAssertionAddDOMType(EPServiceProvider epService) { TryInvalid(epService, "AddedDOMOne"); // First statement with new name var domConfig = new ConfigurationEventTypeXMLDOM(); domConfig.RootElementName = "RootAddedDOMOne"; epService.EPAdministrator.Configuration.AddEventType("AddedDOMOne", domConfig); EPStatement stmt = epService.EPAdministrator.CreateEPL("select * from AddedDOMOne"); var testListener = new SupportUpdateListener(); stmt.Events += testListener.Update; XmlDocument eventOne = MakeDOMEvent("RootAddedDOMOne"); epService.EPRuntime.SendEvent(eventOne); Assert.AreSame(eventOne.DocumentElement, testListener.AssertOneGetNewAndReset().Underlying); TryInvalid(epService, "AddedMapNameSecond"); // Second statement using a new name to the same type, should both receive domConfig = new ConfigurationEventTypeXMLDOM(); domConfig.RootElementName = "RootAddedDOMOne"; epService.EPAdministrator.Configuration.AddEventType("AddedDOMSecond", domConfig); epService.EPAdministrator.Configuration.AddEventType("AddedMapNameSecond", domConfig); var testListenerTwo = new SupportUpdateListener(); stmt = epService.EPAdministrator.CreateEPL("select * from AddedMapNameSecond"); stmt.Events += testListenerTwo.Update; XmlDocument eventTwo = MakeDOMEvent("RootAddedDOMOne"); epService.EPRuntime.SendEvent(eventTwo); Assert.IsTrue(testListener.IsInvoked); Assert.AreEqual(eventTwo.DocumentElement, testListenerTwo.AssertOneGetNewAndReset().Underlying); // Add the same name and type again domConfig = new ConfigurationEventTypeXMLDOM(); domConfig.RootElementName = "RootAddedDOMOne"; epService.EPAdministrator.Configuration.AddEventType("AddedDOMSecond", domConfig); // Add the same name and a different type try { domConfig = new ConfigurationEventTypeXMLDOM(); domConfig.RootElementName = "RootAddedDOMXXX"; epService.EPAdministrator.Configuration.AddEventType("AddedDOMSecond", domConfig); Assert.Fail(); } catch (ConfigurationException) { // expected } epService.EPAdministrator.DestroyAllStatements(); epService.EPAdministrator.Configuration.RemoveEventType("AddedMapNameSecond", true); }
public override void Configure(Configuration configuration) { var desc = new ConfigurationEventTypeXMLDOM(); desc.AddXPathProperty("event.type", "/event/@type", XPathResultType.String); desc.AddXPathProperty("event.uid", "/event/@uid", XPathResultType.String); desc.RootElementName = "event"; configuration.AddEventType("MyEvent", desc); }