示例#1
0
 public static EPStatement compileCreate(EPServiceProvider epService, String epl) {
   EPStatementObjectModel model = epService.getEPAdministrator().compileEPL(epl);
   Assert.assertEquals(epl, model.toEPL());
   EPStatement stmt = epService.getEPAdministrator().create(model);
   Assert.assertEquals(epl, stmt.getText());
   return stmt;
 }
  public void testSingleMethod() throws Exception {
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("SupportBean", SupportBean.class);
    String text = "select power3(intPrimitive) as val from SupportBean";
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(listener);

    runAssertionSingleMethod();

    stmt.destroy();
    EPStatementObjectModel model = epService.getEPAdministrator().compileEPL(text);
    assertEquals(text, model.toEPL());
    stmt = epService.getEPAdministrator().create(model);
    assertEquals(text, stmt.getText());
    stmt.addListener(listener);

    runAssertionSingleMethod();

    stmt.destroy();
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("SupportBean", SupportBean.class);
    text = "select power3(2) as val from SupportBean";
    stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(listener);

    runAssertionSingleMethod();
  }
  public void testAfterCurrentRow() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("MyEvent", SupportRecogBean.class);
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();

    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 current 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);

    runAssertion(epService, listener, stmt);

    stmt.destroy();
    EPStatementObjectModel model = epService.getEPAdministrator().compileEPL(text);
    SerializableObjectCopier.copy(model);
    assertEquals(text, model.toEPL());
    stmt = epService.getEPAdministrator().create(model);
    stmt.addListener(listener);
    assertEquals(text, stmt.getText());

    runAssertion(epService, listener, stmt);
  }
示例#4
0
  public void testVariantOneEPLToOMStmt() throws Exception {
    String epl =
        "insert into Event_1(delta, product) "
            + "select intPrimitive - intBoxed as deltaTag, intPrimitive * intBoxed as productTag "
            + "from "
            + SupportBean.class.getName()
            + ".win:length(100)";

    EPStatementObjectModel model = epService.getEPAdministrator().compileEPL(epl);
    model = (EPStatementObjectModel) SerializableObjectCopier.copy(model);
    assertEquals(epl, model.toEPL());

    EPStatement stmt = runAsserts(null, model);
    assertEquals(epl, stmt.getText());
  }
示例#5
0
  @Override
  public void update(
      EventBean[] newEvents,
      EventBean[] oldEvents,
      EPStatement epStatement,
      EPServiceProvider serviceProvider) {
    DebugListener.logger.debug("");
    DebugListener.logger.debug("-------------------------------");
    DebugListener.logger.debug("Update received for statement:");
    DebugListener.logger.debug("\tname: " + epStatement.getName());
    DebugListener.logger.debug("\ttext: " + epStatement.getText());

    if (newEvents != null) {
      DebugListener.logger.debug("new events:");
      DebugListener.logger.debug("\tsize: " + newEvents.length);

      for (int i = 0; i < newEvents.length; i++) {
        DebugListener.logger.debug("\tnumber " + i);
        DebugListener.logger.debug("\t\tbean:  " + newEvents[i]);

        try {
          Object obj = newEvents[i].get("value");
          DebugListener.logger.debug("\t\tvalue: " + obj);
        } catch (Throwable t) {
          /*empty*/
        }
      }
    } else {
      DebugListener.logger.debug("new events are null");
    }

    if (oldEvents != null) {
      DebugListener.logger.debug("old events:");
      DebugListener.logger.debug("\tsize: " + oldEvents.length);

      for (int i = 0; i < oldEvents.length; i++) {
        DebugListener.logger.debug("\tnumber " + i);
        DebugListener.logger.debug("\t\tbean: " + oldEvents[i]);
      }
    } else {
      DebugListener.logger.debug("old events are null");
    }

    DebugListener.logger.debug("service provider: ");
    DebugListener.logger.debug("\t" + serviceProvider);

    DebugListener.logger.debug("-------------------------------");
  }
示例#6
0
  public void testVariantOneOMToStmt() throws Exception {
    EPStatementObjectModel model = new EPStatementObjectModel();
    model.setInsertInto(InsertIntoClause.create("Event_1", "delta", "product"));
    model.setSelectClause(
        SelectClause.create()
            .add(Expressions.minus("intPrimitive", "intBoxed"), "deltaTag")
            .add(Expressions.multiply("intPrimitive", "intBoxed"), "productTag"));
    model.setFromClause(
        FromClause.create(
            FilterStream.create(SupportBean.class.getName())
                .addView(View.create("win", "length", Expressions.constant(100)))));
    model = (EPStatementObjectModel) SerializableObjectCopier.copy(model);

    EPStatement stmt = runAsserts(null, model);

    String epl =
        "insert into Event_1(delta, product) "
            + "select intPrimitive - intBoxed as deltaTag, intPrimitive * intBoxed as productTag "
            + "from "
            + SupportBean.class.getName()
            + ".win:length(100)";
    assertEquals(epl, model.toEPL());
    assertEquals(epl, stmt.getText());
  }
示例#7
0
  public void testVariantRStreamOMToStmt() throws Exception {
    EPStatementObjectModel model = new EPStatementObjectModel();
    model.setInsertInto(
        InsertIntoClause.create("Event_1", new String[0], StreamSelector.RSTREAM_ONLY));
    model.setSelectClause(SelectClause.create().add("intPrimitive", "intBoxed"));
    model.setFromClause(FromClause.create(FilterStream.create(SupportBean.class.getName())));
    model = (EPStatementObjectModel) SerializableObjectCopier.copy(model);

    EPStatement stmt = epService.getEPAdministrator().create(model, "s1");

    String epl =
        "insert rstream into Event_1 "
            + "select intPrimitive, intBoxed "
            + "from "
            + SupportBean.class.getName();
    assertEquals(epl, model.toEPL());
    assertEquals(epl, stmt.getText());

    EPStatementObjectModel modelTwo = epService.getEPAdministrator().compileEPL(model.toEPL());
    model = (EPStatementObjectModel) SerializableObjectCopier.copy(model);
    assertEquals(epl, modelTwo.toEPL());

    // assert statement-type reference
    EPServiceProviderSPI spi = (EPServiceProviderSPI) epService;
    assertTrue(spi.getStatementEventTypeRef().isInUse("Event_1"));
    Set<String> stmtNames =
        spi.getStatementEventTypeRef().getStatementNamesForType(SupportBean.class.getName());
    assertTrue(stmtNames.contains("s1"));

    stmt.destroy();

    assertFalse(spi.getStatementEventTypeRef().isInUse("Event_1"));
    stmtNames =
        spi.getStatementEventTypeRef().getStatementNamesForType(SupportBean.class.getName());
    assertFalse(stmtNames.contains("s1"));
  }