Beispiel #1
0
        public override void Run(EPServiceProvider epService)
        {
            RunAssertion(epService, null, null, null, null, null);
            RunAssertion(epService, "summary", true, null, null, null);
            RunAssertion(epService, "xml", true, null, null, null);
            RunAssertion(epService, "json", true, null, null, null);
            RunAssertion(epService, "summary", false, null, null, null);
            RunAssertion(epService, "summary", true, "dataflow:%df port:%p instanceId:%i title:%t event:%e", "mytitle", null);
            RunAssertion(epService, "xml", true, null, null, false);
            RunAssertion(epService, "json", true, null, "JSON_HERE", true);

            // invalid: output stream
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(epService, "DF1", "create dataflow DF1 LogSink -> s1 {}",
                                                               "Failed to instantiate data flow 'DF1': Failed initialization for operator 'LogSink': LogSink operator does not provide an output stream");

            string docSmple = "create dataflow MyDataFlow\n" +
                              "  BeaconSource -> instream {}\n" +
                              "  // Output textual event to log using defaults.\n" +
                              "  LogSink(instream) {}\n" +
                              "  \n" +
                              "  // Output JSON-formatted to console.\n" +
                              "  LogSink(instream) {\n" +
                              "    format : 'json',\n" +
                              "    layout : '%t [%e]',\n" +
                              "    log : false,\n" +
                              "    linefeed : true,\n" +
                              "    title : 'My Custom Title:'\n" +
                              "  }";

            epService.EPAdministrator.CreateEPL(docSmple);
            epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlow");
        }
Beispiel #2
0
        public void TestAllTypes()
        {
            DefaultSupportGraphEventUtil.AddTypeConfiguration(_epService);

            RunAssertionAllTypes("MyXMLEvent", DefaultSupportGraphEventUtil.XMLEvents);
            RunAssertionAllTypes("MyOAEvent", DefaultSupportGraphEventUtil.OAEvents);
            RunAssertionAllTypes("MyMapEvent", DefaultSupportGraphEventUtil.MapEvents);
            RunAssertionAllTypes("MyEvent", DefaultSupportGraphEventUtil.PONOEvents);

            // invalid: output stream
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "DF1", "create dataflow DF1 EventBusSink -> s1 {}",
                                                               "Failed to instantiate data flow 'DF1': Failed initialization for operator 'EventBusSink': EventBusSink operator does not provide an output stream");

            _epService.EPAdministrator.CreateEPL("create schema SampleSchema(tagId string, locX double, locY double)");
            String docSmple = "create dataflow MyDataFlow\n" +
                              "BeaconSource -> instream<SampleSchema> {} // produces sample stream to\n" +
                              "//demonstrate below\n" +
                              "// Send SampleSchema events produced by beacon to the event bus.\n" +
                              "EventBusSink(instream) {}\n" +
                              "\n" +
                              "// Send SampleSchema events produced by beacon to the event bus.\n" +
                              "// With collector that performs transformation.\n" +
                              "EventBusSink(instream) {\n" +
                              "collector : {\n" +
                              "class : '" + typeof(MyTransformToEventBus).FullName + "'\n" +
                              "}\n" +
                              "}";

            _epService.EPAdministrator.CreateEPL(docSmple);
            _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlow");
        }
Beispiel #3
0
        public void TestInvalidSyntax()
        {
            SupportDataFlowAssertionUtil.TryInvalidCreate(_epService, "create dataflow MyGraph MySource -> select",
                                                          "Incorrect syntax near 'select' (a reserved keyword) at line 1 column 36 [");

            SupportDataFlowAssertionUtil.TryInvalidCreate(_epService, "create dataflow MyGraph MySource -> myout",
                                                          "Incorrect syntax near end-of-input expecting a left curly bracket '{' but found end-of-input at line 1 column 41 [");
        }
        public void TestInvalid()
        {
            // test no statement name or statement filter provided
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "DF1", "create dataflow DF1 EPStatementSource -> abc {}",
                                                               "Failed to instantiate data flow 'DF1': Failed initialization for operator 'EPStatementSource': Failed to find required 'StatementName' or 'statementFilter' parameter");

            // invalid: no output stream
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "DF1", "create dataflow DF1 EPStatementSource { statementName : 'abc' }",
                                                               "Failed to instantiate data flow 'DF1': Failed initialization for operator 'EPStatementSource': EPStatementSource operator requires one output stream but produces 0 streams");
        }
        private void RunAssertionAllTypes(EPServiceProvider epService)
        {
            DefaultSupportGraphEventUtil.AddTypeConfiguration((EPServiceProviderSPI)epService);

            RunAssertionAllTypes(epService, "MyMapEvent", DefaultSupportGraphEventUtil.MapEventsSendable);
            RunAssertionAllTypes(epService, "MyXMLEvent", DefaultSupportGraphEventUtil.XMLEventsSendable);
            RunAssertionAllTypes(epService, "MyOAEvent", DefaultSupportGraphEventUtil.OAEventsSendable);
            RunAssertionAllTypes(epService, "MyEvent", DefaultSupportGraphEventUtil.PonoEventsSendable);

            // invalid: no output stream
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(epService, "DF1", "create dataflow DF1 EventBusSource {}",
                                                               "Failed to instantiate data flow 'DF1': Failed initialization for operator 'EventBusSource': EventBusSource operator requires one output stream but produces 0 streams");

            // invalid: type not found
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(epService, "DF1", "create dataflow DF1 EventBusSource -> ABC {}",
                                                               "Failed to instantiate data flow 'DF1': Failed initialization for operator 'EventBusSource': EventBusSource operator requires an event type declated for the output stream");

            // test doc samples
            epService.EPAdministrator.CreateEPL("create schema SampleSchema(tagId string, locX double, locY double)");
            string epl = "create dataflow MyDataFlow\n" +
                         "\n" +
                         "  // Receive all SampleSchema events from the event bus.\n" +
                         "  // No transformation.\n" +
                         "  EventBusSource -> stream.one<SampleSchema> {}\n" +
                         "  \n" +
                         "  // Receive all SampleSchema events with tag id '001' from the event bus.\n" +
                         "  // No transformation.\n" +
                         "  EventBusSource -> stream.one<SampleSchema> {\n" +
                         "    filter : tagId = '001'\n" +
                         "  }\n" +
                         "\n" +
                         "  // Receive all SampleSchema events from the event bus.\n" +
                         "  // With collector that performs transformation.\n" +
                         "  EventBusSource -> stream.two<SampleSchema> {\n" +
                         "    collector : {\n" +
                         "      class : '" + typeof(MyDummyCollector).FullName + "'\n" +
                         "    },\n" +
                         "  }";

            epService.EPAdministrator.CreateEPL(epl);
            epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlow");

            epService.EPAdministrator.DestroyAllStatements();
        }
Beispiel #6
0
        public void TestInvalid()
        {
            // invalid: no filter
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "DF1", "create dataflow DF1 BeaconSource -> instream<SupportBean> {} Filter(instream) -> abc {}",
                                                               "Failed to instantiate data flow 'DF1': Failed validation for operator 'Filter': Required parameter 'filter' providing the filter expression is not provided");

            // invalid: too many output streams
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "DF1", "create dataflow DF1 BeaconSource -> instream<SupportBean> {} Filter(instream) -> abc,def,efg { filter : true }",
                                                               "Failed to instantiate data flow 'DF1': Failed initialization for operator 'Filter': Filter operator requires one or two output Stream(s) but produces 3 streams");

            // invalid: too few output streams
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "DF1", "create dataflow DF1 BeaconSource -> instream<SupportBean> {} Filter(instream) { filter : true }",
                                                               "Failed to instantiate data flow 'DF1': Failed initialization for operator 'Filter': Filter operator requires one or two output Stream(s) but produces 0 streams");

            // invalid filter expressions
            TryInvalidInstantiate("TheString = 1",
                                  "Failed to instantiate data flow 'MySelect': Failed validation for operator 'Filter': Failed to validate filter dataflow operator expression 'TheString=1': Implicit conversion from datatype '" + typeof(int?).FullName + "' to 'System.String' is not allowed");

            TryInvalidInstantiate("prev(TheString, 1) = 'abc'",
                                  "Failed to instantiate data flow 'MySelect': Failed validation for operator 'Filter': Invalid filter dataflow operator expression 'prev(TheString,1)=\"abc\"': Aggregation, sub-select, previous or prior functions are not supported in this context");
        }
        public void TestBeaconFields()
        {
            RunAssertionFields(EventRepresentationEnum.MAP, true);
            RunAssertionFields(EventRepresentationEnum.OBJECTARRAY, true);
            RunAssertionFields(EventRepresentationEnum.MAP, false);
            RunAssertionFields(EventRepresentationEnum.OBJECTARRAY, false);

            // test doc samples
            _epService.EPAdministrator.Configuration.AddPlugInSingleRowFunction("GenerateTagId", GetType().FullName, "GenerateTagId");
            var epl = "create dataflow MyDataFlow\n" +
                      "  create schema SampleSchema(tagId string, locX double, locY double)," +
                      "  " +
                      "  // BeaconSource that produces empty object-array events without delay or interval\n" +
                      "  // until cancelled.\n" +
                      "  BeaconSource -> stream.one {}\n" +
                      "  \n" +
                      "  // BeaconSource that produces one RFIDSchema event populating event properties\n" +
                      "  // from a user-defined function \"generateTagId\" and values.\n" +
                      "  BeaconSource -> stream.two<SampleSchema> {\n" +
                      "    iterations : 1,\n" +
                      "    tagId : GenerateTagId(),\n" +
                      "    locX : 10,\n" +
                      "    locY : 20 \n" +
                      "  }\n" +
                      "  \n" +
                      "  // BeaconSource that produces 10 object-array events populating the price property \n" +
                      "  // with a random value.\n" +
                      "  BeaconSource -> stream.three {\n" +
                      "    iterations : 1,\n" +
                      "    interval : 10, // every 10 seconds\n" +
                      "    initialDelay : 5, // start after 5 seconds\n" +
                      "    price : MyMath.Random() * 100,\n" +
                      "  }";

            _epService.EPAdministrator.CreateEPL(epl);
            _epService.EPRuntime.DataFlowRuntime.Instantiate("MyDataFlow");

            // test options-provided beacon field
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean));
            var eplMinimal = "create dataflow MyGraph " +
                             "BeaconSource -> outstream<SupportBean> {iterations:1} " +
                             "EventBusSink(outstream) {}";

            _epService.EPAdministrator.CreateEPL(eplMinimal);

            var options = new EPDataFlowInstantiationOptions();

            options.AddParameterURI("BeaconSource/TheString", "E1");
            var instance = _epService.EPRuntime.DataFlowRuntime.Instantiate("MyGraph", options);

            var listener = new SupportUpdateListener();

            _epService.EPAdministrator.CreateEPL("select * from SupportBean").Events += listener.Update;
            instance.Run();
            Thread.Sleep(200);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "TheString".Split(','), new Object[] { "E1" });

            // invalid: no output stream
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "DF1", "create dataflow DF1 BeaconSource {}",
                                                               "Failed to instantiate data flow 'DF1': Failed initialization for operator 'BeaconSource': BeaconSource operator requires one output stream but produces 0 streams");
        }
Beispiel #8
0
        public void TestWithInvalidGraph()
        {
            _epService.EPAdministrator.Configuration.AddImport(typeof(DefaultSupportSourceOp));
            _epService.EPAdministrator.Configuration.AddImport(typeof(DefaultSupportCaptureOp <object>));
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_A));
            _epService.EPAdministrator.Configuration.AddEventType(typeof(SupportBean_B));
            _epService.EPAdministrator.Configuration.AddImport(typeof(MyInvalidOpFactory));
            _epService.EPAdministrator.Configuration.AddImport(typeof(MyTestOp));
            _epService.EPAdministrator.Configuration.AddImport(typeof(MySBInputOp));
            String epl;

            // type not found
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", "create dataflow MyGraph DefaultSupportSourceOp -> outstream<ABC> {}",
                                                               "Failed to instantiate data flow 'MyGraph': Failed to find event type 'ABC'");

            // invalid schema (need not test all variants, same as create-schema)
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", "create dataflow MyGraph create schema DUMMY com.mycompany.DUMMY, " +
                                                               "DefaultSupportSourceOp -> outstream<?> {}",
                                                               "Failed to instantiate data flow 'MyGraph': Failed to resolve class 'com.mycompany.DUMMY': Could not load class by name 'com.mycompany.DUMMY', please check imports");

            // can't find op
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", "create dataflow MyGraph DummyOp {}",
                                                               "Failed to instantiate data flow 'MyGraph': Failed to resolve operator 'DummyOp': Could not load class by name 'DummyOp', please check imports");

            // op is some other class
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", "create dataflow MyGraph Random {}",
                                                               "Failed to instantiate data flow 'MyGraph': Failed to resolve operator 'Random', operator class System.Random does not declare the DataFlowOperatorAttribute annotation or implement the DataFlowSourceOperator interface");

            // input stream not found
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", "create dataflow MyGraph DefaultSupportCaptureOp(nostream) {}",
                                                               "Failed to instantiate data flow 'MyGraph': Input stream 'nostream' consumed by operator 'DefaultSupportCaptureOp' could not be found");

            // failed op factory
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", "create dataflow MyGraph MyInvalidOp {}",
                                                               "Failed to instantiate data flow 'MyGraph': Failed to obtain operator 'MyInvalidOp', encountered an exception raised by factory class MyInvalidOpFactory: Failed-Here");

            // inject properties: property not found
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", "create dataflow MyGraph DefaultSupportCaptureOp {dummy: 1}",
                                                               "Failed to instantiate data flow 'MyGraph': Failed to find writable property 'dummy' for class");

            // inject properties: property invalid type
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", "create dataflow MyGraph MyTestOp {TheString: 1}",
                                                               "Failed to instantiate data flow 'MyGraph': Property 'TheString' of class com.espertech.esper.regression.dataflow.TestInvalidGraph+MyTestOp expects an System.String but receives a value of type " + typeof(int).FullName);

            // two incompatible input streams: different types
            epl = "create dataflow MyGraph " +
                  "DefaultSupportSourceOp -> out1<SupportBean_A> {}\n" +
                  "DefaultSupportSourceOp -> out2<SupportBean_B> {}\n" +
                  "MyTestOp((out1, out2) as ABC) {}";
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", epl,
                                                               "Failed to instantiate data flow 'MyGraph': For operator 'MyTestOp' stream 'out1' typed 'SupportBean_A' is not the same type as stream 'out2' typed 'SupportBean_B'");

            // two incompatible input streams: one is wildcard
            epl = "create dataflow MyGraph " +
                  "DefaultSupportSourceOp -> out1<?> {}\n" +
                  "DefaultSupportSourceOp -> out2<SupportBean_B> {}\n" +
                  "MyTestOp((out1, out2) as ABC) {}";
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", epl,
                                                               "Failed to instantiate data flow 'MyGraph': For operator 'MyTestOp' streams 'out1' and 'out2' have differing wildcard type information");

            // two incompatible input streams: underlying versus eventbean
            epl = "create dataflow MyGraph " +
                  "DefaultSupportSourceOp -> out1<Eventbean<SupportBean_B>> {}\n" +
                  "DefaultSupportSourceOp -> out2<SupportBean_B> {}\n" +
                  "MyTestOp((out1, out2) as ABC) {}";
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", epl,
                                                               "Failed to instantiate data flow 'MyGraph': For operator 'MyTestOp' streams 'out1' and 'out2' have differing underlying information");

            // output stream multiple type parameters
            epl = "create dataflow MyGraph " +
                  "DefaultSupportSourceOp -> out1<SupportBean_A, SupportBean_B> {}";
            SupportDataFlowAssertionUtil.TryInvalidCreate(_epService, epl,
                                                          "Error starting statement: Failed to validate operator 'DefaultSupportSourceOp': Multiple output types for a single stream 'out1' are not supported [");

            // same output stream declared twice
            epl = "create dataflow MyGraph " +
                  "DefaultSupportSourceOp -> out1<SupportBean_A>, out1<SupportBean_B> {}";
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", epl,
                                                               "Failed to instantiate data flow 'MyGraph': For operator 'DefaultSupportSourceOp' stream 'out1' typed 'SupportBean_A' is not the same type as stream 'out1' typed 'SupportBean_B'");

            epl = "create dataflow MyGraph " +
                  "DefaultSupportSourceOp -> out1<Eventbean<SupportBean_A>>, out1<Eventbean<SupportBean_B>> {}";
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", epl,
                                                               "Failed to instantiate data flow 'MyGraph': For operator 'DefaultSupportSourceOp' stream 'out1' typed 'SupportBean_A' is not the same type as stream 'out1' typed 'SupportBean_B'");

            // two incompatible output streams: underlying versus eventbean
            epl = "create dataflow MyGraph " +
                  "DefaultSupportSourceOp -> out1<SupportBean_A> {}\n" +
                  "DefaultSupportSourceOp -> out1<SupportBean_B> {}\n" +
                  "MyTestOp(out1) {}";
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", epl,
                                                               "Failed to instantiate data flow 'MyGraph': For operator 'MyTestOp' stream 'out1' typed 'SupportBean_A' is not the same type as stream 'out1' typed 'SupportBean_B'");

            // incompatible on-input method
            epl = "create dataflow MyGraph " +
                  "DefaultSupportSourceOp -> out1<SupportBean_A> {}\n" +
                  "MySBInputOp(out1) {}";
            SupportDataFlowAssertionUtil.TryInvalidInstantiate(_epService, "MyGraph", epl,
                                                               "Failed to instantiate data flow 'MyGraph': Failed to find OnInput method on for operator 'MySBInputOp#1(out1)' class com.espertech.esper.regression.dataflow.TestInvalidGraph+MySBInputOp, expected an OnInput method that takes any of {Object, Object[");

            // same schema defined twice
            epl = "create dataflow MyGraph " +
                  "create schema ABC (c0 string), create schema ABC (c1 string), " +
                  "DefaultSupportSourceOp -> out1<SupportBean_A> {}";
            SupportDataFlowAssertionUtil.TryInvalidCreate(_epService, epl,
                                                          "Error starting statement: Schema name 'ABC' is declared more then once [");
        }