Author: nfilotto
Date: 2012-01-31 04:45:37 -0500 (Tue, 31 Jan 2012)
New Revision: 5542
Added:
kernel/trunk/exo.kernel.container/src/test/resources/tsm-excludes.properties
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
Log:
EXOJCR-1736: PortalContainer.getConfigurationXML() returns duplicated configuration
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java
===================================================================
---
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java 2012-01-30
12:34:08 UTC (rev 5541)
+++
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container/xml/Configuration.java 2012-01-31
09:45:37 UTC (rev 5542)
@@ -257,16 +257,8 @@
}
else if (result == null)
{
- try
- {
- // Initialize with the clone of the first non null configuration
- result = (Configuration)conf.clone();
- }
- catch (CloneNotSupportedException e)
- {
- LOG.warn("Could not clone the configuration", e);
- break;
- }
+ // Initialize with the clone of the first non null configuration
+ result = (Configuration)conf.clone();
}
else
{
@@ -276,6 +268,42 @@
}
return result;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Object clone()
+ {
+ try
+ {
+ Configuration conf = (Configuration)super.clone();
+ conf.component_ = (Map<String, Component>)((HashMap<String,
Component>)component_).clone();
+ conf.componentLifecyclePlugin_ =
+ (Map<String, ComponentLifecyclePlugin>)((HashMap<String,
ComponentLifecyclePlugin>)componentLifecyclePlugin_)
+ .clone();
+ conf.containerLifecyclePlugin_ =
+ (Map<String, ContainerLifecyclePlugin>)((HashMap<String,
ContainerLifecyclePlugin>)containerLifecyclePlugin_)
+ .clone();
+ conf.externalComponentPlugins_ =
+ (Map<String, ExternalComponentPlugins>)((HashMap<String,
ExternalComponentPlugins>)externalComponentPlugins_)
+ .clone();
+ if (imports_ != null)
+ {
+ conf.imports_ = (ArrayList<String>)imports_.clone();
+ }
+ if (removeConfiguration_ != null)
+ {
+ conf.removeConfiguration_ =
(ArrayList<String>)removeConfiguration_.clone();
+ }
+ return conf;
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new AssertionError("Could not clone the configuration");
+ }
+ }
/**
* Dumps the configuration in XML format into the given {@link Writer}
Modified:
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java
===================================================================
---
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2012-01-30
12:34:08 UTC (rev 5541)
+++
kernel/trunk/exo.kernel.container/src/test/java/org/exoplatform/container/TestPortalContainer.java 2012-01-31
09:45:37 UTC (rev 5542)
@@ -161,6 +161,36 @@
assertNull(PortalContainer.getCurrentSetting("boolean"));
}
+ public void testGetConfigurationXML()
+ {
+ URL rootURL = getClass().getResource("test-exo-container.xml");
+ URL portalURL = getClass().getResource("/conf/test-configuration.xml");
+ assertNotNull(rootURL);
+ assertNotNull(portalURL);
+ //
+ new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).build();
+
+ String configXML = RootContainer.getInstance().getConfigurationXML();
+ assertNotNull(configXML);
+ int size = configXML.length();
+ int hash = configXML.hashCode();
+ configXML = RootContainer.getInstance().getConfigurationXML();
+ assertNotNull(configXML);
+ assertTrue(size > 0);
+ assertEquals(size, configXML.length());
+ assertEquals(hash, configXML.hashCode());
+
+ configXML = PortalContainer.getInstance().getConfigurationXML();
+ assertNotNull(configXML);
+ assertTrue(size > 0);
+ size = configXML.length();
+ hash = configXML.hashCode();
+ configXML = PortalContainer.getInstance().getConfigurationXML();
+ assertNotNull(configXML);
+ assertEquals(size, configXML.length());
+ assertEquals(hash, configXML.hashCode());
+ }
+
public static class MyComponent
{
private final InitParams params;
Added: kernel/trunk/exo.kernel.container/src/test/resources/tsm-excludes.properties
===================================================================
--- kernel/trunk/exo.kernel.container/src/test/resources/tsm-excludes.properties
(rev 0)
+++
kernel/trunk/exo.kernel.container/src/test/resources/tsm-excludes.properties 2012-01-31
09:45:37 UTC (rev 5542)
@@ -0,0 +1 @@
+org.exoplatform.container.TestPortalContainer.testGetConfigurationXML=getConfigurationXML
\ No newline at end of file
Show replies by date