コード例 #1
0
  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"});
  }
コード例 #2
0
  private void runAssertionCaseStatic(EPServiceProvider epService) throws URISyntaxException {
    EPStatement stmt = epService.getEPAdministrator().createEPL("select * from TestTypeOne");
    stmt.addListener(listeners[0]);
    stmt = epService.getEPAdministrator().createEPL("select * from TestTypeTwo");
    stmt.addListener(listeners[1]);
    stmt = epService.getEPAdministrator().createEPL("select * from TestTypeThree");
    stmt.addListener(listeners[2]);
    stmt = epService.getEPAdministrator().createEPL("select * from TestTypeFour");
    stmt.addListener(listeners[3]);

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

    sender = epService.getEPRuntime().getEventSender("TestTypeTwo");
    sender.sendEvent(makeProperties(new String[][] {{"r2", "C"}, {"t2", "D"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[1].assertOneGetNewAndReset(), new Object[] {"C", "D"});
    assertFalse(listeners[3].isInvoked() || listeners[0].isInvoked() || listeners[2].isInvoked());

    sender = epService.getEPRuntime().getEventSender("TestTypeThree");
    sender.sendEvent(makeProperties(new String[][] {{"r3", "E"}, {"t3", "F"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[2].assertOneGetNewAndReset(), new Object[] {"E", "F"});
    assertFalse(listeners[3].isInvoked() || listeners[1].isInvoked() || listeners[0].isInvoked());

    sender = epService.getEPRuntime().getEventSender("TestTypeFour");
    sender.sendEvent(makeProperties(new String[][] {{"r2", "G"}, {"t4", "H"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[3].assertOneGetNewAndReset(), new Object[] {"G", "H"});
    assertFalse(listeners[0].isInvoked() || listeners[1].isInvoked() || listeners[2].isInvoked());

    // dynamic sender - decides on event type thus a particular update listener should see the event
    URI[] uriList =
        new URI[] {new URI("type://properties/test1"), new URI("type://properties/test2")};
    EventSender dynamicSender = epService.getEPRuntime().getEventSender(uriList);
    dynamicSender.sendEvent(makeProperties(new String[][] {{"r3", "I"}, {"t3", "J"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[2].assertOneGetNewAndReset(), new Object[] {"I", "J"});
    dynamicSender.sendEvent(makeProperties(new String[][] {{"r1", "K"}, {"t1", "L"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[0].assertOneGetNewAndReset(), new Object[] {"K", "L"});
    dynamicSender.sendEvent(makeProperties(new String[][] {{"r2", "M"}, {"t2", "N"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[1].assertOneGetNewAndReset(), new Object[] {"M", "N"});
    dynamicSender.sendEvent(makeProperties(new String[][] {{"r2", "O"}, {"t4", "P"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[3].assertOneGetNewAndReset(), new Object[] {"O", "P"});
    dynamicSender.sendEvent(makeProperties(new String[][] {{"r2", "O"}, {"t3", "P"}}));
    assertNoneReceived();

    uriList = new URI[] {new URI("type://properties/test2")};
    dynamicSender = epService.getEPRuntime().getEventSender(uriList);
    dynamicSender.sendEvent(makeProperties(new String[][] {{"r1", "I"}, {"t1", "J"}}));
    assertNoneReceived();
    dynamicSender.sendEvent(makeProperties(new String[][] {{"r2", "Q"}, {"t2", "R"}}));
    EPAssertionUtil.assertAllPropsSortedByName(
        listeners[1].assertOneGetNewAndReset(), new Object[] {"Q", "R"});
  }