Search in sources :

Example 1 with AlrmStatListenerForTesting

use of alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting in project ACS by ACS-Community.

the class AlarmCategoryClientTest method setUp.

/**
	 * @see extends ComponentClientTestCase
	 */
public void setUp() throws Exception {
    super.setUp();
    categoryClient = new AlarmCategoryClient(getContainerServices());
    assertNotNull(categoryClient);
    AlarmFilter filter = new AlarmFilter(null, null, 2, 2);
    filteredLister = new AlarmListenerForTesting("Filtered_listener");
    assertNotNull(filteredLister);
    categoryClient.addAlarmListener(this);
    categoryClient.addAlarmListener(filteredLister, filter);
    statListener = new AlrmStatListenerForTesting();
    assertNotNull(statListener);
    categoryClient.addStatsListener(statListener);
    alarmsReceived = new Vector<Alarm>();
}
Also used : AlarmCategoryClient(alma.alarmsystem.clients.AlarmCategoryClient) Alarm(cern.laser.client.data.Alarm) AlarmListenerForTesting(alma.alarmsystem.clients.test.utils.AlarmListenerForTesting) AlrmStatListenerForTesting(alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting) AlarmFilter(alma.alarmsystem.clients.alarm.AlarmFilter)

Example 2 with AlrmStatListenerForTesting

use of alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting in project ACS by ACS-Community.

the class AlarmListenerContainerTest method testAddRemoveStatListeners.

/**
	 * Test add.remove statistics listeners
	 * 
	 * @throws Exception
	 */
public void testAddRemoveStatListeners() throws Exception {
    assertEquals(0, container.getStatListenersSize());
    assertEquals(0, container.getAlarmListenersSize());
    AlrmStatListenerForTesting stat1 = new AlrmStatListenerForTesting();
    assertTrue(container.addStatsListener(stat1));
    assertEquals(0, container.getAlarmListenersSize());
    assertEquals(1, container.getStatListenersSize());
    AlrmStatListenerForTesting stat2 = new AlrmStatListenerForTesting();
    assertTrue(container.addStatsListener(stat2));
    assertEquals(0, container.getAlarmListenersSize());
    assertEquals(2, container.getStatListenersSize());
    assertTrue(container.removeStatListener(stat2));
    assertEquals(0, container.getAlarmListenersSize());
    assertEquals(1, container.getStatListenersSize());
    AlrmStatListenerForTesting notExistsentStatL = new AlrmStatListenerForTesting();
    assertFalse(container.removeStatListener(notExistsentStatL));
    assertEquals(0, container.getAlarmListenersSize());
    assertEquals(1, container.getStatListenersSize());
    assertTrue(container.removeStatListener(stat1));
    assertEquals(0, container.getAlarmListenersSize());
    assertEquals(0, container.getStatListenersSize());
}
Also used : AlrmStatListenerForTesting(alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting)

Example 3 with AlrmStatListenerForTesting

use of alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting in project ACS by ACS-Community.

the class AlarmListenerContainerTest method testDispatchStats.

/**
	 * Test the dispatching of statistics
	 */
public void testDispatchStats() throws Exception {
    AlarmStatistics stats = new AlarmStatistics();
    assertNotNull(stats);
    AlrmStatListenerForTesting stat1 = new AlrmStatListenerForTesting();
    assertTrue(container.addStatsListener(stat1));
    AlrmStatListenerForTesting stat2 = new AlrmStatListenerForTesting();
    assertTrue(container.addStatsListener(stat2));
    assertEquals(2, container.getStatListenersSize());
    assertEquals(0, stat1.numActivationNoifies);
    assertEquals(0, stat1.numReductionNofies);
    assertEquals(0, stat2.numActivationNoifies);
    assertEquals(0, stat2.numReductionNofies);
    final int numNotifies = 10;
    for (int t = 1; t < numNotifies + 1; t++) {
        container.dispatchStatistics(stats);
        assertEquals(t, stat1.numActivationNoifies);
        assertEquals(t, stat1.numReductionNofies);
        assertEquals(t, stat2.numActivationNoifies);
        assertEquals(t, stat2.numReductionNofies);
    }
}
Also used : AlarmStatistics(alma.alarmsystem.clients.alarm.AlarmStatistics) AlrmStatListenerForTesting(alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting)

Aggregations

AlrmStatListenerForTesting (alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting)3 AlarmCategoryClient (alma.alarmsystem.clients.AlarmCategoryClient)1 AlarmFilter (alma.alarmsystem.clients.alarm.AlarmFilter)1 AlarmStatistics (alma.alarmsystem.clients.alarm.AlarmStatistics)1 AlarmListenerForTesting (alma.alarmsystem.clients.test.utils.AlarmListenerForTesting)1 Alarm (cern.laser.client.data.Alarm)1