Search in sources :

Example 1 with MvnDependencyListLocalRepositoryResolver

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));
}
Also used : ContainerManager(org.talend.sdk.component.container.ContainerManager) MvnDependencyListLocalRepositoryResolver(org.talend.sdk.component.dependencies.maven.MvnDependencyListLocalRepositoryResolver) File(java.io.File) Date(java.util.Date) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.jupiter.api.Test)

Aggregations

File (java.io.File)1 Date (java.util.Date)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 Test (org.junit.jupiter.api.Test)1 ContainerManager (org.talend.sdk.component.container.ContainerManager)1 MvnDependencyListLocalRepositoryResolver (org.talend.sdk.component.dependencies.maven.MvnDependencyListLocalRepositoryResolver)1