Examples of TimingMetric


Examples of com.bluesoft.util.metrics.core.TimingMetric

    verify( mock );
  }

  @Test
  public void testGetChildren() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    final BasicTimingMetric child1 = new BasicTimingMetric( "child1" );
    final BasicMeteringMetric child2 = new BasicMeteringMetric( "child2" );
    expect( mock.getChildNames() ).andStubReturn( set( "child1", "child2" ) );
    expect( mock.getChild( "child1" ) ).andStubReturn( child1 );
    expect( mock.getChild( "child2" ) ).andStubReturn( child2 );
    replay( mock );
    Map<String, Metric> childMap = rounder.getChildren();
    assertTrue( Map.class.isAssignableFrom( childMap.getClass() ) );
    assertEquals( childMap.size(), 2 );
    assertEquals( childMap.get( "child1" ).getName(), "child1" );
View Full Code Here

Examples of com.bluesoft.util.metrics.core.TimingMetric

    verify( mock );
  }

  @Test
  public void testGetChildrenNull() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    expect( mock.getChildNames() ).andStubReturn( null );
    replay( mock );
    Map<String, Metric> childMap = rounder.getChildren();
    assertTrue( Map.class.isAssignableFrom( childMap.getClass() ) );
    assertEquals( childMap.size(), 0 );
    verify( mock );
View Full Code Here

Examples of com.bluesoft.util.metrics.core.TimingMetric

    verify( mock );
  }

  @Test
  public void testReset() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    final BasicTimingMetric snapshot = new BasicTimingMetric( "test" );
    expect( mock.reset() ).andReturn( snapshot );
    replay( mock );
    assertTrue( rounder.reset().getClass().isAssignableFrom( UnitRoundingTimingMetric.class ) );
    verify( mock );
  }
View Full Code Here

Examples of com.bluesoft.util.metrics.core.TimingMetric

    verify( mock );
  }

  @Test
  public void testAddEvent() {
    TimingMetric mock = createMock( TimingMetric.class );
    UnitRoundingTimingMetric rounder = new UnitRoundingTimingMetric( TimeUnit.MINUTES, TimeUnit.MILLISECONDS, mock );
    final BasicTimingEvent event = new BasicTimingEvent( 0L, 15L );
    mock.addEvent( same( event ) );
    expectLastCall().once();
    replay( mock );
    rounder.addEvent( event );
    verify( mock );
  }
View Full Code Here

Examples of com.bluesoft.util.metrics.core.TimingMetric

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

  @Test
  public void testDistrbution() {
    TimingMetric t = new BasicTimingMetric( "testTimer" );
    MeteringMetric m = new BasicMeteringMetric( "testMeter" );
    DistributingMetric dm = new DistributingMetric<>( "testDist",
                                                      map( pairOf( Conditions.all(), "testTimer" ), pairOf( Conditions.exception(), "testMeter" ) ),
                                                      t, m );

    dm.addEvent( new BasicTimingEvent( 0, 1000L ) );
    dm.addEvent( new BasicTimingEvent( 0, 2000L, null, null, new RuntimeException( "test ex" ) ) );

    assertEquals( t.getCount(), BigInteger.valueOf( 2 ) );
    assertEquals( m.getCount(), BigInteger.valueOf( 1 ) );
  }
View Full Code Here

Examples of com.bluesoft.util.metrics.core.TimingMetric

        eventCount += 1;
        command.run();
      }
    } );

    TimingMetric baseTimingMetric = new BasicTimingMetric( "testTimingMetric" );
    TimingMetric asyncTimingMetric = testManager.createQueuedTimingMetric( baseTimingMetric );
    long now = System.currentTimeMillis();
    asyncTimingMetric.addEvent( new BasicTimingEvent( now - 5, now ) );
    assertEquals( baseTimingMetric.getCount(), BigInteger.ONE );
    assertEquals( asyncTimingMetric.getCount(), BigInteger.ONE );
    assertEquals( eventCount, 1 );
  }
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.