Exemple #1
0
  @Test
  @SuppressWarnings("unchecked")
  public void testHistorical() throws IOException {
    ReportProvider<Report> provider = lookup(ReportProvider.class, HistoricalReportProvider.ID);
    ReportDelegate<Report> delegate = lookup(ReportDelegate.class, TransactionConstants.NAME);
    ReportStorage<Report> storage = lookup(ReportStorage.class);
    Date startTime = new Date(1446885302848L);
    Report report = new TransactionReport("historical").setStartTime(startTime);

    storage.store(delegate, ReportPeriod.HOUR, report, 0, ReportStoragePolicy.FILE_AND_MYSQL);

    RemoteContext ctx =
        new DefaultRemoteContext(
            delegate.getName(), report.getDomain(), startTime, ReportPeriod.HOUR, null);

    Assert.assertEquals(true, provider.isEligible(ctx, delegate));
    Assert.assertEquals(report, provider.getReport(ctx, delegate));
  }
Exemple #2
0
  @Test
  @SuppressWarnings("unchecked")
  public void testDefault2() throws Exception {
    defineComponent(RemoteStub.class, MockRemoteStub.class);
    defineComponent(ReportConfiguration.class, MockReportConfiguration.class);

    ReportProvider<Report> provider = lookup(ReportProvider.class);
    ReportDelegate<Report> delegate = lookup(ReportDelegate.class, TransactionConstants.NAME);
    ReportStorage<Report> storage = lookup(ReportStorage.class);
    Date startTime = new Date();
    Report report = new TransactionReport("default2").setStartTime(startTime);

    storage.store(delegate, ReportPeriod.HOUR, report, 0, ReportStoragePolicy.FILE_AND_MYSQL);

    RemoteContext ctx =
        new DefaultRemoteContext(
            delegate.getName(), report.getDomain(), startTime, ReportPeriod.HOUR, null);

    Assert.assertEquals(true, provider.isEligible(ctx, delegate));
    Assert.assertEquals(report, provider.getReport(ctx, delegate));
  }
Exemple #3
0
  @Test
  @SuppressWarnings("unchecked")
  public void testRecent() throws Exception {
    defineComponent(RemoteStub.class, MockRemoteStub.class);
    defineComponent(ReportConfiguration.class, MockReportConfiguration.class);

    ReportProvider<Report> provider = lookup(ReportProvider.class, RecentReportProvider.ID);
    ReportDelegate<Report> delegate = lookup(ReportDelegate.class, TransactionConstants.NAME);
    Date startTime = new Date();
    Report report = new TransactionReport("recent").setStartTime(startTime);

    s_servers.clear();

    RemoteContext ctx =
        new DefaultRemoteContext(
            delegate.getName(), report.getDomain(), startTime, ReportPeriod.HOUR, null);

    Assert.assertEquals(true, provider.isEligible(ctx, delegate));
    Assert.assertEquals(report, provider.getReport(ctx, delegate));
    Assert.assertEquals("[127.0.0.1, 127.0.0.3]", s_servers.toString());
  }