コード例 #1
0
  /*
   * Test test that event ID calls work as expected
   */
  public void testExtractorEventID() throws Exception {

    RawExtractor extractor = (RawExtractor) PluginLoader.load(DummyExtractor.class.getName());

    extractor.configure(null);
    extractor.prepare(null);

    DBMSEvent event = extractor.extract();
    String currentEventId = extractor.getCurrentResourceEventId();
    Assert.assertEquals(event.getEventId(), currentEventId);

    event = extractor.extract();
    Assert.assertTrue(event.getEventId().compareTo(currentEventId) > 0);

    currentEventId = extractor.getCurrentResourceEventId();
    Assert.assertTrue(event.getEventId().compareTo(currentEventId) == 0);

    extractor.release(null);
  }
コード例 #2
0
  /*
   * Test that dummy extractor works like expected,
   */
  public void testExtractorBasic() throws Exception {

    RawExtractor extractor = (RawExtractor) PluginLoader.load(DummyExtractor.class.getName());

    extractor.configure(null);
    extractor.prepare(null);

    DBMSEvent event = extractor.extract();
    Assert.assertEquals(event.getEventId(), "0");
    event = extractor.extract();
    Assert.assertEquals(event.getEventId(), "1");

    extractor.setLastEventId("0");
    event = extractor.extract();
    Assert.assertEquals(event.getEventId(), "1");

    extractor.setLastEventId(null);
    event = extractor.extract();
    Assert.assertEquals(event.getEventId(), "0");

    for (Integer i = 1; i < 5; ++i) {
      event = extractor.extract();
      Assert.assertEquals(event.getEventId(), i.toString());
    }

    event = extractor.extract("0");
    Assert.assertEquals(event.getEventId(), "0");

    event = extractor.extract("4");
    Assert.assertEquals(event.getEventId(), "4");

    event = extractor.extract("5");
    Assert.assertEquals(event, null);

    extractor.release(null);
  }