コード例 #1
0
 private double GetDoubleValue(ViewFieldEnum field, EventBean theEvent)
 {
     return(theEvent.Get(field.GetName()).AsDouble());
 }
コード例 #2
0
 private void AssertSplitEx(EventBean @event, string typeName, string propertyName, string propertyValue)
 {
     Assert.AreEqual(typeName, @event.EventType.Name);
     Assert.AreEqual(propertyValue, @event.Get(propertyName));
 }
コード例 #3
0
 public void TestCustomProperty()
 {
     Assert.AreEqual(typeof(double?), _event.EventType.GetPropertyType("customProp"));
     Assert.AreEqual(3.0d, _event.Get("customProp"));
 }
コード例 #4
0
 public static bool IsNullValue(
     EventBean @event,
     string propertyName)
 {
     return @event.Get(propertyName) == null;
 }
コード例 #5
0
 private static double GetDoubleValue(ViewFieldEnum field, EventBean values)
 {
     return(values.Get(field.GetName()).AsDouble());
 }
コード例 #6
0
        public void TestArrayExpressions()
        {
            String stmtText = "select {'a', 'b'} as stringArray," +
                              "{} as emptyArray," +
                              "{1} as oneEleArray," +
                              "{1,2,3} as intArray," +
                              "{1,null} as intNullArray," +
                              "{1L,10L} as longArray," +
                              "{'a',1, 1e20} as mixedArray," +
                              "{1, 1.1d, 1e20} as doubleArray," +
                              "{5, 6L} as intLongArray," +
                              "{null} as nullArray," +
                              typeof(TestArrayExpression).FullName + ".DoIt({'a'}, {1}, {1, 'd', null, true}) as func," +
                              "{true, false} as boolArray," +
                              "{IntPrimitive} as dynIntArr," +
                              "{IntPrimitive, LongPrimitive} as dynLongArr," +
                              "{IntPrimitive, TheString} as dynMixedArr," +
                              "{IntPrimitive, IntPrimitive * 2, IntPrimitive * 3} as dynCalcArr," +
                              "{LongBoxed, DoubleBoxed * 2, TheString || 'a'} as dynCalcArrNulls" +
                              " from " + typeof(SupportBean).FullName;

            EPStatement           stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
            SupportUpdateListener listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            SupportBean bean = new SupportBean("a", 10);

            bean.LongPrimitive = 999;
            _epService.EPRuntime.SendEvent(bean);

            EventBean theEvent = listener.AssertOneGetNewAndReset();

            EPAssertionUtil.AssertEqualsExactOrder((String[])theEvent.Get("stringArray"), new String[] { "a", "b" });
            EPAssertionUtil.AssertEqualsExactOrder((Object[])theEvent.Get("emptyArray"), new Object[0]);
            EPAssertionUtil.AssertEqualsExactOrder((int?[])theEvent.Get("oneEleArray"), new int?[] { 1 });
            EPAssertionUtil.AssertEqualsExactOrder((int?[])theEvent.Get("intArray"), new int?[] { 1, 2, 3 });
            EPAssertionUtil.AssertEqualsExactOrder((int?[])theEvent.Get("intNullArray"), new int?[] { 1, null });
            EPAssertionUtil.AssertEqualsExactOrder((long?[])theEvent.Get("longArray"), new long?[] { 1L, 10L });
            EPAssertionUtil.AssertEqualsExactOrder((Object[])theEvent.Get("mixedArray"), new Object[] { "a", 1, 1e20 });
            EPAssertionUtil.AssertEqualsExactOrder((double?[])theEvent.Get("doubleArray"), new double?[] { 1d, 1.1, 1e20 });
            EPAssertionUtil.AssertEqualsExactOrder((long?[])theEvent.Get("intLongArray"), new long?[] { 5L, 6L });
            EPAssertionUtil.AssertEqualsExactOrder((Object[])theEvent.Get("nullArray"), new Object[] { null });
            EPAssertionUtil.AssertEqualsExactOrder((String[])theEvent.Get("func"), new String[] { "a", "b" });
            EPAssertionUtil.AssertEqualsExactOrder((bool?[])theEvent.Get("boolArray"), new bool?[] { true, false });
            EPAssertionUtil.AssertEqualsExactOrder((int?[])theEvent.Get("dynIntArr"), new int?[] { 10 });
            EPAssertionUtil.AssertEqualsExactOrder((long?[])theEvent.Get("dynLongArr"), new long?[] { 10L, 999L });
            EPAssertionUtil.AssertEqualsExactOrder((Object[])theEvent.Get("dynMixedArr"), new Object[] { 10, "a" });
            EPAssertionUtil.AssertEqualsExactOrder((int?[])theEvent.Get("dynCalcArr"), new int?[] { 10, 20, 30 });
            EPAssertionUtil.AssertEqualsExactOrder((Object[])theEvent.Get("dynCalcArrNulls"), new Object[] { null, null, "aa" });

            // assert function parameters
            EPAssertionUtil.AssertEqualsExactOrder(_callbackInts, new int?[] { 1 });
            EPAssertionUtil.AssertEqualsExactOrder(_callbackStrings, new String[] { "a" });
            EPAssertionUtil.AssertEqualsExactOrder(_callbackObjects, new Object[] { 1, "d", null, true });
        }
コード例 #7
0
ファイル: TestTableAccessCore.cs プロジェクト: ikvm/nesper
 private void AssertIntegerIndexed(EventBean @event, SupportBean[] events)
 {
     EPAssertionUtil.AssertEqualsExactOrder(events, (object[])@event.Get("c0.myevents"));
     EPAssertionUtil.AssertEqualsExactOrder(events, (object[])@event.Get("c1"));
     Assert.AreSame(events[events.Length - 1], @event.Get("c2"));
 }
コード例 #8
0
 public static float?GetFloat(this EventBean eventBean, string name)
 {
     return((float?)eventBean.Get(name));
 }
コード例 #9
0
 public static double?GetDouble(this EventBean eventBean, string name)
 {
     return((double?)eventBean.Get(name));
 }
コード例 #10
0
 public void TestSimpleProperties()
 {
     Assert.AreEqual("SAMPLE_V6", eventSchemaOne.Get("prop4"));
 }
コード例 #11
0
        private EventBean MyTransform(EventBean theEvent)
        {
            var value = theEvent.Get("IntPrimitive").AsInt();

            return(SupportEventBeanFactory.CreateObject(new SupportBean_S0(value)));
        }
コード例 #12
0
        public override void Run(EPServiceProvider epService)
        {
            var rootMeta = new ConfigurationEventTypeXMLDOM();

            rootMeta.RootElementName = "simpleEvent";
            rootMeta.AddNamespacePrefix("ss", "samples:schemas:simpleSchema");
            rootMeta.AddXPathPropertyFragment("nested1simple", "/ss:simpleEvent/ss:nested1", XPathResultType.Any, "MyNestedEvent");
            rootMeta.AddXPathPropertyFragment("nested4array", "//ss:nested4", XPathResultType.NodeSet, "MyNestedArrayEvent");
            epService.EPAdministrator.Configuration.AddEventType("MyXMLEvent", rootMeta);

            var metaNested = new ConfigurationEventTypeXMLDOM();

            metaNested.RootElementName = "nested1";
            epService.EPAdministrator.Configuration.AddEventType("MyNestedEvent", metaNested);

            var metaNestedArray = new ConfigurationEventTypeXMLDOM();

            metaNestedArray.RootElementName = "nested4";
            epService.EPAdministrator.Configuration.AddEventType("MyNestedArrayEvent", metaNestedArray);

            EPStatement stmtInsert   = epService.EPAdministrator.CreateEPL("insert into Nested3Stream select nested1simple, nested4array from MyXMLEvent");
            EPStatement stmtWildcard = epService.EPAdministrator.CreateEPL("select * from MyXMLEvent");

            SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.EventType);
            SupportEventTypeAssertionUtil.AssertConsistency(stmtWildcard.EventType);
            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("nested1simple", typeof(XmlNode), null, false, false, false, false, true),
                new EventPropertyDescriptor("nested4array", typeof(XmlNode[]), typeof(XmlNode), false, false, true, false, true),
            }, stmtInsert.EventType.PropertyDescriptors);

            FragmentEventType fragmentTypeNested1 = stmtInsert.EventType.GetFragmentType("nested1simple");

            Assert.IsFalse(fragmentTypeNested1.IsIndexed);
            Assert.AreEqual(0, fragmentTypeNested1.FragmentType.PropertyDescriptors.Count);
            SupportEventTypeAssertionUtil.AssertConsistency(fragmentTypeNested1.FragmentType);

            FragmentEventType fragmentTypeNested4 = stmtInsert.EventType.GetFragmentType("nested4array");

            Assert.IsTrue(fragmentTypeNested4.IsIndexed);
            Assert.AreEqual(0, fragmentTypeNested4.FragmentType.PropertyDescriptors.Count);
            SupportEventTypeAssertionUtil.AssertConsistency(fragmentTypeNested4.FragmentType);

            SupportXML.SendDefaultEvent(epService.EPRuntime, "ABC");

            EventBean received = stmtInsert.First();

            EPAssertionUtil.AssertProps(received, "nested1simple.prop1,nested1simple.prop2,nested1simple.attr1,nested1simple.nested2.prop3[1]".Split(','), new object[] { "SAMPLE_V1", "true", "SAMPLE_ATTR1", "4" });
            EPAssertionUtil.AssertProps(received, "nested4array[0].id,nested4array[0].prop5[1],nested4array[1].id".Split(','), new object[] { "a", "SAMPLE_V8", "b" });

            // assert event and fragments alone
            EventBean wildcardStmtEvent = stmtWildcard.First();

            SupportEventTypeAssertionUtil.AssertConsistency(wildcardStmtEvent);

            FragmentEventType eventType = wildcardStmtEvent.EventType.GetFragmentType("nested1simple");

            Assert.IsFalse(eventType.IsIndexed);
            Assert.IsFalse(eventType.IsNative);
            Assert.AreEqual("MyNestedEvent", eventType.FragmentType.Name);
            Assert.IsTrue(wildcardStmtEvent.Get("nested1simple") is XmlNode);
            Assert.AreEqual("SAMPLE_V1", ((EventBean)wildcardStmtEvent.GetFragment("nested1simple")).Get("prop1"));

            eventType = wildcardStmtEvent.EventType.GetFragmentType("nested4array");
            Assert.IsTrue(eventType.IsIndexed);
            Assert.IsFalse(eventType.IsNative);
            Assert.AreEqual("MyNestedArrayEvent", eventType.FragmentType.Name);
            EventBean[] eventsArray = (EventBean[])wildcardStmtEvent.GetFragment("nested4array");
            Assert.AreEqual(3, eventsArray.Length);
            Assert.AreEqual("SAMPLE_V8", eventsArray[0].Get("prop5[1]"));
            Assert.AreEqual("SAMPLE_V9", eventsArray[1].Get("prop5[0]"));
            Assert.AreEqual(typeof(XmlNodeList), wildcardStmtEvent.EventType.GetPropertyType("nested4array"));
            Assert.IsTrue(wildcardStmtEvent.Get("nested4array") is XmlNodeList);
        }
コード例 #13
0
        public void TestCaseSyntax2StringsNBranches()
        {
            // Test of the various coercion user cases.
            String caseExpr = "select case IntPrimitive" +
                              " when 1 then CompatExtensions.Render(BoolPrimitive) " +
                              " when 2 then CompatExtensions.Render(BoolBoxed) " +
                              " when 3 then CompatExtensions.Render(IntPrimitive) " +
                              " when 4 then CompatExtensions.Render(IntBoxed)" +
                              " when 5 then CompatExtensions.Render(LongPrimitive) " +
                              " when 6 then CompatExtensions.Render(LongBoxed) " +
                              " when 7 then CompatExtensions.Render(CharPrimitive) " +
                              " when 8 then CompatExtensions.Render(CharBoxed) " +
                              " when 9 then CompatExtensions.Render(ShortPrimitive) " +
                              " when 10 then CompatExtensions.Render(ShortBoxed) " +
                              " when 11 then CompatExtensions.Render(BytePrimitive) " +
                              " when 12 then CompatExtensions.Render(ByteBoxed) " +
                              " when 13 then CompatExtensions.Render(FloatPrimitive) " +
                              " when 14 then CompatExtensions.Render(FloatBoxed) " +
                              " when 15 then CompatExtensions.Render(DoublePrimitive) " +
                              " when 16 then CompatExtensions.Render(DoubleBoxed) " +
                              " when 17 then TheString " +
                              " else 'x' end as p1 " +
                              " from " + typeof(SupportBean).FullName + ".win:length(1)";

            EPStatement selectTestCase = _epService.EPAdministrator.CreateEPL(caseExpr);

            selectTestCase.Events += _testListener.Update;
            Assert.AreEqual(typeof(string), selectTestCase.EventType.GetPropertyType("p1"));

            SendSupportBeanEvent(true, false, 1, 0, 0L, 0L, '0', 'a', 0, 0, 0, (0), 0.0f, 0f, 0.0, 0.0, null, SupportEnum.ENUM_VALUE_1);
            EventBean theEvent = _testListener.GetAndResetLastNewData()[0];

            Assert.AreEqual("True", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 2, 0, 0L, 0L, '0', 'a', 0, 0, 0, (0), 0.0f, 0f, 0.0, 0.0, null, SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("False", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 3, 0, 0L, 0L, '0', 'a', 0, 0, 0, (0), 0.0f, 0f, 0.0, 0.0, null, SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("3", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 4, 4, 0L, 0L, '0', 'a', 0, 0, 0, (0), 0.0f, 0f, 0.0, 0.0, null, SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("4", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 5, 0, 5L, 0L, '0', 'a', 0, 0, 0, (0), 0.0f, 0f, 0.0, 0.0, null, SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("5", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 6, 0, 0L, 6L, '0', 'a', 0, 0, 0, (0), 0.0f, 0f, 0.0, 0.0, null, SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("6", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 7, 0, 0L, 0L, 'A', 'a', 0, 0, 0, (0), 0.0f, 0f, 0.0, 0.0, null, SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("A", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 8, 0, 0L, 0L, 'A', 'a', 0, 0, 0, (0), 0.0f, 0f, 0.0, 0.0, null, SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("a", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 9, 0, 0L, 0L, 'A', 'a', 9, 0, 0, (0), 0.0f, 0f, 0.0, 0.0, null, SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("9", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 10, 0, 0L, 0L, 'A', 'a', 9, 10, 11, (12), 13.0f, 14f, 15.0, 16.0, "testCoercion", SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("10", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 11, 0, 0L, 0L, 'A', 'a', 9, 10, 11, (12), 13.0f, 14f, 15.0, 16.0, "testCoercion", SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("11", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 12, 0, 0L, 0L, 'A', 'a', 9, 10, 11, (12), 13.0f, 14f, 15.0, 16.0, "testCoercion", SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("12", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 13, 0, 0L, 0L, 'A', 'a', 9, 10, 11, (12), 13.0f, 14f, 15.0, 16.0, "testCoercion", SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("13.0", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 14, 0, 0L, 0L, 'A', 'a', 9, 10, 11, (12), 13.0f, 14f, 15.0, 16.0, "testCoercion", SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("14.0", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 15, 0, 0L, 0L, 'A', 'a', 9, 10, 11, (12), 13.0f, 14f, 15.0, 16.0, "testCoercion", SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("15.0", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 16, 0, 0L, 0L, 'A', 'a', 9, 10, 11, (12), 13.0f, 14f, 15.0, 16.0, "testCoercion", SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("16.0", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, 17, 0, 0L, 0L, 'A', 'a', 9, 10, 11, (12), 13.0f, 14f, 15.0, 16.0, "testCoercion", SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("testCoercion", theEvent.Get("p1"));

            SendSupportBeanEvent(true, false, -1, 0, 0L, 0L, 'A', 'a', 9, 10, 11, (12), 13.0f, 14f, 15.0, 16.0, "testCoercion", SupportEnum.ENUM_VALUE_1);
            theEvent = _testListener.GetAndResetLastNewData()[0];
            Assert.AreEqual("x", theEvent.Get("p1"));
        }
コード例 #14
0
        public static bool VolumeGreaterZeroEventBean(EventBean bean)
        {
            var volume = bean.Get("volume").AsLong();

            return(volume > 0);
        }
コード例 #15
0
 public static uint?GetUInt32(this EventBean eventBean, string name)
 {
     return((uint?)eventBean.Get(name));
 }
コード例 #16
0
 public static decimal?GetDecimal(this EventBean eventBean, string name)
 {
     return((decimal?)eventBean.Get(name));
 }
コード例 #17
0
 public static ulong?GetUInt64(this EventBean eventBean, string name)
 {
     return((ulong?)eventBean.Get(name));
 }
コード例 #18
0
 public static String GetString(this EventBean eventBean, string name)
 {
     return((String)eventBean.Get(name));
 }
コード例 #19
0
        public override void Run(EPServiceProvider epService)
        {
            var eventTypeMeta = new ConfigurationEventTypeXMLDOM();

            eventTypeMeta.RootElementName = "simpleEvent";
            string schemaUri = SupportContainer.Instance.ResourceManager().ResolveResourceURL(CLASSLOADER_SCHEMA_URI).ToString();

            eventTypeMeta.SchemaResource = schemaUri;
            // eventTypeMeta.IsXPathPropertyExpr = false; <== the default
            epService.EPAdministrator.Configuration.AddEventType("TestXMLSchemaType", eventTypeMeta);

            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, true),
            }, stmtInsert.EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.EventType);

            EPStatement stmtSelect = epService.EPAdministrator.CreateEPL("select nested1.attr1 as attr1, nested1.prop1 as prop1, nested1.prop2 as prop2, nested1.nested2.prop3 as prop3, nested1.nested2.prop3[0] as prop3_0, nested1.nested2 as nested2 from MyNestedStream#lastevent");

            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("prop1", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("prop2", typeof(bool?), null, false, false, false, false, false),
                new EventPropertyDescriptor("attr1", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("prop3", typeof(int?[]), typeof(int?), false, false, true, false, false),
                new EventPropertyDescriptor("prop3_0", typeof(int?), null, false, false, false, false, false),
                new EventPropertyDescriptor("nested2", typeof(XmlNode), null, false, false, false, false, true),
            }, stmtSelect.EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(stmtSelect.EventType);

            EPStatement stmtSelectWildcard = epService.EPAdministrator.CreateEPL("select * from MyNestedStream");

            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("nested1", typeof(XmlNode), null, false, false, false, false, true),
            }, stmtSelectWildcard.EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(stmtSelectWildcard.EventType);

            EPStatement stmtInsertWildcard = epService.EPAdministrator.CreateEPL("insert into MyNestedStreamTwo select nested1.* from TestXMLSchemaType#lastevent");

            EPAssertionUtil.AssertEqualsAnyOrder(new EventPropertyDescriptor[] {
                new EventPropertyDescriptor("prop1", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("prop2", typeof(bool?), null, false, false, false, false, false),
                new EventPropertyDescriptor("attr1", typeof(string), typeof(char), false, false, true, false, false),
                new EventPropertyDescriptor("nested2", typeof(XmlNode), null, false, false, false, false, true),
            }, stmtInsertWildcard.EventType.PropertyDescriptors);
            SupportEventTypeAssertionUtil.AssertConsistency(stmtInsertWildcard.EventType);

            SupportXML.SendDefaultEvent(epService.EPRuntime, "test");
            EventBean stmtInsertWildcardBean = stmtInsertWildcard.First();

            EPAssertionUtil.AssertProps(stmtInsertWildcardBean, "prop1,prop2,attr1".Split(','),
                                        new object[] { "SAMPLE_V1", true, "SAMPLE_ATTR1" });

            SupportEventTypeAssertionUtil.AssertConsistency(stmtSelect.First());
            EventBean stmtInsertBean = stmtInsert.First();

            SupportEventTypeAssertionUtil.AssertConsistency(stmtInsertWildcard.First());
            SupportEventTypeAssertionUtil.AssertConsistency(stmtInsert.First());

            EventBean fragmentNested1 = (EventBean)stmtInsertBean.GetFragment("nested1");

            Assert.AreEqual(5, fragmentNested1.Get("nested2.prop3[2]"));
            Assert.AreEqual("TestXMLSchemaType.nested1", fragmentNested1.EventType.Name);

            EventBean fragmentNested2 = (EventBean)stmtInsertWildcardBean.GetFragment("nested2");

            Assert.AreEqual(4, fragmentNested2.Get("prop3[1]"));
            Assert.AreEqual("TestXMLSchemaType.nested1.nested2", fragmentNested2.EventType.Name);
        }
コード例 #20
0
 public static DateTime?GetDateTime(this EventBean eventBean, string name)
 {
     return((DateTime?)eventBean.Get(name));
 }
コード例 #21
0
 private double GetDoubleValue(ViewFieldEnum field, EventBean eventBean)
 {
     return(eventBean.Get(field.GetName()).AsDouble());
 }
コード例 #22
0
 public static Guid?GetGuid(this EventBean eventBean, string name)
 {
     return((Guid?)eventBean.Get(name));
 }
コード例 #23
0
        public void TestSelectArray()
        {
            EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(_config);

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

            String stmt = "select a, b, a[0] as a0, a[0].id as a0Id, a[1] as a1, a[1].id as a1Id, a[2] as a2, a[2].id as a2Id from pattern [a=A until b=B]";
            SupportUpdateListener listener  = new SupportUpdateListener();
            EPStatement           statement = epService.EPAdministrator.CreateEPL(stmt);

            statement.Events += listener.Update;

            Object eventA1 = new SupportBean_A("A1");

            epService.EPRuntime.SendEvent(eventA1);

            Object eventA2 = new SupportBean_A("A2");

            epService.EPRuntime.SendEvent(eventA2);
            Assert.IsFalse(listener.IsInvoked);

            Object eventB1 = new SupportBean_B("B1");

            epService.EPRuntime.SendEvent(eventB1);

            EventBean theEvent = listener.AssertOneGetNewAndReset();

            EPAssertionUtil.AssertEqualsExactOrder((Object[])theEvent.Get("a"), new Object[] { eventA1, eventA2 });
            Assert.AreSame(eventA1, theEvent.Get("a0"));
            Assert.AreSame(eventA2, theEvent.Get("a1"));
            Assert.IsNull(theEvent.Get("a2"));
            Assert.AreEqual("A1", theEvent.Get("a0Id"));
            Assert.AreEqual("A2", theEvent.Get("a1Id"));
            Assert.IsNull(theEvent.Get("a2Id"));
            Assert.AreSame(eventB1, theEvent.Get("b"));

            // try wildcard
            stmt              = "select * from pattern [a=A until b=B]";
            statement         = epService.EPAdministrator.CreateEPL(stmt);
            statement.Events += listener.Update;

            epService.EPRuntime.SendEvent(eventA1);
            epService.EPRuntime.SendEvent(eventA2);
            Assert.IsFalse(listener.IsInvoked);
            epService.EPRuntime.SendEvent(eventB1);

            theEvent = listener.AssertOneGetNewAndReset();
            EPAssertionUtil.AssertEqualsExactOrder((Object[])theEvent.Get("a"), new Object[] { eventA1, eventA2 });
            Assert.AreSame(eventA1, theEvent.Get("a[0]"));
            Assert.AreSame(eventA2, theEvent.Get("a[1]"));
            Assert.IsNull(theEvent.Get("a[2]"));
            Assert.AreEqual("A1", theEvent.Get("a[0].id"));
            Assert.AreEqual("A2", theEvent.Get("a[1].id"));
            Assert.IsNull(theEvent.Get("a[2].id"));
            Assert.AreSame(eventB1, theEvent.Get("b"));

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }
コード例 #24
0
 public static byte?GetByte(this EventBean eventBean, string name)
 {
     return((byte?)eventBean.Get(name));
 }
コード例 #25
0
 private static long GetLongValue(ViewFieldEnum field, EventBean values)
 {
     return(values.Get(field.GetName()).AsLong());
 }
コード例 #26
0
 public static char?GetChar(this EventBean eventBean, string name)
 {
     return((char?)eventBean.Get(name));
 }
コード例 #27
0
 public static bool LocalIsNullValue(EventBean @event, String propertyName)
 {
     return(@event.Get(propertyName) == null);
 }
コード例 #28
0
 public static ushort?GetUInt16(this EventBean eventBean, string name)
 {
     return((ushort?)eventBean.Get(name));
 }
コード例 #29
0
        public void TestDeclarationAndSelect()
        {
            Object[][] variables = new Object[][] {
                new Object[] { "var1", "int", "1", 1 },
                new Object[] { "var2", "int", "'2'", 2 },
                new Object[] { "var3", "INTEGER", " 3+2 ", 5 },
                new Object[] { "var4", "bool", " true|false ", true },
                new Object[] { "var5", "boolean", " var1=1 ", true },
                new Object[] { "var6", "double", " 1.11 ", 1.11d },
                new Object[] { "var7", "double", " 1.20d ", 1.20d },
                new Object[] { "var8", "Double", " ' 1.12 ' ", 1.12d },
                new Object[] { "var9", "float", " 1.13f*2f ", 2.26f },
                new Object[] { "var10", "FLOAT", " -1.14f ", -1.14f },
                new Object[] { "var11", "string", " ' XXXX ' ", " XXXX " },
                new Object[] { "var12", "string", " \"a\" ", "a" },
                new Object[] { "var13", "character", "'a'", 'a' },
                new Object[] { "var14", "char", "'x'", 'x' },
                new Object[] { "var15", "short", " 20 ", (short)20 },
                new Object[] { "var16", "SHORT", " ' 9 ' ", (short)9 },
                new Object[] { "var17", "long", " 20*2 ", (long)40 },
                new Object[] { "var18", "LONG", " ' 9 ' ", (long)9 },
                new Object[] { "var19", "byte", " 20*2 ", (byte)40 },
                new Object[] { "var20", "BYTE", "9+1", (byte)10 },
                new Object[] { "var21", "int", null, null },
                new Object[] { "var22", "bool", null, null },
                new Object[] { "var23", "double", null, null },
                new Object[] { "var24", "float", null, null },
                new Object[] { "var25", "string", null, null },
                new Object[] { "var26", "char", null, null },
                new Object[] { "var27", "short", null, null },
                new Object[] { "var28", "long", null, null },
                new Object[] { "var29", "BYTE", null, null },
            };

            for (int i = 0; i < variables.Length; i++)
            {
                String text = "create variable " + variables[i][1] + " " + variables[i][0];
                if (variables[i][2] != null)
                {
                    text += " = " + variables[i][2];
                }

                _epService.EPAdministrator.CreateEPL(text);
            }

            // select all variables
            StringBuilder buf       = new StringBuilder();
            String        delimiter = "";

            buf.Append("select ");
            for (int i = 0; i < variables.Length; i++)
            {
                buf.Append(delimiter);
                buf.Append(variables[i][0]);
                delimiter = ",";
            }
            buf.Append(" from ");
            buf.Append(typeof(SupportBean).FullName);
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(buf.ToString());

            stmt.Events += _listener.Update;

            // assert initialization values
            SendSupportBean("E1", 1);
            EventBean received = _listener.AssertOneGetNewAndReset();

            for (int i = 0; i < variables.Length; i++)
            {
                Assert.AreEqual(variables[i][3], received.Get((String)variables[i][0]));
            }
        }
コード例 #30
0
ファイル: TestFollowedByOperator.cs プロジェクト: ikvm/nesper
        public void TestFollowedByWithNot()
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.AddEventType("A", typeof(SupportBean_A).FullName);
            config.AddEventType("B", typeof(SupportBean_B).FullName);
            config.AddEventType("C", typeof(SupportBean_C).FullName);

            EPServiceProvider epService = EPServiceProviderManager.GetDefaultProvider(config);

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

            const string stmt = "select * from pattern [" +
                                " every a=A -> (timer:interval(10 seconds) and not (B(id=a.id) or C(id=a.id)))" +
                                "] ";

            var         listener  = new SupportUpdateListener();
            EPStatement statement = epService.EPAdministrator.CreateEPL(stmt);

            Assert.AreEqual(StatementType.SELECT, ((EPStatementSPI)statement).StatementMetadata.StatementType);
            statement.Events += listener.Update;

            SendTimer(0, epService);

            // test case where no Completed or Cancel event arrives
            SupportBean_A eventA = SendA("A1", epService);

            SendTimer(9999, epService);
            Assert.IsFalse(listener.IsInvoked);
            SendTimer(10000, epService);
            EventBean received = listener.AssertOneGetNewAndReset();

            Assert.AreEqual(eventA, received.Get("a"));

            // test case where Completed event arrives within the time set
            SendTimer(20000, epService);
            eventA = SendA("A2", epService);
            SendTimer(29999, epService);
            SendB("A2", epService);
            SendTimer(30000, epService);
            Assert.IsFalse(listener.IsInvoked);

            // test case where Cancelled event arrives within the time set
            SendTimer(30000, epService);
            eventA = SendA("A3", epService);
            SendTimer(30000, epService);
            SendC("A3", epService);
            SendTimer(40000, epService);
            Assert.IsFalse(listener.IsInvoked);

            // test case where no matching Completed or Cancel event arrives
            eventA = SendA("A4", epService);
            SendB("B4", epService);
            SendC("A5", epService);
            SendTimer(50000, epService);
            received = listener.AssertOneGetNewAndReset();
            Assert.AreEqual(eventA, received.Get("a"));

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }