monitorable.setNotificationSupport("sv.id1", true);
map.put(new MonitorableMockServiceReference("com.acme.pid"), monitorable);
osgiVisitor.setReferences(map);
MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);
monitorable.setListener(common);
monitorable.setMonitorableId("com.acme.pid");
try {
monitorAdmin.startJob("init1", new String[]{"com.acme.pid/sv.id11"}, 1);
Assert.fail();
} catch (IllegalArgumentException e) {
}
try {
monitorAdmin.startJob("init1", new String[]{"com.acme.pid/sv.id2"}, 1);
Assert.fail();
} catch (IllegalArgumentException e) {
}
try {
monitorAdmin.startJob(null, new String[]{"com.acme.pid/sv.id2"}, 1);
Assert.fail();
} catch (IllegalArgumentException e) {
}
try {
monitorAdmin.startJob("init1", new String[]{"com.acme.pid1/sv.id1"}, 1);
Assert.fail();
} catch (IllegalArgumentException e) {
}
try {
monitorAdmin.startJob("init1", new String[]{"com.acme.pid/sv.id1"}, -1);
Assert.fail();
} catch (IllegalArgumentException e) {
}
MonitoringJob job = monitorAdmin.startJob("init1", new String[]{"com.acme.pid/sv.id1"}, 1);
MonitoringJob[] jobs = monitorAdmin.getRunningJobs();
Assert.assertEquals(1, jobs.length);
monitorable.setNewStatusVariableValue("sv.id1", "15");
Event[] events = osgiVisitor.getPostedEvents();
Assert.assertEquals(2, events.length);
Assert.assertEquals(ConstantsMonitorAdmin.TOPIC, events[0].getTopic());
Assert.assertEquals("com.acme.pid", events[0].getProperty(ConstantsMonitorAdmin.MON_MONITORABLE_PID));
Assert.assertEquals("sv.id1", events[0].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_NAME));
Assert.assertEquals("15", events[0].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_VALUE));
Assert.assertNull(events[0].getProperty(ConstantsMonitorAdmin.MON_LISTENER_ID));
Assert.assertEquals(ConstantsMonitorAdmin.TOPIC, events[1].getTopic());
Assert.assertEquals("com.acme.pid", events[1].getProperty(ConstantsMonitorAdmin.MON_MONITORABLE_PID));
Assert.assertEquals("sv.id1", events[1].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_NAME));
Assert.assertEquals("15", events[1].getProperty(ConstantsMonitorAdmin.MON_STATUSVARIABLE_VALUE));
Assert.assertEquals("init1", events[1].getProperty(ConstantsMonitorAdmin.MON_LISTENER_ID));
job.stop();
jobs = monitorAdmin.getRunningJobs();
Assert.assertEquals(0, jobs.length);
osgiVisitor.cleanPostedEvents();
monitorable.setNewStatusVariableValue("sv.id1", "25");