Beispiel #1
0
        public override void Run(EPServiceProvider epService)
        {
            // url='page4'
            string      text           = "select a.url as sesja from pattern [ every a=PageVisitEvent(url='page1') ]";
            EPStatement stmt           = epService.EPAdministrator.CreateEPL(text);
            var         updateListener = new SupportUpdateListener();

            stmt.Events += updateListener.Update;

            SupportXML.SendEvent(epService.EPRuntime,
                                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                                 "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n" +
                                 "<url>page1</url>" +
                                 "</event-page-visit>");
            EventBean theEvent = updateListener.LastNewData[0];

            Assert.AreEqual("page1", theEvent.Get("sesja"));
            updateListener.Reset();

            SupportXML.SendEvent(epService.EPRuntime,
                                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                                 "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n" +
                                 "<url>page2</url>" +
                                 "</event-page-visit>");
            Assert.IsFalse(updateListener.IsInvoked);

            EventType type = epService.EPAdministrator.CreateEPL("select * from PageVisitEvent").EventType;

            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("sessionId", typeof(XmlNode), null, false, false, false, false, true),
                new EventPropertyDescriptor("customerId", typeof(XmlNode), null, false, false, false, false, true),
                new EventPropertyDescriptor("url", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("method", typeof(XmlNode), null, false, false, false, false, true),
            }, type.PropertyDescriptors);
        }
        public override void Run(EPServiceProvider epService)
        {
            var stmtText = "select type?,dyn[1]?,nested.nes2?,map('a')? from MyEvent";
            var stmt     = epService.EPAdministrator.CreateEPL(stmtText);
            var listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("type?", typeof(XmlNode), null, false, false, false, false, false),
                new EventPropertyDescriptor("dyn[1]?", typeof(XmlNode), null, false, false, false, false, false),
                new EventPropertyDescriptor("nested.nes2?", typeof(XmlNode), null, false, false, false, false, false),
                new EventPropertyDescriptor("map('a')?", typeof(XmlNode), null, false, false, false, false, false),
            }, stmt.EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(stmt.EventType);

            var root     = SupportXML.SendEvent(epService.EPRuntime, NOSCHEMA_XML);
            var theEvent = listener.AssertOneGetNewAndReset();

            Assert.AreSame(root.DocumentElement.ChildNodes.Item(0), theEvent.Get("type?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(1), theEvent.Get("dyn[1]?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(3).ChildNodes.Item(0), theEvent.Get("nested.nes2?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(4), theEvent.Get("map('a')?"));
            SupportEventTypeAssertionUtil.AssertConsistency(theEvent);
        }
Beispiel #3
0
        public override void Run(EPServiceProvider epService)
        {
            var 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();
        }
        private static void RunAssertion(
            RegressionEnvironment env,
            String eventTypeName,
            RegressionPath path)
        {
            var stmtText = "@Name('s0') select type?,dyn[1]?,nested.nes2?,map('a')? from " + eventTypeName;
            env.CompileDeploy(stmtText, path).AddListener("s0");

            CollectionAssert.AreEquivalent(
                new EventPropertyDescriptor[] {
                    new EventPropertyDescriptor("type?", typeof(XmlNode), null, false, false, false, false, false),
                    new EventPropertyDescriptor("dyn[1]?", typeof(XmlNode), null, false, false, false, false, false),
                    new EventPropertyDescriptor(
                        "nested.nes2?",
                        typeof(XmlNode),
                        null,
                        false,
                        false,
                        false,
                        false,
                        false),
                    new EventPropertyDescriptor("map('a')?", typeof(XmlNode), null, false, false, false, false, false)
                },
                env.Statement("s0").EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(env.Statement("s0").EventType);

            var sender = env.EventService.GetEventSender("MyEventWithPrefix");
            var root = SupportXML.SendEvent(sender, SCHEMA_XML);

            var theEvent = env.Listener("s0").AssertOneGetNewAndReset();
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(0), theEvent.Get("type?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(2), theEvent.Get("dyn[1]?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(3).ChildNodes.Item(0), theEvent.Get("nested.nes2?"));
            Assert.AreSame(root.DocumentElement.ChildNodes.Item(4), theEvent.Get("map('a')?"));
            SupportEventTypeAssertionUtil.AssertConsistency(theEvent);

            env.UndeployAll();
        }