private void SendAndAssert() { for (int i = 0; i < 1000; i++) { Object theEvent = null; if (i % 3 == 0) { theEvent = new SupportBean(); } else { theEvent = SupportBeanComplexProps.MakeDefaultBean(); } _epService.EPRuntime.SendEvent(theEvent); EventBean eventBean = _updateListener.AssertOneGetNewAndReset(); if (theEvent is SupportBean) { Assert.AreSame(theEvent, eventBean.Get("a")); Assert.IsNull(eventBean.Get("b")); } else { Assert.AreSame(theEvent, eventBean.Get("b")); Assert.IsNull(eventBean.Get("a")); } } }
public void TestRegularJoin() { SupportBeanCombinedProps combined = SupportBeanCombinedProps.MakeDefaultBean(); SupportBeanComplexProps complex = SupportBeanComplexProps.MakeDefaultBean(); Assert.AreEqual("0ma0", combined.GetIndexed(0).GetMapped("0ma").Value); String viewExpr = "select nested.nested, s1.Indexed[0], nested.Indexed[1] from " + typeof(SupportBeanComplexProps).FullName + "#length(3) nested, " + typeof(SupportBeanCombinedProps).FullName + "#length(3) s1" + " where Mapped('keyOne') = Indexed[2].Mapped('2ma').value and" + " Indexed[0].Mapped('0ma').value = '0ma0'"; EPStatement testView = epService.EPAdministrator.CreateEPL(viewExpr); testListener = new SupportUpdateListener(); testView.Events += testListener.Update; epService.EPRuntime.SendEvent(combined); epService.EPRuntime.SendEvent(complex); EventBean theEvent = testListener.GetAndResetLastNewData()[0]; Assert.AreSame(complex.Nested, theEvent.Get("nested.nested")); Assert.AreSame(combined.GetIndexed(0), theEvent.Get("s1.Indexed[0]")); Assert.AreEqual(complex.GetIndexed(1), theEvent.Get("nested.Indexed[1]")); }
public void TestOuterJoin() { String viewExpr = "select * from " + typeof(SupportBeanComplexProps).FullName + "#length(3) s0" + " left outer join " + typeof(SupportBeanCombinedProps).FullName + "#length(3) s1" + " on Mapped('keyOne') = Indexed[2].Mapped('2ma').value"; EPStatement testView = epService.EPAdministrator.CreateEPL(viewExpr); testListener = new SupportUpdateListener(); testView.Events += testListener.Update; SupportBeanCombinedProps combined = SupportBeanCombinedProps.MakeDefaultBean(); epService.EPRuntime.SendEvent(combined); SupportBeanComplexProps complex = SupportBeanComplexProps.MakeDefaultBean(); epService.EPRuntime.SendEvent(complex); // double check that outer join criteria match Assert.AreEqual(complex.GetMapped("keyOne"), combined.GetIndexed(2).GetMapped("2ma").Value); EventBean theEvent = testListener.GetAndResetLastNewData()[0]; Assert.AreEqual("Simple", theEvent.Get("s0.SimpleProperty")); Assert.AreSame(complex, theEvent.Get("s0")); Assert.AreSame(combined, theEvent.Get("s1")); }
private void RunAssertionChainedUnparameterized(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType( "SupportBeanComplexProps", typeof(SupportBeanComplexProps)); var epl = "select " + "nested.NestedValue, " + "nested.NestedNested.NestedNestedValue " + "from SupportBeanComplexProps"; var stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; var bean = SupportBeanComplexProps.MakeDefaultBean(); var rows = new[] { new object[] {"nested.NestedValue", typeof(string)} }; for (var i = 0; i < rows.Length; i++) { var prop = stmt.EventType.PropertyDescriptors[i]; Assert.AreEqual(rows[i][0], prop.PropertyName); Assert.AreEqual(rows[i][1], prop.PropertyType); } epService.EPRuntime.SendEvent(bean); EPAssertionUtil.AssertProps( listener.AssertOneGetNew(), "nested.NestedValue".Split(','), new object[] {bean.Nested.NestedValue}); stmt.Dispose(); }
public override void Run(EPServiceProvider epService) { var epl = "select Mapped('keyOne') as a," + "Indexed[1] as b, " + "Nested.NestedNested.NestedNestedValue as c, " + "MapProperty, " + "ArrayProperty[0] " + " from " + typeof(SupportBeanComplexProps).FullName + "#length(3) " + " where Mapped('keyOne') = 'valueOne' and " + " Indexed[1] = 2 and " + " Nested.NestedNested.NestedNestedValue = 'NestedNestedValue'"; var testView = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); testView.Events += listener.Update; var eventObject = SupportBeanComplexProps.MakeDefaultBean(); epService.EPRuntime.SendEvent(eventObject); var theEvent = listener.GetAndResetLastNewData()[0]; Assert.AreEqual(eventObject.GetMapped("keyOne"), theEvent.Get("a")); Assert.AreEqual(eventObject.GetIndexed(1), theEvent.Get("b")); Assert.AreEqual(eventObject.Nested.NestedNested.NestedNestedValue, theEvent.Get("c")); Assert.AreEqual(eventObject.MapProperty, theEvent.Get("MapProperty")); Assert.AreEqual(eventObject.ArrayProperty[0], theEvent.Get("ArrayProperty[0]")); eventObject.SetIndexed(1, int.MinValue); Assert.IsFalse(listener.IsInvoked); epService.EPRuntime.SendEvent(eventObject); Assert.IsFalse(listener.IsInvoked); eventObject.SetIndexed(1, 2); epService.EPRuntime.SendEvent(eventObject); Assert.IsTrue(listener.IsInvoked); }
private void RunAssertionRegularJoin(EPServiceProvider epService) { SupportBeanCombinedProps combined = SupportBeanCombinedProps.MakeDefaultBean(); SupportBeanComplexProps complex = SupportBeanComplexProps.MakeDefaultBean(); Assert.AreEqual("0ma0", combined.GetIndexed(0).GetMapped("0ma").Value); string epl = "select nested.nested, s1.indexed[0], nested.indexed[1] from " + typeof(SupportBeanComplexProps).FullName + "#length(3) nested, " + typeof(SupportBeanCombinedProps).FullName + "#length(3) s1" + " where Mapped('keyOne') = indexed[2].Mapped('2ma').value and" + " indexed[0].Mapped('0ma').value = '0ma0'"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var testListener = new SupportUpdateListener(); stmt.Events += testListener.Update; epService.EPRuntime.SendEvent(combined); epService.EPRuntime.SendEvent(complex); EventBean theEvent = testListener.GetAndResetLastNewData()[0]; Assert.AreSame(complex.Nested, theEvent.Get("nested.nested")); Assert.AreSame(combined.GetIndexed(0), theEvent.Get("s1.indexed[0]")); Assert.AreEqual(complex.GetIndexed(1), theEvent.Get("nested.indexed[1]")); stmt.Dispose(); }
public void Run(RegressionEnvironment env) { env.CompileDeploy( "@Name('s0') select MYPROPERTY, myproperty, myProperty, MyProperty from SupportBeanDupProperty"); env.AddListener("s0"); env.SendEventBean(new SupportBeanDupProperty("lowercamel", "uppercamel", "upper", "lower")); var result = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual("upper", result.Get("MYPROPERTY")); Assert.AreEqual("lower", result.Get("myproperty")); Assert.AreEqual("lowercamel", result.Get("myProperty")); Assert.AreEqual("uppercamel", result.Get("MyProperty")); env.UndeployAll(); env.CompileDeploy( "@Name('s0') select " + "NESTED.NESTEDVALUE as val1, " + "ARRAYPROPERTY[0] as val2, " + "MAPPED('keyOne') as val3, " + "INDEXED[0] as val4 " + " from SupportBeanComplexProps") .AddListener("s0"); env.SendEventBean(SupportBeanComplexProps.MakeDefaultBean()); var theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual("NestedValue", theEvent.Get("val1")); Assert.AreEqual(10, theEvent.Get("val2")); Assert.AreEqual("valueOne", theEvent.Get("val3")); Assert.AreEqual(1, theEvent.Get("val4")); env.UndeployAll(); }
public void TestGetGetter() { SupportBean nestedSupportBean = new SupportBean(); nestedSupportBean.IntPrimitive = 100; SupportBeanComplexProps complexPropBean = SupportBeanComplexProps.MakeDefaultBean(); Assert.AreEqual(null, _eventType.GetGetter("dummy")); Object[] values = new Object[] { 20, 20, "a", nestedSupportBean, complexPropBean, null }; EventBean eventBean = new ObjectArrayEventBean(values, _eventType); Assert.AreEqual(20, _eventType.GetGetter("myInt").Get(eventBean)); Assert.AreEqual(20, _eventType.GetGetter("myIntBoxed").Get(eventBean)); Assert.AreEqual("a", _eventType.GetGetter("myString").Get(eventBean)); Assert.AreEqual(nestedSupportBean, _eventType.GetGetter("mySupportBean").Get(eventBean)); Assert.AreEqual(100, _eventType.GetGetter("mySupportBean.IntPrimitive").Get(eventBean)); Assert.AreEqual("NestedValue", _eventType.GetGetter("myComplexBean.Nested.NestedValue").Get(eventBean)); try { eventBean = SupportEventBeanFactory.CreateObject(new Object()); _eventType.GetGetter("myInt").Get(eventBean); Assert.IsTrue(false); } catch (InvalidCastException ex) { } }
public void Run(RegressionEnvironment env) { var stmtText = "@Name('s0') select SimpleProperty?, " + "Indexed[1]? as Indexed, " + "Mapped('keyOne')? as Mapped " + "from SupportBeanComplexProps"; env.CompileDeploy(stmtText).AddListener("s0"); var type = env.Statement("s0").EventType; Assert.AreEqual(typeof(object), type.GetPropertyType("SimpleProperty?")); Assert.AreEqual(typeof(object), type.GetPropertyType("Indexed")); Assert.AreEqual(typeof(object), type.GetPropertyType("Mapped")); var inner = SupportBeanComplexProps.MakeDefaultBean(); env.SendEventBean(inner); var theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual(inner.SimpleProperty, theEvent.Get("SimpleProperty?")); Assert.AreEqual(inner.GetIndexed(1), theEvent.Get("Indexed")); Assert.AreEqual(inner.GetMapped("keyOne"), theEvent.Get("Mapped")); var start = PerformanceObserver.MilliTime; for (var i = 0; i < 10000; i++) { env.SendEventBean(inner); if (i % 1000 == 0) { env.Listener("s0").Reset(); } } var end = PerformanceObserver.MilliTime; var delta = end - start; Assert.That(delta, Is.LessThan(1000), "delta=" + delta); env.UndeployAll(); }
public void TestInsertTransposeNestedProperty() { var stmtOneText = "insert into StreamA select nested.* from " + typeof(SupportBeanComplexProps).FullName + " as s0"; var listenerOne = new SupportUpdateListener(); var stmtOne = _epService.EPAdministrator.CreateEPL( stmtOneText); stmtOne.Events += listenerOne.Update; Assert.AreEqual( typeof(SupportBeanComplexProps.SupportBeanSpecialGetterNested), stmtOne.EventType.UnderlyingType); var stmtTwoText = "select NestedValue from StreamA"; var listenerTwo = new SupportUpdateListener(); var stmtTwo = _epService.EPAdministrator.CreateEPL( stmtTwoText); stmtTwo.Events += listenerTwo.Update; Assert.AreEqual(typeof(string), stmtTwo.EventType.GetPropertyType("NestedValue")); _epService.EPRuntime.SendEvent( SupportBeanComplexProps.MakeDefaultBean()); Assert.AreEqual("NestedValue", listenerOne.AssertOneGetNewAndReset().Get("NestedValue")); Assert.AreEqual("NestedValue", listenerTwo.AssertOneGetNewAndReset().Get("NestedValue")); }
public void TestSendMapNative() { var statementText = "select * from MyObjectArrayEvent.win:length(5)"; var statement = _epService.EPAdministrator.CreateEPL(statementText); var listener = new SupportUpdateListener(); statement.Events += listener.Update; // send event var theEvent = new Object[] { 3, "some string", SupportBeanComplexProps.MakeDefaultBean() }; _epService.EPRuntime.SendEvent(theEvent, "MyObjectArrayEvent"); Assert.IsTrue(listener.GetAndClearIsInvoked()); Assert.AreEqual(1, listener.LastNewData.Length); Assert.AreSame(theEvent, listener.LastNewData[0].Underlying); Assert.AreEqual(3, listener.LastNewData[0].Get("myInt")); Assert.AreEqual("some string", listener.LastNewData[0].Get("myString")); // send event theEvent = new Object[] { 4, "string2", null }; _epService.EPRuntime.SendEvent(theEvent, "MyObjectArrayEvent"); Assert.IsTrue(listener.GetAndClearIsInvoked()); Assert.AreEqual(1, listener.LastNewData.Length); Assert.AreEqual(theEvent, listener.LastNewData[0].Underlying); Assert.AreEqual(4, listener.LastNewData[0].Get("myInt")); Assert.AreEqual("string2", listener.LastNewData[0].Get("myString")); }
public override void Run(EPServiceProvider epService) { EPStatement stmt = epService.EPAdministrator.CreateEPL("select MYPROPERTY, myproperty, myProperty, MyProperty from " + typeof(SupportBeanDupProperty).FullName); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBeanDupProperty("lowercamel", "uppercamel", "upper", "lower")); EventBean result = listener.AssertOneGetNewAndReset(); Assert.AreEqual(result.EventType.PropertyNames.Length, 4); Assert.AreEqual(result.Get("MYPROPERTY"), "upper"); Assert.AreEqual(result.Get("MyProperty"), "uppercamel"); Assert.AreEqual(result.Get("myProperty"), "lowercamel"); Assert.AreEqual(result.Get("myproperty"), "lower"); stmt = epService.EPAdministrator.CreateEPL("select " + "NESTED.NESTEDVALUE as val1, " + "ARRAYPROPERTY[0] as val2, " + "MAPPED('keyOne') as val3, " + "INDEXED[0] as val4 " + " from " + typeof(SupportBeanComplexProps).FullName); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(SupportBeanComplexProps.MakeDefaultBean()); EventBean theEvent = listener.AssertOneGetNewAndReset(); Assert.AreEqual("NestedValue", theEvent.Get("val1")); Assert.AreEqual(10, theEvent.Get("val2")); Assert.AreEqual("valueOne", theEvent.Get("val3")); Assert.AreEqual(1, theEvent.Get("val4")); }
public void TestInstanceMethodStatic() { var textOne = "select symbol, s1.SimpleProperty as simpleprop, s1.MakeDefaultBean() as def from " + typeof(SupportMarketDataBean).FullName + "#keepall as s0 " + "left outer join " + typeof(SupportBeanComplexProps).FullName + "#keepall as s1 on s0.symbol=s1.simpleProperty"; var stmtOne = _epService.EPAdministrator.CreateEPL(textOne); var listenerOne = new SupportUpdateListener(); stmtOne.Events += listenerOne.Update; var eventA = new SupportMarketDataBean("ACME", 0, 0L, null); _epService.EPRuntime.SendEvent(eventA); var theEvent = listenerOne.AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps(theEvent, new String[] { "symbol", "simpleprop" }, new Object[] { "ACME", null }); Assert.IsNull(theEvent.Get("def")); var eventComplexProps = SupportBeanComplexProps.MakeDefaultBean(); eventComplexProps.SimpleProperty = "ACME"; _epService.EPRuntime.SendEvent(eventComplexProps); theEvent = listenerOne.AssertOneGetNewAndReset(); EPAssertionUtil.AssertProps(theEvent, new String[] { "symbol", "simpleprop" }, new Object[] { "ACME", "ACME" }); Assert.NotNull(theEvent.Get("def")); }
public override void Run(EPServiceProvider epService) { AddMapEventType(epService); AddOAEventType(epService); epService.EPAdministrator.Configuration.AddEventType(BEAN_TYPE); AddAvroEventType(epService); var notExists = MultipleNotExists(4); // Bean var bean = SupportBeanComplexProps.MakeDefaultBean(); var beanTests = new[] { new PairBean( bean, AllExist( bean.GetIndexed(0), bean.GetIndexed(1), bean.GetMapped("keyOne"), bean.GetMapped("keyTwo"))) }; RunAssertion(epService, BEAN_TYPE.Name, FBEAN, null, beanTests, typeof(object)); // Map var mapTests = new[] { new PairMap(Collections.SingletonDataMap("somekey", "10"), notExists), new PairMap( TwoEntryMap("indexed", new[] {1, 2}, "mapped", TwoEntryMap("keyOne", 3, "keyTwo", 4)), AllExist(1, 2, 3, 4)) }; RunAssertion(epService, MAP_TYPENAME, FMAP, null, mapTests, typeof(object)); // Object-Array var oaTests = new[] { new PairArray(new object[] {null, null}, notExists), new PairArray(new object[] {new[] {1, 2}, TwoEntryMap("keyOne", 3, "keyTwo", 4)}, AllExist(1, 2, 3, 4)) }; RunAssertion(epService, OA_TYPENAME, FOA, null, oaTests, typeof(object)); // XML var xmlTests = new[] { new PairXML("", notExists), new PairXML( "<indexed>1</indexed><indexed>2</indexed><mapped id=\"keyOne\">3</mapped><mapped id=\"keyTwo\">4</mapped>", AllExist("1", "2", "3", "4")) }; RunAssertion(epService, XML_TYPENAME, FXML, XML_TO_VALUE, xmlTests, typeof(XmlNode)); // Avro var datumOne = new GenericRecord(SchemaBuilder.Record(AVRO_TYPENAME)); var datumTwo = new GenericRecord(GetAvroSchema()); datumTwo.Put("indexed", Collections.List(1, 2)); datumTwo.Put("mapped", TwoEntryMap("keyOne", 3, "keyTwo", 4)); var avroTests = new[] { new PairAvro(datumOne, notExists), new PairAvro(datumTwo, AllExist(1, 2, 3, 4)) }; RunAssertion(epService, AVRO_TYPENAME, FAVRO, null, avroTests, typeof(object)); }
private void RunAssertionIndexedFilterProp(EPServiceProvider epService) { var testListener = new SupportUpdateListener(); string type = typeof(SupportBeanComplexProps).FullName; string pattern = "every a=" + type + "(Indexed[0]=3)"; EPStatement stmt = epService.EPAdministrator.CreatePattern(pattern); stmt.Events += testListener.Update; var theEvent = new SupportBeanComplexProps(new int[] { 3, 4 }); epService.EPRuntime.SendEvent(theEvent); Assert.AreSame(theEvent, testListener.AssertOneGetNewAndReset().Get("a")); theEvent = new SupportBeanComplexProps(new int[] { 6 }); epService.EPRuntime.SendEvent(theEvent); Assert.IsFalse(testListener.IsInvoked); theEvent = new SupportBeanComplexProps(new int[] { 3 }); epService.EPRuntime.SendEvent(theEvent); Assert.AreSame(theEvent, testListener.AssertOneGetNewAndReset().Get("a")); stmt.Dispose(); }
public void TestArrayPropertySizeAndGet() { _epService.EPAdministrator.Configuration.AddEventType("SupportBeanComplexProps", typeof(SupportBeanComplexProps)); var epl = "select " + "(ArrayProperty).size() as size, " + "(ArrayProperty).get(0) as get0, " + "(ArrayProperty).get(1) as get1, " + "(ArrayProperty).get(2) as get2, " + "(ArrayProperty).get(3) as get3 " + "from SupportBeanComplexProps"; var stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.AddListener(_listener); var bean = SupportBeanComplexProps.MakeDefaultBean(); var rows = new object[][] { new object[] { "size", typeof(int?) }, new object[] { "get0", typeof(int) }, new object[] { "get1", typeof(int) }, new object[] { "get2", typeof(int) }, new object[] { "get3", typeof(int) } }; for (var i = 0; i < rows.Length; i++) { var prop = stmt.EventType.PropertyDescriptors[i]; Assert.AreEqual(rows[i][0], prop.PropertyName, "failed for " + rows[i][0]); Assert.AreEqual(rows[i][1], prop.PropertyType, "failed for " + rows[i][0]); } _epService.EPRuntime.SendEvent(bean); EPAssertionUtil.AssertProps(_listener.AssertOneGetNew(), "size,get0,get1,get2,get3".Split(','), new object[] { bean.ArrayProperty.Length, bean.ArrayProperty[0], bean.ArrayProperty[1], bean.ArrayProperty[2], null }); }
public void SetUp() { _bean = SupportBeanComplexProps.MakeDefaultBean(); _event = SupportEventBeanFactory.CreateObject(_bean); _getter = MakeGetter(0); _getterOutOfBounds = MakeGetter(int.MaxValue); }
public void TestPropertiesOrPattern() { SetupOrPattern("a, a as myAEvent, b, b as myBEvent, a.IntPrimitive as MyInt, " + "a.TheString, b.SimpleProperty as Simple, b.Indexed[0] as Indexed, b.Nested.NestedValue as NestedVal"); Object theEvent = SupportBeanComplexProps.MakeDefaultBean(); _epService.EPRuntime.SendEvent(theEvent); EventBean eventBean = _updateListener.AssertOneGetNewAndReset(); Assert.AreSame(theEvent, eventBean.Get("b")); Assert.AreEqual("Simple", eventBean.Get("Simple")); Assert.AreEqual(1, eventBean.Get("Indexed")); Assert.AreEqual("NestedValue", eventBean.Get("NestedVal")); Assert.IsNull(eventBean.Get("a")); Assert.IsNull(eventBean.Get("myAEvent")); Assert.IsNull(eventBean.Get("MyInt")); Assert.IsNull(eventBean.Get("a.TheString")); SupportBean eventTwo = new SupportBean(); eventTwo.IntPrimitive = 2; eventTwo.TheString = "test2"; _epService.EPRuntime.SendEvent(eventTwo); eventBean = _updateListener.AssertOneGetNewAndReset(); Assert.AreEqual(2, eventBean.Get("MyInt")); Assert.AreEqual("test2", eventBean.Get("a.TheString")); Assert.IsNull(eventBean.Get("b")); Assert.IsNull(eventBean.Get("myBEvent")); Assert.IsNull(eventBean.Get("Simple")); Assert.IsNull(eventBean.Get("Indexed")); Assert.IsNull(eventBean.Get("NestedVal")); }
public void TestChainedUnparameterized() { _epService.EPAdministrator.Configuration.AddEventType("SupportBeanComplexProps", typeof(SupportBeanComplexProps)); var epl = "select " + "nested.GetNestedValue(), " + "nested.GetNestedNested().GetNestedNestedValue() " + "from SupportBeanComplexProps"; var stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.AddListener(_listener); var bean = SupportBeanComplexProps.MakeDefaultBean(); var rows = new object[][] { new object[] { "nested.GetNestedValue()", typeof(string) } }; for (var i = 0; i < rows.Length; i++) { var prop = stmt.EventType.PropertyDescriptors[i]; Assert.AreEqual(rows[i][0], prop.PropertyName); Assert.AreEqual(rows[i][1], prop.PropertyType); } _epService.EPRuntime.SendEvent(bean); EPAssertionUtil.AssertProps(_listener.AssertOneGetNew(), "nested.GetNestedValue()".Split(','), new object[] { bean.Nested.NestedValue }); }
private IDictionary <String, Object> GetTestDataTwo() { var levelThree = MakeMap(new Object[][] { new Object[] { "simpleThree", 4000L }, new Object[] { "objectThree", new SupportBean_B("B1") }, }); var levelTwo = MakeMap(new Object[][] { new Object[] { "simpleTwo", 300 }, new Object[] { "objectTwo", SupportBeanCombinedProps.MakeDefaultBean() }, new Object[] { "nodefmapTwo", MakeMap(new Object[][] { new Object[] { "key3", "val3" } }) }, new Object[] { "mapTwo", levelThree }, }); var levelOne = MakeMap(new Object[][] { new Object[] { "simpleOne", 10 }, new Object[] { "objectOne", SupportBeanComplexProps.MakeDefaultBean() }, new Object[] { "nodefmapOne", MakeMap(new Object[][] { new Object[] { "key2", "val2" } }) }, new Object[] { "mapOne", levelTwo } }); var levelZero = MakeMap(new Object[][] { new Object[] { "simple", "abc" }, new Object[] { "object", new SupportBean_A("A1") }, new Object[] { "nodefmap", MakeMap(new Object[][] { new Object[] { "key1", "val1" } }) }, new Object[] { "map", levelOne } }); return(levelZero); }
public void TestNestedPropertiesNoDelta() { _epService.EPAdministrator.Configuration.AddEventType <SupportBeanComplexProps>("Nested"); ConfigurationRevisionEventType revEvent = new ConfigurationRevisionEventType(); revEvent.AddNameBaseEventType("Nested"); revEvent.PropertyRevision = PropertyRevisionEnum.MERGE_DECLARED; revEvent.KeyPropertyNames = (new String[] { "SimpleProperty" }); _epService.EPAdministrator.Configuration.AddRevisionEventType("NestedRevision", revEvent); _epService.EPAdministrator.CreateEPL("create window MyWin#time(10 sec) as select * from NestedRevision"); _epService.EPAdministrator.CreateEPL("insert into MyWin select * from Nested"); String[] fields = "key,f1".Split(','); String stmtText = "select irstream SimpleProperty as key, Nested.NestedValue as f1 from MyWin"; EPStatement consumerOne = _epService.EPAdministrator.CreateEPL(stmtText); consumerOne.Events += _listenerOne.Update; EPAssertionUtil.AssertEqualsAnyOrder(consumerOne.EventType.PropertyNames, fields); _epService.EPRuntime.SendEvent(SupportBeanComplexProps.MakeDefaultBean()); EPAssertionUtil.AssertProps(_listenerOne.AssertOneGetNewAndReset(), fields, new Object[] { "Simple", "NestedValue" }); SupportBeanComplexProps bean = SupportBeanComplexProps.MakeDefaultBean(); bean.Nested.NestedValue = "val2"; _epService.EPRuntime.SendEvent(bean); EPAssertionUtil.AssertProps(_listenerOne.LastOldData[0], fields, new Object[] { "Simple", "NestedValue" }); EPAssertionUtil.AssertProps(_listenerOne.LastNewData[0], fields, new Object[] { "Simple", "val2" }); _listenerOne.Reset(); }
public void TestWrapperFragmentWithObjectArray() { _epService.EPAdministrator.Configuration.AddEventType("TypeLev0", new string[] { "p1id" }, new object[] { typeof(int) }); _epService.EPAdministrator.Configuration.AddEventType("TypeRoot", new string[] { "p0simple", "p0bean" }, new object[] { "TypeLev0", typeof(SupportBeanComplexProps) }); var stmt = _epService.EPAdministrator.CreateEPL("select *, p0simple.p1id + 1 as plusone, p0bean as mybean from TypeRoot"); stmt.AddListener(_listener); _epService.EPRuntime.SendEvent(new object[] { new object[] { 10 }, SupportBeanComplexProps.MakeDefaultBean() }, "TypeRoot"); var eventBean = _listener.AssertOneGetNewAndReset(); var eventType = eventBean.EventType; SupportEventTypeAssertionUtil.AssertConsistency(eventType); // resolve property via fragment Assert.IsTrue(eventType.GetPropertyDescriptor("p0simple").IsFragment); Assert.AreEqual(11, eventBean.Get("plusone")); Assert.AreEqual(10, eventBean.Get("p0simple.p1id")); var innerSimpleEvent = (EventBean)eventBean.GetFragment("p0simple"); Assert.AreEqual(10, innerSimpleEvent.Get("p1id")); var innerBeanEvent = (EventBean)eventBean.GetFragment("mybean"); Assert.AreEqual("NestedNestedValue", innerBeanEvent.Get("Nested.NestedNested.NestedNestedValue")); Assert.AreEqual("NestedNestedValue", ((EventBean)eventBean.GetFragment("mybean.Nested.NestedNested")).Get("NestedNestedValue")); }
private object[] GetTestData() { var levelThree = MakeMap( new[] { new object[] {"simpleThree", 4000L}, new object[] {"objectThree", new SupportBean_B("B1")} }); var levelTwo = MakeMap( new[] { new object[] {"simpleTwo", 300}, new object[] {"objectTwo", SupportBeanCombinedProps.MakeDefaultBean()}, new object[] {"nodefmapTwo", MakeMap(new[] {new object[] {"key3", "val3"}})}, new object[] {"mapTwo", levelThree} }); var levelOne = MakeMap( new[] { new object[] {"simpleOne", 10}, new object[] {"objectOne", SupportBeanComplexProps.MakeDefaultBean()}, new object[] {"nodefmapOne", MakeMap(new[] {new object[] {"key2", "val2"}})}, new object[] {"mapOne", levelTwo} }); object[] levelZero = { "abc", new SupportBean_A("A1"), MakeMap( new[] { new object[] {"key1", "val1"} }), levelOne }; return levelZero; }
private void RunAssertionWrapperFragmentWithObjectArray(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType("WheatLev0", new string[] { "p1id" }, new object[] { typeof(int) }); epService.EPAdministrator.Configuration.AddEventType("WheatRoot", new string[] { "p0simple", "p0bean" }, new object[] { "WheatLev0", typeof(SupportBeanComplexProps) }); var stmt = epService.EPAdministrator.CreateEPL("select *, p0simple.p1id + 1 as plusone, p0bean as mybean from WheatRoot"); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new object[] { new object[] { 10 }, SupportBeanComplexProps.MakeDefaultBean() }, "WheatRoot"); var eventBean = listener.AssertOneGetNewAndReset(); // Log.Info(SupportEventTypeAssertionUtil.Print(eventBean)); comment me in var eventType = eventBean.EventType; SupportEventTypeAssertionUtil.AssertConsistency(eventType); // resolve property via fragment Assert.IsTrue(eventType.GetPropertyDescriptor("p0simple").IsFragment); Assert.AreEqual(11, eventBean.Get("plusone")); Assert.AreEqual(10, eventBean.Get("p0simple.p1id")); var innerSimpleEvent = (EventBean)eventBean.GetFragment("p0simple"); Assert.AreEqual(10, innerSimpleEvent.Get("p1id")); var innerBeanEvent = (EventBean)eventBean.GetFragment("mybean"); Assert.AreEqual("NestedNestedValue", innerBeanEvent.Get("Nested.NestedNested.NestedNestedValue")); Assert.AreEqual("NestedNestedValue", ((EventBean)eventBean.GetFragment("mybean.Nested.NestedNested")).Get("NestedNestedValue")); stmt.Dispose(); }
public void TestWhereAndSelect() { String viewExpr = "select Mapped('keyOne') as a," + "Indexed[1] as b, Nested.NestedNested.NestedNestedValue as c, MapProperty, " + "ArrayProperty[0] " + " from " + typeof(SupportBeanComplexProps).FullName + "#length(3) " + " where Mapped('keyOne') = 'valueOne' and " + " Indexed[1] = 2 and " + " Nested.NestedNested.NestedNestedValue = 'NestedNestedValue'"; EPStatement testView = epService.EPAdministrator.CreateEPL(viewExpr); testListener = new SupportUpdateListener(); testView.Events += testListener.Update; SupportBeanComplexProps eventObject = SupportBeanComplexProps.MakeDefaultBean(); epService.EPRuntime.SendEvent(eventObject); EventBean theEvent = testListener.GetAndResetLastNewData()[0]; Assert.AreEqual(eventObject.GetMapped("keyOne"), theEvent.Get("a")); Assert.AreEqual(eventObject.GetIndexed(1), theEvent.Get("b")); Assert.AreEqual(eventObject.Nested.NestedNested.NestedNestedValue, theEvent.Get("c")); Assert.AreEqual(eventObject.MapProperty, theEvent.Get("MapProperty")); Assert.AreEqual(eventObject.ArrayProperty[0], theEvent.Get("ArrayProperty[0]")); eventObject.SetIndexed(1, int.MinValue); Assert.IsFalse(testListener.IsInvoked); epService.EPRuntime.SendEvent(eventObject); Assert.IsFalse(testListener.IsInvoked); eventObject.SetIndexed(1, 2); epService.EPRuntime.SendEvent(eventObject); Assert.IsTrue(testListener.IsInvoked); }
public void SetUp() { bean = SupportBeanComplexProps.MakeDefaultBean(); theEvent = SupportEventBeanFactory.CreateObject(supportEventTypeFactory, bean); getter = MakeGetter(0); getterOutOfBounds = MakeGetter(Int32.MaxValue); }
public void TestGetValueTopComplex() { String stmtText = "select item?.Indexed[0] as Indexed1, " + "item?.Indexed[1]? as Indexed2, " + "item?.ArrayProperty[1]? as Array, " + "item?.Mapped('keyOne') as Mapped1, " + "item?.Mapped('keyTwo')? as Mapped2, " + "item?.MapProperty('xOne')? as map " + "from " + typeof(SupportBeanDynRoot).FullName; EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText); stmt.Events += _listener.Update; Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Indexed1")); Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Indexed2")); Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Mapped1")); Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Mapped2")); Assert.AreEqual(typeof(Object), stmt.EventType.GetPropertyType("Array")); SupportBeanComplexProps inner = SupportBeanComplexProps.MakeDefaultBean(); _epService.EPRuntime.SendEvent(new SupportBeanDynRoot(inner)); EventBean theEvent = _listener.AssertOneGetNewAndReset(); Assert.AreEqual(inner.GetIndexed(0), theEvent.Get("Indexed1")); Assert.AreEqual(inner.GetIndexed(1), theEvent.Get("Indexed2")); Assert.AreEqual(inner.GetMapped("keyOne"), theEvent.Get("Mapped1")); Assert.AreEqual(inner.GetMapped("keyTwo"), theEvent.Get("Mapped2")); Assert.AreEqual(inner.MapProperty.Get("xOne"), theEvent.Get("map")); Assert.AreEqual(inner.ArrayProperty[1], theEvent.Get("Array")); }
public void SetUp() { _bean = SupportBeanComplexProps.MakeDefaultBean(); _theEvent = SupportEventBeanFactory.CreateObject(_bean); var method = typeof(SupportBeanComplexProps).GetMethod("GetIndexed", new Type[] { typeof(int) }); _getter = new KeyedMethodPropertyGetter(method, 1, SupportEventAdapterService.Service); }
public void SetUp() { bean = SupportBeanComplexProps.MakeDefaultBean(); theEvent = SupportEventBeanFactory.CreateObject(supportEventTypeFactory, bean); var method = typeof(SupportBeanComplexProps).GetMethod("GetIndexed", new Type[] { typeof(int) }); getter = new KeyedMethodPropertyGetter(method, 1, null, null); }
public void SetUp() { _prop = new SimpleProperty("SimpleProperty"); _invalidPropMap = new SimpleProperty("Mapped"); _invalidPropIndexed = new SimpleProperty("Indexed"); _invalidDummy = new SimpleProperty("Dummy"); _theEvent = SupportEventBeanFactory.CreateObject(SupportBeanComplexProps.MakeDefaultBean()); _eventType = (BeanEventType)_theEvent.EventType; }