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));
}
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);
}
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);
}
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();
}
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());
}
Aggregations