Ejemplo n.º 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"});
  }
Ejemplo n.º 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();
  }
  public void testAfterNextRow() {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("MyEvent", SupportRecogBean.class);
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();

    String[] fields = "a,b0,b1".split(",");
    String text =
        "select * from MyEvent.win:keepall() "
            + "match_recognize ("
            + "  measures A.theString as a, B[0].theString as b0, B[1].theString as b1"
            + "  AFTER MATCH SKIP TO NEXT ROW "
            + "  pattern (A B*) "
            + "  define "
            + "    A as A.theString like 'A%',"
            + "    B as B.theString like 'B%'"
            + ")";

    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportRecogBean("A1", 1));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"A1", null, null}});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"A1", null, null}});

    // since the first match skipped past A, we do not match again
    epService.getEPRuntime().sendEvent(new SupportRecogBean("B1", 2));
    assertFalse(listener.isInvoked()); // incremental skips to next
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"A1", "B1", null}});
  }
Ejemplo n.º 4
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});
  }
Ejemplo n.º 5
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});
  }
Ejemplo n.º 6
0
  public void testFlattenList() {
    // test many arrays
    EventBean[] testEvents =
        makeEventArray(new String[] {"a1", "a2", "b1", "b2", "b3", "c1", "c2"});
    ArrayDeque<UniformPair<EventBean[]>> eventVector = new ArrayDeque<UniformPair<EventBean[]>>();

    eventVector.add(
        new UniformPair<EventBean[]>(null, new EventBean[] {testEvents[0], testEvents[1]}));
    eventVector.add(new UniformPair<EventBean[]>(new EventBean[] {testEvents[2]}, null));
    eventVector.add(
        new UniformPair<EventBean[]>(
            null, new EventBean[] {testEvents[3], testEvents[4], testEvents[5]}));
    eventVector.add(new UniformPair<EventBean[]>(new EventBean[] {testEvents[6]}, null));

    UniformPair<EventBean[]> events = EventBeanUtility.flattenList(eventVector);
    EPAssertionUtil.assertEqualsExactOrder(
        new EventBean[] {testEvents[2], testEvents[6]}, events.getFirst());
    EPAssertionUtil.assertEqualsExactOrder(
        new EventBean[] {testEvents[0], testEvents[1], testEvents[3], testEvents[4], testEvents[5]},
        events.getSecond());

    // test just one array
    eventVector.clear();
    eventVector.add(new UniformPair<EventBean[]>(new EventBean[] {testEvents[2]}, null));
    events = EventBeanUtility.flattenList(eventVector);
    EPAssertionUtil.assertEqualsExactOrder(new EventBean[] {testEvents[2]}, events.getFirst());
    EPAssertionUtil.assertEqualsExactOrder((Object[]) null, events.getSecond());

    // test empty vector
    eventVector.clear();
    events = EventBeanUtility.flattenList(eventVector);
    assertNull(events);
  }
Ejemplo n.º 7
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"));
  }
Ejemplo n.º 9
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});
  }
Ejemplo n.º 10
0
  public void testStartCaptiveCancel() throws Exception {
    String[] fields = "p0,p1".split(",");
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyOAEventType", fields, new Object[] {String.class, int.class});

    epService
        .getEPAdministrator()
        .createEPL(
            "create dataflow MyDataFlow "
                + "Emitter -> outstream<MyOAEventType> {name:'src1'}"
                + "DefaultSupportCaptureOp(outstream) {}");

    DefaultSupportCaptureOp<Object> captureOp = new DefaultSupportCaptureOp<Object>();
    EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
    options.operatorProvider(new DefaultSupportGraphOpProvider(captureOp));

    EPDataFlowInstance instance =
        epService.getEPRuntime().getDataFlowRuntime().instantiate("MyDataFlow", options);
    EPDataFlowInstanceCaptive captiveStart = instance.startCaptive();
    assertEquals(0, captiveStart.getRunnables().size());
    assertEquals(1, captiveStart.getEmitters().size());
    Emitter emitter = captiveStart.getEmitters().get("src1");
    assertEquals(EPDataFlowState.RUNNING, instance.getState());

    emitter.submit(new Object[] {"E1", 10});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[][] {{"E1", 10}});

    emitter.submit(new Object[] {"E2", 20});
    EPAssertionUtil.assertPropsPerRow(
        captureOp.getCurrent(), fields, new Object[][] {{"E1", 10}, {"E2", 20}});

    emitter.submitSignal(new EPDataFlowSignalFinalMarker() {});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[0][]);
    EPAssertionUtil.assertPropsPerRow(
        captureOp.getAndReset().get(0).toArray(), fields, new Object[][] {{"E1", 10}, {"E2", 20}});

    emitter.submit(new Object[] {"E3", 30});
    EPAssertionUtil.assertPropsPerRow(captureOp.getCurrent(), fields, new Object[][] {{"E3", 30}});

    // stays running until cancelled (no transition to complete)
    assertEquals(EPDataFlowState.RUNNING, instance.getState());

    instance.cancel();
    assertEquals(EPDataFlowState.CANCELLED, instance.getState());

    // test doc sample
    String epl =
        "create dataflow HelloWorldDataFlow\n"
            + "  create schema SampleSchema(text string),\t// sample type\t\t\n"
            + "\t\n"
            + "  Emitter -> helloworld.stream<SampleSchema> { name: 'myemitter' }\n"
            + "  LogSink(helloworld.stream) {}";
    epService.getEPAdministrator().createEPL(epl);
    epService.getEPRuntime().getDataFlowRuntime().instantiate("HelloWorldDataFlow");
  }
  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"));
  }
  private void runQuery(
      String epl, String fields, Object[][] expected, ContextPartitionSelector[] selectors) {
    // try FAF without prepare
    EPOnDemandQueryResult result = epService.getEPRuntime().executeQuery(epl, selectors);
    EPAssertionUtil.assertPropsPerRowAnyOrder(result.getArray(), fields.split(","), expected);

    // test prepare and execute
    EPOnDemandPreparedQuery preparedQuery = epService.getEPRuntime().prepareQuery(epl);
    EPOnDemandQueryResult resultPrepared = preparedQuery.execute(selectors);
    EPAssertionUtil.assertPropsPerRowAnyOrder(
        resultPrepared.getArray(), fields.split(","), expected);
  }
Ejemplo n.º 13
0
  public void testVariantTwoWildcard() throws InterruptedException {
    String stmtText =
        "insert into event1 select * from " + SupportBean.class.getName() + ".win:length(100)";
    String otherText = "select * from default.event1.win:length(10)";

    // Attach listener to feed
    EPStatement stmtOne = epService.getEPAdministrator().createEPL(stmtText, "stmt1");
    assertEquals(
        StatementType.INSERT_INTO,
        ((EPStatementSPI) stmtOne).getStatementMetadata().getStatementType());
    SupportUpdateListener listenerOne = new SupportUpdateListener();
    stmtOne.addListener(listenerOne);
    EPStatement stmtTwo = epService.getEPAdministrator().createEPL(otherText, "stmt2");
    SupportUpdateListener listenerTwo = new SupportUpdateListener();
    stmtTwo.addListener(listenerTwo);

    SupportBean theEvent = sendEvent(10, 11);
    assertTrue(listenerOne.getAndClearIsInvoked());
    assertEquals(1, listenerOne.getLastNewData().length);
    assertEquals(10, listenerOne.getLastNewData()[0].get("intPrimitive"));
    assertEquals(11, listenerOne.getLastNewData()[0].get("intBoxed"));
    assertEquals(20, listenerOne.getLastNewData()[0].getEventType().getPropertyNames().length);
    assertSame(theEvent, listenerOne.getLastNewData()[0].getUnderlying());

    assertTrue(listenerTwo.getAndClearIsInvoked());
    assertEquals(1, listenerTwo.getLastNewData().length);
    assertEquals(10, listenerTwo.getLastNewData()[0].get("intPrimitive"));
    assertEquals(11, listenerTwo.getLastNewData()[0].get("intBoxed"));
    assertEquals(20, listenerTwo.getLastNewData()[0].getEventType().getPropertyNames().length);
    assertSame(theEvent, listenerTwo.getLastNewData()[0].getUnderlying());

    // assert statement-type reference
    EPServiceProviderSPI spi = (EPServiceProviderSPI) epService;
    assertTrue(spi.getStatementEventTypeRef().isInUse("event1"));
    Set<String> stmtNames = spi.getStatementEventTypeRef().getStatementNamesForType("event1");
    EPAssertionUtil.assertEqualsAnyOrder(stmtNames.toArray(), new String[] {"stmt1", "stmt2"});
    assertTrue(spi.getStatementEventTypeRef().isInUse(SupportBean.class.getName()));
    stmtNames =
        spi.getStatementEventTypeRef().getStatementNamesForType(SupportBean.class.getName());
    EPAssertionUtil.assertEqualsAnyOrder(stmtNames.toArray(), new String[] {"stmt1"});

    stmtOne.destroy();
    assertTrue(spi.getStatementEventTypeRef().isInUse("event1"));
    stmtNames = spi.getStatementEventTypeRef().getStatementNamesForType("event1");
    EPAssertionUtil.assertEqualsAnyOrder(new String[] {"stmt2"}, stmtNames.toArray());
    assertFalse(spi.getStatementEventTypeRef().isInUse(SupportBean.class.getName()));

    stmtTwo.destroy();
    assertFalse(spi.getStatementEventTypeRef().isInUse("event1"));
  }
  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});
  }
  private void runAssertion(
      EPServiceProvider epService, SupportUpdateListener listener, EPStatement stmt) {
    String[] fields = "a,b0,b1".split(",");

    epService.getEPRuntime().sendEvent(new SupportRecogBean("A1", 1));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"A1", null, null}});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"A1", null, null}});

    // since the first match skipped past A, we do not match again
    epService.getEPRuntime().sendEvent(new SupportRecogBean("B1", 2));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"A1", "B1", null}});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"A1", "B1", null}});
  }
Ejemplo n.º 16
0
  public void testAnyTypeStaggered() {
    // test insert into staggered with map
    ConfigurationVariantStream configVariantStream = new ConfigurationVariantStream();
    configVariantStream.setTypeVariance(ConfigurationVariantStream.TypeVariance.ANY);
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addVariantStream("VarStream", configVariantStream);
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("SupportBean", SupportBean.class);
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("SupportMarketDataBean", SupportMarketDataBean.class);

    epService
        .getEPAdministrator()
        .createEPL("insert into MyStream select theString, intPrimitive from SupportBean");
    epService
        .getEPAdministrator()
        .createEPL("insert into VarStream select theString as abc from MyStream");
    epService
        .getEPAdministrator()
        .createEPL("@Name('Target') select * from VarStream.win:keepall()");

    epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));

    EventBean[] arr =
        EPAssertionUtil.iteratorToArray(
            epService.getEPAdministrator().getStatement("Target").iterator());
    EPAssertionUtil.assertPropsPerRow(arr, new String[] {"abc"}, new Object[][] {{"E1"}});

    epService
        .getEPAdministrator()
        .createEPL("insert into MyStream2 select feed from SupportMarketDataBean");
    epService
        .getEPAdministrator()
        .createEPL("insert into VarStream select feed as abc from MyStream2");

    epService.getEPRuntime().sendEvent(new SupportMarketDataBean("IBM", 1, 1L, "E2"));

    arr =
        EPAssertionUtil.iteratorToArray(
            epService.getEPAdministrator().getStatement("Target").iterator());
    EPAssertionUtil.assertPropsPerRow(arr, new String[] {"abc"}, new Object[][] {{"E1"}, {"E2"}});
  }
Ejemplo n.º 17
0
  public void testArrayOp() {
    EventBean[] testEvent = makeEventArray(new String[] {"a1", "a2", "a3"});

    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {testEvent[0]}, EventBeanUtility.addToArray(new EventBean[0], testEvent[0]));

    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {testEvent[0], testEvent[1]},
        EventBeanUtility.addToArray(new EventBean[] {testEvent[0]}, testEvent[1]));

    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {testEvent[0], testEvent[1], testEvent[2]},
        EventBeanUtility.addToArray(new EventBean[] {testEvent[0], testEvent[1]}, testEvent[2]));

    System.out.println(EventBeanUtility.printEvents(testEvent));
  }
Ejemplo n.º 18
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});
 }
  private void runAssertionOnSelectWindowAgg(Object[][] expectedType, Object[] rowValues) {
    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL(
                "on SupportBean_S2 select "
                    + "window(win.*) as c0,"
                    + "last(win.*) as c1, "
                    + "first(win.*) as c2, "
                    + "first(p1) as c3,"
                    + "window(p1) as c4,"
                    + "sorted(p1) as c5,"
                    + "minby(p1) as c6"
                    + " from MyTable as win");
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean_S2(0));
    EventBean event = listener.assertOneGetNewAndReset();
    for (String col : "c1,c2,c6".split(",")) {
      assertEventUnd(event.get(col), rowValues);
    }
    for (String col : "c0,c5".split(",")) {
      assertEventUnd(((Object[][]) event.get(col))[0], rowValues);
    }
    assertEquals("b", event.get("c3"));
    EPAssertionUtil.assertEqualsExactOrder(new String[] {"b"}, (String[]) event.get("c4"));

    stmt.destroy();
  }
Ejemplo n.º 20
0
  public void testMixedEntryElement() {
    LinkedList<EventBean> list1 = new LinkedList<EventBean>();
    list1.add(events.get("a"));
    MultiKeyUntyped keyA = new MultiKeyUntyped(new Object[] {"keyA"});
    testMap.put(keyA, list1);
    LinkedList<EventBean> list2 = new LinkedList<EventBean>();
    list2.add(events.get("c"));
    list2.add(events.get("d"));
    MultiKeyUntyped keyB = new MultiKeyUntyped(new Object[] {"keyB"});
    testMap.put(keyB, list2);
    LinkedList<EventBean> list3 = new LinkedList<EventBean>();
    list3.add(events.get("e"));
    list3.add(events.get("f"));
    list3.add(events.get("g"));
    MultiKeyUntyped keyC = new MultiKeyUntyped(new Object[] {"keyC"});
    testMap.put(keyC, list3);

    Iterator<EventBean> it = new SortWindowIterator(testMap);
    EPAssertionUtil.assertEqualsExactOrder(
        new EventBean[] {
          events.get("a"),
          events.get("c"),
          events.get("d"),
          events.get("e"),
          events.get("f"),
          events.get("g")
        },
        it);
  }
Ejemplo n.º 21
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});
  }
  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});
  }
  public void testSkipToNextRow() {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("MyEvent", SupportRecogBean.class);
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();

    String[] fields = "a_string,b_string".split(",");
    String text =
        "select * from MyEvent.win:keepall() "
            + "match_recognize ("
            + "  measures A.theString as a_string, B.theString as b_string "
            + "  all matches "
            + "  after match skip to next row "
            + "  pattern (A B) "
            + "  define B as B.value > A.value"
            + ") "
            + "order by a_string, b_string";

    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E1", 5));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E2", 3));
    assertFalse(listener.isInvoked());
    assertFalse(stmt.iterator().hasNext());

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E3", 6));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"E2", "E3"}});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"E2", "E3"}});

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E4", 4));
    assertFalse(listener.isInvoked());
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"E2", "E3"}});

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E5", 6));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"E4", "E5"}});
    EPAssertionUtil.assertPropsPerRow(
        stmt.iterator(), fields, new Object[][] {{"E2", "E3"}, {"E4", "E5"}});

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E6", 10));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"E5", "E6"}});
    EPAssertionUtil.assertPropsPerRow(
        stmt.iterator(), fields, new Object[][] {{"E2", "E3"}, {"E4", "E5"}, {"E5", "E6"}});

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E7", 9));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E8", 4));
    assertFalse(listener.isInvoked());
    EPAssertionUtil.assertPropsPerRow(
        stmt.iterator(), fields, new Object[][] {{"E2", "E3"}, {"E4", "E5"}, {"E5", "E6"}});

    stmt.stop();
  }
Ejemplo n.º 24
0
  public void testOneElement() {
    LinkedList<EventBean> list = new LinkedList<EventBean>();
    list.add(events.get("a"));
    MultiKeyUntyped key = new MultiKeyUntyped(new Object[] {"akey"});
    testMap.put(key, list);

    Iterator<EventBean> it = new SortWindowIterator(testMap);
    EPAssertionUtil.assertEqualsExactOrder(new EventBean[] {events.get("a")}, it);
  }
  public void testVariableMoreThenOnce() {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("MyEvent", SupportRecogBean.class);
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();

    String[] fields = "a0,b,a1".split(",");
    String text =
        "select * from MyEvent.win:keepall() "
            + "match_recognize ("
            + "  measures A[0].theString as a0, B.theString as b, A[1].theString as a1 "
            + "  all matches "
            + "  after match skip to next row "
            + "  pattern ( A B A ) "
            + "  define "
            + "    A as (A.value = 1),"
            + "    B as (B.value = 2)"
            + ")";

    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E1", 3));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E2", 1));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E3", 2));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E4", 5));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E5", 1));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E6", 2));
    assertFalse(listener.isInvoked());
    assertFalse(stmt.iterator().hasNext());

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E7", 1));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"E5", "E6", "E7"}});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"E5", "E6", "E7"}});

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E8", 2));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E9", 1));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"E7", "E8", "E9"}});
    EPAssertionUtil.assertPropsPerRow(
        stmt.iterator(), fields, new Object[][] {{"E5", "E6", "E7"}, {"E7", "E8", "E9"}});
  }
Ejemplo n.º 26
0
  public void testArrayOpAdd() {
    EventBean[] testEvent = makeEventArray(new String[] {"a1", "a2", "a3"});

    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {testEvent[0], testEvent[1], testEvent[2]},
        EventBeanUtility.addToArray(
            new EventBean[] {testEvent[0]},
            Arrays.asList(new EventBean[] {testEvent[1], testEvent[2]})));

    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {testEvent[1], testEvent[2]},
        EventBeanUtility.addToArray(
            new EventBean[] {}, Arrays.asList(new EventBean[] {testEvent[1], testEvent[2]})));

    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {testEvent[0]},
        EventBeanUtility.addToArray(
            new EventBean[] {testEvent[0]}, Arrays.asList(new EventBean[0])));
  }
Ejemplo n.º 27
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)});
  }
Ejemplo n.º 28
0
  public void testSchemaXMLWSchemaWithAll() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM();
    eventTypeMeta.setRootElementName("event-page-visit");
    String schemaUri =
        TestSchemaXMLEvent.class
            .getClassLoader()
            .getResource(CLASSLOADER_SCHEMA_WITH_ALL_URI)
            .toString();
    eventTypeMeta.setSchemaResource(schemaUri);
    eventTypeMeta.addNamespacePrefix("ss", "samples:schemas:simpleSchemaWithAll");
    eventTypeMeta.addXPathProperty("url", "/ss:event-page-visit/ss:url", XPathConstants.STRING);
    config.addEventType("PageVisitEvent", eventTypeMeta);

    epService = EPServiceProviderManager.getProvider("TestSchemaXML", config);
    epService.initialize();
    updateListener = new SupportUpdateListener();

    // url='page4'
    String text = "select a.url as sesja from pattern [ every a=PageVisitEvent(url='page1') ]";
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(updateListener);

    SupportXML.sendEvent(
        epService.getEPRuntime(),
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n"
            + "<url>page1</url>"
            + "</event-page-visit>");
    EventBean theEvent = updateListener.getLastNewData()[0];
    assertEquals("page1", theEvent.get("sesja"));
    updateListener.reset();

    SupportXML.sendEvent(
        epService.getEPRuntime(),
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n"
            + "<url>page2</url>"
            + "</event-page-visit>");
    assertFalse(updateListener.isInvoked());

    EventType type =
        epService.getEPAdministrator().createEPL("select * from PageVisitEvent").getEventType();
    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {
          new EventPropertyDescriptor(
              "sessionId", Node.class, null, false, false, false, false, true),
          new EventPropertyDescriptor(
              "customerId", Node.class, null, false, false, false, false, true),
          new EventPropertyDescriptor("url", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("method", Node.class, null, false, false, false, false, true),
        },
        type.getPropertyDescriptors());
  }
  private void runAssertionCaseDynamic(EPServiceProvider epService) throws Exception {
    // type resolved for each by the first event representation picking both up, i.e. the one with
    // "r2" since that is the most specific URI
    EPStatement stmt = epService.getEPAdministrator().createEPL("select * from TestTypeOne");
    stmt.addListener(listeners[0]);
    stmt = epService.getEPAdministrator().createEPL("select * from TestTypeTwo");
    stmt.addListener(listeners[1]);

    // static senders
    EventSender sender = epService.getEPRuntime().getEventSender("TestTypeOne");
    sender.sendEvent(makeProperties(new String[][] {{"r2", "A"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[0].assertOneGetNewAndReset(), new Object[] {"A"});
    assertFalse(listeners[0].isInvoked());

    sender = epService.getEPRuntime().getEventSender("TestTypeTwo");
    sender.sendEvent(makeProperties(new String[][] {{"r2", "B"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[1].assertOneGetNewAndReset(), new Object[] {"B"});
  }
Ejemplo n.º 30
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});
  }