예제 #1
0
  public void testCorrel() {
    // further math tests can be found in the view unit test
    EPAdministrator admin = epService.getEPAdministrator();
    admin.getConfiguration().addEventType("Market", SupportMarketDataBean.class);
    EPStatement statement =
        admin.createEPL(
            "select * from Market.std:groupwin(symbol).win:length(1000000).stat:correl(price, volume, feed)");
    SupportUpdateListener listener = new SupportUpdateListener();
    statement.addListener(listener);

    assertEquals(Double.class, statement.getEventType().getPropertyType("correlation"));

    String[] fields = new String[] {"symbol", "correlation", "feed"};

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("ABC", 10.0, 1000L, "f1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"ABC", Double.NaN, "f1"});

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("DEF", 1.0, 2L, "f2"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"DEF", Double.NaN, "f2"});

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("DEF", 2.0, 4L, "f3"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"DEF", 1.0, "f3"});

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("ABC", 20.0, 2000L, "f4"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"ABC", 1.0, "f4"});
  }
예제 #2
0
  private void runAssertion(long timestamp) {
    String[] fields = "engineURI,statementName".split(",");

    assertEquals(4, listener.getNewDataList().size());
    EventBean[] received = listener.getNewDataListFlattened();

    EPAssertionUtil.assertProps(received[0], fields, new Object[] {"MyURI", "cpuStmtOne"});
    EPAssertionUtil.assertProps(received[1], fields, new Object[] {"MyURI", "cpuStmtTwo"});
    EPAssertionUtil.assertProps(received[2], fields, new Object[] {"MyURI", "wallStmtThree"});
    EPAssertionUtil.assertProps(received[3], fields, new Object[] {"MyURI", "wallStmtFour"});

    long cpuOne = (Long) received[0].get("cpuTime");
    long cpuTwo = (Long) received[1].get("cpuTime");
    long wallOne = (Long) received[2].get("wallTime");
    long wallTwo = (Long) received[3].get("wallTime");

    assertTrue("cpuOne=" + cpuOne, cpuOne > cpuGoalOneNano);
    assertTrue("cpuTwo=" + cpuTwo, cpuTwo > cpuGoalTwoNano);
    assertTrue("wallOne=" + wallOne, (wallOne + 50) > wallGoalOneMsec);
    assertTrue("wallTwo=" + wallTwo, (wallTwo + 50) > wallGoalTwoMsec);

    for (int i = 0; i < 4; i++) {
      assertEquals(1L, received[i].get("numOutputIStream"));
      assertEquals(0L, received[i].get("numOutputRStream"));
      assertEquals(timestamp, received[i].get("timestamp"));
    }

    listener.reset();
  }
예제 #3
0
  public void testGroupedThreeKeyNoContext() throws Exception {
    String eplDeclare =
        "create table varTotal (key0 string primary key, key1 int primary key,"
            + "key2 long primary key, total sum(double), cnt count(*))";
    epService.getEPAdministrator().createEPL(eplDeclare);

    String eplBind =
        "into table varTotal "
            + "select sum(doublePrimitive) as total, count(*) as cnt "
            + "from SupportBean group by theString, intPrimitive, longPrimitive";
    epService.getEPAdministrator().createEPL(eplBind);

    String[] fields = "c0,c1".split(",");
    String eplUse =
        "select varTotal[p00, id, 100L].total as c0, varTotal[p00, id, 100L].cnt as c1 from SupportBean_S0";
    epService.getEPAdministrator().createEPL(eplUse).addListener(listener);

    makeSendBean("E1", 10, 100, 1000);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(10, "E1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {1000.0, 1L});

    makeSendBean("E1", 10, 100, 1001);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(10, "E1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {2001.0, 2L});
  }
예제 #4
0
  public void testEngineMetrics() {
    epService = EPServiceProviderManager.getProvider("MyURI", getConfig(10000, -1, true));
    epService.initialize();

    String[] engineFields =
        "engineURI,timestamp,inputCount,inputCountDelta,scheduleDepth".split(",");
    sendTimer(1000);

    String text = "select * from " + EngineMetric.class.getName();
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean());

    sendTimer(10999);
    assertFalse(listener.isInvoked());

    epService.getEPAdministrator().createEPL("select * from pattern[timer:interval(5 sec)]");

    sendTimer(11000);
    EventBean theEvent = listener.assertOneGetNewAndReset();
    EPAssertionUtil.assertProps(theEvent, engineFields, new Object[] {"MyURI", 11000L, 1L, 1L, 1L});

    epService.getEPRuntime().sendEvent(new SupportBean());
    epService.getEPRuntime().sendEvent(new SupportBean());

    sendTimer(20000);
    sendTimer(21000);
    theEvent = listener.assertOneGetNewAndReset();
    EPAssertionUtil.assertProps(theEvent, engineFields, new Object[] {"MyURI", 21000L, 4L, 3L, 0L});
  }
예제 #5
0
  private void runAssertionGroupedMixedMethodAndAccess(boolean soda) throws Exception {
    String eplDeclare =
        "create table varMyAgg ("
            + "key string primary key, "
            + "c0 count(*), "
            + "c1 count(distinct object), "
            + "c2 window(*) @type('SupportBean'), "
            + "c3 sum(long)"
            + ")";
    SupportModelHelper.createByCompileOrParse(epService, soda, eplDeclare);

    String eplBind =
        "into table varMyAgg select "
            + "count(*) as c0, "
            + "count(distinct intPrimitive) as c1, "
            + "window(*) as c2, "
            + "sum(longPrimitive) as c3 "
            + "from SupportBean.win:length(3) group by theString";
    SupportModelHelper.createByCompileOrParse(epService, soda, eplBind);

    String eplSelect =
        "select "
            + "varMyAgg[p00].c0 as c0, "
            + "varMyAgg[p00].c1 as c1, "
            + "varMyAgg[p00].c2 as c2, "
            + "varMyAgg[p00].c3 as c3"
            + " from SupportBean_S0";
    EPStatement stmtSelect = SupportModelHelper.createByCompileOrParse(epService, soda, eplSelect);
    stmtSelect.addListener(listener);
    String[] fields = "c0,c1,c2,c3".split(",");

    assertEquals(Long.class, stmtSelect.getEventType().getPropertyType("c0"));
    assertEquals(Long.class, stmtSelect.getEventType().getPropertyType("c1"));
    assertEquals(SupportBean[].class, stmtSelect.getEventType().getPropertyType("c2"));
    assertEquals(Long.class, stmtSelect.getEventType().getPropertyType("c3"));

    SupportBean b1 = makeSendBean("E1", 10, 100);
    SupportBean b2 = makeSendBean("E1", 11, 101);
    SupportBean b3 = makeSendBean("E1", 10, 102);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0, "E1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fields,
        new Object[] {3L, 2L, new SupportBean[] {b1, b2, b3}, 303L});

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0, "E2"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null, null, null});

    SupportBean b4 = makeSendBean("E2", 20, 200);
    epService.getEPRuntime().sendEvent(new SupportBean_S0(0, "E2"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fields,
        new Object[] {1L, 1L, new SupportBean[] {b4}, 200L});

    epService.getEPAdministrator().destroyAllStatements();
  }
  public void testMapNamePropertyNested() {
    EPServiceProvider epService = getEngineInitialized(null, null, null);

    // create a named map
    Map<String, Object> namedDef = makeMap(new Object[][] {{"n0", int.class}});
    epService.getEPAdministrator().getConfiguration().addEventType("MyNamedMap", namedDef);

    // create a map using the name
    Map<String, Object> eventDef =
        makeMap(new Object[][] {{"p0", "MyNamedMap"}, {"p1", "MyNamedMap[]"}});
    epService.getEPAdministrator().getConfiguration().addEventType("MyMapWithAMap", eventDef);

    // test named-map at the second level of a nested map
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyObjectArrayMapOuter", new String[] {"outer"}, new Object[] {eventDef});

    SupportUpdateListener listener = new SupportUpdateListener();
    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL(
                "select outer.p0.n0 as a, outer.p1[0].n0 as b, outer.p1[1].n0 as c, outer.p0 as d, outer.p1 as e from MyObjectArrayMapOuter");
    stmt.addListener(listener);

    Map<String, Object> n0_1 = makeMap(new Object[][] {{"n0", 1}});
    Map<String, Object> n0_21 = makeMap(new Object[][] {{"n0", 2}});
    Map<String, Object> n0_22 = makeMap(new Object[][] {{"n0", 3}});
    Map[] n0_2 = new Map[] {n0_21, n0_22};
    Map<String, Object> theEvent = makeMap(new Object[][] {{"p0", n0_1}, {"p1", n0_2}});
    epService.getEPRuntime().sendEvent(new Object[] {theEvent}, "MyObjectArrayMapOuter");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        "a,b,c,d,e".split(","),
        new Object[] {1, 2, 3, n0_1, n0_2});
    assertEquals(int.class, stmt.getEventType().getPropertyType("a"));
    assertEquals(int.class, stmt.getEventType().getPropertyType("b"));
    assertEquals(int.class, stmt.getEventType().getPropertyType("c"));
    assertEquals(Map.class, stmt.getEventType().getPropertyType("d"));
    assertEquals(Map[].class, stmt.getEventType().getPropertyType("e"));

    stmt.destroy();
    stmt =
        epService
            .getEPAdministrator()
            .createEPL(
                "select outer.p0.n0? as a, outer.p1[0].n0? as b, outer.p1[1]?.n0 as c, outer.p0? as d, outer.p1? as e from MyObjectArrayMapOuter");
    stmt.addListener(listener);
    epService.getEPRuntime().sendEvent(new Object[] {theEvent}, "MyObjectArrayMapOuter");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        "a,b,c,d,e".split(","),
        new Object[] {1, 2, 3, n0_1, n0_2});
    assertEquals(int.class, stmt.getEventType().getPropertyType("a"));
  }
예제 #7
0
  private void assertMultiStmtContributingTotal(String c0, int total) {
    String[] fields = "c0,total".split(",");
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {c0, total});

    epService.getEPRuntime().sendEvent(new SupportBean(c0, 0));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {c0, total});
  }
  public void testArrayProperty() {
    EPServiceProvider epService = getEngineInitialized(null, null, null);

    // test map containing first-level property that is an array of primitive or Class
    String[] props = {"p0", "p1"};
    Object[] types = {int[].class, SupportBean[].class};
    epService.getEPAdministrator().getConfiguration().addEventType("MyArrayOA", props, types);

    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL(
                "select p0[0] as a, p0[1] as b, p1[0].intPrimitive as c, p1[1] as d, p0 as e from MyArrayOA");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    int[] p0 = new int[] {1, 2, 3};
    SupportBean[] beans = new SupportBean[] {new SupportBean("e1", 5), new SupportBean("e2", 6)};
    Object[] eventData = new Object[] {p0, beans};
    epService.getEPRuntime().sendEvent(eventData, "MyArrayOA");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        "a,b,c,d,e".split(","),
        new Object[] {1, 2, 5, beans[1], p0});
    assertEquals(int.class, stmt.getEventType().getPropertyType("a"));
    assertEquals(int.class, stmt.getEventType().getPropertyType("b"));
    assertEquals(int.class, stmt.getEventType().getPropertyType("c"));
    assertEquals(SupportBean.class, stmt.getEventType().getPropertyType("d"));
    assertEquals(int[].class, stmt.getEventType().getPropertyType("e"));
    stmt.destroy();

    // test map at the second level of a nested map that is an array of primitive or Class
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyArrayOAMapOuter", new String[] {"outer"}, new Object[] {"MyArrayOA"});

    stmt =
        epService
            .getEPAdministrator()
            .createEPL(
                "select outer.p0[0] as a, outer.p0[1] as b, outer.p1[0].intPrimitive as c, outer.p1[1] as d, outer.p0 as e from MyArrayOAMapOuter");
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new Object[] {eventData}, "MyArrayOAMapOuter");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), "a,b,c,d".split(","), new Object[] {1, 2, 5, beans[1]});
    assertEquals(int.class, stmt.getEventType().getPropertyType("a"));
    assertEquals(int.class, stmt.getEventType().getPropertyType("b"));
    assertEquals(int.class, stmt.getEventType().getPropertyType("c"));
    assertEquals(SupportBean.class, stmt.getEventType().getPropertyType("d"));
    assertEquals(int[].class, stmt.getEventType().getPropertyType("e"));
  }
  public void testScalar() {

    String[] fields = "val0,val1".split(",");
    String eplFragment =
        "select "
            + "strvals.mostFrequent() as val0, "
            + "strvals.leastFrequent() as val1 "
            + "from SupportCollection";
    EPStatement stmtFragment = epService.getEPAdministrator().createEPL(eplFragment);
    stmtFragment.addListener(listener);
    LambdaAssertionUtil.assertTypes(
        stmtFragment.getEventType(), fields, new Class[] {String.class, String.class});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString("E2,E1,E2,E1,E3,E3,E4,E3"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"E3", "E4"});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString("E1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"E1", "E1"});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString(null));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString(""));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null});
    stmtFragment.destroy();

    epService
        .getEPAdministrator()
        .getConfiguration()
        .addPlugInSingleRowFunction(
            "extractNum", TestEnumMinMax.MyService.class.getName(), "extractNum");
    String eplLambda =
        "select "
            + "strvals.mostFrequent(v => extractNum(v)) as val0, "
            + "strvals.leastFrequent(v => extractNum(v)) as val1 "
            + "from SupportCollection";
    EPStatement stmtLambda = epService.getEPAdministrator().createEPL(eplLambda);
    stmtLambda.addListener(listener);
    LambdaAssertionUtil.assertTypes(
        stmtLambda.getEventType(), fields, new Class[] {Integer.class, Integer.class});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString("E2,E1,E2,E1,E3,E3,E4,E3"));
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {3, 4});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString("E1"));
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {1, 1});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString(null));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString(""));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null});
  }
  public void testObjectArrayNested() {
    EPServiceProvider epService = getEngineInitialized(null, null, null);
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("TypeLev1", new String[] {"p1id"}, new Object[] {int.class});
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType(
            "TypeLev0", new String[] {"p0id", "p1"}, new Object[] {int.class, "TypeLev1"});
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType(
            "TypeRoot", new String[] {"rootId", "p0"}, new Object[] {int.class, "TypeLev0"});

    EPStatement stmt =
        epService.getEPAdministrator().createEPL("select * from TypeRoot.std:lastevent()");
    Object[] dataLev1 = {1000};
    Object[] dataLev0 = {100, dataLev1};
    epService.getEPRuntime().sendEvent(new Object[] {10, dataLev0}, "TypeRoot");
    EventBean theEvent = stmt.iterator().next();
    EPAssertionUtil.assertProps(
        theEvent, "rootId,p0.p0id,p0.p1.p1id".split(","), new Object[] {10, 100, 1000});
  }
예제 #11
0
  public void testNamedWindowAndFireAndForget() throws Exception {
    String epl =
        "create window MyWindow.win:length(2) as SupportBean;\n"
            + "insert into MyWindow select * from SupportBean;\n"
            + "create table varagg (total sum(int));\n"
            + "into table varagg select sum(intPrimitive) as total from MyWindow;\n";
    epService.getEPAdministrator().getDeploymentAdmin().parseDeploy(epl);

    epService.getEPRuntime().sendEvent(new SupportBean("E1", 10));
    EPOnDemandQueryResult resultSelect =
        epService.getEPRuntime().executeQuery("select varagg.total as c0 from MyWindow");
    assertEquals(10, resultSelect.getArray()[0].get("c0"));

    EPOnDemandQueryResult resultDelete =
        epService
            .getEPRuntime()
            .executeQuery("delete from MyWindow where varagg.total = intPrimitive");
    assertEquals(1, resultDelete.getArray().length);

    epService.getEPRuntime().sendEvent(new SupportBean("E2", 20));
    EPOnDemandQueryResult resultUpdate =
        epService
            .getEPRuntime()
            .executeQuery(
                "update MyWindow set doublePrimitive = 100 where varagg.total = intPrimitive");
    assertEquals(100d, resultUpdate.getArray()[0].get("doublePrimitive"));

    EPOnDemandQueryResult resultInsert =
        epService
            .getEPRuntime()
            .executeQuery(
                "insert into MyWindow (theString, intPrimitive) values ('A', varagg.total)");
    EPAssertionUtil.assertProps(
        resultInsert.getArray()[0], "theString,intPrimitive".split(","), new Object[] {"A", 20});
  }
예제 #12
0
 private void sendEventsAndAssert(String theString, int intPrimitive, String p00, int total) {
   String[] fields = "c0,c1".split(",");
   epService.getEPRuntime().sendEvent(new SupportBean(theString, intPrimitive));
   epService.getEPRuntime().sendEvent(new SupportBean_S0(0, p00));
   EPAssertionUtil.assertProps(
       listener.assertOneGetNewAndReset(), fields, new Object[] {p00, total});
 }
예제 #13
0
  public void testAverageEvents() {

    String[] fields = "val0,val1,val2,val3".split(",");
    String eplFragment =
        "select "
            + "beans.average(x => intBoxed) as val0,"
            + "beans.average(x => doubleBoxed) as val1,"
            + "beans.average(x => longBoxed) as val2,"
            + "beans.average(x => bigDecimal) as val3 "
            + "from Bean";
    EPStatement stmtFragment = epService.getEPAdministrator().createEPL(eplFragment);
    stmtFragment.addListener(listener);
    LambdaAssertionUtil.assertTypes(
        stmtFragment.getEventType(),
        fields,
        new Class[] {Double.class, Double.class, Double.class, BigDecimal.class});

    epService.getEPRuntime().sendEvent(new SupportBean_Container(null));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null, null, null});

    epService
        .getEPRuntime()
        .sendEvent(new SupportBean_Container(Collections.<SupportBean>emptyList()));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null, null, null});

    List<SupportBean> list = new ArrayList<SupportBean>();
    list.add(make(2, 3d, 4l, 5));
    epService.getEPRuntime().sendEvent(new SupportBean_Container(list));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fields,
        new Object[] {2d, 3d, 4d, new BigDecimal(5.0d)});

    list.add(make(4, 6d, 8l, 10));
    epService.getEPRuntime().sendEvent(new SupportBean_Container(list));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fields,
        new Object[] {(2 + 4) / 2d, (3d + 6d) / 2d, (4L + 8L) / 2d, new BigDecimal((5 + 10) / 2d)});
  }
예제 #14
0
  private void runAssertionTopLevelSingle() {
    sendEventsAndAssert("A", 10, "A", 10);
    sendEventsAndAssert("A", 11, "A", 21);
    sendEventsAndAssert("B", 20, "A", 21);
    sendEventsAndAssert("B", 21, "B", 41);
    sendEventsAndAssert("C", 30, "A", 21);
    sendEventsAndAssert("D", 40, "C", 30);

    String[] fields = "c0,c1".split(",");
    int[] expected = new int[] {21, 41, 30, 40};
    int count = 0;
    for (String p00 : "A,B,C,D".split(",")) {
      epService.getEPRuntime().sendEvent(new SupportBean_S0(0, p00));
      EPAssertionUtil.assertProps(
          listener.assertOneGetNewAndReset(), fields, new Object[] {p00, expected[count]});
      count++;
    }

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0, "A"));
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {"A", 21});
  }
예제 #15
0
  public void testExpressionAliasAndDecl() {
    epService.getEPAdministrator().createEPL("create expression sumi {a -> sum(intPrimitive)}");
    epService
        .getEPAdministrator()
        .createEPL("create expression sumd alias for {sum(doublePrimitive)}");
    epService
        .getEPAdministrator()
        .createEPL(
            "create table varagg ("
                + "sumi sum(int), sumd sum(double), sumf sum(float), suml sum(long))");
    epService
        .getEPAdministrator()
        .createEPL(
            "expression suml alias for {sum(longPrimitive)} "
                + "into table varagg "
                + "select suml, sum(floatPrimitive) as sumf, sumd, sumi(sb) from SupportBean as sb");

    makeSendBean("E1", 10, 100L, 1000d, 10000f);

    String fields = "varagg.sumi,varagg.sumd,varagg.sumf,varagg.suml";
    epService
        .getEPAdministrator()
        .createEPL("select " + fields + " from SupportBean_S0")
        .addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(1));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fields.split(","),
        new Object[] {10, 1000d, 10000f, 100L});

    makeSendBean("E1", 11, 101L, 1001d, 10001f);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(1));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fields.split(","),
        new Object[] {21, 2001d, 20001f, 201L});
  }
예제 #16
0
  public void testObjectArrayEvent() {
    String[] fields = "p1,sp2".split(",");
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType(
            "MyOAEvent", new String[] {"p1", "p2"}, new Object[] {String.class, int.class});
    epService
        .getEPAdministrator()
        .createEPL("select p1,sum(p2) as sp2 from MyOAEvent.std:groupwin(p1).win:length(2)")
        .addListener(listener);

    epService.getEPRuntime().sendEvent(new Object[] {"A", 10}, "MyOAEvent");
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {"A", 10});

    epService.getEPRuntime().sendEvent(new Object[] {"B", 11}, "MyOAEvent");
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {"B", 21});

    epService.getEPRuntime().sendEvent(new Object[] {"A", 12}, "MyOAEvent");
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {"A", 33});

    epService.getEPRuntime().sendEvent(new Object[] {"A", 13}, "MyOAEvent");
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {"A", 36});
  }
  public void testConfiguredViaPropsAndXML() {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration
        .getEngineDefaults()
        .getEventMeta()
        .setDefaultEventRepresentation(Configuration.EventRepresentation.OBJECTARRAY);
    configuration.addEventType(
        "MyOAType",
        "bean,theString,map".split(","),
        new Object[] {SupportBean.class.getName(), "string", "java.util.Map"});

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }

    EventType eventType =
        epService.getEPAdministrator().getConfiguration().getEventType("MyOAType");
    assertEquals(Object[].class, eventType.getUnderlyingType());
    assertEquals(String.class, eventType.getPropertyType("theString"));
    assertEquals(Map.class, eventType.getPropertyType("map"));
    assertEquals(SupportBean.class, eventType.getPropertyType("bean"));

    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL("select bean, theString, map('key'), bean.theString from MyOAType");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);
    assertEquals(Object[].class, stmt.getEventType().getUnderlyingType());

    SupportBean bean = new SupportBean("E1", 1);
    epService
        .getEPRuntime()
        .sendEvent(
            new Object[] {bean, "abc", Collections.singletonMap("key", "value")}, "MyOAType");
    EPAssertionUtil.assertProps(
        listener.assertOneGetNew(),
        "bean,theString,map('key'),bean.theString".split(","),
        new Object[] {bean, "abc", "value", "E1"});

    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.endTest();
    }
  }
  public void testMapNameProperty() {
    EPServiceProvider epService = getEngineInitialized(null, null, null);

    // create a named map
    Map<String, Object> namedDef = makeMap(new Object[][] {{"n0", int.class}});
    epService.getEPAdministrator().getConfiguration().addEventType("MyNamedMap", namedDef);

    // create a map using the name
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType(
            "MyOAWithAMap", new String[] {"p0", "p1"}, new Object[] {"MyNamedMap", "MyNamedMap[]"});

    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL(
                "select p0.n0 as a, p1[0].n0 as b, p1[1].n0 as c, p0 as d, p1 as e from MyOAWithAMap");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    Map<String, Object> n0_1 = makeMap(new Object[][] {{"n0", 1}});
    Map<String, Object> n0_21 = makeMap(new Object[][] {{"n0", 2}});
    Map<String, Object> n0_22 = makeMap(new Object[][] {{"n0", 3}});
    Map[] n0_2 = new Map[] {n0_21, n0_22};
    epService.getEPRuntime().sendEvent(new Object[] {n0_1, n0_2}, "MyOAWithAMap");

    EventBean eventResult = listener.assertOneGetNewAndReset();
    EPAssertionUtil.assertProps(eventResult, "a,b,c,d".split(","), new Object[] {1, 2, 3, n0_1});
    Map[] valueE = (Map[]) eventResult.get("e");
    assertSame(valueE[0], n0_2[0]);
    assertSame(valueE[1], n0_2[1]);

    assertEquals(int.class, stmt.getEventType().getPropertyType("a"));
    assertEquals(int.class, stmt.getEventType().getPropertyType("b"));
    assertEquals(int.class, stmt.getEventType().getPropertyType("c"));
    assertEquals(Map.class, stmt.getEventType().getPropertyType("d"));
    assertEquals(Map[].class, stmt.getEventType().getPropertyType("e"));
  }
  public void testMostLeastEvents() {

    String[] fields = "val0,val1".split(",");
    String eplFragment =
        "select "
            + "contained.mostFrequent(x => p00) as val0,"
            + "contained.leastFrequent(x => p00) as val1 "
            + "from Bean";
    EPStatement stmtFragment = epService.getEPAdministrator().createEPL(eplFragment);
    stmtFragment.addListener(listener);
    LambdaAssertionUtil.assertTypes(
        stmtFragment.getEventType(), fields, new Class[] {Integer.class, Integer.class});

    SupportBean_ST0_Container bean =
        SupportBean_ST0_Container.make2Value("E1,12", "E2,11", "E2,2", "E3,12");
    epService.getEPRuntime().sendEvent(bean);
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {12, 11});

    bean = SupportBean_ST0_Container.make2Value("E1,12");
    epService.getEPRuntime().sendEvent(bean);
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {12, 12});

    bean =
        SupportBean_ST0_Container.make2Value(
            "E1,12", "E2,11", "E2,2", "E3,12", "E1,12", "E2,11", "E3,11");
    epService.getEPRuntime().sendEvent(bean);
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {12, 2});

    bean =
        SupportBean_ST0_Container.make2Value(
            "E2,11", "E1,12", "E2,15", "E3,12", "E1,12", "E2,11", "E3,11");
    epService.getEPRuntime().sendEvent(bean);
    EPAssertionUtil.assertProps(listener.assertOneGetNewAndReset(), fields, new Object[] {11, 15});

    epService.getEPRuntime().sendEvent(SupportBean_ST0_Container.make2Value(null));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null});

    epService.getEPRuntime().sendEvent(SupportBean_ST0_Container.make2Value());
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, null});
  }
예제 #20
0
  public void testAnyType() {
    assertTrue(
        epService.getEPAdministrator().getConfiguration().isVariantStreamExists("MyVariantStream"));
    epService
        .getEPAdministrator()
        .createEPL("insert into MyVariantStream select * from " + SupportBean.class.getName());
    epService
        .getEPAdministrator()
        .createEPL(
            "insert into MyVariantStream select * from "
                + SupportBeanVariantStream.class.getName());
    epService
        .getEPAdministrator()
        .createEPL("insert into MyVariantStream select * from " + SupportBean_A.class.getName());
    epService
        .getEPAdministrator()
        .createEPL(
            "insert into MyVariantStream select symbol as theString, volume as intPrimitive, feed as id from "
                + SupportMarketDataBean.class.getName());

    EPStatement stmt = epService.getEPAdministrator().createEPL("select * from MyVariantStream");
    stmt.addListener(listener);
    assertEquals(0, stmt.getEventType().getPropertyNames().length);

    Object eventOne = new SupportBean("E0", -1);
    epService.getEPRuntime().sendEvent(eventOne);
    assertSame(eventOne, listener.assertOneGetNewAndReset().getUnderlying());

    Object eventTwo = new SupportBean_A("E1");
    epService.getEPRuntime().sendEvent(eventTwo);
    assertSame(eventTwo, listener.assertOneGetNewAndReset().getUnderlying());

    stmt.destroy();
    stmt =
        epService
            .getEPAdministrator()
            .createEPL("select theString,id,intPrimitive from MyVariantStream");
    stmt.addListener(listener);
    assertEquals(Object.class, stmt.getEventType().getPropertyType("theString"));
    assertEquals(Object.class, stmt.getEventType().getPropertyType("id"));
    assertEquals(Object.class, stmt.getEventType().getPropertyType("intPrimitive"));

    String[] fields = "theString,id,intPrimitive".split(",");
    epService.getEPRuntime().sendEvent(new SupportBeanVariantStream("E1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"E1", null, null});

    epService.getEPRuntime().sendEvent(new SupportBean("E2", 10));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"E2", null, 10});

    epService.getEPRuntime().sendEvent(new SupportBean_A("E3"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {null, "E3", null});

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("s1", 100, 1000L, "f1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"s1", "f1", 1000L});
    epService.getEPAdministrator().destroyAllStatements();

    // Test inserting a wrapper of underlying plus properties
    epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);
    epService.getEPAdministrator().createEPL("create variant schema TheVariantStream as *");
    epService
        .getEPAdministrator()
        .createEPL(
            "insert into TheVariantStream select 'test' as eventConfigId, * from SupportBean");
    epService
        .getEPAdministrator()
        .createEPL("select * from TheVariantStream")
        .addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
    EventBean event = listener.assertOneGetNewAndReset();
    assertEquals("test", event.get("eventConfigId"));
    assertEquals(1, event.get("intPrimitive"));
  }
  private void runObjectArrInheritanceAssertion(EPServiceProvider epService) {
    SupportUpdateListener listeners[] = new SupportUpdateListener[5];
    String[] statements = {
      "select base as vbase, sub1? as v1, sub2? as v2, suba? as va, subb? as vb from RootEvent", // 0
      "select base as vbase, sub1 as v1, sub2? as v2, suba? as va, subb? as vb from Sub1Event", // 1
      "select base as vbase, sub1? as v1, sub2 as v2, suba? as va, subb? as vb from Sub2Event", // 2
      "select base as vbase, sub1 as v1, sub2? as v2, suba as va, subb? as vb from SubAEvent", // 3
      "select base as vbase, sub1? as v1, sub2? as v2, suba? as va, subb as vb from SubBEvent" // 4
    };
    for (int i = 0; i < statements.length; i++) {
      EPStatement statement = epService.getEPAdministrator().createEPL(statements[i]);
      listeners[i] = new SupportUpdateListener();
      statement.addListener(listeners[i]);
    }
    String[] fields = "vbase,v1,v2,va,vb".split(",");

    EventType type = epService.getEPAdministrator().getConfiguration().getEventType("SubAEvent");
    assertEquals("base", type.getPropertyDescriptors()[0].getPropertyName());
    assertEquals("sub1", type.getPropertyDescriptors()[1].getPropertyName());
    assertEquals("suba", type.getPropertyDescriptors()[2].getPropertyName());
    assertEquals(3, type.getPropertyDescriptors().length);

    type = epService.getEPAdministrator().getConfiguration().getEventType("SubBEvent");
    assertEquals("[base, sub1, suba, subb]", Arrays.toString(type.getPropertyNames()));
    assertEquals(4, type.getPropertyDescriptors().length);

    type = epService.getEPAdministrator().getConfiguration().getEventType("Sub1Event");
    assertEquals("[base, sub1]", Arrays.toString(type.getPropertyNames()));
    assertEquals(2, type.getPropertyDescriptors().length);

    type = epService.getEPAdministrator().getConfiguration().getEventType("Sub2Event");
    assertEquals("[base, sub2]", Arrays.toString(type.getPropertyNames()));
    assertEquals(2, type.getPropertyDescriptors().length);

    epService
        .getEPRuntime()
        .sendEvent(new Object[] {"a", "b", "x"}, "SubAEvent"); // base, sub1, suba
    EPAssertionUtil.assertProps(
        listeners[0].assertOneGetNewAndReset(), fields, new Object[] {"a", "b", null, "x", null});
    assertFalse(listeners[2].isInvoked() || listeners[4].isInvoked());
    EPAssertionUtil.assertProps(
        listeners[1].assertOneGetNewAndReset(), fields, new Object[] {"a", "b", null, "x", null});
    EPAssertionUtil.assertProps(
        listeners[3].assertOneGetNewAndReset(), fields, new Object[] {"a", "b", null, "x", null});

    epService.getEPRuntime().sendEvent(new Object[] {"f1", "f2", "f4"}, "SubAEvent");
    EPAssertionUtil.assertProps(
        listeners[0].assertOneGetNewAndReset(),
        fields,
        new Object[] {"f1", "f2", null, "f4", null});
    assertFalse(listeners[2].isInvoked() || listeners[4].isInvoked());
    EPAssertionUtil.assertProps(
        listeners[1].assertOneGetNewAndReset(),
        fields,
        new Object[] {"f1", "f2", null, "f4", null});
    EPAssertionUtil.assertProps(
        listeners[3].assertOneGetNewAndReset(),
        fields,
        new Object[] {"f1", "f2", null, "f4", null});

    epService.getEPRuntime().sendEvent(new Object[] {"XBASE", "X1", "X2", "XY"}, "SubBEvent");
    Object[] values = new Object[] {"XBASE", "X1", null, "X2", "XY"};
    EPAssertionUtil.assertProps(listeners[0].assertOneGetNewAndReset(), fields, values);
    assertFalse(listeners[2].isInvoked());
    EPAssertionUtil.assertProps(listeners[1].assertOneGetNewAndReset(), fields, values);
    EPAssertionUtil.assertProps(listeners[3].assertOneGetNewAndReset(), fields, values);
    EPAssertionUtil.assertProps(listeners[4].assertOneGetNewAndReset(), fields, values);

    epService.getEPRuntime().sendEvent(new Object[] {"YBASE", "Y1"}, "Sub1Event");
    values = new Object[] {"YBASE", "Y1", null, null, null};
    EPAssertionUtil.assertProps(listeners[0].assertOneGetNewAndReset(), fields, values);
    assertFalse(listeners[2].isInvoked() || listeners[3].isInvoked() || listeners[4].isInvoked());
    EPAssertionUtil.assertProps(listeners[1].assertOneGetNewAndReset(), fields, values);

    epService.getEPRuntime().sendEvent(new Object[] {"YBASE", "Y2"}, "Sub2Event");
    values = new Object[] {"YBASE", null, "Y2", null, null};
    EPAssertionUtil.assertProps(listeners[0].assertOneGetNewAndReset(), fields, values);
    assertFalse(listeners[1].isInvoked() || listeners[3].isInvoked() || listeners[4].isInvoked());
    EPAssertionUtil.assertProps(listeners[2].assertOneGetNewAndReset(), fields, values);

    epService.getEPRuntime().sendEvent(new Object[] {"ZBASE"}, "RootEvent");
    values = new Object[] {"ZBASE", null, null, null, null};
    EPAssertionUtil.assertProps(listeners[0].assertOneGetNewAndReset(), fields, values);
    assertFalse(
        listeners[1].isInvoked()
            || listeners[2].isInvoked()
            || listeners[3].isInvoked()
            || listeners[4].isInvoked());

    // try property not available
    try {
      epService.getEPAdministrator().createEPL("select suba from Sub1Event");
      fail();
    } catch (EPStatementException ex) {
      assertEquals(
          "Error starting statement: Failed to validate select-clause expression 'suba': Property named 'suba' is not valid in any stream (did you mean 'sub1'?) [select suba from Sub1Event]",
          ex.getMessage());
    }

    // try supertype not exists
    try {
      epService
          .getEPAdministrator()
          .getConfiguration()
          .addEventType("Sub1Event", makeMap(""), new String[] {"doodle"});
      fail();
    } catch (ConfigurationException ex) {
      assertEquals("Supertype by name 'doodle' could not be found", ex.getMessage());
    }
  }
  public void testNestedPojo() {
    Pair<String[], Object[]> pair = getTestDefTwo();
    EPServiceProvider epService =
        getEngineInitialized("NestedObjectArr", pair.getFirst(), pair.getSecond());

    String statementText =
        "select "
            + "simple, object, nodefmap, map, "
            + "object.id as a1, nodefmap.key1? as a2, nodefmap.key2? as a3, nodefmap.key3?.key4 as a4, "
            + "map.objectOne as b1, map.simpleOne as b2, map.nodefmapOne.key2? as b3, map.mapOne.simpleTwo? as b4, "
            + "map.objectOne.indexed[1] as c1, map.objectOne.nested.nestedValue as c2,"
            + "map.mapOne.simpleTwo as d1, map.mapOne.objectTwo as d2, map.mapOne.nodefmapTwo as d3, "
            + "map.mapOne.mapTwo as e1, map.mapOne.mapTwo.simpleThree as e2, map.mapOne.mapTwo.objectThree as e3, "
            + "map.mapOne.objectTwo.array[1].mapped('1ma').value as f1, map.mapOne.mapTwo.objectThree.id as f2"
            + " from NestedObjectArr";
    EPStatement statement = epService.getEPAdministrator().createEPL(statementText);
    SupportUpdateListener listener = new SupportUpdateListener();
    statement.addListener(listener);

    Object[] testdata = getTestDataTwo();
    epService.getEPRuntime().sendEvent(testdata, "NestedObjectArr");

    // test all properties exist
    EventBean received = listener.assertOneGetNewAndReset();
    EPAssertionUtil.assertProps(
        received,
        "simple,object,nodefmap,map".split(","),
        new Object[] {"abc", new SupportBean_A("A1"), testdata[2], testdata[3]});
    EPAssertionUtil.assertProps(
        received, "a1,a2,a3,a4".split(","), new Object[] {"A1", "val1", null, null});
    EPAssertionUtil.assertProps(
        received,
        "b1,b2,b3,b4".split(","),
        new Object[] {getNestedKey(testdata, 3, "objectOne"), 10, "val2", 300});
    EPAssertionUtil.assertProps(received, "c1,c2".split(","), new Object[] {2, "nestedValue"});
    EPAssertionUtil.assertProps(
        received,
        "d1,d2,d3".split(","),
        new Object[] {
          300,
          getNestedKey(testdata, 3, "mapOne", "objectTwo"),
          getNestedKey(testdata, 3, "mapOne", "nodefmapTwo")
        });
    EPAssertionUtil.assertProps(
        received,
        "e1,e2,e3".split(","),
        new Object[] {
          getNestedKey(testdata, 3, "mapOne", "mapTwo"), 4000L, new SupportBean_B("B1")
        });
    EPAssertionUtil.assertProps(received, "f1,f2".split(","), new Object[] {"1ma0", "B1"});

    // assert type info
    EPStatement stmt = epService.getEPAdministrator().createEPL(("select * from NestedObjectArr"));
    EventType eventType = stmt.getEventType();

    String[] propertiesReceived = eventType.getPropertyNames();
    String[] propertiesExpected = new String[] {"simple", "object", "nodefmap", "map"};
    EPAssertionUtil.assertEqualsAnyOrder(propertiesReceived, propertiesExpected);
    assertEquals(String.class, eventType.getPropertyType("simple"));
    assertEquals(Map.class, eventType.getPropertyType("map"));
    assertEquals(Map.class, eventType.getPropertyType("nodefmap"));
    assertEquals(SupportBean_A.class, eventType.getPropertyType("object"));

    assertNull(eventType.getPropertyType("map.mapOne.simpleOne"));

    // nested POJO with generic return type
    listener.reset();
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyNested", new String[] {"bean"}, new Object[] {MyNested.class});
    EPStatement stmtTwo =
        epService
            .getEPAdministrator()
            .createEPL("select * from MyNested(bean.insides.anyOf(i=>id = 'A'))");
    stmtTwo.addListener(listener);

    epService
        .getEPRuntime()
        .sendEvent(
            new Object[] {new MyNested(Arrays.asList(new MyInside[] {new MyInside("A")}))},
            "MyNested");
    assertTrue(listener.isInvoked());
  }
  public void testMappedProperty() {
    EPServiceProvider epService = getEngineInitialized(null, null, null);

    // test map containing first-level property that is an array of primitive or Class
    Map<String, Object> mappedDef = makeMap(new Object[][] {{"p0", Map.class}});
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyMappedPropertyMap", mappedDef);

    EPStatement stmt =
        epService.getEPAdministrator().createEPL("select p0('k1') as a from MyMappedPropertyMap");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    Map<String, Object> eventVal = new HashMap<String, Object>();
    eventVal.put("k1", "v1");
    Map<String, Object> theEvent = makeMap(new Object[][] {{"p0", eventVal}});
    epService.getEPRuntime().sendEvent(theEvent, "MyMappedPropertyMap");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), "a".split(","), new Object[] {"v1"});
    assertEquals(Object.class, stmt.getEventType().getPropertyType("a"));
    stmt.destroy();

    // test map at the second level of a nested map that is an array of primitive or Class
    Map<String, Object> mappedDefOuter = makeMap(new Object[][] {{"outer", mappedDef}});
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyMappedPropertyMapOuter", mappedDefOuter);

    stmt =
        epService
            .getEPAdministrator()
            .createEPL("select outer.p0('k1') as a from MyMappedPropertyMapOuter");
    stmt.addListener(listener);

    Map<String, Object> eventOuter = makeMap(new Object[][] {{"outer", theEvent}});
    epService.getEPRuntime().sendEvent(eventOuter, "MyMappedPropertyMapOuter");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), "a".split(","), new Object[] {"v1"});
    assertEquals(Object.class, stmt.getEventType().getPropertyType("a"));

    // test map that contains a bean which has a map property
    Map<String, Object> mappedDefOuterTwo =
        makeMap(new Object[][] {{"outerTwo", SupportBeanComplexProps.class}});
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyMappedPropertyMapOuterTwo", mappedDefOuterTwo);

    stmt =
        epService
            .getEPAdministrator()
            .createEPL("select outerTwo.mapProperty('xOne') as a from MyMappedPropertyMapOuterTwo");
    stmt.addListener(listener);

    Map<String, Object> eventOuterTwo =
        makeMap(new Object[][] {{"outerTwo", SupportBeanComplexProps.makeDefaultBean()}});
    epService.getEPRuntime().sendEvent(eventOuterTwo, "MyMappedPropertyMapOuterTwo");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), "a".split(","), new Object[] {"yOne"});
    assertEquals(String.class, stmt.getEventType().getPropertyType("a"));
  }
예제 #24
0
  private void runAssertionOrderOfAggs(boolean ungrouped) {

    String eplDeclare =
        "create table varagg ("
            + (ungrouped ? "" : "key string primary key, ")
            + "sumint sum(int), "
            + "sumlong sum(long), "
            + "mysort sorted(intPrimitive) @type(SupportBean),"
            + "mywindow window(*) @type(SupportBean)"
            + ")";
    epService.getEPAdministrator().createEPL(eplDeclare);

    String[] fieldsTable = "sumint,sumlong,mywindow,mysort".split(",");
    SupportUpdateListener listenerIntoTable = new SupportUpdateListener();
    String eplSelect =
        "into table varagg select "
            + "sum(longPrimitive) as sumlong, "
            + "sum(intPrimitive) as sumint, "
            + "window(*) as mywindow,"
            + "sorted() as mysort "
            + "from SupportBean.win:length(2) "
            + (ungrouped ? "" : "group by theString ");
    epService.getEPAdministrator().createEPL(eplSelect).addListener(listenerIntoTable);

    String[] fieldsSelect = "c0,c1,c2,c3".split(",");
    String groupKey = ungrouped ? "" : "['E1']";
    epService
        .getEPAdministrator()
        .createEPL(
            "select "
                + "varagg"
                + groupKey
                + ".sumint as c0, "
                + "varagg"
                + groupKey
                + ".sumlong as c1,"
                + "varagg"
                + groupKey
                + ".mywindow as c2,"
                + "varagg"
                + groupKey
                + ".mysort as c3 from SupportBean_S0")
        .addListener(listener);

    SupportBean e1 = makeSendBean("E1", 10, 100);
    EPAssertionUtil.assertProps(
        listenerIntoTable.assertOneGetNewAndReset(),
        fieldsTable,
        new Object[] {10, 100L, new Object[] {e1}, new Object[] {e1}});

    SupportBean e2 = makeSendBean("E1", 5, 50);
    EPAssertionUtil.assertProps(
        listenerIntoTable.assertOneGetNewAndReset(),
        fieldsTable,
        new Object[] {15, 150L, new Object[] {e1, e2}, new Object[] {e2, e1}});

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fieldsSelect,
        new Object[] {15, 150L, new Object[] {e1, e2}, new Object[] {e2, e1}});

    SupportBean e3 = makeSendBean("E1", 12, 120);
    EPAssertionUtil.assertProps(
        listenerIntoTable.assertOneGetNewAndReset(),
        fieldsTable,
        new Object[] {17, 170L, new Object[] {e2, e3}, new Object[] {e2, e3}});

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fieldsSelect,
        new Object[] {17, 170L, new Object[] {e2, e3}, new Object[] {e2, e3}});

    epService.getEPAdministrator().destroyAllStatements();
    epService
        .getEPAdministrator()
        .getConfiguration()
        .removeEventType("table_varagg__internal", false);
    epService
        .getEPAdministrator()
        .getConfiguration()
        .removeEventType("table_varagg__public", false);
  }
예제 #25
0
  private void runAssertionMultiStmtContributingDifferentAggs(boolean grouped) {
    String eplDeclare =
        "create table varagg ("
            + (grouped ? "key string primary key," : "")
            + "s0sum sum(int), s0cnt count(*), s0win window(*) @type(SupportBean_S0),"
            + "s1sum sum(int), s1cnt count(*), s1win window(*) @type(SupportBean_S1)"
            + ")";
    epService.getEPAdministrator().createEPL(eplDeclare);

    String[] fieldsSelect = "c0,c1,c2,c3,c4,c5".split(",");
    String eplSelectUngrouped =
        "select varagg.s0sum as c0, varagg.s0cnt as c1,"
            + "varagg.s0win as c2, varagg.s1sum as c3, varagg.s1cnt as c4,"
            + "varagg.s1win as c5 from SupportBean";
    String eplSelectGrouped =
        "select varagg[theString].s0sum as c0, varagg[theString].s0cnt as c1,"
            + "varagg[theString].s0win as c2, varagg[theString].s1sum as c3, varagg[theString].s1cnt as c4,"
            + "varagg[theString].s1win as c5 from SupportBean";
    epService
        .getEPAdministrator()
        .createEPL(grouped ? eplSelectGrouped : eplSelectUngrouped)
        .addListener(listener);

    SupportUpdateListener listenerOne = new SupportUpdateListener();
    String[] fieldsOne = "s0sum,s0cnt,s0win".split(",");
    String eplBindOne =
        "into table varagg select sum(id) as s0sum, count(*) as s0cnt, window(*) as s0win from SupportBean_S0.win:length(2) "
            + (grouped ? "group by p00" : "");
    epService.getEPAdministrator().createEPL(eplBindOne).addListener(listenerOne);

    SupportUpdateListener listenerTwo = new SupportUpdateListener();
    String[] fieldsTwo = "s1sum,s1cnt,s1win".split(",");
    String eplBindTwo =
        "into table varagg select sum(id) as s1sum, count(*) as s1cnt, window(*) as s1win from SupportBean_S1.win:length(2) "
            + (grouped ? "group by p10" : "");
    epService.getEPAdministrator().createEPL(eplBindTwo).addListener(listenerTwo);

    // contribute S1
    SupportBean_S1 s1_1 = makeSendS1(10, "G1");
    EPAssertionUtil.assertProps(
        listenerTwo.assertOneGetNewAndReset(),
        fieldsTwo,
        new Object[] {10, 1L, new Object[] {s1_1}});

    epService.getEPRuntime().sendEvent(new SupportBean("G1", 0));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fieldsSelect,
        new Object[] {null, 0L, null, 10, 1L, new Object[] {s1_1}});

    // contribute S0
    SupportBean_S0 s0_1 = makeSendS0(20, "G1");
    EPAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(),
        fieldsOne,
        new Object[] {20, 1L, new Object[] {s0_1}});

    epService.getEPRuntime().sendEvent(new SupportBean("G1", 0));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fieldsSelect,
        new Object[] {20, 1L, new Object[] {s0_1}, 10, 1L, new Object[] {s1_1}});

    // contribute S1 and S0
    SupportBean_S1 s1_2 = makeSendS1(11, "G1");
    EPAssertionUtil.assertProps(
        listenerTwo.assertOneGetNewAndReset(),
        fieldsTwo,
        new Object[] {21, 2L, new Object[] {s1_1, s1_2}});
    SupportBean_S0 s0_2 = makeSendS0(21, "G1");
    EPAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(),
        fieldsOne,
        new Object[] {41, 2L, new Object[] {s0_1, s0_2}});

    epService.getEPRuntime().sendEvent(new SupportBean("G1", 0));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fieldsSelect,
        new Object[] {41, 2L, new Object[] {s0_1, s0_2}, 21, 2L, new Object[] {s1_1, s1_2}});

    // contribute S1 and S0 (leave)
    SupportBean_S1 s1_3 = makeSendS1(12, "G1");
    EPAssertionUtil.assertProps(
        listenerTwo.assertOneGetNewAndReset(),
        fieldsTwo,
        new Object[] {23, 2L, new Object[] {s1_2, s1_3}});
    SupportBean_S0 s0_3 = makeSendS0(22, "G1");
    EPAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(),
        fieldsOne,
        new Object[] {43, 2L, new Object[] {s0_2, s0_3}});

    epService.getEPRuntime().sendEvent(new SupportBean("G1", 0));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fieldsSelect,
        new Object[] {43, 2L, new Object[] {s0_2, s0_3}, 23, 2L, new Object[] {s1_2, s1_3}});

    epService.getEPAdministrator().destroyAllStatements();
    epService
        .getEPAdministrator()
        .getConfiguration()
        .removeEventType("table_varagg__internal", false);
    epService
        .getEPAdministrator()
        .getConfiguration()
        .removeEventType("table_varagg__public", false);
  }
  public void testObjectArrayTypeUpdate() {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration
        .getEngineDefaults()
        .getEventMeta()
        .setDefaultEventRepresentation(Configuration.EventRepresentation.OBJECTARRAY);

    String[] names = {"base1", "base2"};
    Object[] types = {String.class, makeMap(new Object[][] {{"n1", int.class}})};
    configuration.addEventType("MyOAEvent", names, types);

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }

    EPStatement statementOne =
        epService
            .getEPAdministrator()
            .createEPL(
                "select base1 as v1, base2.n1 as v2, base3? as v3, base2.n2? as v4 from MyOAEvent");
    assertEquals(Object[].class, statementOne.getEventType().getUnderlyingType());
    EPStatement statementOneSelectAll =
        epService.getEPAdministrator().createEPL("select * from MyOAEvent");
    assertEquals(
        "[base1, base2]", Arrays.toString(statementOneSelectAll.getEventType().getPropertyNames()));
    SupportUpdateListener listenerOne = new SupportUpdateListener();
    statementOne.addListener(listenerOne);
    String[] fields = "v1,v2,v3,v4".split(",");

    epService
        .getEPRuntime()
        .sendEvent(new Object[] {"abc", makeMap(new Object[][] {{"n1", 10}}), ""}, "MyOAEvent");
    EPAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(), fields, new Object[] {"abc", 10, null, null});

    // update type
    String[] namesNew = {"base3", "base2"};
    Object[] typesNew = new Object[] {Long.class, makeMap(new Object[][] {{"n2", String.class}})};
    epService
        .getEPAdministrator()
        .getConfiguration()
        .updateObjectArrayEventType("MyOAEvent", namesNew, typesNew);

    EPStatement statementTwo =
        epService
            .getEPAdministrator()
            .createEPL(
                "select base1 as v1, base2.n1 as v2, base3 as v3, base2.n2 as v4 from MyOAEvent");
    EPStatement statementTwoSelectAll =
        epService.getEPAdministrator().createEPL("select * from MyOAEvent");
    SupportUpdateListener listenerTwo = new SupportUpdateListener();
    statementTwo.addListener(listenerTwo);

    epService
        .getEPRuntime()
        .sendEvent(
            new Object[] {"def", makeMap(new Object[][] {{"n1", 9}, {"n2", "xyz"}}), 20L},
            "MyOAEvent");
    EPAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(), fields, new Object[] {"def", 9, 20L, "xyz"});
    EPAssertionUtil.assertProps(
        listenerTwo.assertOneGetNewAndReset(), fields, new Object[] {"def", 9, 20L, "xyz"});

    // assert event type
    assertEquals(
        "[base1, base2, base3]",
        Arrays.toString(statementOneSelectAll.getEventType().getPropertyNames()));
    assertEquals(
        "[base1, base2, base3]",
        Arrays.toString(statementTwoSelectAll.getEventType().getPropertyNames()));

    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {
          new EventPropertyDescriptor("base3", Long.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("base2", Map.class, null, false, false, false, true, false),
          new EventPropertyDescriptor(
              "base1", String.class, null, false, false, false, false, false),
        },
        statementTwoSelectAll.getEventType().getPropertyDescriptors());

    try {
      epService
          .getEPAdministrator()
          .getConfiguration()
          .updateObjectArrayEventType("dummy", new String[0], new Object[0]);
      fail();
    } catch (ConfigurationException ex) {
      assertEquals(
          "Error updating Object-array event type: Event type named 'dummy' has not been declared",
          ex.getMessage());
    }

    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("SupportBean", SupportBean.class);
    try {
      epService
          .getEPAdministrator()
          .getConfiguration()
          .updateObjectArrayEventType("SupportBean", new String[0], new Object[0]);
      fail();
    } catch (ConfigurationException ex) {
      assertEquals(
          "Error updating Object-array event type: Event type by name 'SupportBean' is not an Object-array event type",
          ex.getMessage());
    }

    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.endTest();
    }
  }
예제 #27
0
  public void testTopLevelReadUnGrouped() {
    epService.getEPAdministrator().getConfiguration().addEventType(AggBean.class);
    epService.getEPAdministrator().createEPL("create objectarray schema MyEvent(c0 int)");
    epService
        .getEPAdministrator()
        .createEPL(
            "create table windowAndTotal ("
                + "thewindow window(*) @type(MyEvent), thetotal sum(int))");
    epService
        .getEPAdministrator()
        .createEPL(
            "into table windowAndTotal "
                + "select window(*) as thewindow, sum(c0) as thetotal from MyEvent.win:length(2)");

    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL("select windowAndTotal as val0 from SupportBean_S0");
    stmt.addListener(listener);

    Object[] e1 = new Object[] {10};
    epService.getEPRuntime().sendEvent(e1, "MyEvent");

    String[] fieldsInner = "thewindow,thetotal".split(",");
    epService.getEPRuntime().sendEvent(new SupportBean_S0(0));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"), fieldsInner, new Object[][] {e1}, 10);

    Object[] e2 = new Object[] {20};
    epService.getEPRuntime().sendEvent(e2, "MyEvent");

    epService.getEPRuntime().sendEvent(new SupportBean_S0(1));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"),
        fieldsInner,
        new Object[][] {e1, e2},
        30);

    Object[] e3 = new Object[] {30};
    epService.getEPRuntime().sendEvent(e3, "MyEvent");

    epService.getEPRuntime().sendEvent(new SupportBean_S0(2));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"),
        fieldsInner,
        new Object[][] {e2, e3},
        50);

    // test typable output
    stmt.destroy();
    EPStatement stmtConvert =
        epService
            .getEPAdministrator()
            .createEPL("insert into AggBean select windowAndTotal as val0 from SupportBean_S0");
    stmtConvert.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(2));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        "val0.thewindow,val0.thetotal".split(","),
        new Object[] {new Object[][] {e2, e3}, 50});
  }
예제 #28
0
  private void runAssertionTopLevelReadGrouped2Keys(boolean soda) {
    SupportModelHelper.createByCompileOrParse(
        epService, soda, "create objectarray schema MyEvent as (c0 int, c1 string, c2 int)");
    SupportModelHelper.createByCompileOrParse(
        epService,
        soda,
        "create table windowAndTotal ("
            + "keyi int primary key, keys string primary key, thewindow window(*) @type('MyEvent'), thetotal sum(int))");
    SupportModelHelper.createByCompileOrParse(
        epService,
        soda,
        "into table windowAndTotal "
            + "select window(*) as thewindow, sum(c2) as thetotal from MyEvent.win:length(2) group by c0, c1");

    EPStatement stmtSelect =
        SupportModelHelper.createByCompileOrParse(
            epService, soda, "select windowAndTotal[id,p00] as val0 from SupportBean_S0");
    stmtSelect.addListener(listener);
    assertTopLevelTypeInfo(stmtSelect);

    Object[] e1 = new Object[] {10, "G1", 100};
    epService.getEPRuntime().sendEvent(e1, "MyEvent");

    String[] fieldsInner = "thewindow,thetotal".split(",");
    epService.getEPRuntime().sendEvent(new SupportBean_S0(10, "G1"));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"),
        fieldsInner,
        new Object[][] {e1},
        100);

    Object[] e2 = new Object[] {20, "G2", 200};
    epService.getEPRuntime().sendEvent(e2, "MyEvent");

    epService.getEPRuntime().sendEvent(new SupportBean_S0(20, "G2"));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"),
        fieldsInner,
        new Object[][] {e2},
        200);

    Object[] e3 = new Object[] {20, "G2", 300};
    epService.getEPRuntime().sendEvent(e3, "MyEvent");

    epService.getEPRuntime().sendEvent(new SupportBean_S0(10, "G1"));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"), fieldsInner, null, null);
    epService.getEPRuntime().sendEvent(new SupportBean_S0(20, "G2"));
    EPAssertionUtil.assertPropsMap(
        (Map) listener.assertOneGetNewAndReset().get("val0"),
        fieldsInner,
        new Object[][] {e2, e3},
        500);

    // test typable output
    stmtSelect.destroy();
    EPStatement stmtConvert =
        epService
            .getEPAdministrator()
            .createEPL(
                "insert into AggBean select windowAndTotal[20, 'G2'] as val0 from SupportBean_S0");
    stmtConvert.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        "val0.thewindow,val0.thetotal".split(","),
        new Object[] {new Object[][] {e2, e3}, 500});

    epService.getEPAdministrator().destroyAllStatements();
  }
예제 #29
0
  public void testAverageScalar() {

    String[] fields = "val0,val1".split(",");
    String eplFragment =
        "select "
            + "intvals.average() as val0,"
            + "bdvals.average() as val1 "
            + "from SupportCollection";
    EPStatement stmtFragment = epService.getEPAdministrator().createEPL(eplFragment);
    stmtFragment.addListener(listener);
    LambdaAssertionUtil.assertTypes(
        stmtFragment.getEventType(), fields, new Class[] {Double.class, BigDecimal.class});

    epService.getEPRuntime().sendEvent(SupportCollection.makeNumeric("1,2,3"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {2d, new BigDecimal(2d)});

    epService.getEPRuntime().sendEvent(SupportCollection.makeNumeric("1,null,3"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {2d, new BigDecimal(2d)});

    epService.getEPRuntime().sendEvent(SupportCollection.makeNumeric("4"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {4d, new BigDecimal(4d)});
    stmtFragment.destroy();

    // test average with lambda
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addPlugInSingleRowFunction(
            "extractNum", TestEnumMinMax.MyService.class.getName(), "extractNum");
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addPlugInSingleRowFunction(
            "extractBigDecimal", TestEnumMinMax.MyService.class.getName(), "extractBigDecimal");

    String[] fieldsLambda = "val0,val1".split(",");
    String eplLambda =
        "select "
            + "strvals.average(v => extractNum(v)) as val0, "
            + "strvals.average(v => extractBigDecimal(v)) as val1 "
            + "from SupportCollection";
    EPStatement stmtLambda = epService.getEPAdministrator().createEPL(eplLambda);
    stmtLambda.addListener(listener);
    LambdaAssertionUtil.assertTypes(
        stmtLambda.getEventType(), fieldsLambda, new Class[] {Double.class, BigDecimal.class});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString("E2,E1,E5,E4"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fieldsLambda,
        new Object[] {(2 + 1 + 5 + 4) / 4d, new BigDecimal((2 + 1 + 5 + 4) / 4d)});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString("E1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fieldsLambda, new Object[] {1d, new BigDecimal(1)});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString(null));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fieldsLambda, new Object[] {null, null});

    epService.getEPRuntime().sendEvent(SupportCollection.makeString(""));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fieldsLambda, new Object[] {null, null});
  }
예제 #30
0
  public void testLinest() {
    // further math tests can be found in the view unit test
    EPAdministrator admin = epService.getEPAdministrator();
    admin.getConfiguration().addEventType("Market", SupportMarketDataBean.class);
    EPStatement statement =
        admin.createEPL(
            "select * from Market.std:groupwin(symbol).win:length(1000000).stat:linest(price, volume, feed)");
    SupportUpdateListener listener = new SupportUpdateListener();
    statement.addListener(listener);

    assertEquals(Double.class, statement.getEventType().getPropertyType("slope"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("YIntercept"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("XAverage"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("XStandardDeviationPop"));
    assertEquals(
        Double.class, statement.getEventType().getPropertyType("XStandardDeviationSample"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("XSum"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("XVariance"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("YAverage"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("YStandardDeviationPop"));
    assertEquals(
        Double.class, statement.getEventType().getPropertyType("YStandardDeviationSample"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("YSum"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("YVariance"));
    assertEquals(Long.class, statement.getEventType().getPropertyType("dataPoints"));
    assertEquals(Long.class, statement.getEventType().getPropertyType("n"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("sumX"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("sumXSq"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("sumXY"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("sumY"));
    assertEquals(Double.class, statement.getEventType().getPropertyType("sumYSq"));

    String[] fields = new String[] {"symbol", "slope", "YIntercept", "feed"};

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("ABC", 10.0, 50000L, "f1"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(),
        fields,
        new Object[] {"ABC", Double.NaN, Double.NaN, "f1"});

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("DEF", 1.0, 1L, "f2"));
    EventBean theEvent = listener.assertOneGetNewAndReset();
    EPAssertionUtil.assertProps(
        theEvent, fields, new Object[] {"DEF", Double.NaN, Double.NaN, "f2"});
    assertEquals(1d, theEvent.get("XAverage"));
    assertEquals(0d, theEvent.get("XStandardDeviationPop"));
    assertEquals(Double.NaN, theEvent.get("XStandardDeviationSample"));
    assertEquals(1d, theEvent.get("XSum"));
    assertEquals(Double.NaN, theEvent.get("XVariance"));
    assertEquals(1d, theEvent.get("YAverage"));
    assertEquals(0d, theEvent.get("YStandardDeviationPop"));
    assertEquals(Double.NaN, theEvent.get("YStandardDeviationSample"));
    assertEquals(1d, theEvent.get("YSum"));
    assertEquals(Double.NaN, theEvent.get("YVariance"));
    assertEquals(1L, theEvent.get("dataPoints"));
    assertEquals(1L, theEvent.get("n"));
    assertEquals(1d, theEvent.get("sumX"));
    assertEquals(1d, theEvent.get("sumXSq"));
    assertEquals(1d, theEvent.get("sumXY"));
    assertEquals(1d, theEvent.get("sumY"));
    assertEquals(1d, theEvent.get("sumYSq"));
    // above computed values tested in more detail in RegressionBean test

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("DEF", 2.0, 2L, "f3"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"DEF", 1.0, 0.0, "f3"});

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("ABC", 11.0, 50100L, "f4"));
    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), fields, new Object[] {"ABC", 100.0, 49000.0, "f4"});
  }