public void setUp() {
   Configuration configuration = SupportConfigFactory.getConfiguration();
   configuration.addEventType("SupportBean", SupportBean.class);
   configuration.addEventType("SupportBean_S0", SupportBean_S0.class);
   configuration.addEventType("SupportBean_S1", SupportBean_S1.class);
   configuration.getEngineDefaults().getLogging().setEnableExecutionDebug(true);
   epService = EPServiceProviderManager.getDefaultProvider(configuration);
   epService.initialize();
 }
  public void setUp() {

    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("Bean", SupportBean_ST0_Container.class);
    config.addEventType("SupportCollection", SupportCollection.class);
    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    listener = new SupportUpdateListener();
  }
Exemplo n.º 3
0
 public void setUp() {
   Configuration config = SupportConfigFactory.getConfiguration();
   config.addEventType("S0", SupportBean_S0.class);
   config.addEventType("S1", SupportBean_S1.class);
   config.addEventType("S2", SupportBean_S2.class);
   config.addEventType("S3", SupportBean_S3.class);
   config.addEventType("S4", SupportBean_S4.class);
   config.addEventType("S5", SupportBean_S5.class);
   epService = EPServiceProviderManager.getDefaultProvider(config);
   epService.initialize();
   listener = new SupportUpdateListener();
 }
Exemplo n.º 4
0
  public void setUp() {

    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("Bean", SupportBean_Container.class);
    config.addEventType("SupportCollection", SupportCollection.class);
    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }
    listener = new SupportUpdateListener();
  }
Exemplo n.º 5
0
  public void testSchemaXMLWSchemaWithRestriction() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM();
    eventTypeMeta.setRootElementName("order");
    InputStream schemaStream =
        TestSchemaXMLEvent.class
            .getClassLoader()
            .getResourceAsStream(CLASSLOADER_SCHEMA_WITH_RESTRICTION_URI);
    assertNotNull(schemaStream);
    String schemaText = ParserTool.linesToText(ParserTool.readFile(schemaStream));
    eventTypeMeta.setSchemaText(schemaText);
    config.addEventType("OrderEvent", eventTypeMeta);

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

    String text = "select order_amount from OrderEvent";
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(updateListener);

    SupportXML.sendEvent(
        epService.getEPRuntime(),
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<order>\n"
            + "<order_amount>202.1</order_amount>"
            + "</order>");
    EventBean theEvent = updateListener.getLastNewData()[0];
    assertEquals(Double.class, theEvent.get("order_amount").getClass());
    assertEquals(202.1d, theEvent.get("order_amount"));
    updateListener.reset();
  }
  public void testObjectArrayInheritanceInitTime() {
    Configuration configuration = SupportConfigFactory.getConfiguration();

    configuration.addEventType("RootEvent", new String[] {"base"}, new Object[] {String.class});
    configuration.addEventType("Sub1Event", new String[] {"sub1"}, new Object[] {String.class});
    configuration.addEventType("Sub2Event", new String[] {"sub2"}, new Object[] {String.class});
    configuration.addEventType("SubAEvent", new String[] {"suba"}, new Object[] {String.class});
    configuration.addEventType("SubBEvent", new String[] {"subb"}, new Object[] {String.class});

    configuration.addObjectArraySuperType("Sub1Event", "RootEvent");
    configuration.addObjectArraySuperType("Sub2Event", "RootEvent");
    configuration.addObjectArraySuperType("SubAEvent", "Sub1Event");
    configuration.addObjectArraySuperType("SubBEvent", "SubAEvent");

    try {
      configuration.addObjectArraySuperType("SubBEvent", "Sub2Event");
      fail();
    } catch (ConfigurationException ex) {
      assertEquals("Object-array event types may not have multiple supertypes", ex.getMessage());
    }

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }

    EPAssertionUtil.assertEqualsExactOrder(
        new Object[] {
          new EventPropertyDescriptor(
              "base", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor(
              "sub1", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor(
              "suba", String.class, null, false, false, false, false, false),
        },
        ((EPServiceProviderSPI) epService)
            .getEventAdapterService()
            .getExistsTypeByName("SubAEvent")
            .getPropertyDescriptors());

    runObjectArrInheritanceAssertion(epService);

    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.endTest();
    }
  }
Exemplo n.º 7
0
  protected void setUp() {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("SupportBean", SupportBean.class);

    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    mergeListener = new SupportUpdateListener();
  }
Exemplo n.º 8
0
  @Before
  public void setup() {
    Configuration config = new Configuration();
    config.addEventType("StockTick", StockTick.class);
    epService = EPServiceProviderManager.getProvider("EPLTest", config);

    esperRunner = new EsperRunner(epService);
  }
Exemplo n.º 9
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 EPServiceProvider getEngineInitialized(
      String name, String[] propertyNames, Object[] propertyTypes) {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    if (name != null) {
      configuration.addEventType(name, propertyNames, propertyTypes);
    }

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
    return epService;
  }
Exemplo n.º 11
0
  public void setUp() {
    Map<String, Object> typeInfo = new HashMap<String, Object>();
    typeInfo.put("id", String.class);
    typeInfo.put("p00", int.class);

    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("MapS0", typeInfo);
    config.addEventType("MapS1", typeInfo);

    config.getEngineDefaults().getLogging().setEnableQueryPlan(true);
    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }
    listener = new SupportUpdateListener();
  }
  public void testConfiguredViaPropsAndXML() {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration
        .getEngineDefaults()
        .getEventMeta()
        .setDefaultEventRepresentation(Configuration.EventRepresentation.OBJECTARRAY);
    configuration.addEventType(
        "MyOAType",
        "bean,theString,map".split(","),
        new Object[] {SupportBean.class.getName(), "string", "java.util.Map"});

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }

    EventType eventType =
        epService.getEPAdministrator().getConfiguration().getEventType("MyOAType");
    assertEquals(Object[].class, eventType.getUnderlyingType());
    assertEquals(String.class, eventType.getPropertyType("theString"));
    assertEquals(Map.class, eventType.getPropertyType("map"));
    assertEquals(SupportBean.class, eventType.getPropertyType("bean"));

    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL("select bean, theString, map('key'), bean.theString from MyOAType");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);
    assertEquals(Object[].class, stmt.getEventType().getUnderlyingType());

    SupportBean bean = new SupportBean("E1", 1);
    epService
        .getEPRuntime()
        .sendEvent(
            new Object[] {bean, "abc", Collections.singletonMap("key", "value")}, "MyOAType");
    EPAssertionUtil.assertProps(
        listener.assertOneGetNew(),
        "bean,theString,map('key'),bean.theString".split(","),
        new Object[] {bean, "abc", "value", "E1"});

    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.endTest();
    }
  }
  public void setUp() throws Exception {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration.addEventType(MyEventA.class);
    configuration.addEventType(MyEventB.class);
    service = EPServiceProviderManager.getDefaultProvider(configuration);
    service.initialize();

    String epl =
        "create window A.std:unique(key) as MyEventA;\n"
            + "create window B.std:unique(key) as MyEventB;\n"
            + "insert into A select * from MyEventA;\n"
            + "insert into B select * from MyEventB;\n"
            + "\n"
            + "@Name('stmt') select sum(A.data) as aTotal,sum(B.data) as bTotal "
            + "from A unidirectional, B where A.key = B.key;\n";
    EPDeploymentAdmin deployment = service.getEPAdministrator().getDeploymentAdmin();
    deployment.parseDeploy(epl);
  }
Exemplo n.º 14
0
  private Configuration getConfig(
      long engineMetricInterval, long stmtMetricInterval, boolean shareViews) {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration.getEngineDefaults().getViewResources().setShareViews(shareViews);
    configuration.getEngineDefaults().getMetricsReporting().setEnableMetricsReporting(true);
    configuration.getEngineDefaults().getMetricsReporting().setThreading(false);
    configuration.getEngineDefaults().getMetricsReporting().setEngineInterval(engineMetricInterval);
    configuration
        .getEngineDefaults()
        .getMetricsReporting()
        .setStatementInterval(stmtMetricInterval);

    configuration.addImport(MyMetricFunctions.class.getName());

    configuration.addEventType("SupportBean", SupportBean.class);

    return configuration;
  }
Exemplo n.º 15
0
 private Configuration getConfig(boolean isUseXPathPropertyExpression) {
   Configuration configuration = SupportConfigFactory.getConfiguration();
   configuration.addEventType(
       "TestXMLSchemaType", getConfigTestType(null, isUseXPathPropertyExpression));
   return configuration;
 }
Exemplo n.º 16
0
  public void setUp() {
    Configuration config = SupportConfigFactory.getConfiguration();

    config.addEventType("SupportBean", SupportBean.class);
    config.addEventType("FullEvent", SupportRevisionFull.class);
    config.addEventType("D1", SupportDeltaOne.class);
    config.addEventType("D2", SupportDeltaTwo.class);
    config.addEventType("D3", SupportDeltaThree.class);
    config.addEventType("D4", SupportDeltaFour.class);
    config.addEventType("D5", SupportDeltaFive.class);

    ConfigurationRevisionEventType configRev = new ConfigurationRevisionEventType();
    configRev.setKeyPropertyNames(new String[] {"k0"});
    configRev.addNameBaseEventType("FullEvent");
    configRev.addNameDeltaEventType("D1");
    configRev.addNameDeltaEventType("D2");
    configRev.addNameDeltaEventType("D3");
    configRev.addNameDeltaEventType("D4");
    configRev.addNameDeltaEventType("D5");
    config.addRevisionEventType("RevisableQuote", configRev);

    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    listenerOne = new SupportUpdateListener();
    listenerTwo = new SupportUpdateListener();
    listenerThree = new SupportUpdateListener();

    stmtCreateWin =
        epService
            .getEPAdministrator()
            .createEPL("create window RevQuote.win:keepall() as select * from RevisableQuote");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from FullEvent");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D1");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D2");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D3");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D4");
    epService.getEPAdministrator().createEPL("insert into RevQuote select * from D5");

    // assert type metadata
    EventTypeSPI type =
        (EventTypeSPI)
            ((EPServiceProviderSPI) epService)
                .getValueAddEventService()
                .getValueAddProcessor("RevQuote")
                .getValueAddEventType();
    assertEquals(null, type.getMetadata().getOptionalApplicationType());
    assertEquals(null, type.getMetadata().getOptionalSecondaryNames());
    assertEquals("RevisableQuote", type.getMetadata().getPrimaryName());
    assertEquals("RevisableQuote", type.getMetadata().getPublicName());
    assertEquals("RevisableQuote", type.getName());
    assertEquals(EventTypeMetadata.TypeClass.REVISION, type.getMetadata().getTypeClass());
    assertEquals(true, type.getMetadata().isApplicationConfigured());
    assertEquals(true, type.getMetadata().isApplicationPreConfigured());
    assertEquals(true, type.getMetadata().isApplicationPreConfiguredStatic());

    EventType[] valueAddTypes =
        ((EPServiceProviderSPI) epService).getValueAddEventService().getValueAddedTypes();
    assertEquals(1, valueAddTypes.length);
    assertSame(type, valueAddTypes[0]);

    ArrayAssertionUtil.assertEqualsAnyOrder(
        new Object[] {
          new EventPropertyDescriptor("k0", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p0", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p1", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p2", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p3", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p4", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("p5", String.class, null, false, false, false, false, false)
        },
        type.getPropertyDescriptors());
  }
  public void testObjectArrayTypeUpdate() {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration
        .getEngineDefaults()
        .getEventMeta()
        .setDefaultEventRepresentation(Configuration.EventRepresentation.OBJECTARRAY);

    String[] names = {"base1", "base2"};
    Object[] types = {String.class, makeMap(new Object[][] {{"n1", int.class}})};
    configuration.addEventType("MyOAEvent", names, types);

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }

    EPStatement statementOne =
        epService
            .getEPAdministrator()
            .createEPL(
                "select base1 as v1, base2.n1 as v2, base3? as v3, base2.n2? as v4 from MyOAEvent");
    assertEquals(Object[].class, statementOne.getEventType().getUnderlyingType());
    EPStatement statementOneSelectAll =
        epService.getEPAdministrator().createEPL("select * from MyOAEvent");
    assertEquals(
        "[base1, base2]", Arrays.toString(statementOneSelectAll.getEventType().getPropertyNames()));
    SupportUpdateListener listenerOne = new SupportUpdateListener();
    statementOne.addListener(listenerOne);
    String[] fields = "v1,v2,v3,v4".split(",");

    epService
        .getEPRuntime()
        .sendEvent(new Object[] {"abc", makeMap(new Object[][] {{"n1", 10}}), ""}, "MyOAEvent");
    EPAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(), fields, new Object[] {"abc", 10, null, null});

    // update type
    String[] namesNew = {"base3", "base2"};
    Object[] typesNew = new Object[] {Long.class, makeMap(new Object[][] {{"n2", String.class}})};
    epService
        .getEPAdministrator()
        .getConfiguration()
        .updateObjectArrayEventType("MyOAEvent", namesNew, typesNew);

    EPStatement statementTwo =
        epService
            .getEPAdministrator()
            .createEPL(
                "select base1 as v1, base2.n1 as v2, base3 as v3, base2.n2 as v4 from MyOAEvent");
    EPStatement statementTwoSelectAll =
        epService.getEPAdministrator().createEPL("select * from MyOAEvent");
    SupportUpdateListener listenerTwo = new SupportUpdateListener();
    statementTwo.addListener(listenerTwo);

    epService
        .getEPRuntime()
        .sendEvent(
            new Object[] {"def", makeMap(new Object[][] {{"n1", 9}, {"n2", "xyz"}}), 20L},
            "MyOAEvent");
    EPAssertionUtil.assertProps(
        listenerOne.assertOneGetNewAndReset(), fields, new Object[] {"def", 9, 20L, "xyz"});
    EPAssertionUtil.assertProps(
        listenerTwo.assertOneGetNewAndReset(), fields, new Object[] {"def", 9, 20L, "xyz"});

    // assert event type
    assertEquals(
        "[base1, base2, base3]",
        Arrays.toString(statementOneSelectAll.getEventType().getPropertyNames()));
    assertEquals(
        "[base1, base2, base3]",
        Arrays.toString(statementTwoSelectAll.getEventType().getPropertyNames()));

    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {
          new EventPropertyDescriptor("base3", Long.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("base2", Map.class, null, false, false, false, true, false),
          new EventPropertyDescriptor(
              "base1", String.class, null, false, false, false, false, false),
        },
        statementTwoSelectAll.getEventType().getPropertyDescriptors());

    try {
      epService
          .getEPAdministrator()
          .getConfiguration()
          .updateObjectArrayEventType("dummy", new String[0], new Object[0]);
      fail();
    } catch (ConfigurationException ex) {
      assertEquals(
          "Error updating Object-array event type: Event type named 'dummy' has not been declared",
          ex.getMessage());
    }

    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("SupportBean", SupportBean.class);
    try {
      epService
          .getEPAdministrator()
          .getConfiguration()
          .updateObjectArrayEventType("SupportBean", new String[0], new Object[0]);
      fail();
    } catch (ConfigurationException ex) {
      assertEquals(
          "Error updating Object-array event type: Event type by name 'SupportBean' is not an Object-array event type",
          ex.getMessage());
    }

    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.endTest();
    }
  }