コード例 #1
0
  public void testEngineMetrics() {
    epService = EPServiceProviderManager.getProvider("MyURI", getConfig(10000, -1, true));
    epService.initialize();

    String[] engineFields =
        "engineURI,timestamp,inputCount,inputCountDelta,scheduleDepth".split(",");
    sendTimer(1000);

    String text = "select * from " + EngineMetric.class.getName();
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean());

    sendTimer(10999);
    assertFalse(listener.isInvoked());

    epService.getEPAdministrator().createEPL("select * from pattern[timer:interval(5 sec)]");

    sendTimer(11000);
    EventBean event = listener.assertOneGetNewAndReset();
    ArrayAssertionUtil.assertProps(event, engineFields, new Object[] {"MyURI", 11000L, 1L, 1L, 1L});

    epService.getEPRuntime().sendEvent(new SupportBean());
    epService.getEPRuntime().sendEvent(new SupportBean());

    sendTimer(20000);
    sendTimer(21000);
    event = listener.assertOneGetNewAndReset();
    ArrayAssertionUtil.assertProps(event, engineFields, new Object[] {"MyURI", 21000L, 4L, 3L, 0L});
  }
コード例 #2
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();
  }
コード例 #3
0
ファイル: RuntimeConfigMain.java プロジェクト: arberzal/esper
  public void runExample() {
    // Allocate default provider in default configuration
    provider = EPServiceProviderManager.getDefaultProvider();

    // Add an event type
    Map<String, Object> typeDefinition = new HashMap<String, Object>();
    typeDefinition.put("propertyOne", "string");
    typeDefinition.put("propertyTwo", "int");
    provider.getEPAdministrator().getConfiguration().addEventType("MyEvent", typeDefinition);

    // Configure and test variables
    configureVariables();

    // Configure and test a variant stream
    configureVariantStream();

    // Configure and test an import
    configureImport();

    // Add a single-row function
    configureSingleRowFunction();

    // Add a custom aggregation function
    configureCustomAggregationFunction();

    // Use a revision event type
    configureRevisionType();
  }
コード例 #4
0
  public void testContextContents() throws Exception {
    Configuration configuration = getConfiguration();
    configuration.addPlugInEventRepresentation(
        new URI("type://test/support"), SupportEventRepresentation.class.getName(), "abc");
    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();

    PlugInEventRepresentationContext initContext = SupportEventRepresentation.getInitContext();
    assertEquals(new URI("type://test/support"), initContext.getEventRepresentationRootURI());
    assertEquals("abc", initContext.getRepresentationInitializer());
    assertNotNull(initContext.getEventAdapterService());

    ConfigurationOperations runtimeConfig = epService.getEPAdministrator().getConfiguration();
    runtimeConfig.addPlugInEventType(
        "TestTypeOne", new URI[] {new URI("type://test/support?a=b&c=d")}, "t1");

    PlugInEventTypeHandlerContext context = SupportEventRepresentation.getAcceptTypeContext();
    assertEquals(new URI("type://test/support?a=b&c=d"), context.getEventTypeResolutionURI());
    assertEquals("t1", context.getTypeInitializer());
    assertEquals("TestTypeOne", context.getEventTypeName());

    context = SupportEventRepresentation.getEventTypeContext();
    assertEquals(new URI("type://test/support?a=b&c=d"), context.getEventTypeResolutionURI());
    assertEquals("t1", context.getTypeInitializer());
    assertEquals("TestTypeOne", context.getEventTypeName());

    epService.getEPRuntime().getEventSender(new URI[] {new URI("type://test/support?a=b")});
    PlugInEventBeanReflectorContext contextBean = SupportEventRepresentation.getEventBeanContext();
    assertEquals("type://test/support?a=b", contextBean.getResolutionURI().toString());
  }
コード例 #5
0
ファイル: EPLTest.java プロジェクト: hancy2013/esper-practice
  @Before
  public void setup() {
    Configuration config = new Configuration();
    config.addEventType("StockTick", StockTick.class);
    epService = EPServiceProviderManager.getProvider("EPLTest", config);

    esperRunner = new EsperRunner(epService);
  }
コード例 #6
0
  protected void setUp() {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("SupportBean", SupportBean.class);

    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    mergeListener = new SupportUpdateListener();
  }
コード例 #7
0
ファイル: TestInsertInto.java プロジェクト: jimmyathf/esper
 public void setUp() {
   epService =
       EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
   epService.initialize();
   feedListener = new SupportUpdateListener();
   resultListenerDelta = new SupportUpdateListener();
   resultListenerProduct = new SupportUpdateListener();
 }
コード例 #8
0
  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();
  }
コード例 #9
0
 public void setUp() {
   epService =
       EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
   epService.initialize();
   if (InstrumentationHelper.ENABLED) {
     InstrumentationHelper.startTest(epService, this.getClass(), getName());
   }
   updateListener = new SupportUpdateListener();
 }
コード例 #10
0
 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();
 }
コード例 #11
0
  public void testStaticConfigDynamicTypeResolution() throws Exception {
    URI[] uriList = new URI[] {new URI("type://properties/test2/myresolver")};
    Configuration configuration = getConfiguration();
    configuration.setPlugInEventTypeResolutionURIs(uriList);
    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();

    runAssertionCaseDynamic(epService);
  }
コード例 #12
0
 public void setUp() {
   Configuration config = SupportConfigFactory.getConfiguration();
   epService = EPServiceProviderManager.getDefaultProvider(config);
   epService.initialize();
   epService
       .getEPAdministrator()
       .getConfiguration()
       .addEventType("SupportBean", SupportBean.class);
   epService.getEPAdministrator().getConfiguration().addEventType("ABean", SupportBean_S0.class);
 }
コード例 #13
0
  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;
  }
コード例 #14
0
  public void setUp() {
    listener = new SupportUpdateListener();
    priceLast3StatsListener = new SupportUpdateListener();
    priceAllStatsListener = new SupportUpdateListener();
    volumeLast3StatsListener = new SupportUpdateListener();
    volumeAllStatsListener = new SupportUpdateListener();

    epService =
        EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
    epService.initialize();
  }
コード例 #15
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());
  }
コード例 #16
0
  public void testEnabledDisableRuntime() {
    EPStatement[] statements = new EPStatement[5];
    Configuration config = getConfig(10000, 10000, true);
    epService = EPServiceProviderManager.getProvider("MyURI", config);
    epService.initialize();

    sendTimer(1000);

    statements[0] =
        epService
            .getEPAdministrator()
            .createEPL("select * from " + StatementMetric.class.getName(), "stmtmetric");
    statements[0].addListener(listenerStmtMetric);

    statements[1] =
        epService
            .getEPAdministrator()
            .createEPL("select * from " + EngineMetric.class.getName(), "enginemetric");
    statements[1].addListener(listenerEngineMetric);

    statements[2] =
        epService
            .getEPAdministrator()
            .createEPL(
                "select * from SupportBean(intPrimitive=1).win:keepall() where MyMetricFunctions.takeCPUTime(longPrimitive)");
    sendEvent("E1", 1, cpuGoalOneNano);

    sendTimer(11000);
    assertTrue(listenerStmtMetric.getAndClearIsInvoked());
    assertTrue(listenerEngineMetric.getAndClearIsInvoked());

    epService.getEPAdministrator().getConfiguration().setMetricsReportingDisabled();
    sendEvent("E2", 2, cpuGoalOneNano);
    sendTimer(21000);
    assertFalse(listenerStmtMetric.getAndClearIsInvoked());
    assertFalse(listenerEngineMetric.getAndClearIsInvoked());

    sendTimer(31000);
    sendEvent("E3", 3, cpuGoalOneNano);
    assertFalse(listenerStmtMetric.getAndClearIsInvoked());
    assertFalse(listenerEngineMetric.getAndClearIsInvoked());

    epService.getEPAdministrator().getConfiguration().setMetricsReportingEnabled();
    sendEvent("E4", 4, cpuGoalOneNano);
    sendTimer(41000);
    assertTrue(listenerStmtMetric.getAndClearIsInvoked());
    assertTrue(listenerEngineMetric.getAndClearIsInvoked());

    statements[2].destroy();
    sendTimer(51000);
    assertTrue(listenerStmtMetric.isInvoked()); // metrics statements reported themselves
    assertTrue(listenerEngineMetric.isInvoked());
  }
コード例 #17
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();
 }
コード例 #18
0
ファイル: TestEnumAverage.java プロジェクト: triplekill/esper
  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();
  }
コード例 #19
0
  public void setUp() {
    listener = new SupportUpdateListener();

    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration.addPlugInSingleRowFunction(
        "power3", MySingleRowFunction.class.getName(), "computePower3");
    configuration.addPlugInSingleRowFunction(
        "chainTop", MySingleRowFunction.class.getName(), "getChainTop");
    configuration.addPlugInSingleRowFunction(
        "surroundx", MySingleRowFunction.class.getName(), "surroundx");
    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
  }
コード例 #20
0
 public void setUp() {
   epService =
       EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
   epService.initialize();
   for (Class clazz :
       new Class[] {SupportBean.class, SupportBean_S0.class, SupportBean_S1.class}) {
     epService.getEPAdministrator().getConfiguration().addEventType(clazz);
   }
   listener = new SupportUpdateListener();
   if (InstrumentationHelper.ENABLED) {
     InstrumentationHelper.startTest(epService, this.getClass(), getName());
   }
 }
コード例 #21
0
  public void testInvalid() throws Exception {
    Configuration configuration = getConfiguration();
    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();

    try {
      epService.getEPRuntime().getEventSender(new URI[0]);
      fail();
    } catch (EventTypeException ex) {
      assertEquals(
          "Event sender for resolution URIs '[]' did not return at least one event representation's event factory",
          ex.getMessage());
    }
  }
コード例 #22
0
  public void testInvalid() {
    epService = EPServiceProviderManager.getProvider("TestSchemaXML", getConfig(false));
    epService.initialize();

    try {
      epService
          .getEPAdministrator()
          .createEPL("select element1 from TestXMLSchemaType.win:length(100)");
      fail();
    } catch (EPStatementException ex) {
      assertEquals(
          "Error starting statement: Property named 'element1' is not valid in any stream [select element1 from TestXMLSchemaType.win:length(100)]",
          ex.getMessage());
    }
  }
コード例 #23
0
  public void testFailedValidation() {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration.addPlugInSingleRowFunction(
        "singlerow", MySingleRowFunctionTwo.class.getName(), "testSingleRow");
    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();

    try {
      String text = "select singlerow('a', 'b') from " + SupportBean.class.getName();
      epService.getEPAdministrator().createEPL(text);
    } catch (EPStatementException ex) {
      assertEquals(
          "Error starting statement: Could not find static method named 'testSingleRow' in class 'com.espertech.esper.regression.client.MySingleRowFunctionTwo' with matching parameter number and expected parameter type(s) 'String, String' (nearest match found was 'testSingleRow' taking type(s) 'String, int') [select singlerow('a', 'b') from com.espertech.esper.support.bean.SupportBean]",
          ex.getMessage());
    }
  }
コード例 #24
0
  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();
    }
  }
コード例 #25
0
ファイル: TestJoinMapType.java プロジェクト: triplekill/esper
  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();
  }
コード例 #26
0
  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();
    }
  }
コード例 #27
0
  public static void main(String[] args) {
    EPServiceProvider esProvider = EPServiceProviderManager.getDefaultProvider();
    EPAdministrator admin = esProvider.getEPAdministrator();
    EPRuntime er = esProvider.getEPRuntime();

    Review r1 = new Review();
    r1.setReviewId(1);
    r1.setComment("r1");

    Book b1 = new Book();
    b1.setAuthor("b1");
    b1.setBookId(1);
    b1.setReview(r1);

    Book b2 = new Book();
    b2.setAuthor("b2");
    b2.setBookId(2);

    Item i1 = new Item();
    i1.setItemId(1);
    i1.setProductId(1);
    i1.setPrice(1.11);
    i1.setAmount(2);

    // 添加Bean对象
    MediaOrder mo1 = new MediaOrder();
    Books bs = new Books();
    Items is = new Items();
    List<Item> items = new ArrayList<Item>();
    List<Book> books = new ArrayList<Book>();
    items.add(i1);
    books.add(b1);
    books.add(b2);
    mo1.setOrderId(1);
    bs.setBook(books);
    is.setItem(items);
    mo1.setItems(is);
    mo1.setBooks(bs);

    String mediaOrder = MediaOrder.class.getName();
    String epl = "select * from " + mediaOrder + "[books.book]";
    EPStatement stat1 = admin.createEPL(epl);
    stat1.addListener(new SelectContainedListener());

    er.sendEvent(mo1);
  }
コード例 #28
0
  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);
  }
コード例 #29
0
  /*
   * Use case 1: static event type resolution, no event object reflection (static event type assignment)
   * Use case 2: static event type resolution, dynamic event object reflection and event type assignment
   *   a) Register all representations with URI via configuration
   *   b) Register event type name and specify the list of URI to use for resolving:
   *     // at engine initialization time it obtain instances of an EventType for each name
   *   c) Create statement using the registered event type name
   *   d) Get EventSender to send in that specific type of event
   */
  public void testPreConfigStaticTypeResolution() throws Exception {
    Configuration configuration = getConfiguration();
    configuration.addPlugInEventType(
        "TestTypeOne", new URI[] {new URI("type://properties/test1/testtype")}, "t1");
    configuration.addPlugInEventType(
        "TestTypeTwo", new URI[] {new URI("type://properties/test2")}, "t2");
    configuration.addPlugInEventType(
        "TestTypeThree", new URI[] {new URI("type://properties/test3")}, "t3");
    configuration.addPlugInEventType(
        "TestTypeFour",
        new URI[] {new URI("type://properties/test2/x"), new URI("type://properties/test3")},
        "t4");

    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();

    runAssertionCaseStatic(epService);
  }
コード例 #30
0
  public void testObjectArrayInheritanceRuntime() {
    Configuration configuration = SupportConfigFactory.getConfiguration();

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

    ConfigurationOperations configOps = epService.getEPAdministrator().getConfiguration();
    configOps.addEventType("RootEvent", new String[] {"base"}, new Object[] {String.class});
    configOps.addEventType(
        "Sub1Event",
        new String[] {"sub1"},
        new Object[] {String.class},
        new ConfigurationEventTypeObjectArray(Collections.singleton("RootEvent")));
    configOps.addEventType(
        "Sub2Event",
        new String[] {"sub2"},
        new Object[] {String.class},
        new ConfigurationEventTypeObjectArray(Collections.singleton("RootEvent")));
    configOps.addEventType(
        "SubAEvent",
        new String[] {"suba"},
        new Object[] {String.class},
        new ConfigurationEventTypeObjectArray(Collections.singleton("Sub1Event")));
    configOps.addEventType(
        "SubBEvent",
        new String[] {"subb"},
        new Object[] {String.class},
        new ConfigurationEventTypeObjectArray(Collections.singleton("SubAEvent")));

    runObjectArrInheritanceAssertion(epService);

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