use of org.talend.sdk.component.dependencies.maven.MvnDependencyListLocalRepositoryResolver in project component-runtime by Talend.
the class JmxManagerTest method jmx.
@Test
void jmx() throws Exception {
final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
final JmxManager jmxManager = new JmxManager(null, "org.talend.test:type=plugin,name=%s", mBeanServer);
final ContainerManager containerManager = new ContainerManager(ContainerManager.DependenciesResolutionConfiguration.builder().resolver(new MvnDependencyListLocalRepositoryResolver(Constants.DEPENDENCIES_LIST_RESOURCE_PATH)).rootRepositoryLocation(new File(Constants.DEPENDENCIES_LOCATION)).create(), ContainerManager.ClassLoaderConfiguration.builder().create(), null, Level.INFO);
containerManager.registerListener(jmxManager);
containerManager.builder("foo.jar", new File("missing/normally").getName()).create();
final ObjectName name = new ObjectName("org.talend.test:name=foo.jar,type=plugin");
try {
assertTrue(mBeanServer.isRegistered(name));
assertFalse(Boolean.class.cast(mBeanServer.getAttribute(name, "closed")));
final Object created = mBeanServer.getAttribute(name, "created");
assertTrue(Date.class.isInstance(created));
// ensure date is stable until reloading
assertEquals(created, created);
mBeanServer.invoke(name, "reload", new Object[0], new String[0]);
assertNotSame(created, mBeanServer.getAttribute(name, "created"));
} finally {
containerManager.close();
}
assertFalse(mBeanServer.isRegistered(name));
}
Aggregations