Search in sources :

Example 1 with TestCurrentMillis

use of org.forgerock.openam.cts.monitoring.TestCurrentMillis in project OpenAM by OpenRock.

the class OperationMonitorTest method recalculatingRateShouldNotBlockGetRateIfNotModifying.

@Test
public void recalculatingRateShouldNotBlockGetRateIfNotModifying() {
    //Given
    RateTimer timer = new TestCurrentMillis();
    RateWindow rateWindow = new RateWindow(timer, 10, 1000L);
    final OperationMonitor monitor = new OperationMonitor(timer, rateWindow);
    //When
    new Thread(new Runnable() {

        public void run() {
            monitor.increment();
        }
    }).start();
    double rate = monitor.getAverageRate();
    //Then
    assertEquals(rate, 0D);
}
Also used : RateWindow(org.forgerock.openam.shared.monitoring.RateWindow) TestCurrentMillis(org.forgerock.openam.cts.monitoring.TestCurrentMillis) RateTimer(org.forgerock.openam.shared.monitoring.RateTimer) Test(org.testng.annotations.Test)

Example 2 with TestCurrentMillis

use of org.forgerock.openam.cts.monitoring.TestCurrentMillis in project OpenAM by OpenRock.

the class ConnectionsMonitorTest method recalculatingRateShouldNotBlockGetRateIfNotModifying.

@Test
public void recalculatingRateShouldNotBlockGetRateIfNotModifying() {
    //Given
    RateTimer timer = new TestCurrentMillis();
    RateWindow rateWindow = new RateWindow(timer, 10, 1000L);
    final ConnectionMonitor monitor = new ConnectionMonitor(timer, rateWindow);
    //When
    new Thread(new Runnable() {

        public void run() {
            monitor.add();
        }
    }).start();
    double rate = monitor.getAverageRate();
    //Then
    assertEquals(rate, 0D);
}
Also used : RateWindow(org.forgerock.openam.shared.monitoring.RateWindow) TestCurrentMillis(org.forgerock.openam.cts.monitoring.TestCurrentMillis) RateTimer(org.forgerock.openam.shared.monitoring.RateTimer) Test(org.testng.annotations.Test)

Aggregations

TestCurrentMillis (org.forgerock.openam.cts.monitoring.TestCurrentMillis)2 RateTimer (org.forgerock.openam.shared.monitoring.RateTimer)2 RateWindow (org.forgerock.openam.shared.monitoring.RateWindow)2 Test (org.testng.annotations.Test)2