You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by gr...@apache.org on 2005/12/01 17:51:18 UTC
svn commit: r350273 - in /struts/sandbox/trunk/tiles: ./ src/conf/
src/java/org/apache/tiles/ src/java/org/apache/tiles/definition/
src/java/org/apache/tiles/digester/ src/java/org/apache/tiles/servlets/
src/java/org/apache/tiles/taglib/ src/java/org/a...
Author: greddin
Date: Thu Dec 1 08:50:58 2005
New Revision: 350273
URL: http://svn.apache.org/viewcvs?rev=350273&view=rev
Log:
Major Tiles Refactoring - API Cleanup
- Added more unit tests.
- Removed old compatibility layer components.
- Cleaned up API by shrinking layers
- Replaced variaous AttributeX classes with ComponentAttribute.
- Removed xmlDefinitions package and pushed all that functionality up to
ComponentDefinition, ComponentDefinitions, ComponentListAttribute, and
ComponentAttribute
- Corrected URLs in DTD and TLD.
Added:
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentAttribute.java (with props)
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentListAttribute.java (with props)
struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinition.java (with props)
struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestTilesServlet.java (with props)
Removed:
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/AttributeDefinition.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentDefinitionsFactory.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/DefinitionAttribute.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/DefinitionNameAttribute.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/DirectStringAttribute.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/PathAttribute.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/UntypedAttribute.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/definition/ComponentDefinitionsFactoryWrapper.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/definition/ReloadableDefinitionsFactory.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/xmlDefinition/
Modified:
struts/sandbox/trunk/tiles/build.xml
struts/sandbox/trunk/tiles/project.xml
struts/sandbox/trunk/tiles/src/conf/tiles-config_1_2.dtd
struts/sandbox/trunk/tiles/src/conf/tiles-core.tld
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentDefinition.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/TilesUtilImpl.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/digester/DigesterDefinitionsReader.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/servlets/TilesServlet.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/DefinitionTag.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/InsertTag.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutListTag.java
struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutTag.java
struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinitions.java
struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestDigesterDefinitionsReader.java
Modified: struts/sandbox/trunk/tiles/build.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/build.xml?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/build.xml (original)
+++ struts/sandbox/trunk/tiles/build.xml Thu Dec 1 08:50:58 2005
@@ -308,6 +308,10 @@
ignoreerrors="true"
src="${maven.repo}/servletapi/jars/servletapi-2.3.jar"
usetimestamp="true"/>
+ <get dest="${lib.home}/strutstestcase-2.1.2-1.1-2.3.jar"
+ ignoreerrors="true"
+ src="${maven.repo}/strutstestcase/jars/strutstestcase-2.1.2-1.1-2.3.jar"
+ usetimestamp="true"/>
</target>
Modified: struts/sandbox/trunk/tiles/project.xml
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/project.xml?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/project.xml (original)
+++ struts/sandbox/trunk/tiles/project.xml Thu Dec 1 08:50:58 2005
@@ -89,6 +89,16 @@
</dependency>
<dependency>
+ <groupId>strutstestcase</groupId>
+ <artifactId>strutstestcase</artifactId>
+ <version>2.1.2-1.1-2.3</version>
+ <url>http://ibiblio.org/maven/strutstestcase/</url>
+ <properties>
+ <war.bundle>false</war.bundle>
+ </properties>
+ </dependency>
+
+ <dependency>
<groupId>maven-taglib</groupId>
<artifactId>maven-taglib-plugin</artifactId>
<version>1.4</version>
Modified: struts/sandbox/trunk/tiles/src/conf/tiles-config_1_2.dtd
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/conf/tiles-config_1_2.dtd?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/conf/tiles-config_1_2.dtd (original)
+++ struts/sandbox/trunk/tiles/src/conf/tiles-config_1_2.dtd Thu Dec 1 08:50:58 2005
@@ -6,7 +6,7 @@
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.2//EN"
- "http://apache.org/dtds/tiles-config_1_2.dtd">
+ "http://struts.apache.org/dtds/tiles-config_1_2.dtd">
-->
Modified: struts/sandbox/trunk/tiles/src/conf/tiles-core.tld
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/conf/tiles-core.tld?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/conf/tiles-core.tld (original)
+++ struts/sandbox/trunk/tiles/src/conf/tiles-core.tld Thu Dec 1 08:50:58 2005
@@ -6,7 +6,7 @@
<tlib-version>0.2</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>tiles</short-name>
- <uri>http://jakarta.apache.org/tiles</uri>
+ <uri>http://struts.apache.org/tags-tiles</uri>
<tag>
<name>insert</name>
<tag-class>org.apache.tiles.taglib.InsertTag</tag-class>
Added: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentAttribute.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentAttribute.java?rev=350273&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentAttribute.java (added)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentAttribute.java Thu Dec 1 08:50:58 2005
@@ -0,0 +1,145 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.io.Serializable;
+
+/**
+ * Common implementation of attribute definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentAttribute implements Serializable {
+
+ /**
+ * Role associated to this attribute.
+ */
+ protected String role = null;
+
+ protected Object value=null;
+
+ private String type = null;
+
+ private String name = null;
+
+ /**
+ * Constructor.
+ * @param value Object to store.
+ */
+ public ComponentAttribute() {
+ }
+
+ /**
+ * Constructor.
+ * @param value Object to store.
+ */
+ public ComponentAttribute(Object value) {
+ this.value = value;
+ }
+
+ /**
+ * Constructor.
+ * @param value Object to store.
+ */
+ public ComponentAttribute(String name, Object value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ * Constructor.
+ * @param value Object to store.
+ * @param role Asociated role.
+ */
+ public ComponentAttribute(Object value, String role) {
+ this.value = value;
+ this.role = role;
+ }
+
+ /**
+ * Constructor.
+ * @param value Object to store.
+ * @param role Asociated role.
+ * @param type Attribute type.
+ */
+ public ComponentAttribute(Object value, String role, String type) {
+ this.value = value;
+ this.role = role;
+ this.type = type;
+ }
+
+ /**
+ * Get role.
+ */
+ public String getRole() {
+ return role;
+ }
+
+ /**
+ * Set role.
+ * @param role Associated role.
+ */
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ /**
+ * Get value.
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * Set value.
+ * @param value New value.
+ */
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ /**
+ * Get String representation of this object.
+ */
+ public String toString() {
+ return value.toString();
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setBody(String body) {
+ if (body != null && body.length() != 0) {
+ setValue(body);
+ }
+ }
+}
Propchange: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentAttribute.java
------------------------------------------------------------------------------
svn:keywords = date author id rev
Modified: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentDefinition.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentDefinition.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentDefinition.java (original)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentDefinition.java Thu Dec 1 08:50:58 2005
@@ -26,8 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.tiles.xmlDefinition.XmlAttribute;
-import org.apache.tiles.xmlDefinition.XmlDefinition;
import org.apache.tiles.util.RequestUtils;
/**
@@ -127,25 +125,6 @@
/**
* Constructor.
- * Create a new definition initialized from a RawDefinition.
- * Raw definitions are used to read definition from a data source (xml file, db, ...).
- * A RawDefinition mainly contains properties of type String, while Definition
- * contains more complex type (ex : Controller).
- * Do a shallow copy : attributes are shared between objects, but not the Map
- * containing attributes.
- * OO Design issues : Actually RawDefinition (XmlDefinition) extends ComponentDefinition.
- * This must not be the case. I have do it because I am lazy.
- * @throws InstantiationException if an error occur while instanciating Controller :
- * (classname can't be instanciated, Illegal access with instanciated class,
- * Error while instanciating class, classname can't be instanciated.
- */
- public ComponentDefinition(XmlDefinition definition) {
-
- this((ComponentDefinition) definition);
- }
-
- /**
- * Constructor.
*/
public ComponentDefinition(String name, String path, Map attributes) {
this.name = name;
@@ -259,7 +238,12 @@
* @return requested attribute or null if not found
*/
public Object getAttribute(String key) {
- return attributes.get(key);
+ ComponentAttribute attribute = (ComponentAttribute) attributes.get(key);
+ if (attribute != null) {
+ return attribute.getValue();
+ } else {
+ return null;
+ }
}
/**
@@ -268,7 +252,7 @@
* @param key String key for attribute
* @param value Attibute value.
*/
- public void putAttribute(String key, Object value) {
+ public void putAttribute(String key, ComponentAttribute value) {
attributes.put(key, value);
}
@@ -322,30 +306,7 @@
// Is there a type set ?
// First check direct attribute, and translate it to a valueType.
// Then, evaluate valueType, and create requested typed attribute.
- AttributeDefinition attribute = null;
-
- if (content != null
- && type != null
- && !(content instanceof AttributeDefinition)) {
-
- String strValue = content.toString();
- if (type.equalsIgnoreCase("string")) {
- attribute = new DirectStringAttribute(strValue);
-
- } else if (type.equalsIgnoreCase("page")) {
- attribute = new PathAttribute(strValue);
-
- } else if (type.equalsIgnoreCase("template")) {
- attribute = new PathAttribute(strValue);
-
- } else if (type.equalsIgnoreCase("instance")) {
- attribute = new DefinitionNameAttribute(strValue);
-
- } else if (type.equalsIgnoreCase("definition")) {
- attribute = new DefinitionNameAttribute(strValue);
- }
- }
-
+ ComponentAttribute attribute = new ComponentAttribute(content, role, type);
putAttribute(name, attribute);
}
@@ -557,11 +518,13 @@
/**
* Add an attribute to this component.
*
+ * This method is used by Digester to load definitions.
+ *
* @param attribute Attribute to add.
*/
- public void addAttribute( XmlAttribute attribute)
+ public void addAttribute( ComponentAttribute attribute)
{
- putAttribute( attribute.getName(), attribute.getValue() );
+ putAttribute( attribute.getName(), attribute );
}
/**
@@ -643,7 +606,7 @@
{
String name = (String)parentAttributes.next();
if( !getAttributes().containsKey(name) )
- putAttribute( name, parent.getAttribute(name) );
+ put( name, parent.getAttribute(name) );
}
// Set path and role if not setted
if( path == null )
@@ -699,7 +662,7 @@
{
String name = (String)parentAttributes.next();
if( !getAttributes().containsKey(name) )
- putAttribute( name, parent.getAttribute(name) );
+ put( name, parent.getAttribute(name) );
}
// Set path and role if not setted
if( path == null )
Added: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentListAttribute.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentListAttribute.java?rev=350273&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentListAttribute.java (added)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentListAttribute.java Thu Dec 1 08:50:58 2005
@@ -0,0 +1,93 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.tiles;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * An attribute as a <code>List</code>.
+ * This attribute associates a name with a list. The list can be found by the
+ * property name.
+ * Elements in list are retrieved using List methods.
+ * This class is used to read configuration files.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentListAttribute extends ComponentAttribute {
+ /** List.
+ * We declare a List to avoid cast.
+ * Parent "value" property points to the same list.
+ */
+ private List list;
+
+ /**
+ * Constructor.
+ */
+ public ComponentListAttribute() {
+ list = new ArrayList();
+ setValue(list);
+ }
+
+ /**
+ * Constructor.
+ * @param name Name.
+ * @param value List.
+ */
+ public ComponentListAttribute( String name, List value) {
+ super( name, value );
+ list = value;
+ }
+
+ /**
+ * Add an element in list.
+ * We use a property to avoid rewriting a new class.
+ * @param element XmlAttribute to add.
+ */
+ public void add( ComponentAttribute element ) {
+ list.add( element.getValue() );
+ }
+
+ /**
+ * Add an element in list.
+ * @param value Object to add.
+ */
+ public void add( Object value ) {
+ //list.add( value );
+ // To correct a bug in digester, we need to check the object type
+ // Digester doesn't call correct method according to object type ;-(
+ if(value instanceof ComponentAttribute) {
+ add((ComponentAttribute)value);
+ return;
+ } else {
+ list.add( value );
+ }
+ }
+
+ /**
+ * Add an element in list.
+ * @param value Object to add.
+ */
+ public void addObject( Object value ) {
+ list.add( value );
+ }
+
+}
Propchange: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentListAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/ComponentListAttribute.java
------------------------------------------------------------------------------
svn:keywords = date author id rev
Modified: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/TilesUtilImpl.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/TilesUtilImpl.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/TilesUtilImpl.java (original)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/TilesUtilImpl.java Thu Dec 1 08:50:58 2005
@@ -38,7 +38,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.tiles.definition.ComponentDefinitionsFactoryWrapper;
import org.apache.tiles.util.RequestUtils;
/**
@@ -242,8 +241,6 @@
/**
* Create Definition factory of specified classname.
* Factory class must extend the {@link DefinitionsFactory} class.
- * The factory is wrapped appropriately with {@link ComponentDefinitionsFactoryWrapper}
- * if it is an instance of the deprecated ComponentDefinitionsFactory class.
* @param classname Class name of the factory to create.
* @return newly created factory.
* @throws DefinitionsFactoryException If an error occur while initializing factory
@@ -255,13 +252,6 @@
Class factoryClass = RequestUtils.applicationClass(classname);
Object factory = factoryClass.newInstance();
- // Backward compatibility : if factory classes implements old interface,
- // provide appropriate wrapper
- if (factory instanceof ComponentDefinitionsFactory) {
- factory =
- new ComponentDefinitionsFactoryWrapper(
- (ComponentDefinitionsFactory) factory);
- }
return (DefinitionsFactory) factory;
} catch (ClassCastException ex) { // Bad classname
Modified: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java (original)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java Thu Dec 1 08:50:58 2005
@@ -22,6 +22,7 @@
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
+import org.apache.tiles.ComponentAttribute;
import org.apache.tiles.ComponentDefinition;
import org.apache.tiles.ComponentDefinitions;
import org.apache.tiles.NoSuchDefinitionException;
@@ -65,6 +66,7 @@
*/
public void addDefinitions(Map defsMap) throws NoSuchDefinitionException {
this.baseDefinitions.putAll(defsMap);
+ resolveAttributeDependencies();
resolveInheritances();
}
@@ -77,6 +79,7 @@
*/
public void addDefinitions(Map defsMap, Locale locale) throws NoSuchDefinitionException {
localeSpecificDefinitions.put(locale, defsMap);
+ resolveAttributeDependencies();
resolveInheritances(locale);
}
@@ -142,5 +145,25 @@
*/
public Map getBaseDefinitions() {
return this.baseDefinitions;
+ }
+
+ public void resolveAttributeDependencies() {
+ Iterator i = this.baseDefinitions.values().iterator();
+
+ // FIXME: Need to repeat the following for locale-specific defs.
+ while (i.hasNext()) {
+ ComponentDefinition def = (ComponentDefinition) i.next();
+ Map attributes = def.getAttributes();
+ Iterator j = attributes.values().iterator();
+ while (j.hasNext()) {
+ ComponentAttribute attr = (ComponentAttribute) j.next();
+ if (attr.getType() != null &&
+ (attr.getType().equalsIgnoreCase("definition") ||
+ attr.getType().equalsIgnoreCase("instance")) ) {
+ ComponentDefinition subDef = this.getDefinition((String) attr.getValue());
+ attr.setValue(subDef);
+ }
+ }
+ }
}
}
Modified: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/digester/DigesterDefinitionsReader.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/digester/DigesterDefinitionsReader.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/digester/DigesterDefinitionsReader.java (original)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/digester/DigesterDefinitionsReader.java Thu Dec 1 08:50:58 2005
@@ -99,7 +99,7 @@
// Register our local copy of the DTDs that we can find
for (int i = 0; i < registrations.length; i += 2) {
- URL url = this.getClass().getClassLoader().getResource(
+ URL url = this.getClass().getResource(
registrations[i+1]);
if (url != null) {
digester.register(registrations[i], url.toString());
@@ -197,15 +197,16 @@
*/
private void initDigesterForComponentsDefinitionsSyntax( Digester digester ) {
// Common constants
- String PACKAGE_NAME = "org.apache.tiles.xmlDefinition";
+ String PACKAGE_NAME = "org.apache.tiles";
String DEFINITION_TAG = "component-definitions/definition";
- String definitionHandlerClass = PACKAGE_NAME + ".XmlDefinition";
+ String definitionHandlerClass = PACKAGE_NAME + ".ComponentDefinition";
String PUT_TAG = DEFINITION_TAG + "/put";
- String putAttributeHandlerClass = PACKAGE_NAME + ".XmlAttribute";
+ String putAttributeHandlerClass = PACKAGE_NAME + ".ComponentAttribute";
String LIST_TAG = DEFINITION_TAG + "/putList";
- String listHandlerClass = PACKAGE_NAME + ".XmlListAttribute";
+
+ String listHandlerClass = PACKAGE_NAME + ".ComponentListAttribute";
String ADD_LIST_ELE_TAG = LIST_TAG + "/add";
@@ -238,18 +239,19 @@
*/
private void initDigesterForTilesDefinitionsSyntax( Digester digester ) {
// Common constants
- String PACKAGE_NAME = "org.apache.tiles.xmlDefinition";
+ String PACKAGE_NAME = "org.apache.tiles";
String DEFINITION_TAG = "tiles-definitions/definition";
- String definitionHandlerClass = PACKAGE_NAME + ".XmlDefinition";
+ String definitionHandlerClass = PACKAGE_NAME + ".ComponentDefinition";
String PUT_TAG = DEFINITION_TAG + "/put";
- String putAttributeHandlerClass = PACKAGE_NAME + ".XmlAttribute";
+ String putAttributeHandlerClass = PACKAGE_NAME + ".ComponentAttribute";
//String LIST_TAG = DEFINITION_TAG + "/putList";
// List tag value
String LIST_TAG = "putList";
String DEF_LIST_TAG = DEFINITION_TAG + "/" + LIST_TAG;
- String listHandlerClass = PACKAGE_NAME + ".XmlListAttribute";
+
+ String listHandlerClass = PACKAGE_NAME + ".ComponentListAttribute";
// Tag value for adding an element in a list
String ADD_LIST_ELE_TAG = "*/" + LIST_TAG + "/add";
@@ -263,8 +265,8 @@
// SetNext and CallMethod use rule.end() method. So, placing SetNext in
// first position ensure it will be called last (sic).
digester.addObjectCreate( PUT_TAG, putAttributeHandlerClass);
- digester.addSetNext( PUT_TAG, "addAttribute", putAttributeHandlerClass);
digester.addSetProperties( PUT_TAG);
+ digester.addSetNext( PUT_TAG, "addAttribute", putAttributeHandlerClass);
digester.addCallMethod( PUT_TAG, "setBody", 0);
// Definition level list rules
// This is rules for lists nested in a definition
@@ -275,8 +277,8 @@
// We use Attribute class to avoid rewriting a new class.
// Name part can't be used in listElement attribute.
digester.addObjectCreate( ADD_LIST_ELE_TAG, putAttributeHandlerClass);
- digester.addSetNext( ADD_LIST_ELE_TAG, "add", putAttributeHandlerClass);
digester.addSetProperties( ADD_LIST_ELE_TAG);
+ digester.addSetNext( ADD_LIST_ELE_TAG, "add", putAttributeHandlerClass);
digester.addCallMethod( ADD_LIST_ELE_TAG, "setBody", 0);
// nested list elements rules
@@ -301,8 +303,8 @@
String BEAN_TAG = "*/bean";
String beanDefaultClass = "org.apache.tiles.beans.SimpleMenuItem";
digester.addObjectCreate( BEAN_TAG, beanDefaultClass, "classtype");
- digester.addSetNext( BEAN_TAG, "add", "java.lang.Object");
digester.addSetProperties( BEAN_TAG);
+ digester.addSetNext( BEAN_TAG, "add", "java.lang.Object");
// Set properties to surrounding element
digester.addSetProperty(BEAN_TAG+ "/set-property", "property", "value");
@@ -316,16 +318,17 @@
*/
private void initDigesterForInstancesSyntax( Digester digester ) {
// Build a digester to process our configuration resource
- String PACKAGE_NAME = "org.apache.tiles.xmlDefinition";
+ String PACKAGE_NAME = "org.apache.tiles";
String INSTANCE_TAG = "component-instances/instance";
- String instanceHandlerClass = PACKAGE_NAME + ".XmlDefinition";
+ String instanceHandlerClass = PACKAGE_NAME + ".ComponentDefinition";
String PUT_TAG = INSTANCE_TAG + "/put";
String PUTATTRIBUTE_TAG = INSTANCE_TAG + "/putAttribute";
- String putAttributeHandlerClass = PACKAGE_NAME + ".XmlAttribute";
+ String putAttributeHandlerClass = PACKAGE_NAME + ".ComponentAttribute";
String LIST_TAG = INSTANCE_TAG + "/putList";
- String listHandlerClass = PACKAGE_NAME + ".XmlListAttribute";
+
+ String listHandlerClass = PACKAGE_NAME + ".ComponentListAttribute";
String ADD_LIST_ELE_TAG = LIST_TAG + "/add";
Modified: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/servlets/TilesServlet.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/servlets/TilesServlet.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/servlets/TilesServlet.java (original)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/servlets/TilesServlet.java Thu Dec 1 08:50:58 2005
@@ -173,7 +173,7 @@
}
catch(Exception ex) {
saveExceptionMessage(config, ex);
- throw new ServletException(ex.getMessage());
+ throw new ServletException(ex.getMessage(), ex);
}
}
@@ -229,8 +229,8 @@
definitionFactory = DefinitionsUtil.createDefinitionsFactory(
servletContext, factoryConfig);
} catch (DefinitionsFactoryException ex) {
- saveExceptionMessage(getServletConfig(), ex);
- throw new ServletException(ex.getMessage());
+ ex.printStackTrace();
+ throw new ServletException(ex.getMessage(), ex);
}
}
Modified: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/DefinitionTag.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/DefinitionTag.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/DefinitionTag.java (original)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/DefinitionTag.java Thu Dec 1 08:50:58 2005
@@ -21,9 +21,8 @@
import javax.servlet.jsp.JspException;
import org.apache.tiles.taglib.util.TagUtils;
-import org.apache.tiles.AttributeDefinition;
import org.apache.tiles.ComponentDefinition;
-import org.apache.tiles.UntypedAttribute;
+import org.apache.tiles.ComponentAttribute;
/**
* This is the tag handler for <tiles:definition>, which defines
@@ -84,7 +83,7 @@
* Content is already typed by caller.
*/
public void putAttribute(String name, Object content) {
- definition.putAttribute(name, content);
+ definition.putAttribute(name, new ComponentAttribute(content));
}
/**
@@ -99,9 +98,10 @@
// If role is set, add it in attribute definition if any.
// If no attribute definition, create untyped one and set role.
Object attributeValue = nestedTag.getRealValue();
- AttributeDefinition def;
+// AttributeDefinition def;
if (nestedTag.getRole() != null) {
+ /* FIXME
try {
def = ((AttributeDefinition) attributeValue);
} catch (ClassCastException ex) {
@@ -109,10 +109,11 @@
}
def.setRole(nestedTag.getRole());
attributeValue = def;
+ */
}
// now add attribute to enclosing parent (i.e. : this object)
- putAttribute(nestedTag.getName(), attributeValue);
+ putAttribute(nestedTag.getName(), new ComponentAttribute(attributeValue));
}
/**
@@ -129,9 +130,11 @@
Object attributeValue = nestedTag.getList();
if (nestedTag.getRole() != null) {
+ /* FIXME
AttributeDefinition def = new UntypedAttribute(attributeValue);
def.setRole(nestedTag.getRole());
attributeValue = def;
+ */
}
// Check if a name is defined
@@ -140,7 +143,7 @@
}
// now add attribute to enclosing parent (i.e. : this object).
- putAttribute(nestedTag.getName(), attributeValue);
+ putAttribute(nestedTag.getName(), new ComponentAttribute(attributeValue));
}
/**
Modified: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/InsertTag.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/InsertTag.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/InsertTag.java (original)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/InsertTag.java Thu Dec 1 08:50:58 2005
@@ -32,14 +32,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tiles.taglib.util.TagUtils;
-import org.apache.tiles.AttributeDefinition;
import org.apache.tiles.ComponentContext;
import org.apache.tiles.ComponentDefinition;
import org.apache.tiles.Controller;
-import org.apache.tiles.DefinitionAttribute;
-import org.apache.tiles.DefinitionNameAttribute;
import org.apache.tiles.DefinitionsFactoryException;
-import org.apache.tiles.DirectStringAttribute;
import org.apache.tiles.FactoryNotFoundException;
import org.apache.tiles.NoSuchDefinitionException;
import org.apache.tiles.TilesUtil;
@@ -496,6 +492,7 @@
*/
public TagHandler processObjectValue(Object value) throws JspException {
// First, check if value is one of the Typed Attribute
+ /* FIXME
if (value instanceof AttributeDefinition) {
// We have a type => return appropriate IncludeType
return processTypedAttribute((AttributeDefinition) value);
@@ -503,6 +500,7 @@
} else if (value instanceof ComponentDefinition) {
return processDefinition((ComponentDefinition) value);
}
+ */
// Value must denote a valid String
return processAsDefinitionOrURL(value.toString());
@@ -728,6 +726,7 @@
* @return appropriate TagHandler.
* @throws JspException - Throws by underlying nested call to processDefinitionName()
*/
+ /* FIXME
public TagHandler processTypedAttribute(AttributeDefinition value)
throws JspException {
if (value instanceof DirectStringAttribute) {
@@ -745,6 +744,7 @@
role,
getController());
}
+ */
/**
* Do an include of specified page.
Modified: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutListTag.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutListTag.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutListTag.java (original)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutListTag.java Thu Dec 1 08:50:58 2005
@@ -24,9 +24,6 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
-import org.apache.tiles.AttributeDefinition;
-import org.apache.tiles.UntypedAttribute;
-
/**
* PutList tag implementation.
*/
@@ -133,9 +130,12 @@
Object attributeValue = nestedTag.getList();
if (nestedTag.getRole() != null) {
+ // FIXME - What to do here?
+ /*
AttributeDefinition def = new UntypedAttribute(attributeValue);
def.setRole(nestedTag.getRole());
attributeValue = def;
+ */
}
// now add attribute to enclosing parent (i.e. : this object)
@@ -154,9 +154,11 @@
// If role is set, add it in attribute definition if any.
// If no attribute definition, create untyped one, and set role.
Object attributeValue = nestedTag.getRealValue();
- AttributeDefinition def;
+// AttributeDefinition def;
if (nestedTag.getRole() != null) {
+ /*
+ FIXME - What to do here?
try {
def = ((AttributeDefinition) attributeValue);
} catch (ClassCastException ex) {
@@ -164,6 +166,7 @@
}
def.setRole(nestedTag.getRole());
attributeValue = def;
+ */
}
// now add attribute to enclosing parent (i.e. : this object)
Modified: struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutTag.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutTag.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutTag.java (original)
+++ struts/sandbox/trunk/tiles/src/java/org/apache/tiles/taglib/PutTag.java Thu Dec 1 08:50:58 2005
@@ -25,10 +25,6 @@
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.tiles.taglib.util.TagUtils;
-import org.apache.tiles.AttributeDefinition;
-import org.apache.tiles.DefinitionNameAttribute;
-import org.apache.tiles.DirectStringAttribute;
-import org.apache.tiles.PathAttribute;
/**
* Put an attribute in enclosing attribute container tag.
@@ -346,25 +342,25 @@
}
}
+ // FIXME - How to handle this now?
if (realValue != null
- && valueType != null
- && !(value instanceof AttributeDefinition)) {
+ && valueType != null) {
String strValue = realValue.toString();
if (valueType.equalsIgnoreCase("string")) {
- realValue = new DirectStringAttribute(strValue);
+// realValue = new DirectStringAttribute(strValue);
} else if (valueType.equalsIgnoreCase("page")) {
- realValue = new PathAttribute(strValue);
+// realValue = new PathAttribute(strValue);
} else if (valueType.equalsIgnoreCase("template")) {
- realValue = new PathAttribute(strValue);
+// realValue = new PathAttribute(strValue);
} else if (valueType.equalsIgnoreCase("instance")) {
- realValue = new DefinitionNameAttribute(strValue);
+// realValue = new DefinitionNameAttribute(strValue);
} else if (valueType.equalsIgnoreCase("definition")) {
- realValue = new DefinitionNameAttribute(strValue);
+// realValue = new DefinitionNameAttribute(strValue);
} else { // bad type
throw new JspException(
Added: struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinition.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinition.java?rev=350273&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinition.java (added)
+++ struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinition.java Thu Dec 1 08:50:58 2005
@@ -0,0 +1,72 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Tests the ComponentDefinition class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestComponentDefinition extends TestCase{
+
+ /** Creates a new instance of TestComponentDefinition */
+ public TestComponentDefinition(String name) {
+ super(name);
+ }
+
+ /**
+ * Start the tests.
+ *
+ * @param theArgs the arguments. Not used
+ */
+ public static void main(String[] theArgs) {
+ junit.awtui.TestRunner.main(
+ new String[] { TestComponentDefinition.class.getName()});
+ }
+
+ /**
+ * @return a test suite (<code>TestSuite</code>) that includes all methods
+ * starting with "test"
+ */
+ public static Test suite() {
+ return new TestSuite(TestComponentDefinition.class);
+ }
+
+ /**
+ * Verifies the put Attribute functionality.
+ *
+ * Attributes are added or replaced in the component definition.
+ */
+ public void testPutAttribute() {
+ ComponentDefinition def = new ComponentDefinition();
+ def.setName("test1");
+ def.setPath("/page1.jsp");
+ def.put("attr1", new ComponentDefinition(), "definition", null);
+
+ Object attr1 = def.getAttribute("attr1");
+ assertNotNull("Null attribute.", attr1);
+ assertTrue("Wrong attribute type", attr1 instanceof ComponentDefinition);
+ }
+
+
+}
Propchange: struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinition.java
------------------------------------------------------------------------------
svn:keywords = date author id rev
Modified: struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinitions.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinitions.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinitions.java (original)
+++ struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestComponentDefinitions.java Thu Dec 1 08:50:58 2005
@@ -25,7 +25,6 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.tiles.definition.ComponentDefinitionsImpl;
-import org.apache.tiles.xmlDefinition.XmlAttribute;
/**
* Tests the ComponentDefinitionsImpl class.
@@ -66,7 +65,7 @@
ComponentDefinition def = new ComponentDefinition();
def.setName("parent.def1");
def.setPath("/test1.jsp");
- XmlAttribute attr = new XmlAttribute();
+ ComponentAttribute attr = new ComponentAttribute();
attr.setName("attr1");
attr.setValue("value1");
def.addAttribute(attr);
@@ -75,7 +74,7 @@
def = new ComponentDefinition();
def.setName("child.def1");
def.setExtends("parent.def1");
- attr = new XmlAttribute();
+ attr = new ComponentAttribute();
attr.setName("attr1");
attr.setValue("New value");
def.addAttribute(attr);
@@ -111,7 +110,7 @@
ComponentDefinition def = new ComponentDefinition();
def.setName("parent.def1");
def.setPath("/test1.jsp");
- XmlAttribute attr = new XmlAttribute();
+ ComponentAttribute attr = new ComponentAttribute();
attr.setName("attr1");
attr.setValue("value1");
def.addAttribute(attr);
@@ -120,7 +119,7 @@
def = new ComponentDefinition();
def.setName("child.def1");
def.setExtends("parent.def1");
- attr = new XmlAttribute();
+ attr = new ComponentAttribute();
attr.setName("attr1");
attr.setValue("New value");
def.addAttribute(attr);
@@ -130,7 +129,7 @@
def = new ComponentDefinition();
def.setName("child.def1");
def.setExtends("parent.def1");
- attr = new XmlAttribute();
+ attr = new ComponentAttribute();
attr.setName("attr1");
attr.setValue("US Value");
def.addAttribute(attr);
@@ -182,7 +181,7 @@
ComponentDefinition def = new ComponentDefinition();
def.setName("parent.def1");
def.setPath("/test1.jsp");
- XmlAttribute attr = new XmlAttribute();
+ ComponentAttribute attr = new ComponentAttribute();
attr.setName("attr1");
attr.setValue("value1");
def.addAttribute(attr);
@@ -191,7 +190,7 @@
def = new ComponentDefinition();
def.setName("child.def1");
def.setExtends("parent.def1");
- attr = new XmlAttribute();
+ attr = new ComponentAttribute();
attr.setName("attr1");
attr.setValue("New value");
def.addAttribute(attr);
@@ -210,5 +209,48 @@
definitions.reset();
assertNull("Definitions should be null.",
definitions.getDefinition("parent.def1"));
+ }
+
+ /**
+ * Verifies that attribute dependencies are resolved.
+ *
+ * A Component (tile) can have an attribute that points to another component.
+ * This test verifies that the <code>resolveAttributes</code> method is
+ * executed and attribute dependencies are calculated.
+ */
+ public void testResolveAttributeDependencies() {
+ Map defs = new HashMap();
+
+ ComponentDefinition def = new ComponentDefinition();
+ def.setName("parent.def1");
+ def.setPath("/test1.jsp");
+ ComponentAttribute attr = new ComponentAttribute();
+ attr.setName("attr1");
+ attr.setValue("tiles.def2");
+ attr.setType("definition");
+ def.addAttribute(attr);
+ defs.put(def.getName(), def);
+
+ def = new ComponentDefinition();
+ def.setName("tiles.def2");
+ defs.put(def.getName(), def);
+
+ ComponentDefinitions definitions = new ComponentDefinitionsImpl();
+ try {
+ definitions.addDefinitions(defs);
+ } catch (NoSuchDefinitionException e) {
+ fail("Test failure: " + e);
+ }
+
+ ComponentDefinition newDef = definitions.getDefinition("parent.def1");
+ assertNotNull("Parent definition not found.", newDef);
+
+ Object newAttr = newDef.getAttribute("attr1");
+ assertNotNull("Dependent attribute not found.", newAttr);
+ assertTrue("Dependent attribute incorrect type.",
+ newAttr instanceof ComponentDefinition);
+
+ assertEquals("Incorrect dependent attribute name.", "tiles.def2",
+ ((ComponentDefinition) newAttr).getName());
}
}
Modified: struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestDigesterDefinitionsReader.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestDigesterDefinitionsReader.java?rev=350273&r1=350272&r2=350273&view=diff
==============================================================================
--- struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestDigesterDefinitionsReader.java (original)
+++ struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestDigesterDefinitionsReader.java Thu Dec 1 08:50:58 2005
@@ -77,6 +77,13 @@
assertNotNull("Definitions not returned.", definitions);
assertNotNull("Couldn't find doc.mainLayout tile.",
(ComponentDefinition) definitions.get("doc.mainLayout"));
+ assertNotNull("Couldn't Find title attribute.",
+ ((ComponentDefinition) definitions.get("doc.mainLayout"))
+ .getAttribute("title"));
+ assertEquals("Incorrect Find title attribute.",
+ "Tiles Library Documentation",
+ ((ComponentDefinition) definitions.get("doc.mainLayout"))
+ .getAttribute("title"));
} catch (Exception e) {
fail("Exception reading configuration." + e);
Added: struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestTilesServlet.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestTilesServlet.java?rev=350273&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestTilesServlet.java (added)
+++ struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestTilesServlet.java Thu Dec 1 08:50:58 2005
@@ -0,0 +1,74 @@
+/*
+ * $Id$
+ *
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.tiles;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import servletunit.ServletConfigSimulator;
+import servletunit.ServletContextSimulator;
+import org.apache.tiles.servlets.TilesServlet;
+
+/**
+ * Verifies the functionality of the TilesServlet
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestTilesServlet extends TestCase {
+
+ /** Creates a new instance of TestTilesServlet */
+ public TestTilesServlet(String name) {
+ super(name);
+ }
+
+ /**
+ * Start the tests.
+ *
+ * @param theArgs the arguments. Not used
+ */
+ public static void main(String[] theArgs) {
+ junit.awtui.TestRunner.main(
+ new String[] { TestTilesServlet.class.getName()});
+ }
+
+ /**
+ * @return a test suite (<code>TestSuite</code>) that includes all methods
+ * starting with "test"
+ */
+ public static Test suite() {
+ return new TestSuite(TestTilesServlet.class);
+ }
+
+ /**
+ * Executes the servlet init() method.
+ */
+ public void testInitTilesServlet() {
+ try {
+ ServletConfigSimulator servletConfig = new ServletConfigSimulator();
+ servletConfig.setInitParameter("definitions-config",
+ "org/apache/tiles/config/tiles-defs.xml");
+
+ TilesServlet servlet = new TilesServlet();
+ servlet.init(servletConfig);
+ } catch (Exception e) {
+ fail("Eception initializing servlet: " + e);
+ }
+ }
+}
Propchange: struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestTilesServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/src/test/org/apache/tiles/TestTilesServlet.java
------------------------------------------------------------------------------
svn:keywords = date author id rev
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org