Search in sources :

Example 1 with RootContainer

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"));
}
Also used : RootContainer(org.exoplatform.container.RootContainer)

Example 2 with RootContainer

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());
      */
}
Also used : RootContainer(org.exoplatform.container.RootContainer) MBeanServer(javax.management.MBeanServer)

Example 3 with RootContainer

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

Example 4 with RootContainer

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

the class TestCollectionValue method getCollection.

private List getCollection(String... profiles) throws Exception {
    RootContainer config = getKernel("collection-configuration.xml", profiles);
    InitParamsHolder holder = (InitParamsHolder) config.getComponentInstanceOfType(InitParamsHolder.class);
    InitParams params = holder.getParams();
    ObjectParameter op = params.getObjectParam("test.configuration");
    ConfigParam cp = (ConfigParam) op.getObject();
    return cp.getRole();
}
Also used : InitParams(org.exoplatform.container.xml.InitParams) ObjectParameter(org.exoplatform.container.xml.ObjectParameter) RootContainer(org.exoplatform.container.RootContainer)

Example 5 with RootContainer

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

the class TestRootContainerManagedIntegration method testManagementAwareManagingOtherBeans.

public void testManagementAwareManagingOtherBeans() throws Exception {
    RootContainer container = createRootContainer("configuration4.xml");
    ManagedManagementAware aware = (ManagedManagementAware) container.getComponentInstance("ManagedManagementAware");
    aware.context.register(new ManagedWithObjectNameTemplate("juu"));
    container.getMBeanServer().getObjectInstance(new ObjectName("exo:object=juu"));
}
Also used : ManagedWithObjectNameTemplate(org.exoplatform.container.jmx.support.ManagedWithObjectNameTemplate) ManagedManagementAware(org.exoplatform.container.jmx.support.ManagedManagementAware) RootContainer(org.exoplatform.container.RootContainer) ObjectName(javax.management.ObjectName)

Aggregations

RootContainer (org.exoplatform.container.RootContainer)38 URL (java.net.URL)14 ContainerBuilder (org.exoplatform.container.ContainerBuilder)14 PortalContainer (org.exoplatform.container.PortalContainer)9 MBeanServer (javax.management.MBeanServer)8 ExoContainer (org.exoplatform.container.ExoContainer)4 ObjectName (javax.management.ObjectName)3 ObjectInstance (javax.management.ObjectInstance)2 ManagedManagementAware (org.exoplatform.container.jmx.support.ManagedManagementAware)2 ManagedWithObjectNameTemplate (org.exoplatform.container.jmx.support.ManagedWithObjectNameTemplate)2 ComponentAdapter (org.exoplatform.container.spi.ComponentAdapter)2 InitParams (org.exoplatform.container.xml.InitParams)2 ObjectParameter (org.exoplatform.container.xml.ObjectParameter)2 Set (java.util.Set)1 ComponentPlugin (org.exoplatform.container.component.ComponentPlugin)1 ComponentRequestLifecycle (org.exoplatform.container.component.ComponentRequestLifecycle)1 ExoContainerFinder (org.exoplatform.container.jmx.support.ExoContainerFinder)1 ManagedByManager (org.exoplatform.container.jmx.support.ManagedByManager)1 ManagedComponentRequestLifeCycle (org.exoplatform.container.jmx.support.ManagedComponentRequestLifeCycle)1 ManagedDependent (org.exoplatform.container.jmx.support.ManagedDependent)1