示例#1
0
        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();
            }
        }
示例#2
0
        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();
            }
        }
示例#4
0
        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();
            }
        }
示例#5
0
        public void TryBeanAccessor(CodeGenerationEnum codeGeneration)
        {
            var config    = SupportConfigFactory.GetConfiguration();
            var legacyDef = new ConfigurationEventTypeLegacy();

            legacyDef.AccessorStyle  = AccessorStyleEnum.NATIVE;
            legacyDef.CodeGeneration = codeGeneration;
            legacyDef.AddFieldProperty("explicitFInt", "fieldIntPrimitive");
            legacyDef.AddMethodProperty("explicitMGetInt", "get_IntPrimitive");
            legacyDef.AddMethodProperty("explicitMReadInt", "ReadIntPrimitive");
            config.AddEventType("MyLegacyEvent", typeof(SupportLegacyBeanInt).FullName, legacyDef);

            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName);
            }

            var statementText = "select IntPrimitive as intPrimitive, explicitFInt, explicitMGetInt, explicitMReadInt " +
                                " from MyLegacyEvent#length(5)";

            var statement = _epService.EPAdministrator.CreateEPL(statementText);
            var listener  = new SupportUpdateListener();

            statement.AddListener(listener);
            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 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();
            }
        }
示例#7
0
        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();
        }
示例#8
0
        public void SetUp()
        {
            _epService = EPServiceProviderManager.GetDefaultProvider(SupportConfigFactory.GetConfiguration());
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _updateListener = new SupportUpdateListener();

            long[] volumesOne = new long[] { 10, 20, 20, 40, 50 };
            long[] volumesTwo = new long[] { 10, 20, 30, 40, 50 };

            for (int i = 0; i < setOne.Length; i++)
            {
                setOne[i] = new SupportMarketDataBean("IBM", volumesOne[i], (long)i, "");
                setTwo[i] = new SupportMarketDataBean("CSCO", volumesTwo[i], (long)i, "");
            }
        }
        public void SetUp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.ViewResources.IsShareViews = false;
            config.AddEventType("MyEvent", typeof(SupportRecogBean));
            config.EngineDefaults.Execution.IsAllowIsolatedService = true;

            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _listener = new SupportUpdateListener();

            _epService.EPAdministrator.Configuration.AddEventType("TemperatureSensorEvent",
                                                                  "id,device,temp".Split(','), new Object[] { typeof(string), typeof(int), typeof(double) });
        }
        private void TrySend(int numThreads, int numEventsPerThread)
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.EventMeta.DefaultEventRepresentation = EventUnderlyingType.MAP; // use Map-type events for testing
            config.AddEventType <SupportBean>();
            _engine = EPServiceProviderManager.GetDefaultProvider(config);
            _engine.Initialize();

            // setup statements
            _engine.EPAdministrator.CreateEPL("create schema MyUpdateEvent as (key string, intupd int)");
            _engine.EPAdministrator.CreateEPL("create schema MySchema as (TheString string, intval int)");
            EPStatement namedWindow = _engine.EPAdministrator.CreateEPL("create window MyWindow#keepall as MySchema");

            _engine.EPAdministrator.CreateEPL("on MyUpdateEvent mue merge MyWindow mw " +
                                              "where mw.TheString = mue.key " +
                                              "when not matched then insert select key as TheString, intupd as intval " +
                                              "when matched then delete");
            EPStatement targetStatement = _engine.EPAdministrator.CreateEPL("select (select intval from MyWindow mw where mw.TheString = sb.TheString) as val from SupportBean sb");

            // execute
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                future[i] = threadPool.Submit(new StmtNamedWindowSubqueryLookupCallable(i, _engine, numEventsPerThread, targetStatement));
            }

            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);
            }

            EventBean[] events = namedWindow.ToArray();
            Assert.AreEqual(0, events.Length);
        }
        public void TestContextContents()
        {
            Configuration configuration = GetConfiguration();

            configuration.AddPlugInEventRepresentation(new Uri("type://test/support"), typeof(SupportEventRepresentation).FullName, "abc");
            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            PlugInEventRepresentationContext initContext = SupportEventRepresentation.InitContext;

            Assert.AreEqual(new Uri("type://test/support"), initContext.EventRepresentationRootURI);
            Assert.AreEqual("abc", initContext.RepresentationInitializer);
            Assert.NotNull(initContext.EventAdapterService);

            ConfigurationOperations runtimeConfig = _epService.EPAdministrator.Configuration;

            runtimeConfig.AddPlugInEventType("TestTypeOne", new Uri[] { new Uri("type://test/support?a=b&c=d") }, "t1");

            PlugInEventTypeHandlerContext context = SupportEventRepresentation.AcceptTypeContext;

            Assert.AreEqual(new Uri("type://test/support?a=b&c=d"), context.EventTypeResolutionURI);
            Assert.AreEqual("t1", context.TypeInitializer);
            Assert.AreEqual("TestTypeOne", context.EventTypeName);

            context = SupportEventRepresentation.EventTypeContext;
            Assert.AreEqual(new Uri("type://test/support?a=b&c=d"), context.EventTypeResolutionURI);
            Assert.AreEqual("t1", context.TypeInitializer);
            Assert.AreEqual("TestTypeOne", context.EventTypeName);

            _epService.EPRuntime.GetEventSender(new Uri[] { new Uri("type://test/support?a=b") });
            PlugInEventBeanReflectorContext contextBean = SupportEventRepresentation.EventBeanContext;

            Assert.AreEqual("type://test/support?a=b", contextBean.ResolutionURI.ToString());

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
示例#12
0
        public void SetUp()
        {
            _listener = new SupportUpdateListener();
            var config = SupportConfigFactory.GetConfiguration();

            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();

            foreach (var clazz in new Type[] { typeof(SupportBean), typeof(SupportBean_S0), typeof(SupportBean_S1) })
            {
                _epService.EPAdministrator.Configuration.AddEventType(clazz);
            }
            SupportAggLevelPlanHook.GetAndReset();

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName);
            }
        }
示例#13
0
        public void TestNestedXMLDOMGetter()
        {
            var configuration       = SupportConfigFactory.GetConfiguration();
            var 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, this.GetType(), this.GetType().FullName);
            }
            _updateListener = new SupportUpdateListener();

            var stmt     = "select b.c as type, element1, result1 from AEvent";
            var joinView = _epService.EPAdministrator.CreateEPL(stmt);

            joinView.AddListener(_updateListener);

            SendXMLEvent("<a><b><c></c></b></a>");
            var 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();
            }
        }
        private void RunAssertionAdapterLoader()
        {
            SupportPluginLoader.Reset();
            // Assure destroy order ESPER-489

            var props = new Properties();

            props.Put("name", "val");
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.AddPluginLoader("MyLoader", typeof(SupportPluginLoader).FullName, props);

            props = new Properties();
            props.Put("name2", "val2");
            config.AddPluginLoader("MyLoader2", typeof(SupportPluginLoader).FullName, props);

            EPServiceProvider service = EPServiceProviderManager.GetProvider(
                SupportContainer.Instance, "ExecClientAdapterLoader", config);

            Assert.AreEqual(2, SupportPluginLoader.Names.Count);
            Assert.AreEqual(2, SupportPluginLoader.PostInitializes.Count);
            Assert.AreEqual("MyLoader", SupportPluginLoader.Names[0]);
            Assert.AreEqual("MyLoader2", SupportPluginLoader.Names[1]);
            Assert.AreEqual("val", SupportPluginLoader.Props[0].Get("name"));
            Assert.AreEqual("val2", SupportPluginLoader.Props[1].Get("name2"));

            Object loader = service.Directory.Lookup("plugin-loader/MyLoader");

            Assert.IsTrue(loader is SupportPluginLoader);
            loader = service.Directory.Lookup("plugin-loader/MyLoader2");
            Assert.IsTrue(loader is SupportPluginLoader);

            SupportPluginLoader.PostInitializes.Clear();
            SupportPluginLoader.Names.Clear();
            service.Initialize();
            Assert.AreEqual(2, SupportPluginLoader.PostInitializes.Count);
            Assert.AreEqual(2, SupportPluginLoader.Names.Count);

            service.Dispose();
            Assert.AreEqual(2, SupportPluginLoader.Destroys.Count);
            Assert.AreEqual("val2", SupportPluginLoader.Destroys[0].Get("name2"));
            Assert.AreEqual("val", SupportPluginLoader.Destroys[1].Get("name"));
        }
示例#15
0
        public void SetUp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.Logging.IsEnableQueryPlan = true;
            epService = (EPServiceProviderSPI)EPServiceProviderManager.GetDefaultProvider(config);
            epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(epService, this.GetType(), GetType().FullName);
            }
            listenerInfra  = new SupportUpdateListener();
            listenerDelete = new SupportUpdateListener();
            listenerSelect = new SupportUpdateListener();
            foreach (Type clazz in new Type[] { typeof(SupportBean), typeof(SupportBean_A), typeof(SupportBean_B) })
            {
                epService.EPAdministrator.Configuration.AddEventType(clazz);
            }
        }
示例#16
0
        public void TestRevision()
        {
            var config = SupportConfigFactory.GetConfiguration();

            config.AddEventType <SupportBean_S0>();
            config.AddEventType <SupportBean_S1>();

            var revType = new ConfigurationRevisionEventType();

            revType.AddNameBaseEventType("SupportBean_S0");
            revType.AddNameDeltaEventType("SupportBean_S1");
            revType.KeyPropertyNames = new string[] { "Id" };
            revType.PropertyRevision = PropertyRevisionEnum.MERGE_EXISTS;
            config.AddRevisionEventType("RevType", revType);

            var epService = EPServiceProviderManager.GetDefaultProvider(config);

            epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(epService, this.GetType(), GetType().FullName);
            }

            // widen to long
            var stmtTextCreate = "create window MyWindowOne.win:keepall() as select * from RevType";

            epService.EPAdministrator.CreateEPL(stmtTextCreate);
            epService.EPAdministrator.CreateEPL("insert into MyWindowOne select * from SupportBean_S0");
            epService.EPAdministrator.CreateEPL("insert into MyWindowOne select * from SupportBean_S1");

            epService.EPAdministrator.CreateEPL("create index MyWindowOneIndex1 on MyWindowOne(P10)");
            epService.EPAdministrator.CreateEPL("create index MyWindowOneIndex2 on MyWindowOne(P00)");

            epService.EPRuntime.SendEvent(new SupportBean_S0(1, "P00"));
            epService.EPRuntime.SendEvent(new SupportBean_S1(1, "P10"));

            var result = epService.EPRuntime.ExecuteQuery("select * from MyWindowOne where P10='1'");

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
示例#17
0
        public void TestInvalid()
        {
            _epService = EPServiceProviderManager.GetProvider("TestSchemaXML", GetConfig(false));
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            try
            {
                _epService.EPAdministrator.CreateEPL("select element1 from TestXMLSchemaType.win:length(100)");
                Assert.Fail();
            }
            catch (EPStatementException ex)
            {
                Assert.AreEqual("Error starting statement: Failed to validate select-clause expression 'element1': Property named 'element1' is not valid in any stream [select element1 from TestXMLSchemaType.win:length(100)]", ex.Message);
            }
        }
示例#18
0
        public ServiceBusLocalCEP()
        {
            Configuration configuration = new Configuration();

            configuration.AddEventType("BacktestRequestEvent", typeof(BacktestRequestEvent).FullName);
            configuration.AddEventType("LinkedNavigationEvent", typeof(LinkedNavigationEvent).FullName);
            configuration.AddEventType("StatusEvent", typeof(StatusEvent).FullName);
            configuration.AddEventType("TradeEvent", typeof(TradeEvent).FullName);
            configuration.EngineDefaults.EventMetaConfig.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE;
            _epService = EPServiceProviderManager.GetProvider("ServiceBusLocalCEP", configuration);

            statementDict = new Dictionary <EventType, EPStatement>();
            statementDict.Add(EventType.BacktestRequest, _epService.EPAdministrator.CreateEPL("select * from BacktestRequestEvent"));
            statementDict.Add(EventType.LinkedNavigation, _epService.EPAdministrator.CreateEPL("select * from LinkedNavigationEvent"));
            statementDict.Add(EventType.Status, _epService.EPAdministrator.CreateEPL("select * from StatusEvent"));
            statementDict.Add(EventType.Trade, _epService.EPAdministrator.CreateEPL("select * from TradeEvent"));

            statementDict[EventType.BacktestRequest].Events += HandleBacktestRequest;
        }
示例#19
0
        public void SetUp()
        {
            _listener = new SupportUpdateListener();
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.ViewResources.IsAllowMultipleExpiryPolicies = true;
            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            _events = new SupportBean[100];
            for (int i = 0; i < _events.Length; i++)
            {
                _events[i] = new SupportBean();
            }
        }
示例#20
0
 public void TestInvalid()
 {
     try
     {
         Configuration configuration = SupportConfigFactory.GetConfiguration();
         configuration.AddPlugInPatternGuard("namespace", "name", typeof(string).FullName);
         _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
         _epService.Initialize();
         String stmtText = "select * from pattern [every " + typeof(SupportBean).FullName +
                           " where namespace:name(10)]";
         _epService.EPAdministrator.CreateEPL(stmtText);
         Assert.Fail();
     }
     catch (EPStatementException ex)
     {
         SupportMessageAssertUtil.AssertMessage(
             ex, "Failed to resolve pattern guard 'com.espertech.esper.support.bean.SupportBean where namespace:name(10)': Error invoking pattern object factory constructor for object 'name', no invocation access for Activator.CreateInstance [select * from pattern [every com.espertech.esper.support.bean.SupportBean where namespace:name(10)]]");
     }
 }
        public void SetUp()
        {
            Configuration configuration = SupportConfigFactory.GetConfiguration();

            AddXMLEventType(configuration);

            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();

            AddMapEventType();
            AddOAEventType();
            _epService.EPAdministrator.Configuration.AddEventType(BEAN_TYPE);
            AddAvroEventType();

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, this.GetType(), this.GetType().FullName);
            }
        }
示例#22
0
        public void SetUp()
        {
            _listener = new StockTickerResultListener();

            var container = ContainerExtensions.CreateDefaultContainer(false)
                            .InitializeDefaultServices()
                            .InitializeDatabaseDrivers();

            var configuration = new Configuration(container);

            configuration.AddEventType("PriceLimit", typeof(PriceLimit).FullName);
            configuration.AddEventType("StockTick", typeof(StockTick).FullName);

            _epService = EPServiceProviderManager.GetProvider(
                container, "TestStockTickerSimple", configuration);

            // To reduce logging noise and get max performance
            _epService.EPRuntime.SendEvent(new TimerControlEvent(TimerControlEvent.ClockTypeEnum.CLOCK_EXTERNAL));
        }
示例#23
0
        public void SetUp()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.AddEventType("Item", typeof(Item));
            config.AddEventType("LocationReport", typeof(LocationReport));
            config.AddEventType("Zone", typeof(Zone));
            config.AddPlugInSingleRowFunction("inrect", typeof(LRUtil).FullName, "Inrect");
            config.AddPlugInSingleRowFunction("distance", typeof(LRUtil).FullName, "Distance");
            config.AddPlugInSingleRowFunction("getZoneNames", typeof(Zone).FullName, "GetZoneNames");

            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _listener = new SupportUpdateListener();
        }
示例#24
0
        public void TestCaseDistinctInsensitive()
        {
            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.EngineDefaults.EventMetaConfig.ClassPropertyResolutionStyle =
                PropertyResolutionStyle.DISTINCT_CASE_INSENSITIVE;
            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }

            EPStatement stmt = _epService.EPAdministrator.CreateEPL(
                "select MYPROPERTY, myproperty, myProperty from " + typeof(SupportBeanDupProperty).FullName);
            SupportUpdateListener listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            _epService.EPRuntime.SendEvent(
                new SupportBeanDupProperty("lowercamel", "uppercamel", "upper", "lower"));
            EventBean result = listener.AssertOneGetNewAndReset();

            Assert.AreEqual("upper", result.Get("MYPROPERTY"));
            Assert.AreEqual("lower", result.Get("myproperty"));
            Assert.AreEqual("lowercamel", result.Get("myProperty"));

            try {
                _epService.EPAdministrator.CreateEPL(
                    "select MyProPerty from " + typeof(SupportBeanDupProperty).FullName);
                Assert.Fail();
            } catch (EPException ex) {
                Assert.AreEqual(
                    "Unexpected exception starting statement: Unable to determine which property to use for \"MyProPerty\" because more than one property matched [select MyProPerty from com.espertech.esper.support.bean.SupportBeanDupProperty]",
                    ex.Message);
                // expected
            }

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
示例#25
0
        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++)
            {
                int group = i % 10;
                _events[i] = new SupportMarketDataBean("S" + Convert.ToString(group), "id_" + Convert.ToString(i), i);
            }
        }
        public void SetUp()
        {
            listener    = new SupportUpdateListener();
            listenerTwo = new SupportUpdateListener();

            Configuration config = SupportConfigFactory.GetConfiguration();

            config.AddEventType <SupportBean>();
            config.EngineDefaults.Execution.IsPrioritized = true;     // also sets share-views to false

            epService = EPServiceProviderManager.GetDefaultProvider(config);
            epService.Initialize();

            listeners = new SupportUpdateListener[10];
            for (int i = 0; i < listeners.Length; i++)
            {
                listeners[i] = new SupportUpdateListener();
            }
        }
示例#27
0
        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();
        }
示例#28
0
        public void SetUp()
        {
            var config = SupportConfigFactory.GetConfiguration();

            config.AddEventType <SupportBean>();
            config.AddEventType("S0", typeof(SupportBean_S0));
            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _listener  = new SupportUpdateListener();
            _listeners = new SupportUpdateListener[10];
            for (var i = 0; i < _listeners.Length; i++)
            {
                _listeners[i] = new SupportUpdateListener();
            }
        }
示例#29
0
        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();
            }
        }
示例#30
0
        /// <summary>
        /// Initializes Esper and prepares event listeners.
        /// </summary>
        static void InitializeEsper()
        {
            var serviceProvider = EPServiceProviderManager.GetDefaultProvider();

            _runtime       = serviceProvider.EPRuntime;
            _administrator = serviceProvider.EPAdministrator;
            // You must tell esper about your events, failure to do so means you will be using
            // the fully qualified names of your events.  There are many ways to do that, but
            // this one is short-hand which makes the name of your event aliased to the fully
            // qualified name of your type.
            _administrator.Configuration.AddEventType <TradeEvent>();
            // Create a statement or pattern; these are the bread and butter of esper.  This
            // method creates a statement.  You want to hang on to the statement if you intend
            // to listen directly to the results.
            var statement = _administrator.CreateEPL("select * from TradeEvent");

            // Hook up an event handler to the statement
            statement.Events += new UpdateEventHandler(HandleEvent);
        }