public void TestSenderPONO()
        {
            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.AddEventType("SupportBean", typeof(SupportBean));
            configuration.AddEventType("Marker", typeof(SupportMarkerInterface));

            _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 SupportBean");

            stmt.Events += _listener.Update;

            // send right event
            EventSender sender      = _epService.EPRuntime.GetEventSender("SupportBean");
            Object      supportBean = new SupportBean();

            sender.SendEvent(supportBean);
            Assert.AreSame(supportBean, _listener.AssertOneGetNewAndReset().Underlying);

            // send wrong event
            try
            {
                sender.SendEvent(new SupportBean_G("G1"));
                Assert.Fail();
            }
            catch (EPException ex)
            {
                Assert.AreEqual(
                    "Event object of type com.espertech.esper.support.bean.SupportBean_G does not equal, extend or implement the type com.espertech.esper.support.bean.SupportBean of event type 'SupportBean'",
                    ex.Message);
            }

            // test an interface
            sender = _epService.EPRuntime.GetEventSender("Marker");
            stmt.Dispose();
            stmt         = _epService.EPAdministrator.CreateEPL("select * from Marker");
            stmt.Events += _listener.Update;
            var implA = new SupportMarkerImplA("Q2");

            sender.SendEvent(implA);
            Assert.AreSame(implA, _listener.AssertOneGetNewAndReset().Underlying);
            var implB = new SupportBean_G("Q3");

            sender.SendEvent(implB);
            Assert.AreSame(implB, _listener.AssertOneGetNewAndReset().Underlying);
            sender.SendEvent(implB);
            Assert.AreSame(implB, _listener.AssertOneGetNewAndReset().Underlying);

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
Exemple #2
0
        private static LinkedHashMap <String, Object> MakeMixedSet()
        {
            LinkedHashMap <String, Object> testData = new LinkedHashMap <String, Object>();

            testData["A1"] = new SupportBean_A("A1");
            testData["B1"] = new SupportBean_B("B1");
            testData["C1"] = new SupportBean_C("C1");
            testData["B2"] = new SupportBean_B("B2");
            testData["A2"] = new SupportBean_A("A2");
            testData["D1"] = new SupportBean_D("D1");
            testData["E1"] = new SupportBean_E("E1");
            testData["F1"] = new SupportBean_F("F1");
            testData["D2"] = new SupportBean_D("D2");
            testData["B3"] = new SupportBean_B("B3");
            testData["G1"] = new SupportBean_G("G1");
            testData["D3"] = new SupportBean_D("D3");

            return(testData);
        }