use of org.apache.aries.jmx.agent.JMXAgent in project aries by apache.
the class ServiceStateMBeanHandlerTest method testOpen.
@Test
public void testOpen() throws Exception {
BundleContext context = mock(BundleContext.class);
when(context.getProperty(Constants.FRAMEWORK_UUID)).thenReturn("some-uuid");
Logger logger = mock(Logger.class);
Bundle mockSystemBundle = mock(Bundle.class);
when(mockSystemBundle.getSymbolicName()).thenReturn("the.sytem.bundle");
when(context.getBundle(0)).thenReturn(mockSystemBundle);
JMXAgent agent = mock(JMXAgent.class);
JMXAgentContext agentContext = new JMXAgentContext(context, agent, logger);
ServiceStateMBeanHandler handler = new ServiceStateMBeanHandler(agentContext, new StateConfig());
handler.open();
assertNotNull(handler.getMbean());
}
use of org.apache.aries.jmx.agent.JMXAgent in project aries by apache.
the class BundleStateMBeanHandlerTest method testOpenAndClose.
@Test
public void testOpenAndClose() throws Exception {
BundleContext context = mock(BundleContext.class);
when(context.getProperty(Constants.FRAMEWORK_UUID)).thenReturn("some-uuid");
Logger logger = mock(Logger.class);
Bundle mockSystemBundle = mock(Bundle.class);
when(mockSystemBundle.getSymbolicName()).thenReturn("the.sytem.bundle");
when(context.getBundle(0)).thenReturn(mockSystemBundle);
ServiceReference packageAdminRef = mock(ServiceReference.class);
PackageAdmin packageAdmin = mock(PackageAdmin.class);
when(context.getServiceReference(PackageAdmin.class.getName())).thenReturn(packageAdminRef);
when(context.getService(packageAdminRef)).thenReturn(packageAdmin);
ServiceReference startLevelRef = mock(ServiceReference.class);
StartLevel startLevel = mock(StartLevel.class);
when(context.getServiceReference(StartLevel.class.getName())).thenReturn(startLevelRef);
when(context.getService(startLevelRef)).thenReturn(startLevel);
JMXAgent agent = mock(JMXAgent.class);
JMXAgentContext agentContext = new JMXAgentContext(context, agent, logger);
BundleStateMBeanHandler handler = new BundleStateMBeanHandler(agentContext, new StateConfig());
handler.open();
assertNotNull(handler.getMbean());
handler.close();
verify(context).ungetService(packageAdminRef);
verify(context).ungetService(startLevelRef);
}
Aggregations