public void testGetStatusVariable() throws Exception {
HashMap<ServiceReference, Monitorable> map = new HashMap<ServiceReference, Monitorable>();
MockMonitorable monitorable = new MockMonitorable();
StatusVariable[] statusVariables = {new StatusVariable("sv.id", StatusVariable.CM_CC, 0)};
monitorable.setStatusVariables(statusVariables);
map.put(new MonitorableMockServiceReference("com.acme.pid"), monitorable);
osgiVisitor.setReferences(map);
MonitorAdmin monitorAdmin = new MonitorAdminImpl(logVisitor, common, bundle);
try {
monitorAdmin.getStatusVariable(null);
Assert.fail();
} catch (IllegalArgumentException e) {
}
try {
monitorAdmin.getStatusVariable("/&%(/=");
Assert.fail();
} catch (IllegalArgumentException e) {
}
try {
monitorAdmin.getStatusVariable("com.aaa/sv.id");
Assert.fail();
} catch (IllegalArgumentException e) {
}
try {
monitorAdmin.getStatusVariable("com.acme.pid/sv.id_u");
Assert.fail();
} catch (IllegalArgumentException e) {
}
StatusVariable sv = monitorAdmin.getStatusVariable("com.acme.pid/sv.id");
Assert.assertNotNull(sv);
Assert.assertEquals("sv.id", sv.getID());
Assert.assertEquals(StatusVariable.CM_CC, sv.getCollectionMethod());
Assert.assertEquals(StatusVariable.TYPE_INTEGER, sv.getType());
Assert.assertEquals(0, sv.getInteger());
}