use of org.exoplatform.container.RootContainer in project kernel by exoplatform.
the class TestContainer method testComponent.
public void testComponent() throws Exception {
RootContainer rootContainer = RootContainer.getInstance();
MockService mservice = (MockService) rootContainer.getComponentInstance("MockService");
assertTrue(mservice != null);
assertTrue(mservice.getPlugins().size() == 2);
}
use of org.exoplatform.container.RootContainer in project kernel by exoplatform.
the class TestContainer method testComponent3.
public void testComponent3() throws Exception {
RootContainer rootContainer = RootContainer.getInstance();
PortalContainer pcontainer = rootContainer.getPortalContainer("portal");
assertNotNull(pcontainer);
DefaultComponent c = (DefaultComponent) pcontainer.getComponentInstanceOfType(DefaultComponent.class);
assertNotNull(c);
c = (DefaultComponent) pcontainer.getComponentInstanceOfType(DefaultComponent.class);
assertNotNull(c);
c = (DefaultComponent) pcontainer.getComponentInstanceOfType(DefaultComponent.class);
assertNotNull(c);
}
use of org.exoplatform.container.RootContainer in project kernel by exoplatform.
the class TestWeldContainer 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));
}
Aggregations