use of alma.alarmsystem.clients.test.utils.AlarmListenerForTesting 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>();
}
use of alma.alarmsystem.clients.test.utils.AlarmListenerForTesting in project ACS by ACS-Community.
the class AlarmListenerContainerTest method testDispatchAlarms.
/**
* Test the dispatching of alarms
*
* {@link AlarmListenerForTesting} prints received alarms on the stdout.
*
* This test checks the number of alarms received by 2 listeners:
* <OL>
* <LI>The un-filtered listener must receive all the notifications
* <LI>The filtered listener must be notified only for alarms that pass the filter
* </OL>
*
* This test checks if the filter is applied.
* The correctness of the filtering is tested by {@link AlarmFilterTest}
*/
public void testDispatchAlarms() throws Exception {
// Instantiates 2 listeners one un-filtered and one filtered
assertEquals(0, container.getAlarmListenersSize());
AlarmListenerForTesting alarmL1 = new AlarmListenerForTesting("Unfiltered-listener");
// Unfiltered
AlarmListener listener1 = container.addAlarmListener(alarmL1);
assertNotNull(listener1);
AlarmFilter filter = new AlarmFilter(null, null, 10, 25);
AlarmListenerForTesting alarmL2 = new AlarmListenerForTesting("Filtered-listener");
// Filtered
AlarmListener listener2 = container.addAlarmListener(alarmL2, filter);
assertNotNull(listener2);
assertEquals(2, container.getAlarmListenersSize());
assertEquals(0, container.getStatListenersSize());
int numOfAlarmsToDispatch = 50;
for (int t = 1; t < numOfAlarmsToDispatch + 1; t++) {
AlarmForTesting alarm = new AlarmForTesting("faultFamily", "faultMember", t, 2, true, false, true);
container.dispatchAlarm(alarm);
assertEquals(t, alarmL1.numAlarms);
}
// Filtered listeners is supposed to receive less alarms
// i.e. all the alarms whose FC is in [10,15]
assertEquals(16, alarmL2.numAlarms);
}
use of alma.alarmsystem.clients.test.utils.AlarmListenerForTesting in project ACS by ACS-Community.
the class AlarmListenerContainerTest method testAddRemoveAlarmListeners.
/**
* Test add.remove alarm listeners
*
* @throws Exception
*/
public void testAddRemoveAlarmListeners() throws Exception {
assertEquals(0, container.getStatListenersSize());
assertEquals(0, container.getAlarmListenersSize());
AlarmListenerForTesting alarmL1 = new AlarmListenerForTesting("AlarmListenerName");
AlarmListener listener1 = container.addAlarmListener(alarmL1);
assertNotNull(listener1);
assertEquals(1, container.getAlarmListenersSize());
assertEquals(0, container.getStatListenersSize());
AlarmListenerForTesting alarmL2 = new AlarmListenerForTesting("AlarmListenerName");
AlarmFilter filter = new AlarmFilter("TheFF", ".*FM.*", -1, 9999);
AlarmListener listener2 = container.addAlarmListener(alarmL2, filter);
assertNotNull(listener2);
assertEquals(2, container.getAlarmListenersSize());
assertEquals(0, container.getStatListenersSize());
AlarmFilter filter2 = new AlarmFilter("TheFF2", "FM", -1, 9999);
AlarmListenerForTesting alarmL3 = new AlarmListenerForTesting("AlarmListenerName");
AlarmListener listener3 = container.new AlarmListener(alarmL3, filter2);
assertTrue(container.addAlarmListener(listener3));
assertEquals(3, container.getAlarmListenersSize());
assertEquals(0, container.getStatListenersSize());
assertTrue(container.removeAlarmListener(listener2));
assertEquals(2, container.getAlarmListenersSize());
assertEquals(0, container.getStatListenersSize());
assertTrue(container.removeAlarmListener(listener1));
assertEquals(1, container.getAlarmListenersSize());
assertEquals(0, container.getStatListenersSize());
AlarmListenerForTesting alarmL4 = new AlarmListenerForTesting("AlarmListenerName");
AlarmListener notExistentListener = container.new AlarmListener(alarmL4, null);
assertFalse(container.removeAlarmListener(notExistentListener));
assertEquals(1, container.getAlarmListenersSize());
assertEquals(0, container.getStatListenersSize());
assertTrue(container.removeAlarmListener(listener3));
assertEquals(0, container.getAlarmListenersSize());
assertEquals(0, container.getStatListenersSize());
}
use of alma.alarmsystem.clients.test.utils.AlarmListenerForTesting in project ACS by ACS-Community.
the class AlarmListenerContainerTest method testDispatchException.
/**
* Test the dispatching of exception
*
*
*/
public void testDispatchException() throws Exception {
assertEquals(0, container.getAlarmListenersSize());
AlarmListenerForTesting alarmL1 = new AlarmListenerForTesting("AlarmListenerName");
AlarmListener listener1 = container.addAlarmListener(alarmL1);
assertNotNull(listener1);
assertEquals(1, container.getAlarmListenersSize());
assertEquals(0, container.getStatListenersSize());
int numExceptions = 25;
for (int t = 1; t < numExceptions + 1; t++) {
container.dispatchException(new LaserSelectionException("Code_" + t));
assertEquals(t, alarmL1.numExceptions);
assertEquals(0, alarmL1.numAlarms);
}
}
Aggregations