Commits

Anonymous committed 0698dc2

Global Results conflict
Issue number: WW-945
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/xwork_1-2@1051e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (2)

src/test/com/opensymphony/xwork/config/providers/XmlConfigurationProviderGlobalResultInheritenceTest.java

+package com.opensymphony.xwork.config.providers;
+
+
+import com.opensymphony.xwork.config.Configuration;
+import com.opensymphony.xwork.config.ConfigurationManager;
+import com.opensymphony.xwork.config.ConfigurationProvider;
+import com.opensymphony.xwork.config.entities.ActionConfig;
+import com.opensymphony.xwork.config.entities.ResultConfig;
+
+/**
+ * <code>XmlConfigurationProviderGlobalResultInheritenceTest</code>
+ *
+ * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
+ * @version $Id$
+ */
+public class XmlConfigurationProviderGlobalResultInheritenceTest extends ConfigurationTestBase {
+
+    public void testGlobalResultInheritenceTest() throws Exception {
+        ConfigurationProvider provider = buildConfigurationProvider("com/opensymphony/xwork/config/providers/xwork-test-global-result-inheritence.xml");
+
+        ConfigurationManager.addConfigurationProvider(provider);
+        Configuration configuration = ConfigurationManager.getConfiguration();
+
+        ActionConfig parentActionConfig = configuration.getRuntimeConfiguration().getActionConfig("/base", "parentAction");
+        ActionConfig anotherActionConfig = configuration.getRuntimeConfiguration().getActionConfig("/base", "anotherAction");
+        ActionConfig childActionConfig = configuration.getRuntimeConfiguration().getActionConfig("/base", "childAction");
+
+        ResultConfig parentResultConfig1 = (ResultConfig) parentActionConfig.getResults().get("mockResult1");
+        ResultConfig parentResultConfig2 = (ResultConfig) parentActionConfig.getResults().get("mockResult2");
+        ResultConfig anotherResultConfig1 = (ResultConfig) anotherActionConfig.getResults().get("mockResult1");
+        ResultConfig anotherResultConfig2 = (ResultConfig) anotherActionConfig.getResults().get("mockResult2");
+        ResultConfig childResultConfig1 = (ResultConfig) childActionConfig.getResults().get("mockResult1");
+        ResultConfig childResultConfig2 = (ResultConfig) childActionConfig.getResults().get("mockResult2");
+
+        System.out.println(parentResultConfig1.getParams().get("identity"));
+        System.out.println(parentResultConfig2.getParams().get("identity"));
+        System.out.println(anotherResultConfig1.getParams().get("identity"));
+        System.out.println(anotherResultConfig2.getParams().get("identity"));
+        System.out.println(childResultConfig1.getParams().get("identity"));
+        System.out.println(childResultConfig2.getParams().get("identity"));
+
+        assertFalse(parentResultConfig1 == anotherResultConfig1);
+        assertFalse(parentResultConfig2 == anotherResultConfig2);
+
+        assertTrue(parentResultConfig1 == childResultConfig1);
+        assertTrue(parentResultConfig2 == childResultConfig2);
+    }
+}
+

src/test/com/opensymphony/xwork/config/providers/xwork-test-global-result-inheritence.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xwork PUBLIC
+    "-//OpenSymphony Group//XWork 1.1.1//EN"
+    "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd"
+ >
+
+<xwork>
+
+	<package name="parent" namespace="/base">
+		<result-types>
+			<result-type name="mockResult" class="com.opensymphony.xwork.mock.MockResult" />
+		</result-types>
+		<global-results>
+			<result name="mockResult1" type="mockResult">
+				<param name="identity">p1</param>
+			</result>
+			<result name="mockResult2" type="mockResult">
+				<param name="identity">p2</param>
+			</result>
+		</global-results>
+		<action name="parentAction" />
+	</package>
+
+
+	<package name="another" namespace="/base">
+		<result-types>
+			<result-type name="anotherMockResult" class="com.opensymphony.xwork.mock.MockResult" />
+		</result-types>
+		<global-results>
+			<result name="mockResult1" type="anotherMockResult">
+				<param name="identity">a1</param>
+			</result>
+			<result name="mockResult2" type="anotherMockResult">
+				<param name="identity">a2</param>
+			</result>
+		</global-results>
+		<action name="anotherAction" />
+	</package>
+
+	<package name="child" extends="parent" namespace="/base">
+		<global-results>
+			<result name="mockResult1" type="mockResult">
+				<param name="identity">c1</param>
+			</result>
+		</global-results>
+		<action name="childAction" />
+	</package>
+</xwork>