Search in sources :

Example 1 with ContainerBuilder

use of org.exoplatform.container.ContainerBuilder in project kernel by exoplatform.

the class TestGuiceContainer method testIntegration.

public void testIntegration() {
    URL rootURL = getClass().getResource("test-exo-container.xml");
    URL portalURL = getClass().getResource("test-exo-container2.xml");
    assertNotNull(rootURL);
    assertNotNull(portalURL);
    // 
    new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).build();
    RootContainer root = RootContainer.getInstance();
    testIntegration(root);
    ComponentAdapter<H> adapterH = root.getComponentAdapterOfType(H.class);
    assertNull(adapterH);
    PortalContainer portal = PortalContainer.getInstance();
    adapterH = portal.getComponentAdapterOfType(H.class);
    assertNotNull(adapterH);
    H h = root.getComponentInstanceOfType(H.class);
    assertNull(h);
    h = portal.getComponentInstanceOfType(H.class);
    assertNotNull(h);
    assertSame(h, portal.getComponentInstanceOfType(H.class));
    assertSame(h, adapterH.getComponentInstance());
    List<ComponentAdapter<H>> adapters = root.getComponentAdaptersOfType(H.class);
    assertTrue(adapters == null || adapters.isEmpty());
    adapters = portal.getComponentAdaptersOfType(H.class);
    assertNotNull(adapters);
    assertEquals(1, adapters.size());
    assertSame(h, adapters.get(0).getComponentInstance());
    List<H> allH = root.getComponentInstancesOfType(H.class);
    assertTrue(allH == null || allH.isEmpty());
    allH = portal.getComponentInstancesOfType(H.class);
    assertNotNull(allH);
    assertEquals(1, allH.size());
    assertSame(h, allH.get(0));
}
Also used : ContainerBuilder(org.exoplatform.container.ContainerBuilder) RootContainer(org.exoplatform.container.RootContainer) URL(java.net.URL) ComponentAdapter(org.exoplatform.container.spi.ComponentAdapter) PortalContainer(org.exoplatform.container.PortalContainer)

Example 2 with ContainerBuilder

use of org.exoplatform.container.ContainerBuilder in project kernel by exoplatform.

the class TestXSD_1_0 method testInitParams.

public void testInitParams() throws Exception {
    URL url = getClass().getResource("../../../../xsd_1_0/test-validation.xml");
    assertNotNull(url);
    RootContainer container = new ContainerBuilder().withRoot(url).build();
    container.getComponentInstanceOfType(TestValidation.class);
}
Also used : ContainerBuilder(org.exoplatform.container.ContainerBuilder) RootContainer(org.exoplatform.container.RootContainer) URL(java.net.URL)

Example 3 with ContainerBuilder

use of org.exoplatform.container.ContainerBuilder in project kernel by exoplatform.

the class TestXSD_1_3 method testInitParams.

public void testInitParams() throws Exception {
    URL url = getClass().getResource("../../../../xsd_1_3/test-validation.xml");
    assertNotNull(url);
    RootContainer container = new ContainerBuilder().withRoot(url).build();
    container.getComponentInstanceOfType(TestValidation.class);
}
Also used : ContainerBuilder(org.exoplatform.container.ContainerBuilder) RootContainer(org.exoplatform.container.RootContainer) URL(java.net.URL)

Example 4 with ContainerBuilder

use of org.exoplatform.container.ContainerBuilder in project kernel by exoplatform.

the class AbstractTestContainer method createRootContainer.

public static RootContainer createRootContainer(Class<?> callerClass, String relativeConfigurationFile) {
    URL url = callerClass.getResource(relativeConfigurationFile);
    assertNotNull(url);
    return new ContainerBuilder().withRoot(url).build();
}
Also used : ContainerBuilder(org.exoplatform.container.ContainerBuilder) URL(java.net.URL)

Example 5 with ContainerBuilder

use of org.exoplatform.container.ContainerBuilder in project kernel by exoplatform.

the class TestPortalContainerManagedIntegration method testManagementContext.

public void testManagementContext() {
    URL rootURL = TestPortalContainerManagedIntegration.class.getResource("root-configuration.xml");
    URL portalURL = TestPortalContainerManagedIntegration.class.getResource("portal-configuration.xml");
    // 
    RootContainer root = new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).build();
    ManagementContextImpl rootManagementContext = (ManagementContextImpl) root.getManagementContext();
    // 
    PortalContainer portal = PortalContainer.getInstance();
    ManagementContextImpl portalManagementContext = (ManagementContextImpl) portal.getManagementContext();
    assertSame(root.getManagementContext(), portalManagementContext.getParent());
    assertNotNull(portalManagementContext.findContainer());
    // 
    SimpleManagementAware rootManagementAware = (SimpleManagementAware) root.getComponentInstance("RootManagementAware");
    ManagementContextImpl rootManagementAwareContext = (ManagementContextImpl) rootManagementAware.context;
    assertSame(rootManagementContext, rootManagementAwareContext.getParent());
    // 
    SimpleManagementAware portalManagementAware = (SimpleManagementAware) portal.getComponentInstance("PortalManagementAware");
    ManagementContextImpl portalManagementAwareContext = (ManagementContextImpl) portalManagementAware.context;
    assertSame(portalManagementContext, portalManagementAwareContext.getParent());
}
Also used : ContainerBuilder(org.exoplatform.container.ContainerBuilder) RootContainer(org.exoplatform.container.RootContainer) ManagementContextImpl(org.exoplatform.container.management.ManagementContextImpl) SimpleManagementAware(org.exoplatform.container.jmx.support.SimpleManagementAware) URL(java.net.URL) PortalContainer(org.exoplatform.container.PortalContainer)

Aggregations

URL (java.net.URL)15 ContainerBuilder (org.exoplatform.container.ContainerBuilder)15 RootContainer (org.exoplatform.container.RootContainer)14 PortalContainer (org.exoplatform.container.PortalContainer)4 ComponentAdapter (org.exoplatform.container.spi.ComponentAdapter)2 SimpleManagementAware (org.exoplatform.container.jmx.support.SimpleManagementAware)1 ManagementContextImpl (org.exoplatform.container.management.ManagementContextImpl)1