use of cern.laser.client.data.Alarm 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 cern.laser.client.data.Alarm in project ACS by ACS-Community.
the class CategoryClientTest method setUp.
/**
* @see extends ComponentClientTestCase
*/
public void setUp() throws Exception {
super.setUp();
categoryClient = new CategoryClient(getContainerServices());
assertNotNull(categoryClient);
alarmsReceived = new Vector<Alarm>();
}
use of cern.laser.client.data.Alarm in project ACS by ACS-Community.
the class SpecialAlarmTest method testCreateSpecialAlarmWronglURL.
/**
* Test the creation of the alarm when the URL is <code>null</code>.
*/
public void testCreateSpecialAlarmWronglURL() throws Exception {
Alarm alarmNull = new SpecialAlarm(family, member, code, true, action, description, cause, consequences, priority, null, email, props);
assertNull(alarmNull.getHelpURL());
Alarm alarmEmpty = new SpecialAlarm(family, member, code, true, action, description, cause, consequences, priority, "", email, props);
assertNull(alarmEmpty.getHelpURL());
}
use of cern.laser.client.data.Alarm in project ACS by ACS-Community.
the class AlarmContainerTest method populateContainer.
/**
* Populate the container with the passed number of randomly generated alarms.
*
* @param size The number of alarms to add to the container
* @param fm The fault family of the added alarms
* @param generatedAlarms A <code>Collection</code> containing the generated alarms;
* it can be <code>null</code>; if it is not null, the newly generated
* alarms are added to the collection.
* @param entries The <code>AlarmtableEntry</code> generated while adding alarms to the container
* it can be <code>null</code>; if it is not <code>null</code>, the newly generated
* entries are added to the collection.
*
* @return The number of not reduced alarms in the collection
*/
private int populateContainer(int size, String fm, Collection<Alarm> generatedAlarms, Collection<AlarmTableEntry> entries) throws Exception {
int notReduced = 0;
int originalCollectionAlarmsSize = 0;
if (generatedAlarms != null) {
originalCollectionAlarmsSize = generatedAlarms.size();
}
int originalCollectionEntriesSize = 0;
if (entries != null) {
originalCollectionEntriesSize = entries.size();
}
for (int t = 0; t < size; t++) {
Alarm alarm = TestAlarm.generateRndAlarm(fm);
if (generatedAlarms != null) {
generatedAlarms.add(alarm);
}
if (!alarm.getStatus().isReduced()) {
notReduced++;
}
container.add(new AlarmTableEntry(alarm));
}
if (generatedAlarms != null) {
assertEquals(size, generatedAlarms.size() - originalCollectionAlarmsSize);
}
if (entries != null) {
assertEquals(size, entries.size() - originalCollectionEntriesSize);
}
return notReduced;
}
use of cern.laser.client.data.Alarm in project ACS by ACS-Community.
the class AlarmContainerTest method testAlarmsRemove.
/**
* Test the removal of alarms
*
* @throws Exception
*/
public void testAlarmsRemove() throws Exception {
// Add some alarms
int notReduced = 0;
Vector<Alarm> alarms = new Vector<Alarm>();
notReduced = populateContainer(CONTAINER_SIZE / 2, "TEST", alarms, null);
class EDTReader implements Runnable {
// The value to check after reading from EDT
private final int value;
EDTReader(int val) {
value = val;
}
public void run() {
assertEquals("Wrong not reduced size", CONTAINER_SIZE / 2, container.size(false));
assertEquals("Wrong reduced size", value, container.size(true));
}
}
EDTExecutor.instance().executeSync(new EDTReader(notReduced));
// Trying to remove an alarm not in the container throws an exception
Alarm al = TestAlarm.generateRndAlarm("EXCEPTION");
boolean exceptionOccurred = false;
try {
container.remove(new AlarmTableEntry(al));
} catch (AlarmContainerException e) {
exceptionOccurred = true;
}
assertTrue(exceptionOccurred);
// Remove all the alarms checking the number of alarms in the container
int sz = CONTAINER_SIZE / 2;
int reducedToRemove = notReduced;
for (Alarm removedAlarm : alarms) {
container.remove(new AlarmTableEntry(removedAlarm));
sz--;
if (!removedAlarm.getStatus().isReduced()) {
reducedToRemove--;
}
class EDTReader2 implements Runnable {
// The values to check after reading from EDT
private final int sz;
private final int reducedToRemove;
EDTReader2(int sz, int reducedToRemove) {
this.sz = sz;
this.reducedToRemove = reducedToRemove;
}
public void run() {
assertEquals(sz, container.size(false));
assertEquals(reducedToRemove, container.size(true));
}
}
EDTExecutor.instance().executeSync(new EDTReader2(sz, reducedToRemove));
}
// The container is empty
EDTExecutor.instance().executeSync(new Runnable() {
@Override
public void run() {
assertEquals(0, container.size(false));
assertEquals(0, container.size(true));
}
});
}
Aggregations