public void TestXPathArray() { 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>"; ConfigurationEventTypeXMLDOM desc = new ConfigurationEventTypeXMLDOM(); desc.RootElementName = "Event"; desc.AddXPathProperty("A", "//Field[@Name='A']/@Value", XPathResultType.NodeSet, "String[]"); _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration()); _epService.Initialize(); _epService.EPAdministrator.Configuration.AddEventType("Event", desc); EPStatement stmt = _epService.EPAdministrator.CreateEPL("select * from Event"); _updateListener = new SupportUpdateListener(); stmt.Events += _updateListener.Update; var doc = XDocument.Parse(xml); _epService.EPRuntime.SendEvent(doc.Root); EventBean theEvent = _updateListener.AssertOneGetNewAndReset(); Object value = theEvent.Get("A"); EPAssertionUtil.AssertProps( theEvent, new String[] { "A" }, new Object[] { new Object[] { "987654321", "9876543210" } }); }
public void TestNoSchemaXPathGetter() { Configuration configuration = SupportConfigFactory.GetConfiguration(); ConfigurationEventTypeXMLDOM desc = new ConfigurationEventTypeXMLDOM(); desc.RootElementName = "simpleEvent"; desc.IsXPathPropertyExpr = true; configuration.AddEventType("MyEvent", desc); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } String stmtText = "select type?,dyn[1]?,nested.nes2?,map('a')?,other? from MyEvent"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.Events += _listener.Update; EPAssertionUtil.AssertEqualsAnyOrder(new[] { 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), new EventPropertyDescriptor("other?", typeof(XmlNode), null, false, false, false, false, false), }, stmt.EventType.PropertyDescriptors); EventTypeAssertionUtil.AssertConsistency(stmt.EventType); XmlDocument root = SupportXML.SendEvent(_epService.EPRuntime, NOSCHEMA_XML); EventBean 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')?")); Assert.IsNull(theEvent.Get("other?")); EventTypeAssertionUtil.AssertConsistency(theEvent); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestMemoryRFIDEvent() { Configuration config = SupportConfigFactory.GetConfiguration(); config.AddEventType("LR", typeof(SupportRFIDEvent).FullName); EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(config); epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, GetType(), GetType().FullName); } const string expression = "select 'Tag May Be Broken' as alert, " + "tagMayBeBroken.mac, " + "tagMayBeBroken.zoneID " + "from pattern [" + "every tagMayBeBroken=LR -> (timer:interval(10 sec) and not LR(mac=tagMayBeBroken.mac))" + "]"; EPStatement statement = epService.EPAdministrator.CreateEPL(expression); var listener = new SupportUpdateListener(); statement.Events += listener.Update; for (int i = 0; i < 10000; i++) { /* * if (i % 1000 == 0) * { * log.Info(".testMemoryRFIDEvent now at " + i); * } */ var theEvent = new SupportRFIDEvent("a", "111"); epService.EPRuntime.SendEvent(theEvent); theEvent = new SupportRFIDEvent("a", "111"); epService.EPRuntime.SendEvent(theEvent); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
public void TestSchemaXMLWSchemaWithRestriction() { Configuration config = SupportConfigFactory.GetConfiguration(); ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.RootElementName = "order"; var schemaStream = ResourceManager.GetResourceAsStream(CLASSLOADER_SCHEMA_WITH_RESTRICTION_URI); Assert.NotNull(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, GetType(), GetType().FullName); } _updateListener = new SupportUpdateListener(); String text = "select order_amount from OrderEvent"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(text); stmt.Events += _updateListener.Update; SupportXML.SendEvent(_epService.EPRuntime, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<order>\n" + "<order_amount>202.1</order_amount>" + "</order>"); EventBean 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 SetUp() { var configuration = SupportConfigFactory.GetConfiguration(); var avroSchema = SchemaBuilder.Record(SupportEventInfra.AVRO_TYPENAME, TypeBuilder.Field("intPrimitive", TypeBuilder.Int())); //SchemaBuilder.Record(SupportEventInfra.AVRO_TYPENAME).Fields() // .Name("intPrimitive").Type().IntType().NoDefault().EndRecord(); string avroSchemaText = avroSchema.ToString().Replace("\"", """); string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<esper-configuration>\t\n" + "\t<event-type name=\"MyStaticBean\" class=\"" + typeof(SupportBean).FullName + "\"/>\n" + "\t<event-type name=\"" + SupportEventInfra.MAP_TYPENAME + "\">\n" + "\t\t<map>\n" + "\t \t\t<map-property name=\"intPrimitive\" class=\"int\"/>\n" + "\t \t</map>\n" + "\t</event-type>\n" + "\t\n" + "\t<event-type name=\"" + SupportEventInfra.OA_TYPENAME + "\">\n" + "\t\t<objectarray>\n" + "\t \t\t<objectarray-property name=\"intPrimitive\" class=\"int\"/>\n" + "\t \t</objectarray>\n" + "\t</event-type>\n" + "\t<event-type name=\"" + SupportEventInfra.XML_TYPENAME + "\">\n" + "\t\t<xml-dom root-element-name=\"myevent\">\n" + "\t\t\t<xpath-property property-name=\"intPrimitive\" xpath=\"@intPrimitive\" type=\"number\"/>\n" + "\t\t</xml-dom>\n" + "\t</event-type>\n" + "\t<event-type name=\"" + SupportEventInfra.AVRO_TYPENAME + "\">\n" + "\t\t<avro schema-text=\"" + avroSchemaText + "\"/>\n" + "\t</event-type>\n" + "</esper-configuration>\n"; configuration.Configure(SupportXML.GetDocument(xml)); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName); } }
public void TestOp() { Configuration config = SupportConfigFactory.GetConfiguration(); config.EngineDefaults.Threading.IsInternalTimerEnabled = true; config.EngineDefaults.Expression.IsUdfCache = false; config.EngineDefaults.Threading.IsThreadPoolRouteExec = true; config.EngineDefaults.Threading.ThreadPoolRouteExecNumThreads = 5; config.AddEventType <SupportBean>(); config.AddImport(typeof(SupportStaticMethodLib).FullName); EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(config); epService.Initialize(); Log.Debug("Creating statements"); int countStatements = 100; SupportListenerTimerHRes listener = new SupportListenerTimerHRes(); for (int i = 0; i < countStatements; i++) { EPStatement innerStmt = epService.EPAdministrator.CreateEPL("select SupportStaticMethodLib.Sleep(10) from SupportBean"); innerStmt.Events += listener.Update; } Log.Info("Sending trigger event"); long delta = PerformanceObserver.TimeMillis(() => epService.EPRuntime.SendEvent(new SupportBean())); Assert.LessOrEqual(delta, 100, "Delta is " + delta); Thread.Sleep(2000); Assert.AreEqual(100, listener.NewEvents.Count); listener.NewEvents.Clear(); // destroy all statements epService.EPAdministrator.DestroyAllStatements(); EPStatement stmt = epService.EPAdministrator.CreateEPL("select SupportStaticMethodLib.Sleep(10) from SupportBean, SupportBean"); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean()); Thread.Sleep(100); Assert.AreEqual(1, listener.NewEvents.Count); epService.Dispose(); }
public void TestAfterCurrentRow() { Configuration config = SupportConfigFactory.GetConfiguration(); config.AddEventType("MyEvent", typeof(SupportRecogBean)); EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider( config); epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(epService, GetType(), GetType().FullName); } String text = "select * from MyEvent#keepall " + "match_recognize (" + " measures A.TheString as a, B[0].TheString as b0, B[1].TheString as b1" + " after match skip to current row" + " pattern (A B*)" + " define" + " A as A.TheString like \"A%\"," + " B as B.TheString like \"B%\"" + ")"; EPStatement stmt = epService.EPAdministrator.CreateEPL(text); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; RunAssertion(epService, listener, stmt); stmt.Dispose(); EPStatementObjectModel model = epService.EPAdministrator.CompileEPL( text); SerializableObjectCopier.Copy(model); Assert.AreEqual(text, model.ToEPL()); stmt = epService.EPAdministrator.Create(model); stmt.Events += listener.Update; Assert.AreEqual(text, stmt.Text); RunAssertion(epService, listener, stmt); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } }
private void TrySend(int numThreads, int numEventsPerThread) { Configuration config = SupportConfigFactory.GetConfiguration(); config.AddEventType("SupportBean", typeof(SupportBean)); _engine = EPServiceProviderManager.GetDefaultProvider(config); _engine.Initialize(); // setup statements _engine.EPAdministrator.CreateEPL("create window MyWindow.win:keepall() as select * from SupportBean"); _engine.EPAdministrator.CreateEPL("on SupportBean sb " + "merge MyWindow nw where nw.TheString = sb.TheString " + " when not matched then insert select * " + " when matched then Update set IntPrimitive = nw.IntPrimitive + 1"); // execute var threadPool = Executors.NewFixedThreadPool(numThreads); var future = new Future <bool?> [numThreads]; for (int i = 0; i < numThreads; i++) { future[i] = threadPool.Submit(new StmtNamedWindowMergeCallable(_engine, numEventsPerThread)); } threadPool.Shutdown(); threadPool.AwaitTermination(TimeSpan.FromSeconds(10)); // total up result for (int i = 0; i < numThreads; i++) { bool?result = future[i].GetValueOrDefault(); Assert.IsNotNull(result); Assert.IsTrue(result.Value); } // compare EventBean[] rows = _engine.EPRuntime.ExecuteQuery("select * from MyWindow").Array; Assert.AreEqual(numEventsPerThread, rows.Length); foreach (EventBean row in rows) { Assert.AreEqual(numThreads - 1, row.Get("IntPrimitive")); } //long deltaTime = endTime - startTime; //Console.Out.WriteLine("Totals updated: " + totalUpdates + " Delta cumu: " + deltaCumulative + " Delta pooled: " + deltaTime); }
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 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() { Configuration configuration = new Configuration(); configuration.AddEventType("MarketDataEvent", typeof(MarketDataEvent).FullName); configuration.EngineDefaults.EventMetaConfig.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; epService = EPServiceProviderManager.GetProvider("TestTicksPerSecondStatement", configuration); epService.Initialize(); listener = new SupportUpdateListener(); var stmt = TicksPerSecondStatement.Create(epService.EPAdministrator); stmt.Events += listener.Update; // Use external clocking for the test epService.EPRuntime.SendEvent(new TimerControlEvent(TimerControlEvent.ClockTypeEnum.CLOCK_EXTERNAL)); }
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() { 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(); }
private void Init(bool isAllowMultipleDataWindows) { _listener = new SupportUpdateListener(); var config = SupportConfigFactory.GetConfiguration(); config.EngineDefaults.ViewResourcesConfig.IsAllowMultipleExpiryPolicies = isAllowMultipleDataWindows; _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _epService.EPAdministrator.Configuration.AddEventType("SupportBean", typeof(SupportBean)); _epService.EPAdministrator.Configuration.AddEventType("SupportBean_S0", typeof(SupportBean_S0)); _epService.EPAdministrator.Configuration.AddEventType("SupportBean_S1", typeof(SupportBean_S1)); }
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 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() { var config = SupportConfigFactory.GetConfiguration(); config.EngineDefaults.Logging.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>(); _epService.EPAdministrator.Configuration.AddEventType("ABean", typeof(SupportBean_S0)); _epService.EPAdministrator.Configuration.AddEventType("SB2", typeof(SupportBeanTwo)); _listenerStmtOne = new SupportUpdateListener(); SupportQueryPlanIndexHook.Reset(); }
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() { 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 SetUp() { Configuration 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, this.GetType(), GetType().FullName); } listenerSelect = new SupportUpdateListener(); listenerNamedWindow = 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 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 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 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 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 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(); } }
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 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 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(); } }