Author: apetrelli
Date: Tue Jul 1 12:20:30 2008
New Revision: 673186
URL: http://svn.apache.org/viewvc?rev=673186&view=rev
Log:
TILES-83
Added a new "inherit" attribute for <put-list-attribute> element.
Modified the test case.
Modified:
tiles/framework/trunk/tiles-core/src/main/resources/org/apache/tiles/resources/tiles-config_2_1.dtd
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/config/tiles-defs-2.1.xml
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/digester/TestDigesterDefinitionsReader.java
Modified:
tiles/framework/trunk/tiles-core/src/main/resources/org/apache/tiles/resources/tiles-config_2_1.dtd
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/resources/org/apache/tiles/resources/tiles-config_2_1.dtd?rev=673186&r1=673185&r2=673186&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/main/resources/org/apache/tiles/resources/tiles-config_2_1.dtd
(original)
+++
tiles/framework/trunk/tiles-core/src/main/resources/org/apache/tiles/resources/tiles-config_2_1.dtd
Tue Jul 1 12:20:30 2008
@@ -240,12 +240,6 @@
specified java classtype. This bean is initialized with appropriate nested
<set-property>.
-->
-<!ATTLIST put-list-attribute inherit %Boolean; #IMPLIED>
-<!--
[EMAIL PROTECTED] inherit If true, the attribute will put the elements
of the attribute
- with the same name of the parent definition before the
ones
- specified here. By default, it is 'false'.
--->
<!ELEMENT bean (set-property*)>
<!ATTLIST bean id ID #IMPLIED>
<!--
Modified:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/config/tiles-defs-2.1.xml
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/config/tiles-defs-2.1.xml?rev=673186&r1=673185&r2=673186&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/config/tiles-defs-2.1.xml
(original)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/config/tiles-defs-2.1.xml
Tue Jul 1 12:20:30 2008
@@ -58,4 +58,21 @@
</put-list-attribute>
</definition>
+ <definition name="test.inherit.list.base" template="/layout.jsp">
+ <put-list-attribute name="list">
+ <add-attribute value="first" />
+ </put-list-attribute>
+ </definition>
+
+ <definition name="test.inherit.list" extends="test.inherit.list.base">
+ <put-list-attribute name="list" inherit="true">
+ <add-attribute value="second" />
+ </put-list-attribute>
+ </definition>
+
+ <definition name="test.noinherit.list" extends="test.inherit.list.base">
+ <put-list-attribute name="list">
+ <add-attribute value="second" />
+ </put-list-attribute>
+ </definition>
</tiles-definitions>
Modified:
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/digester/TestDigesterDefinitionsReader.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/digester/TestDigesterDefinitionsReader.java?rev=673186&r1=673185&r2=673186&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/digester/TestDigesterDefinitionsReader.java
(original)
+++
tiles/framework/trunk/tiles-core/src/test/java/org/apache/tiles/definition/digester/TestDigesterDefinitionsReader.java
Tue Jul 1 12:20:30 2008
@@ -21,6 +21,7 @@
package org.apache.tiles.definition.digester;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
@@ -92,110 +93,119 @@
/**
* Tests the read method under normal conditions.
+ * @throws IOException If something goes wrong.
*/
- public void testRead() {
- try {
- reader.init(new HashMap<String, String>());
-
- URL configFile = this.getClass().getClassLoader().getResource(
- "org/apache/tiles/config/tiles-defs.xml");
- assertNotNull("Config file not found", configFile);
+ public void testRead() throws IOException {
+ reader.init(new HashMap<String, String>());
- InputStream source = configFile.openStream();
- Map<String, Definition> definitions = reader.read(source);
-
- assertNotNull("Definitions not returned.", definitions);
- assertNotNull("Couldn't find doc.mainLayout tile.",
- definitions.get("doc.mainLayout"));
- assertNotNull("Couldn't Find title attribute.", definitions.get(
- "doc.mainLayout").getAttribute("title").getValue());
- assertEquals("Incorrect Find title attribute.",
- "Tiles Library Documentation", definitions.get(
-
"doc.mainLayout").getAttribute("title").getValue());
-
- Definition def = definitions.get("doc.role.test");
- assertNotNull("Couldn't find doc.role.test tile.", def);
- Attribute attribute = def.getAttribute("title");
- assertNotNull("Couldn't Find title attribute.", attribute
- .getValue());
- assertEquals("Role 'myrole' expected", attribute.getRole(),
- "myrole");
-
- def = definitions.get("doc.listattribute.test");
- assertNotNull("Couldn't find doc.listattribute.test tile.", def);
- attribute = def.getAttribute("items");
- assertNotNull("Couldn't Find items attribute.", attribute);
- assertTrue("The class of the attribute is not right",
- attribute instanceof ListAttribute);
- assertTrue("The class of value of the attribute is not right",
- attribute.getValue() instanceof List);
- } catch (Exception e) {
- fail("Exception reading configuration." + e);
- }
+ URL configFile = this.getClass().getClassLoader().getResource(
+ "org/apache/tiles/config/tiles-defs.xml");
+ assertNotNull("Config file not found", configFile);
+
+ InputStream source = configFile.openStream();
+ Map<String, Definition> definitions = reader.read(source);
+
+ assertNotNull("Definitions not returned.", definitions);
+ assertNotNull("Couldn't find doc.mainLayout tile.",
+ definitions.get("doc.mainLayout"));
+ assertNotNull("Couldn't Find title attribute.", definitions.get(
+ "doc.mainLayout").getAttribute("title").getValue());
+ assertEquals("Incorrect Find title attribute.",
+ "Tiles Library Documentation", definitions.get(
+ "doc.mainLayout").getAttribute("title").getValue());
+
+ Definition def = definitions.get("doc.role.test");
+ assertNotNull("Couldn't find doc.role.test tile.", def);
+ Attribute attribute = def.getAttribute("title");
+ assertNotNull("Couldn't Find title attribute.", attribute
+ .getValue());
+ assertEquals("Role 'myrole' expected", attribute.getRole(),
+ "myrole");
+
+ def = definitions.get("doc.listattribute.test");
+ assertNotNull("Couldn't find doc.listattribute.test tile.", def);
+ attribute = def.getAttribute("items");
+ assertNotNull("Couldn't Find items attribute.", attribute);
+ assertTrue("The class of the attribute is not right",
+ attribute instanceof ListAttribute);
+ assertTrue("The class of value of the attribute is not right",
+ attribute.getValue() instanceof List);
}
/**
* Tests the read method under normal conditions for the new features in
2.1
* version of the DTD.
+ * @throws IOException If something goes wrong.
*/
@SuppressWarnings("unchecked")
- public void testRead21Version() {
- try {
- reader.init(new HashMap<String, String>());
-
- URL configFile = this.getClass().getClassLoader().getResource(
- "org/apache/tiles/config/tiles-defs-2.1.xml");
- assertNotNull("Config file not found", configFile);
-
- InputStream source = configFile.openStream();
- Map<String, Definition> definitions = reader.read(source);
-
- assertNotNull("Definitions not returned.", definitions);
- Definition def = definitions.get("doc.cascaded.test");
+ public void testRead21Version() throws IOException {
+ reader.init(new HashMap<String, String>());
- assertNotNull("Couldn't find doc.role.test tile.", def);
- Attribute attribute = def.getLocalAttribute("title");
- assertNotNull("Couldn't Find title local attribute.", attribute);
- attribute = def.getCascadedAttribute("title2");
- assertNotNull("Couldn't Find title2 cascaded attribute.",
attribute);
- attribute = def.getLocalAttribute("items1");
- assertNotNull("Couldn't Find items1 local attribute.", attribute);
- attribute = def.getCascadedAttribute("items2");
- assertNotNull("Couldn't Find items2 cascaded attribute.",
attribute);
-
- def = definitions.get("test.nesting.definitions");
- assertNotNull("Couldn't find test.nesting.definitions tile.", def);
- attribute = def.getAttribute("body");
- assertNotNull("Couldn't Find body attribute.", attribute);
- assertEquals("Attribute not of 'definition' type", "definition",
- attribute.getRenderer());
- assertNotNull("Attribute value null", attribute.getValue());
- String defName = attribute.getValue().toString();
- def = definitions.get(defName);
- assertNotNull("Couldn't find " + defName + " tile.", def);
-
- def = definitions.get("test.nesting.list.definitions");
- assertNotNull("Couldn't find test.nesting.list.definitions tile.",
- def);
- attribute = def.getAttribute("list");
- assertNotNull("Couldn't Find list attribute.", attribute);
- assertTrue("Attribute not of valid type",
- attribute instanceof ListAttribute);
- ListAttribute listAttribute = (ListAttribute) attribute;
- List<Attribute> list = (List<Attribute>) listAttribute.getValue();
- assertEquals("The list is not of correct size", 1, list.size());
- attribute = list.get(0);
- assertNotNull("Couldn't Find element attribute.", attribute);
- assertEquals("Attribute not of 'definition' type", "definition",
- attribute.getRenderer());
- assertNotNull("Attribute value null", attribute.getValue());
- defName = attribute.getValue().toString();
- def = definitions.get(defName);
- assertNotNull("Couldn't find " + defName + " tile.", def);
- } catch (Exception e) {
- fail("Exception reading configuration." + e);
- }
+ URL configFile = this.getClass().getClassLoader().getResource(
+ "org/apache/tiles/config/tiles-defs-2.1.xml");
+ assertNotNull("Config file not found", configFile);
+
+ InputStream source = configFile.openStream();
+ Map<String, Definition> definitions = reader.read(source);
+
+ assertNotNull("Definitions not returned.", definitions);
+ Definition def = definitions.get("doc.cascaded.test");
+
+ assertNotNull("Couldn't find doc.role.test tile.", def);
+ Attribute attribute = def.getLocalAttribute("title");
+ assertNotNull("Couldn't Find title local attribute.", attribute);
+ attribute = def.getCascadedAttribute("title2");
+ assertNotNull("Couldn't Find title2 cascaded attribute.", attribute);
+ attribute = def.getLocalAttribute("items1");
+ assertNotNull("Couldn't Find items1 local attribute.", attribute);
+ attribute = def.getCascadedAttribute("items2");
+ assertNotNull("Couldn't Find items2 cascaded attribute.", attribute);
+
+ def = definitions.get("test.nesting.definitions");
+ assertNotNull("Couldn't find test.nesting.definitions tile.", def);
+ attribute = def.getAttribute("body");
+ assertNotNull("Couldn't Find body attribute.", attribute);
+ assertEquals("Attribute not of 'definition' type", "definition",
+ attribute.getRenderer());
+ assertNotNull("Attribute value null", attribute.getValue());
+ String defName = attribute.getValue().toString();
+ def = definitions.get(defName);
+ assertNotNull("Couldn't find " + defName + " tile.", def);
+
+ def = definitions.get("test.nesting.list.definitions");
+ assertNotNull("Couldn't find test.nesting.list.definitions tile.",
+ def);
+ attribute = def.getAttribute("list");
+ assertNotNull("Couldn't Find list attribute.", attribute);
+ assertTrue("Attribute not of valid type",
+ attribute instanceof ListAttribute);
+ ListAttribute listAttribute = (ListAttribute) attribute;
+ List<Attribute> list = (List<Attribute>) listAttribute.getValue();
+ assertEquals("The list is not of correct size", 1, list.size());
+ attribute = list.get(0);
+ assertNotNull("Couldn't Find element attribute.", attribute);
+ assertEquals("Attribute not of 'definition' type", "definition",
+ attribute.getRenderer());
+ assertNotNull("Attribute value null", attribute.getValue());
+ defName = attribute.getValue().toString();
+ def = definitions.get(defName);
+ assertNotNull("Couldn't find " + defName + " tile.", def);
+
+ defName = "test.inherit.list.base";
+ def = definitions.get(defName);
+ assertNotNull("Couldn't find " + defName + " tile.", def);
+ defName = "test.inherit.list";
+ def = definitions.get(defName);
+ assertNotNull("Couldn't find " + defName + " tile.", def);
+ listAttribute = (ListAttribute) def.getAttribute("list");
+ assertEquals("This definition does not inherit its list attribute",
+ true, listAttribute.isInherit());
+ defName = "test.noinherit.list";
+ def = definitions.get(defName);
+ listAttribute = (ListAttribute) def.getAttribute("list");
+ assertEquals("This definition inherits its list attribute",
+ false, listAttribute.isInherit());
}
/**