Ejemplo n.º 1
0
  public void testExprSelectClauseRenderingUnnamedCol() {
    epService
        .getEPAdministrator()
        .createEPL(
            "create table varagg ("
                + "key string primary key, theEvents window(*) @type(SupportBean))");

    EPStatement stmtSelect =
        epService
            .getEPAdministrator()
            .createEPL(
                "select "
                    + "varagg.keys(),"
                    + "varagg[p00].theEvents,"
                    + "varagg[p00],"
                    + "varagg[p00].theEvents.last(*),"
                    + "varagg[p00].theEvents.window(*).take(1) from SupportBean_S0");

    Object[][] expectedAggType =
        new Object[][] {
          {"varagg.keys()", Object[].class},
          {"varagg[p00].theEvents", SupportBean[].class},
          {"varagg[p00]", Map.class},
          {"varagg[p00].theEvents.last(*)", SupportBean.class},
          {"varagg[p00].theEvents.window(*).take(1)", Collection.class},
        };
    EventTypeAssertionUtil.assertEventTypeProperties(
        expectedAggType,
        stmtSelect.getEventType(),
        EventTypeAssertionEnum.NAME,
        EventTypeAssertionEnum.TYPE);
  }
Ejemplo n.º 2
0
  public void testSchemaXMLQuery_DOMGetterBacked() throws Exception {
    epService = EPServiceProviderManager.getProvider("TestSchemaXML", getConfig(false));
    epService.initialize();
    updateListener = new SupportUpdateListener();

    String stmtSelectWild = "select * from TestXMLSchemaType";
    EPStatement wildStmt = epService.getEPAdministrator().createEPL(stmtSelectWild);
    EventType type = wildStmt.getEventType();
    EventTypeAssertionUtil.assertConsistency(type);

    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {
          new EventPropertyDescriptor(
              "nested1", Node.class, null, false, false, false, false, true),
          new EventPropertyDescriptor(
              "prop4", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor(
              "nested3", Node.class, null, false, false, false, false, true),
          new EventPropertyDescriptor(
              "customProp", Double.class, null, false, false, false, false, false),
        },
        type.getPropertyDescriptors());

    String stmt =
        "select nested1 as nodeProp,"
            + "prop4 as nested1Prop,"
            + "nested1.prop2 as nested2Prop,"
            + "nested3.nested4('a').prop5[1] as complexProp,"
            + "nested1.nested2.prop3[2] as indexedProp,"
            + "customProp,"
            + "prop4.attr2 as attrOneProp,"
            + "nested3.nested4[2].id as attrTwoProp"
            + " from TestXMLSchemaType.win:length(100)";

    EPStatement selectStmt = epService.getEPAdministrator().createEPL(stmt);
    selectStmt.addListener(updateListener);
    type = selectStmt.getEventType();
    EventTypeAssertionUtil.assertConsistency(type);
    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {
          new EventPropertyDescriptor(
              "nodeProp", Node.class, null, false, false, false, false, true),
          new EventPropertyDescriptor(
              "nested1Prop", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor(
              "nested2Prop", Boolean.class, null, false, false, false, false, false),
          new EventPropertyDescriptor(
              "complexProp", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor(
              "indexedProp", Integer.class, null, false, false, false, false, false),
          new EventPropertyDescriptor(
              "customProp", Double.class, null, false, false, false, false, false),
          new EventPropertyDescriptor(
              "attrOneProp", Boolean.class, null, false, false, false, false, false),
          new EventPropertyDescriptor(
              "attrTwoProp", String.class, null, false, false, false, false, false),
        },
        type.getPropertyDescriptors());

    Document eventDoc = SupportXML.sendDefaultEvent(epService.getEPRuntime(), "test");

    assertNotNull(updateListener.getLastNewData());
    EventBean theEvent = updateListener.getLastNewData()[0];

    assertSame(eventDoc.getDocumentElement().getChildNodes().item(1), theEvent.get("nodeProp"));
    assertEquals("SAMPLE_V6", theEvent.get("nested1Prop"));
    assertEquals(true, theEvent.get("nested2Prop"));
    assertEquals("SAMPLE_V8", theEvent.get("complexProp"));
    assertEquals(5, theEvent.get("indexedProp"));
    assertEquals(3.0, theEvent.get("customProp"));
    assertEquals(true, theEvent.get("attrOneProp"));
    assertEquals("c", theEvent.get("attrTwoProp"));

    /**
     * Comment-in for performance testing long start = System.nanoTime(); for (int i = 0; i < 1000;
     * i++) { sendEvent("test"); } long end = System.nanoTime(); double delta = (end - start) /
     * 1000d / 1000d / 1000d; System.out.println(delta);
     */
  }
 private void assertEventType(EventType eventType, Object[][] expectedType) {
   EventTypeAssertionUtil.assertEventTypeProperties(
       expectedType, eventType, EventTypeAssertionEnum.NAME, EventTypeAssertionEnum.TYPE);
 }