Examples of FakeReporter


Examples of com.ryantenney.metrics.spring.reporter.FakeReporter

  @SuppressWarnings("resource")
  @Test
  public void fakeReporters() throws Throwable {
    ClassPathXmlApplicationContext ctx = null;
    FakeReporter one = null;
    FakeReporter two = null;
    try {
      final MetricRegistry registry = SharedMetricRegistries.getOrCreate("reporterTestRegistry");

      ctx = new ClassPathXmlApplicationContext("classpath:fake-reporter-test.xml");
      ctx.start();

      Thread.sleep(1000);

      one = ctx.getBean("fakeReporterOne", FakeReporter.class);
      Assert.assertFalse(AopUtils.isAopProxy(one.getRegistry()));
      Assert.assertSame(registry, one.getRegistry());
      Assert.assertEquals("milliseconds", one.getDurationUnit());
      Assert.assertEquals("second", one.getRateUnit());
      Assert.assertEquals(100000000, one.getPeriod());
      Assert.assertThat(one.getCalls(), allOf(greaterThanOrEqualTo(9), lessThanOrEqualTo(11)));
      Assert.assertEquals("[MetricFilter regex=foo]", one.getFilter().toString());
      Assert.assertTrue(one.isRunning());

      two = ctx.getBean("fakeReporterTwo", FakeReporter.class);
      Assert.assertFalse(AopUtils.isAopProxy(one.getRegistry()));
      Assert.assertSame(registry, two.getRegistry());
      Assert.assertEquals("nanoseconds", two.getDurationUnit());
      Assert.assertEquals("hour", two.getRateUnit());
      Assert.assertEquals(100000000, two.getPeriod());
      Assert.assertThat(two.getCalls(), allOf(greaterThanOrEqualTo(9), lessThanOrEqualTo(11)));
      Assert.assertEquals(ctx.getBean(BarFilter.class), two.getFilter());
      Assert.assertTrue(one.isRunning());

      // Make certain reporters aren't candidates for autowiring
      ReporterCollaborator collab = ctx.getBean(ReporterCollaborator.class);
      Assert.assertNotNull(collab.metricRegistry);
      Assert.assertNull(collab.fakeReporter);

    }
    finally {
      if (ctx != null) {
        ctx.stop();
        ctx.close();
      }
    }

    if (one != null) {
      Assert.assertFalse(one.isRunning());
    }

    if (two != null) {
      Assert.assertFalse(two.isRunning());
    }
  }
View Full Code Here

Examples of com.ryantenney.metrics.spring.reporter.FakeReporter

  public void reportersPropertyPlaceholders() throws Throwable {
    ClassPathXmlApplicationContext ctx = null;
    try {
      ctx = new ClassPathXmlApplicationContext("classpath:reporter-placeholder-test.xml");

      @SuppressWarnings("resource")
      FakeReporter reporter = ctx.getBean(FakeReporter.class);
      Assert.assertEquals("nanoseconds", reporter.getDurationUnit());
      Assert.assertEquals("hour", reporter.getRateUnit());
      Assert.assertEquals(100000000, reporter.getPeriod());
      Assert.assertSame(ctx.getBean(BarFilter.class), reporter.getFilter());
    }
    finally {
      if (ctx != null) {
        ctx.close();
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.