use of org.exoplatform.container.RootContainer 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.RootContainer in project kernel by exoplatform.
the class TestPortalContainerConfig method testDependencies.
public void testDependencies() {
// Empty
RootContainer rootContainer = createRootContainer("portal-container-config-with-no-default-values.xml");
PortalContainerConfig config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getDependencies(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
assertNull(config.getDependencies("foo"));
assertNull(config.getDependencies("myPortal"));
assertNull(config.getDependencies("myPortal-pcdef"));
List<String> names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal"));
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal-pcdef"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("foo"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal-pcdef"));
assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("foo"));
assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("myPortal"));
assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertFalse(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
// Needed for backward compatibility
assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
assertFalse(config.hasDefinition());
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-no-default-values.xml", "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
// Empty with AddDependencies, AddDependenciesBefore and AddDependenciesAfter
String[] profiles = { "AddDependencies", "AddDependenciesBefore-No-Target", "AddDependenciesBefore-With-Fake-Target", "AddDependenciesAfter-No-Target", "AddDependenciesAfter-With-Fake-Target" };
List<String> deps;
for (String profile : profiles) {
rootContainer = createRootContainer("portal-container-config-with-no-default-values2.xml", profile);
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME);
assertTrue(deps != null && deps.size() == 1 && deps.contains("foo"));
deps = config.getDependencies("foo");
assertTrue(deps != null && deps.size() == 1 && deps.contains("foo"));
deps = config.getDependencies("myPortal");
assertTrue(deps != null && deps.size() == 1 && deps.contains("foo"));
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 1 && deps.contains("foo"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal"));
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("myPortal-pcdef"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("foo"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal"));
assertEquals(PortalContainerConfig.DEFAULT_REST_CONTEXT_NAME, config.getRestContextName("myPortal-pcdef"));
assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("foo"));
assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("myPortal"));
assertEquals(PortalContainerConfig.DEFAULT_REALM_NAME, config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertFalse(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
// Needed for backward compatibility
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
assertFalse(config.hasDefinition());
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-no-default-values2.xml", profile, "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, config.getPortalContainerName("foo"));
assertTrue(config.isPortalContainerName(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME));
assertTrue(config.isScopeValid(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, "foo"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(PortalContainerConfig.DEFAULT_PORTAL_CONTAINER_NAME, names.get(0));
}
// Without dependencies
String[] ignoreWebappProfiles = { "ignore.unregistered.webapp-default", "ignore.unregistered.webapp-false", "ignore.unregistered.webapp-true" };
for (int i = 0; i < ignoreWebappProfiles.length; i++) {
try {
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml", ignoreWebappProfiles[i]);
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getDependencies("foo"));
assertNull(config.getDependencies("myPortal"));
assertNull(config.getDependencies("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
if (i < ignoreWebappProfiles.length - 1) {
// Default behavior
assertTrue(names != null && !names.isEmpty());
assertEquals(2, names.size());
assertTrue(names.contains("myPortal"));
assertTrue(names.contains("myPortal-pcdef"));
assertEquals("myPortal", config.getPortalContainerName("foo"));
} else {
// Ignore webapp needed for EXOJCR-795
assertTrue(names != null && names.isEmpty());
assertNull(config.getPortalContainerName("foo"));
}
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
assertEquals("myRest-pcdef", config.getRestContextName("myPortal-pcdef"));
assertEquals("my-exo-domain", config.getRealmName("foo"));
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
assertFalse(config.isScopeValid("foo", "foo"));
if (i < ignoreWebappProfiles.length - 1) {
// Default behavior
assertTrue(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
} else {
// Ignore webapp needed for EXOJCR-795
assertFalse(config.isScopeValid("myPortal", "foo"));
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
}
assertTrue(config.isScopeValid("myPortal", "myPortal"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertTrue(config.hasDefinition());
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_ignore.unregistered.webapp.true");
System.getProperties().remove("_ignore.unregistered.webapp.false");
PropertyManager.refresh();
}
}
try {
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml", "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertTrue(config.isPortalContainerName("myPortal"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertFalse(config.isScopeValid("myPortal", "myPortal-pcdef"));
assertTrue(config.isScopeValid("myPortal", "myPortal"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal"));
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_ignore.unregistered.webapp.true");
System.getProperties().remove("_ignore.unregistered.webapp.false");
PropertyManager.refresh();
}
try {
// Unregister the default portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def.xml", "disable-pc2");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertNull(config.getPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertFalse(config.isScopeValid("myPortal", "myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal", "myPortal"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && names.isEmpty());
config.disablePortalContainer("myPortal-pcdef");
assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertNull(config.getPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("myPortal"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertFalse(config.isScopeValid("myPortal", "myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal", "myPortal"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && names.isEmpty());
config.registerPortalContainerName("myPortal-pcdef");
assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertNull(config.getPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("myPortal"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertFalse(config.isScopeValid("myPortal", "myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal", "myPortal"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && names.isEmpty());
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_ignore.unregistered.webapp.true");
System.getProperties().remove("_ignore.unregistered.webapp.false");
PropertyManager.refresh();
}
// Without dependencies and with no portal container name
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def.xml");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getDependencies("foo"));
assertNull(config.getDependencies("myPortal"));
assertNull(config.getDependencies("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
assertEquals("myPortal", config.getPortalContainerName("foo"));
assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertEquals("myPortal", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
assertEquals("myRest", config.getRestContextName("myPortal-pcdef"));
assertEquals("my-exo-domain", config.getRealmName("foo"));
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def.xml", "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal", config.getPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isScopeValid("myPortal", "foo"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
try {
// Without dependencies and with no rest context name an realm name
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def2.xml");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getDependencies("foo"));
assertNull(config.getDependencies("myPortal"));
assertNull(config.getDependencies("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(2, names.size());
assertTrue(names.contains("myPortal"));
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal", config.getPortalContainerName("foo"));
assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
assertEquals("myRest", config.getRestContextName("myPortal-pcdef"));
assertEquals("my-exo-domain", config.getRealmName("foo"));
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
// Needed for backward compatibility
assertFalse(config.isScopeValid("foo", "foo"));
assertTrue(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.isScopeValid("myPortal", "myPortal"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertTrue(config.hasDefinition());
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_default.portal.container");
System.getProperties().remove("_default.rest.context");
System.getProperties().remove("_default.realm.name");
System.getProperties().remove("_portal.container");
PropertyManager.refresh();
}
try {
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-empty-portal-def2.xml", "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && names.isEmpty());
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_default.portal.container");
System.getProperties().remove("_default.rest.context");
System.getProperties().remove("_default.realm.name");
System.getProperties().remove("_portal.container");
PropertyManager.refresh();
}
try {
// Without dependencies and with default portal container definition
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
assertNull(deps);
deps = config.getDependencies("myPortal");
assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 1 && deps.contains("fooX"));
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
assertEquals(2, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(2, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals(2, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-dpcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal-dpcdef", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest-dpcdef", config.getRestContextName("foo"));
assertEquals("myRest-dpcdef", config.getRestContextName("myPortal"));
assertEquals("myRest-pcdef", config.getRestContextName("myPortal-pcdef"));
assertEquals("my-exo-domain-dpcdef", config.getRealmName("foo"));
assertEquals("my-exo-domain-dpcdef", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-dpcdef"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "fooX"));
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertTrue(config.isScopeValid("myPortal-dpcdef", "fooX"));
assertTrue(config.isScopeValid("myPortal-pcdef", "fooX"));
assertTrue(config.hasDefinition());
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_portal.container");
PropertyManager.refresh();
}
try {
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml", "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal-dpcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal-dpcdef", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-dpcdef", config.getPortalContainerName("myPortal-dpcdef"));
assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "fooX"));
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertTrue(config.isScopeValid("myPortal-dpcdef", "fooX"));
assertFalse(config.isScopeValid("myPortal-pcdef", "fooX"));
assertTrue(config.isScopeValid("myPortal-dpcdef", "myPortal-dpcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-dpcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_portal.container");
PropertyManager.refresh();
}
try {
// Unregister the default portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml", "disable-pc2");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal"));
assertNull(config.getPortalContainerName("myPortal-dpcdef"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertFalse(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-dpcdef"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "fooX"));
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertFalse(config.isScopeValid("myPortal-dpcdef", "fooX"));
assertTrue(config.isScopeValid("myPortal-pcdef", "fooX"));
assertFalse(config.isScopeValid("myPortal-dpcdef", "myPortal-dpcdef"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-dpcdef");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_portal.container");
PropertyManager.refresh();
}
profiles = new String[] { "AddDependencies", "AddDependenciesBefore-No-Target", "AddDependenciesBefore-With-Fake-Target", "AddDependenciesBefore-With-Target", "AddDependenciesAfter-No-Target", "AddDependenciesAfter-With-Fake-Target", "AddDependenciesAfter-With-Target" };
for (String profile : profiles) {
try {
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml", "with-profiles", profile);
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
assertNull(deps);
deps = config.getDependencies("myPortal");
assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 2 && deps.contains("fooX") && deps.contains("foo"));
int index = deps.indexOf("foo");
if (profile.equals("AddDependenciesBefore-No-Target") || profile.equals("AddDependenciesBefore-With-Fake-Target") || profile.equals("AddDependenciesBefore-With-Target")) {
assertEquals(0, index);
} else {
assertEquals(1, index);
}
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
assertEquals(2, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(2, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals(2, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal-dpcdef", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest-dpcdef", config.getRestContextName("foo"));
assertEquals("myRest-dpcdef", config.getRestContextName("myPortal"));
assertEquals("myRest-pcdef", config.getRestContextName("myPortal-pcdef"));
assertEquals("my-exo-domain-dpcdef", config.getRealmName("foo"));
assertEquals("my-exo-domain-dpcdef", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "fooX"));
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertTrue(config.isScopeValid("myPortal-pcdef", "fooX"));
assertTrue(config.hasDefinition());
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_portal.container");
PropertyManager.refresh();
}
try {
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml", "with-profiles", profile, "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal-dpcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal-dpcdef", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-dpcdef", config.getPortalContainerName("myPortal-dpcdef"));
assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-dpcdef"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "fooX"));
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertTrue(config.isScopeValid("myPortal-dpcdef", "fooX"));
assertFalse(config.isScopeValid("myPortal-pcdef", "fooX"));
assertTrue(config.isScopeValid("myPortal-dpcdef", "myPortal-dpcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal-dpcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-dpcdef"));
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_portal.container");
PropertyManager.refresh();
}
try {
// Unregister the default portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def.xml", "with-profiles", profile, "disable-pc2");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal"));
assertNull(config.getPortalContainerName("myPortal-dpcdef"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertFalse(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-dpcdef"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "fooX"));
assertFalse(config.isScopeValid("myPortal", "fooX"));
assertFalse(config.isScopeValid("myPortal-dpcdef", "fooX"));
assertTrue(config.isScopeValid("myPortal-pcdef", "fooX"));
assertFalse(config.isScopeValid("myPortal-dpcdef", "myPortal-dpcdef"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-dpcdef");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
} finally {
// Clear the System Properties added by the PropertyConfigurator
System.getProperties().remove("_portal.container");
PropertyManager.refresh();
}
}
// With dependencies
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertNull(config.getDependencies("foo"));
assertNull(config.getDependencies("myPortal"));
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 3);
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
assertEquals("myRest-pcdef", config.getRestContextName("myPortal-pcdef"));
assertEquals("my-exo-domain", config.getRealmName("foo"));
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertTrue(config.isScopeValid("myPortal-pcdef", "fooY"));
assertTrue(config.hasDefinition());
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml", "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal", config.getPortalContainerName("foo"));
assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertTrue(config.isPortalContainerName("myPortal"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
assertFalse(config.isScopeValid("myPortal", "myPortal-pcdef"));
assertTrue(config.isScopeValid("myPortal", "myPortal"));
assertTrue(config.isScopeValid("myPortal", "foo"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && names.isEmpty());
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal"));
// Unregister the default portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml", "disable-pc2");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
assertTrue(config.isScopeValid("myPortal-pcdef", "myPortal"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertFalse(config.isScopeValid("myPortal", "myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal", "myPortal"));
assertFalse(config.isScopeValid("myPortal", "foo"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal-pcdef"));
for (String profile : profiles) {
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml", "with-profiles", profile);
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
assertNull(deps);
deps = config.getDependencies("myPortal");
assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 4);
int index = deps.indexOf("fooX");
if (profile.equals("AddDependenciesBefore-No-Target") || profile.equals("AddDependenciesBefore-With-Fake-Target")) {
assertEquals(0, index);
} else if (profile.equals("AddDependenciesBefore-With-Target")) {
assertEquals(1, index);
} else if (profile.equals("AddDependenciesAfter-With-Target")) {
assertEquals(2, index);
} else {
assertEquals(3, index);
}
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
assertEquals("myRest-pcdef", config.getRestContextName("myPortal-pcdef"));
assertEquals("my-exo-domain", config.getRealmName("foo"));
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.hasDefinition());
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def2.xml", "with-profiles", profile, "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal", config.getPortalContainerName("foo"));
assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && names.isEmpty());
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal"));
}
// With dependencies and with default portal container definition
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
deps = config.getDependencies("foo");
assertNull(deps);
deps = config.getDependencies("myPortal");
assertNull(deps);
deps = config.getDependencies("myPortal-pcdef");
assertTrue(deps != null && deps.size() == 3);
names = config.getPortalContainerNames("fooX");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertEquals("myPortal-pcdef", names.get(0));
names = config.getPortalContainerNames("myPortal");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal", names.get(0));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && !names.isEmpty());
assertEquals("myPortal-pcdef", names.get(0));
assertEquals("myPortal-pcdef", config.getPortalContainerName("foo"));
assertEquals("myPortal", config.getPortalContainerName("myPortal"));
assertEquals("myPortal-pcdef", config.getPortalContainerName("myPortal-pcdef"));
assertEquals("myRest", config.getRestContextName("foo"));
assertEquals("myRest", config.getRestContextName("myPortal"));
assertEquals("myRest-pcdef", config.getRestContextName("myPortal-pcdef"));
assertEquals("my-exo-domain", config.getRealmName("foo"));
assertEquals("my-exo-domain", config.getRealmName("myPortal"));
assertEquals("my-exo-domain-pcdef", config.getRealmName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("foo"));
assertTrue(config.isPortalContainerName("myPortal"));
assertTrue(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("foo", "foo"));
assertFalse(config.isScopeValid("myPortal", "foo"));
assertTrue(config.isScopeValid("myPortal-pcdef", "foo"));
assertTrue(config.hasDefinition());
// Unregister the portal container
rootContainer = createRootContainer("portal-container-config-with-default-values-and-with-portal-def-with-default-portal-def2.xml", "disable-pc");
config = (PortalContainerConfig) rootContainer.getComponentInstanceOfType(PortalContainerConfig.class);
assertEquals("myPortal", config.getPortalContainerName("foo"));
assertNull(config.getPortalContainerName("myPortal-pcdef"));
assertFalse(config.isPortalContainerName("myPortal-pcdef"));
assertFalse(config.isScopeValid("myPortal-pcdef", "myPortal-pcdef"));
names = config.getPortalContainerNames("myPortal-pcdef");
assertTrue(names != null && names.isEmpty());
assertFalse(config.isScopeValid("myPortal-pcdef", "foo"));
names = config.getPortalContainerNames("foo");
assertTrue(names != null && !names.isEmpty());
assertEquals(1, names.size());
assertTrue(names.contains("myPortal"));
}
use of org.exoplatform.container.RootContainer in project kernel by exoplatform.
the class TestContainerScoping method testFoo.
public void testFoo() throws Exception {
RootContainer root = createRootContainer("scoped-configuration.xml");
//
ManagedContainer child = new ManagedContainer(root);
child.start(true);
//
MBeanServer server = root.getMBeanServer();
assertSame(server, child.getMBeanServer());
//
/*
child.registerComponentInstance(new ManagedWithObjectNameTemplate("bar"));
Set bilto2 = server.queryMBeans(new ObjectName("exo:object=\"bar\",foo=bar"), null);
assertEquals(1, bilto2.size());
*/
}
use of org.exoplatform.container.RootContainer 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());
}
use of org.exoplatform.container.RootContainer in project kernel by exoplatform.
the class TestRegistration method testFoo.
public void testFoo() throws Exception {
RootContainer root = createRootContainer("registration-configuration.xml");
assertNotNull(root.getMBeanServer());
Object instance = root.getComponentInstance("Foo");
assertNotNull(instance);
MBeanServer server = root.getMBeanServer();
Set<ObjectInstance> set = server.queryMBeans(ObjectName.getInstance("exo:object=Foo"), null);
assertEquals(1, set.size());
ObjectInstance oi = set.iterator().next();
ExoContainer oldContainer = ExoContainerContext.getCurrentContainerIfPresent();
ExoContainer currentContainer = new ExoContainer();
ExoContainerContext.setCurrentContainer(currentContainer);
try {
ExoContainerFinder proxyObject = MBeanServerInvocationHandler.newProxyInstance(server, oi.getObjectName(), ExoContainerFinder.class, false);
assertTrue("We expect to get the current exo container", oldContainer == proxyObject.getCurrentExoContainer());
assertTrue("We expect to get the previous exo container", ExoContainerContext.getCurrentContainerIfPresent() == currentContainer);
ExoContainerContext.setCurrentContainer(oldContainer);
assertTrue("We expect to get the current exo container", oldContainer == proxyObject.getCurrentExoContainer());
assertTrue("We expect to get the previous exo container", ExoContainerContext.getCurrentContainerIfPresent() == oldContainer);
ExoContainerContext.setCurrentContainer(null);
assertTrue("We expect to get the current exo container", oldContainer == proxyObject.getCurrentExoContainer());
assertTrue("We expect to get the previous exo container", ExoContainerContext.getCurrentContainerIfPresent() == oldContainer);
} finally {
ExoContainerContext.setCurrentContainer(oldContainer);
}
// Manual
root.registerComponentInstance("Bar", new ManagedWithObjectNameTemplate("Bar"));
Object instance2 = root.getComponentInstance("Bar");
assertNotNull(instance2);
Set set2 = server.queryMBeans(ObjectName.getInstance("exo:object=Bar"), null);
assertEquals(1, set2.size());
}
Aggregations