Search in sources :

Example 1 with RateTimer

use of org.forgerock.openam.shared.monitoring.RateTimer in project OpenAM by OpenRock.

the class OperationMonitorTest method setUp.

@BeforeMethod
public void setUp() {
    RateTimer timer = mock(RateTimer.class);
    rateWindow = mock(RateWindow.class);
    operationMonitor = new OperationMonitor(timer, rateWindow);
}
Also used : RateWindow(org.forgerock.openam.shared.monitoring.RateWindow) RateTimer(org.forgerock.openam.shared.monitoring.RateTimer) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with RateTimer

use of org.forgerock.openam.shared.monitoring.RateTimer 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 3 with RateTimer

use of org.forgerock.openam.shared.monitoring.RateTimer in project OpenAM by OpenRock.

the class ConnectionsMonitorTest method setUp.

@BeforeMethod
public void setUp() {
    RateTimer timer = mock(RateTimer.class);
    rateWindow = mock(RateWindow.class);
    connectionMonitor = new ConnectionMonitor(timer, rateWindow);
}
Also used : RateWindow(org.forgerock.openam.shared.monitoring.RateWindow) RateTimer(org.forgerock.openam.shared.monitoring.RateTimer) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with RateTimer

use of org.forgerock.openam.shared.monitoring.RateTimer 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

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