Package com.bluesoft.util.metrics.core.impl

Examples of com.bluesoft.util.metrics.core.impl.BasicMeteringMetric


  private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger( CounterTest.class );

  @Test
  public void testCounter() throws Exception {
    MeteringMetric metric = new BasicMeteringMetric( "test" );
    Counter counter = new Counter( metric );
    String result = counter.count( new Callable<String>() {

      @Override
      public String call() throws Exception {
        Thread.sleep( 1000 );
        return "Done";
      }
    } );
    assertEquals( result, "Done" );
    assertEquals( metric.getCount(), BigInteger.ONE );
    counter = new Counter();
    counter.setMetric( metric );
    final Exception theException = new Exception();
    try {
      counter.count( new Callable<String>() {

        @Override
        public String call() throws Exception {
          Thread.sleep( 1000 );
          throw theException;
        }
      } );
      assertEquals( result, "Done" );
    } catch ( Exception ex ) {
      assertSame( ex, theException );
    }
    assertEquals( metric.getCount(), BigInteger.valueOf( 2 ) );
  }
View Full Code Here

TOP

Related Classes of com.bluesoft.util.metrics.core.impl.BasicMeteringMetric

Copyright © 2018 www.massapicom. 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.