Beispiel #1
0
 private void assertReceivedMinMax(int minDelta, int maxDelta, int minProduct, int maxProduct) {
   assertEquals(1, resultListenerDelta.getNewDataList().size());
   assertEquals(1, resultListenerDelta.getLastNewData().length);
   assertEquals(1, resultListenerProduct.getNewDataList().size());
   assertEquals(1, resultListenerProduct.getLastNewData().length);
   assertEquals(minDelta, resultListenerDelta.getLastNewData()[0].get("minD"));
   assertEquals(maxDelta, resultListenerDelta.getLastNewData()[0].get("maxD"));
   assertEquals(minProduct, resultListenerProduct.getLastNewData()[0].get("minP"));
   assertEquals(maxProduct, resultListenerProduct.getLastNewData()[0].get("maxP"));
   resultListenerDelta.reset();
   resultListenerProduct.reset();
 }
Beispiel #2
0
 private void assertReceivedFeed(int delta, int product) {
   assertEquals(1, feedListener.getNewDataList().size());
   assertEquals(1, feedListener.getLastNewData().length);
   assertEquals(delta, feedListener.getLastNewData()[0].get("delta"));
   assertEquals(product, feedListener.getLastNewData()[0].get("product"));
   feedListener.reset();
 }
  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();
  }
Beispiel #4
0
  public void testWithOutputLimitAndSort() {
    // NOTICE: we are inserting the RSTREAM (removed events)
    String stmtText =
        "insert rstream into StockTicks(mySymbol, myPrice) "
            + "select symbol, price from "
            + SupportMarketDataBean.class.getName()
            + ".win:time(60) "
            + "output every 5 seconds "
            + "order by symbol asc";
    epService.getEPAdministrator().createEPL(stmtText);

    stmtText = "select mySymbol, sum(myPrice) as pricesum from StockTicks.win:length(100)";
    EPStatement statement = epService.getEPAdministrator().createEPL(stmtText);
    statement.addListener(feedListener);

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(0));
    sendEvent("IBM", 50);
    sendEvent("CSC", 10);
    sendEvent("GE", 20);
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(10 * 1000));
    sendEvent("DEF", 100);
    sendEvent("ABC", 11);
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(20 * 1000));
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(30 * 1000));
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(40 * 1000));
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(50 * 1000));
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(55 * 1000));

    assertFalse(feedListener.isInvoked());
    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(60 * 1000));

    assertTrue(feedListener.isInvoked());
    assertEquals(3, feedListener.getNewDataList().size());
    assertEquals("CSC", feedListener.getNewDataList().get(0)[0].get("mySymbol"));
    assertEquals(10.0, feedListener.getNewDataList().get(0)[0].get("pricesum"));
    assertEquals("GE", feedListener.getNewDataList().get(1)[0].get("mySymbol"));
    assertEquals(30.0, feedListener.getNewDataList().get(1)[0].get("pricesum"));
    assertEquals("IBM", feedListener.getNewDataList().get(2)[0].get("mySymbol"));
    assertEquals(80.0, feedListener.getNewDataList().get(2)[0].get("pricesum"));
    feedListener.reset();

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(65 * 1000));
    assertFalse(feedListener.isInvoked());

    epService.getEPRuntime().sendEvent(new CurrentTimeEvent(70 * 1000));
    assertEquals("ABC", feedListener.getNewDataList().get(0)[0].get("mySymbol"));
    assertEquals(91.0, feedListener.getNewDataList().get(0)[0].get("pricesum"));
    assertEquals("DEF", feedListener.getNewDataList().get(1)[0].get("mySymbol"));
    assertEquals(191.0, feedListener.getNewDataList().get(1)[0].get("pricesum"));
  }