private void RunAssertionArrayAvroResult() { _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean)); Schema intArraySchema = SchemaBuilder.Array(TypeBuilder.Int()); Schema mixedArraySchema = SchemaBuilder.Array(TypeBuilder.Union(TypeBuilder.Int(), TypeBuilder.String(), TypeBuilder.Double())); Schema nullArraySchema = SchemaBuilder.Array(TypeBuilder.Null()); string stmtText = "@AvroSchemaField(Name='emptyArray', Schema='" + intArraySchema.ToString() + "')" + "@AvroSchemaField(Name='mixedArray', Schema='" + mixedArraySchema.ToString() + "')" + "@AvroSchemaField(Name='nullArray', Schema='" + nullArraySchema.ToString() + "')" + EventRepresentationChoice.AVRO.GetAnnotationText() + " " + "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," + "{true, false} as boolArray" + " from " + typeof(SupportBean).Name; EPStatement stmt = _epService.EPAdministrator.CreateEPL(stmtText); var listener = new SupportUpdateListener(); stmt.AddListener(listener); _epService.EPRuntime.SendEvent(new SupportBean()); EventBean theEvent = listener.AssertOneGetNewAndReset(); SupportAvroUtil.AvroToJson(theEvent); CompareColl(theEvent, "stringArray", new string[] { "a", "b" }); CompareColl(theEvent, "emptyArray", new object[0]); CompareColl(theEvent, "oneEleArray", new int[] { 1 }); CompareColl(theEvent, "intArray", new int[] { 1, 2, 3 }); CompareColl(theEvent, "intNullArray", new int?[] { 1, null }); CompareColl(theEvent, "longArray", new long[] { 1L, 10L }); CompareColl(theEvent, "mixedArray", new object[] { "a", 1, 1e20 }); CompareColl(theEvent, "doubleArray", new double[] { 1d, 1.1, 1e20 }); CompareColl(theEvent, "intLongArray", new long[] { 5L, 6L }); CompareColl(theEvent, "nullArray", new object[] { null }); CompareColl(theEvent, "boolArray", new bool[] { true, false }); stmt.Dispose(); }
private void RunAssertionArrayAvroResult(EPServiceProvider epService) { epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); Schema intArraySchema = SchemaBuilder.Array(IntType()); Schema mixedArraySchema = SchemaBuilder.Array(Union(IntType(), StringType(), DoubleType())); Schema nullArraySchema = SchemaBuilder.Array(NullType()); var stmtText = "@AvroSchemaField(Name='emptyArray', Schema='" + intArraySchema + "')" + "@AvroSchemaField(Name='mixedArray', Schema='" + mixedArraySchema + "')" + "@AvroSchemaField(Name='nullArray', Schema='" + nullArraySchema + "')" + EventRepresentationChoice.AVRO.GetAnnotationText() + "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," + "{true, false} as boolArray" + " from " + typeof(SupportBean).FullName; var stmt = epService.EPAdministrator.CreateEPL(stmtText); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(new SupportBean()); var theEvent = listener.AssertOneGetNewAndReset(); SupportAvroUtil.AvroToJson(theEvent); CompareColl(theEvent, "stringArray", new object[] { "a", "b" }); CompareColl(theEvent, "emptyArray", new object[0]); CompareColl(theEvent, "oneEleArray", new object[] { 1 }); CompareColl(theEvent, "intArray", new object[] { 1, 2, 3 }); CompareColl(theEvent, "intNullArray", new object[] { 1, null }); CompareColl(theEvent, "longArray", new object[] { 1L, 10L }); CompareColl(theEvent, "mixedArray", new object[] { "a", 1, 1e20 }); CompareColl(theEvent, "doubleArray", new object[] { 1d, 1.1, 1e20 }); CompareColl(theEvent, "intLongArray", new object[] { 5L, 6L }); CompareColl(theEvent, "nullArray", new object[] { null }); CompareColl(theEvent, "boolArray", new object[] { true, false }); stmt.Dispose(); }
public void Run(RegressionEnvironment env) { var intArraySchema = SchemaBuilder.Array(IntType()); var mixedArraySchema = SchemaBuilder.Array(Union(IntType(), StringType(), DoubleType())); var nullArraySchema = SchemaBuilder.Array(NullType()); var stmtText = "@Name('s0') " + "@AvroSchemaField(Name='EmptyArray', Schema='" + intArraySchema + "')" + "@AvroSchemaField(Name='MixedArray', Schema='" + mixedArraySchema + "')" + "@AvroSchemaField(Name='NullArray', Schema='" + nullArraySchema + "')" + EventRepresentationChoice.AVRO.GetAnnotationText() + "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," + "{true, false} as BoolArray" + " from SupportBean"; env.CompileDeploy(stmtText).AddListener("s0"); env.SendEventBean(new SupportBean()); var theEvent = env.Listener("s0").AssertOneGetNewAndReset(); SupportAvroUtil.AvroToJson(theEvent); CompareColl(theEvent, "StringArray", new[] { "a", "b" }); CompareColl(theEvent, "EmptyArray", new object[0]); CompareColl(theEvent, "OneEleArray", new int?[] { 1 }); CompareColl(theEvent, "IntArray", new int?[] { 1, 2, 3 }); CompareColl(theEvent, "IntNullArray", new int?[] { 1, null }); CompareColl(theEvent, "LongArray", new long?[] { 1L, 10L }); CompareColl(theEvent, "MixedArray", new object[] { "a", 1, 1e20 }); CompareColl(theEvent, "DoubleArray", new double?[] { 1d, 1.1, 1e20 }); CompareColl(theEvent, "IntLongArray", new long?[] { 5L, 6L }); CompareColl(theEvent, "NullArray", new object[] { null }); CompareColl(theEvent, "BoolArray", new bool?[] { true, false }); env.UndeployAll(); }