You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tiles.apache.org by ap...@apache.org on 2010/02/21 15:00:57 UTC
svn commit: r912350 - in /tiles/sandbox/trunk/tiles3/tiles-template/src:
main/java/org/apache/tiles/template/ test/java/org/apache/tiles/template/
Author: apetrelli
Date: Sun Feb 21 14:00:56 2010
New Revision: 912350
URL: http://svn.apache.org/viewvc?rev=912350&view=rev
Log:
TILESSB-23
Removed start and end methods in models.
Modified:
tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java
tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java
tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java
tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java
tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java
tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java
tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java
tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java
tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java
tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddAttributeModelTest.java
tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddListAttributeModelTest.java
tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/DefinitionModelTest.java
tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/GetAsStringModelTest.java
tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertAttributeModelTest.java
tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertDefinitionModelTest.java
tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertTemplateModelTest.java
tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutAttributeModelTest.java
tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutListAttributeModelTest.java
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddAttributeModel.java Sun Feb 21 14:00:56 2010
@@ -48,41 +48,6 @@
public class AddAttributeModel {
/**
- * Starts the operation..
- * @param request TODO
- *
- * @since 2.2.0
- */
- public void start(Request request) {
- Attribute attribute = new Attribute();
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- composeStack.push(attribute);
- }
-
- /**
- * Ends the operation.
- * @param value The value of the attribute. Use this parameter, or
- * expression, or body.
- * @param expression The expression to calculate the value from. Use this
- * parameter, or value, or body.
- * @param body The body of the tag. Use this parameter, or value, or
- * expression.
- * @param role A comma-separated list of roles. If present, the attribute
- * will be rendered only if the current user belongs to one of the roles.
- * @param type The type (renderer) of the attribute.
- * @param request TODO
- *
- * @since 2.2.0
- */
- public void end(Object value, String expression,
- String body, String role, String type, Request request) {
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- Attribute attribute = (Attribute) composeStack.pop();
- addAttributeToList(attribute, composeStack, value, expression, body,
- role, type);
- }
-
- /**
* Executes the operation.
* @param value The value of the attribute. Use this parameter, or
* expression, or body.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/AddListAttributeModel.java Sun Feb 21 14:00:56 2010
@@ -43,34 +43,6 @@
*/
public class AddListAttributeModel {
- /**
- * Starts the operation.
- * @param role A comma-separated list of roles. If present, the attribute
- * will be rendered only if the current user belongs to one of the roles.
- * @param request TODO
- *
- * @since 2.2.0
- */
- public void start(String role, Request request) {
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- ListAttribute listAttribute = new ListAttribute();
- listAttribute.setRole(role);
- composeStack.push(listAttribute);
- }
-
- /**
- * Ends the operation.
- * @param request TODO
- *
- * @since 2.2.0
- */
- public void end(Request request) {
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- ListAttribute listAttribute = (ListAttribute) composeStack.pop();
- ListAttribute parent = (ListAttribute) composeStack.peek();
- parent.add(listAttribute);
- }
-
public void execute(String role, Request request, ModelBody modelBody) throws IOException {
ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
ListAttribute listAttribute = new ListAttribute();
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/DefinitionModel.java Sun Feb 21 14:00:56 2010
@@ -46,48 +46,6 @@
public class DefinitionModel {
/**
- * Starts the operation.
- *
- * @param name The name of the definition to create. If not specified, an
- * anonymous definition will be created.
- * @param template The template of this definition.
- * @param role A comma-separated list of roles. If present, the definition
- * will be rendered only if the current user belongs to one of the roles.
- * @param extendsParam The definition name that this definition extends.
- * @param preparer The preparer to use to invoke before the definition is
- * rendered.
- * @param request TODO
- * @param composeStack The compose stack,
- * @since 2.2.0
- */
- public void start(String name, String template, String role,
- String extendsParam, String preparer, Request request) {
- ArrayStack<Object> composeStack = ComposeStackUtil
- .getComposeStack(request);
- Definition definition = createDefinition(name, template, role,
- extendsParam, preparer);
- composeStack.push(definition);
- }
-
- /**
- * Ends the operation.
- *
- * @param request TODO
- * @param container The Tiles container to use. It must be "mutable".
- * @param composeStack The compose stack.
- *
- * @since 2.2.0
- */
- public void end(Request request) {
- MutableTilesContainer container = (MutableTilesContainer) TilesAccess
- .getCurrentContainer(request);
- ArrayStack<Object> composeStack = ComposeStackUtil
- .getComposeStack(request);
- Definition definition = (Definition) composeStack.pop();
- registerDefinition(definition, container, composeStack, request);
- }
-
- /**
* Executes the operation.
*
* @param name The name of the definition to create. If not specified, an
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/GetAsStringModel.java Sun Feb 21 14:00:56 2010
@@ -71,56 +71,6 @@
}
/**
- * Starts the operation.
- * @param ignore If <code>true</code>, if an exception happens during
- * rendering, of if the attribute is null, the problem will be ignored.
- * @param preparer The preparer to invoke before rendering the attribute.
- * @param role A comma-separated list of roles. If present, the attribute
- * will be rendered only if the current user belongs to one of the roles.
- * @param defaultValue The default value of the attribute. To use only if
- * the attribute was not computed.
- * @param defaultValueRole The default comma-separated list of roles. To use
- * only if the attribute was not computed.
- * @param defaultValueType The default type of the attribute. To use only if
- * the attribute was not computed.
- * @param name The name of the attribute.
- * @param value The attribute to use immediately, if not null.
- * @param request TODO
- * @param container The Tiles container to use.
- * @param composeStack The compose stack,
- * @since 2.2.0
- */
- public void start(boolean ignore, String preparer,
- String role, Object defaultValue, String defaultValueRole, String defaultValueType,
- String name, Attribute value, Request request) {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- Attribute attribute = resolveAttribute(container, ignore, preparer,
- role, defaultValue, defaultValueRole, defaultValueType, name,
- value, request);
- composeStack.push(attribute);
- }
-
- /**
- * Ends the operation.
- * @param ignore If <code>true</code>, if an exception happens during
- * rendering, of if the attribute is null, the problem will be ignored.
- * @param request TODO
- * @param writer The writer into which the attribute will be written.
- * @param container The Tiles container to use.
- * @param composeStack The compose stack,
- * @throws IOException If an I/O error happens during rendering.
- */
- public void end(boolean ignore, Request request)
- throws IOException {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- Writer writer = request.getWriter();
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- Attribute attribute = (Attribute) composeStack.pop();
- renderAttribute(attribute, container, writer, ignore, request);
- }
-
- /**
* Executes the operation.
* @param ignore If <code>true</code>, if an exception happens during
* rendering, of if the attribute is null, the problem will be ignored.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertAttributeModel.java Sun Feb 21 14:00:56 2010
@@ -83,53 +83,6 @@
}
/**
- * Starts the operation.
- * @param ignore If <code>true</code>, if an exception happens during
- * rendering, of if the attribute is null, the problem will be ignored.
- * @param preparer The preparer to invoke before rendering the attribute.
- * @param role A comma-separated list of roles. If present, the attribute
- * will be rendered only if the current user belongs to one of the roles.
- * @param defaultValue The default value of the attribute. To use only if
- * the attribute was not computed.
- * @param defaultValueRole The default comma-separated list of roles. To use
- * only if the attribute was not computed.
- * @param defaultValueType The default type of the attribute. To use only if
- * the attribute was not computed.
- * @param name The name of the attribute.
- * @param value The attribute to use immediately, if not null.
- * @param request TODO
- * @param container The Tiles container to use.
- * @param composeStack The compose stack,
- * @since 2.2.0
- */
- public void start(boolean ignore, String preparer,
- String role, Object defaultValue, String defaultValueRole, String defaultValueType,
- String name, Attribute value, Request request) {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- Attribute attribute = resolveAttribute(container, ignore, preparer,
- role, defaultValue, defaultValueRole, defaultValueType, name,
- value, request);
- composeStack.push(attribute);
- }
-
- /**
- * Ends the operation.
- * @param ignore If <code>true</code>, if an exception happens during
- * rendering, of if the attribute is null, the problem will be ignored.
- * @param request TODO
- * @param container The Tiles container to use.
- * @param composeStack The compose stack,
- * @throws IOException If an I/O error happens during rendering.
- */
- public void end(boolean ignore, Request request) throws IOException {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- Attribute attribute = (Attribute) composeStack.pop();
- renderAttribute(container, ignore, attribute, request);
- }
-
- /**
* Executes the operation.
* @param ignore If <code>true</code>, if an exception happens during
* rendering, of if the attribute is null, the problem will be ignored.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertDefinitionModel.java Sun Feb 21 14:00:56 2010
@@ -69,43 +69,6 @@
public class InsertDefinitionModel {
/**
- * Starts the operation.
- * @param request TODO
- * @param container The Tiles container.
- *
- * @since 2.2.0
- */
- public void start(Request request) {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- container.startContext(request);
- }
-
- /**
- * Ends the operation.
- * @param definitionName The name of the definition to render.
- * @param template If specified, this template will be used instead of the
- * one used by the definition.
- * @param templateType The type of the template attribute.
- * @param templateExpression The expression to evaluate to get the value of the template.
- * @param role A comma-separated list of roles. If present, the definition
- * will be rendered only if the current user belongs to one of the roles.
- * @param preparer The preparer to use to invoke before the definition is
- * rendered. If specified, it overrides the preparer specified in the
- * definition itself.
- * @param request TODO
- * @param container The Tiles container.
- *
- * @since 2.2.0
- */
- public void end(String definitionName, String template,
- String templateType, String templateExpression, String role,
- String preparer, Request request) {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- renderDefinition(container, definitionName, template, templateType,
- templateExpression, role, preparer, request);
- }
-
- /**
* Executes the operation.
* @param definitionName The name of the definition to render.
* @param template If specified, this template will be used instead of the
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/InsertTemplateModel.java Sun Feb 21 14:00:56 2010
@@ -69,40 +69,6 @@
public class InsertTemplateModel {
/**
- * Starts the operation.
- * @param request TODO
- * @param container The Tiles container.
- *
- * @since 2.2.0
- */
- public void start(Request request) {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- container.startContext(request);
- }
-
- /**
- * Ends the operation.
- * @param template The template to render.
- * @param templateType The type of the template attribute.
- * @param templateExpression The expression to evaluate to get the value of the template.
- * @param role A comma-separated list of roles. If present, the template
- * will be rendered only if the current user belongs to one of the roles.
- * @param preparer The preparer to use to invoke before the definition is
- * rendered. If specified, it overrides the preparer specified in the
- * definition itself.
- * @param request TODO
- * @param container The Tiles container.
- *
- * @since 2.2.0
- */
- public void end(String template, String templateType, String templateExpression,
- String role, String preparer, Request request) {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- renderTemplate(container, template, templateType, templateExpression,
- role, preparer, request);
- }
-
- /**
* Executes the operation.
* @param template The template to render.
* @param templateType The type of the template attribute.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutAttributeModel.java Sun Feb 21 14:00:56 2010
@@ -71,48 +71,6 @@
public class PutAttributeModel {
/**
- * Starts the operation.
- * @param request TODO
- * @param composeStack The compose stack.
- *
- * @since 2.2.0
- */
- public void start(Request request) {
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- Attribute attribute = new Attribute();
- composeStack.push(attribute);
- }
-
- /**
- * Ends the operation.
- * @param name The name of the attribute to put.
- * @param value The value of the attribute. Use this parameter, or
- * expression, or body.
- * @param expression The expression to calculate the value from. Use this
- * parameter, or value, or body.
- * @param body The body of the tag. Use this parameter, or value, or
- * expression.
- * @param role A comma-separated list of roles. If present, the attribute
- * will be rendered only if the current user belongs to one of the roles.
- * @param type The type (renderer) of the attribute.
- * @param cascade If <code>true</code> the attribute will be cascaded to all nested attributes.
- * @param request TODO
- * @param container The Tiles container to use.
- * @param composeStack The composing stack.
- *
- * @since 2.2.0
- */
- public void end(String name, Object value,
- String expression, String body, String role, String type,
- boolean cascade, Request request) {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- Attribute attribute = (Attribute) composeStack.pop();
- putAttributeInParent(attribute, container, composeStack, name, value,
- expression, body, role, type, cascade, request);
- }
-
- /**
* Executes the operation.
* @param name The name of the attribute to put.
* @param value The value of the attribute. Use this parameter, or
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/main/java/org/apache/tiles/template/PutListAttributeModel.java Sun Feb 21 14:00:56 2010
@@ -47,52 +47,6 @@
*/
public class PutListAttributeModel {
- /**
- * Starts the operation.
- * @param role A comma-separated list of roles. If present, the attribute
- * will be rendered only if the current user belongs to one of the roles.
- * @param inherit If <code>true</code> the list contained in the in the same
- * attribute of the parent definition will be extended.
- * @param request TODO
- * @param composeStack The composing stack.
- *
- * @since 2.2.0
- */
- public void start(String role, boolean inherit, Request request) {
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- ListAttribute listAttribute = new ListAttribute();
- listAttribute.setRole(role);
- listAttribute.setInherit(inherit);
- composeStack.push(listAttribute);
- }
-
- /**
- * Ends the operation.
- * @param name The name of the attribute to put.
- * @param cascade If <code>true</code> the attribute will be cascaded to all nested attributes.
- * @param request TODO
- * @param container The Tiles container to use.
- * @param composeStack The composing stack.
- *
- * @since 2.2.0
- */
- public void end(String name, boolean cascade, Request request) {
- TilesContainer container = TilesAccess.getCurrentContainer(request);
- ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
- ListAttribute listAttribute = (ListAttribute) composeStack.pop();
- AttributeContext attributeContext = null;
- if (!composeStack.isEmpty()) {
- Object obj = composeStack.peek();
- if (obj instanceof Definition) {
- attributeContext = (AttributeContext) obj;
- }
- }
- if (attributeContext == null) {
- attributeContext = container.getAttributeContext(request);
- }
- attributeContext.putAttribute(name, listAttribute, cascade);
- }
-
public void execute(String name, String role, boolean inherit,
boolean cascade, Request request, ModelBody modelBody) throws IOException {
ArrayStack<Object> composeStack = ComposeStackUtil.getComposeStack(request);
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddAttributeModelTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddAttributeModelTest.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddAttributeModelTest.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddAttributeModelTest.java Sun Feb 21 14:00:56 2010
@@ -56,72 +56,6 @@
}
/**
- * Test method for {@link org.apache.tiles.template.AddAttributeModel#start(Request)}.
- */
- @SuppressWarnings("unchecked")
- @Test
- public void testStart() {
- ArrayStack<Object> composeStack = createMock(ArrayStack.class);
- Request request = createMock(Request.class);
- Attribute attribute = new Attribute();
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
-
- expect(composeStack.push(isA(Attribute.class))).andReturn(attribute);
- expect(request.getContext("request")).andReturn(requestScope);
-
- replay(composeStack, request);
- model.start(request);
- verify(composeStack, request);
- }
-
- /**
- * Test method for
- * {@link org.apache.tiles.template.AddAttributeModel
- * #end(java.lang.Object, java.lang.String, java.lang.String, java.lang.String, java.lang.String, Request)}
- * .
- */
- @Test
- public void testEnd() {
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- Request request = createMock(Request.class);
- ListAttribute listAttribute = new ListAttribute();
- Attribute attribute = new Attribute();
- composeStack.push(listAttribute);
- composeStack.push(attribute);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
-
- expect(request.getContext("request")).andReturn(requestScope).times(2);
-
- replay(request);
- model.end("myValue", "myExpression", "myBody", "myRole", "myType",
- request);
- assertEquals(1, listAttribute.getValue().size());
- assertEquals("myValue", attribute.getValue());
- assertEquals("myExpression", attribute.getExpressionObject()
- .getExpression());
- assertEquals("myRole", attribute.getRole());
- assertEquals("myType", attribute.getRenderer());
-
- composeStack.clear();
- listAttribute = new ListAttribute();
- attribute = new Attribute();
- composeStack.push(listAttribute);
- composeStack.push(attribute);
-
- model.end(null, "myExpression", "myBody", "myRole", "myType",
- request);
- assertEquals(1, listAttribute.getValue().size());
- assertEquals("myBody", attribute.getValue());
- assertEquals("myExpression", attribute.getExpressionObject()
- .getExpression());
- assertEquals("myRole", attribute.getRole());
- assertEquals("myType", attribute.getRenderer());
- verify(request);
- }
-
- /**
* Test method for {@link org.apache.tiles.template.AddAttributeModel
* #execute(java.lang.Object, java.lang.String, java.lang.String, java.lang.String,
* Request, ModelBody)}.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddListAttributeModelTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddListAttributeModelTest.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddListAttributeModelTest.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/AddListAttributeModelTest.java Sun Feb 21 14:00:56 2010
@@ -21,17 +21,18 @@
package org.apache.tiles.template;
+import static org.easymock.EasyMock.*;
import static org.easymock.classextension.EasyMock.*;
import static org.junit.Assert.*;
+import java.io.IOException;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.tiles.ArrayStack;
-import org.apache.tiles.Attribute;
import org.apache.tiles.ListAttribute;
import org.apache.tiles.request.Request;
+import org.apache.tiles.template.body.ModelBody;
import org.junit.Before;
import org.junit.Test;
@@ -56,49 +57,31 @@
}
/**
- * Test method for {@link org.apache.tiles.template.AddListAttributeModel#start(java.lang.String, Request)}.
+ * Test method for
+ * {@link org.apache.tiles.template.AddListAttributeModel#execute(String, Request, org.apache.tiles.template.body.ModelBody)}
+ * .
+ * @throws IOException If something goes wrong.
*/
@Test
- public void testStart() {
+ public void testExecute() throws IOException {
ArrayStack<Object> composeStack = new ArrayStack<Object>();
Request request = createMock(Request.class);
Map<String, Object> requestScope = new HashMap<String, Object>();
+ ModelBody modelBody = createMock(ModelBody.class);
+ modelBody.evaluateWithoutWriting();
requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
expect(request.getContext("request")).andReturn(requestScope);
- replay(request);
- model.start("myRole", request);
- assertEquals(1, composeStack.size());
- ListAttribute listAttribute = (ListAttribute) composeStack.peek();
- assertEquals("myRole", listAttribute.getRole());
- verify(request);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.AddListAttributeModel#end(Request)}.
- */
- @Test
- public void testEnd() {
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- ListAttribute listAttribute = new ListAttribute();
- Request request = createMock(Request.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
-
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
- expect(request.getContext("request")).andReturn(requestScope);
-
- replay(request);
+ replay(request, modelBody);
ListAttribute parent = new ListAttribute();
composeStack.push(parent);
- composeStack.push(listAttribute);
- model.end(request);
+ model.execute("myRole", request, modelBody);
assertEquals(1, composeStack.size());
- assertEquals(parent, composeStack.peek());
- List<Attribute> attributes = parent.getValue();
- assertEquals(1, attributes.size());
- assertEquals(listAttribute, attributes.get(0));
- verify(request);
+ assertEquals(parent, composeStack.pop());
+ assertEquals(1, parent.getValue().size());
+ ListAttribute listAttribute = (ListAttribute) parent.getValue().get(0);
+ assertEquals("myRole", listAttribute.getRole());
+ verify(request, modelBody);
}
-
}
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/DefinitionModelTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/DefinitionModelTest.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/DefinitionModelTest.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/DefinitionModelTest.java Sun Feb 21 14:00:56 2010
@@ -61,87 +61,6 @@
/**
* Test method for {@link org.apache.tiles.template.DefinitionModel
- * #start(java.lang.String, java.lang.String, java.lang.String, java.lang.String,
- * java.lang.String, Request)}.
- */
- @Test
- public void testStart() {
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- Request request = createMock(Request.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
-
- expect(request.getContext("request")).andReturn(requestScope);
-
- replay(request);
- model.start("myName", "myTemplate", "myRole", "myExtends", "myPreparer", request);
- assertEquals(1, composeStack.size());
- Definition definition = (Definition) composeStack.peek();
- assertEquals("myName", definition.getName());
- assertEquals("myTemplate", definition.getTemplateAttribute().getValue());
- assertEquals("myRole", definition.getTemplateAttribute().getRole());
- assertEquals("myPreparer", definition.getPreparer());
- verify(request);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.DefinitionModel
- * #end(Request)}.
- */
- @Test
- public void testEnd() {
- MutableTilesContainer container = createMock(MutableTilesContainer.class);
- Request request = createMock(Request.class);
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- Definition definition = new Definition();
- composeStack.push(definition);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- container.register(definition, request);
-
- replay(container, request, applicationContext);
- model.end(request);
- verify(container, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.DefinitionModel
- * #end(Request)}.
- */
- @Test
- public void testEndInAttribute() {
- MutableTilesContainer container = createMock(MutableTilesContainer.class);
- Request request = createMock(Request.class);
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- Attribute attribute = new Attribute();
- composeStack.push(attribute);
- Definition definition = new Definition();
- composeStack.push(definition);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- container.register(definition, request);
-
- replay(container, request, applicationContext);
- model.end(request);
- assertEquals(1, composeStack.size());
- attribute = (Attribute) composeStack.peek();
- assertEquals(definition.getName(), attribute.getValue());
- assertEquals("definition", attribute.getRenderer());
- verify(container, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.DefinitionModel
* #execute(java.lang.String, java.lang.String,
* java.lang.String, java.lang.String, java.lang.String, Request, ModelBody)}.
* @throws IOException If something goes wrong.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/GetAsStringModelTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/GetAsStringModelTest.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/GetAsStringModelTest.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/GetAsStringModelTest.java Sun Feb 21 14:00:56 2010
@@ -23,7 +23,6 @@
import static org.easymock.EasyMock.*;
import static org.easymock.classextension.EasyMock.*;
-import static org.junit.Assert.*;
import java.io.IOException;
import java.io.Writer;
@@ -69,67 +68,6 @@
/**
* Test method for {@link org.apache.tiles.template.GetAsStringModel
- * #start(boolean, java.lang.String, java.lang.String, java.lang.Object,
- * java.lang.String, java.lang.String, java.lang.String, org.apache.tiles.Attribute, Request)}.
- */
- @Test
- public void testStart() {
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- Attribute attribute = new Attribute();
- AttributeContext attributeContext = createMock(AttributeContext.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- container.prepare("myPreparer", request);
- expect(resolver.computeAttribute(container, attribute, "myName", "myRole", false, "myDefaultValue",
- "myDefaultValueRole", "myDefaultValueType", request)).andReturn(attribute);
- expect(container.startContext(request)).andReturn(attributeContext);
-
- replay(resolver, container, attributeContext, request, applicationContext);
- model.start(false, "myPreparer", "myRole", "myDefaultValue", "myDefaultValueRole", "myDefaultValueType",
- "myName", attribute, request);
- assertEquals(1, composeStack.size());
- assertEquals(attribute, composeStack.peek());
- verify(resolver, container, attributeContext, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.GetAsStringModel
- * #end(boolean, Request)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testEnd() throws IOException {
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- Attribute attribute = new Attribute("myValue");
- composeStack.push(attribute);
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- Writer writer = createMock(Writer.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getWriter()).andReturn(writer);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- writer.write("myValue");
- container.endContext(request);
-
- replay(resolver, container, writer, request, applicationContext);
- model.end(false, request);
- verify(resolver, container, writer, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.GetAsStringModel
* #execute(boolean, java.lang.String, java.lang.String,
* java.lang.Object, java.lang.String, java.lang.String, java.lang.String,
* org.apache.tiles.Attribute, Request, ModelBody)}.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertAttributeModelTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertAttributeModelTest.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertAttributeModelTest.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertAttributeModelTest.java Sun Feb 21 14:00:56 2010
@@ -22,13 +22,11 @@
package org.apache.tiles.template;
import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import org.apache.tiles.ArrayStack;
import org.apache.tiles.Attribute;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.TilesContainer;
@@ -67,65 +65,6 @@
/**
* Test method for {@link org.apache.tiles.template.InsertAttributeModel
- * #start(boolean, String, String, Object, String, String, String,
- * Attribute, Request)}.
- */
- @Test
- public void testStart() {
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- Attribute attribute = new Attribute();
- AttributeContext attributeContext = createMock(AttributeContext.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- container.prepare("myPreparer", request);
- expect(resolver.computeAttribute(container, attribute, "myName", "myRole", false, "myDefaultValue",
- "myDefaultValueRole", "myDefaultValueType", request)).andReturn(attribute);
- expect(container.startContext(request)).andReturn(attributeContext);
-
- replay(resolver, container, attributeContext, request, applicationContext);
- model.start(false, "myPreparer", "myRole", "myDefaultValue", "myDefaultValueRole", "myDefaultValueType",
- "myName", attribute, request);
- assertEquals(1, composeStack.size());
- assertEquals(attribute, composeStack.peek());
- verify(resolver, container, attributeContext, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.InsertAttributeModel
- * #end(boolean, Request)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testEnd() throws IOException {
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- Attribute attribute = new Attribute("myValue");
- composeStack.push(attribute);
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- container.endContext(request);
- container.render(attribute, request);
-
- replay(resolver, container, request, applicationContext);
- model.end(false, request);
- verify(resolver, container, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.InsertAttributeModel
* #execute(boolean, String, String, Object, String, String, String,
* Attribute, Request, ModelBody)}.
* @throws IOException If something goes wrong.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertDefinitionModelTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertDefinitionModelTest.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertDefinitionModelTest.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertDefinitionModelTest.java Sun Feb 21 14:00:56 2010
@@ -60,57 +60,6 @@
/**
* Test method for {@link org.apache.tiles.template.InsertDefinitionModel
- * #start(Request)}.
- */
- @Test
- public void testStart() {
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- AttributeContext attributeContext = createMock(AttributeContext.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- expect(container.startContext(request)).andReturn(attributeContext);
-
- replay(container, attributeContext, request, applicationContext);
- model.start(request);
- verify(container, attributeContext, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.InsertDefinitionModel
- * #end(java.lang.String, java.lang.String, String,
- * String, java.lang.String, java.lang.String, Request)}.
- */
- @Test
- public void testEnd() {
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- AttributeContext attributeContext = createMock(AttributeContext.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- expect(container.getAttributeContext(request)).andReturn(attributeContext);
- container.endContext(request);
- attributeContext.setPreparer("myPreparer");
- attributeContext.setTemplateAttribute((Attribute) notNull());
- container.render("myDefinitionName", request);
-
- replay(container, attributeContext, request, applicationContext);
- model.end("myDefinitionName", "myTemplate", "myTemplateType",
- "myTemplateExpression", "myRole", "myPreparer",
- request);
- verify(container, attributeContext, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.InsertDefinitionModel
* #execute(java.lang.String, java.lang.String, String,
* String, java.lang.String, java.lang.String, Request, ModelBody)}.
* @throws IOException If something goes wrong.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertTemplateModelTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertTemplateModelTest.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertTemplateModelTest.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/InsertTemplateModelTest.java Sun Feb 21 14:00:56 2010
@@ -59,55 +59,6 @@
/**
* Test method for {@link org.apache.tiles.template.InsertTemplateModel
- * #start(Request)}.
- */
- @Test
- public void testStart() {
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- AttributeContext attributeContext = createMock(AttributeContext.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- expect(container.startContext(request)).andReturn(attributeContext);
-
- replay(container, attributeContext, request, applicationContext);
- model.start(request);
- verify(container, attributeContext, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.InsertTemplateModel
- * #end(String, String, String, String, String, Request)}.
- */
- @Test
- public void testEnd() {
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- AttributeContext attributeContext = createMock(AttributeContext.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- expect(container.getAttributeContext(request)).andReturn(attributeContext);
- container.endContext(request);
- attributeContext.setPreparer("myPreparer");
- attributeContext.setTemplateAttribute((Attribute) notNull());
- container.renderContext(request);
-
- replay(container, attributeContext, request, applicationContext);
- model.end("myTemplate", "myTemplateType", "myTemplateExpression",
- "myRole", "myPreparer", request);
- verify(container, attributeContext, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.InsertTemplateModel
* #execute(String, String, String, String, String, Request, ModelBody)}.
* @throws IOException If something goes wrong.
*/
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutAttributeModelTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutAttributeModelTest.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutAttributeModelTest.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutAttributeModelTest.java Sun Feb 21 14:00:56 2010
@@ -23,7 +23,6 @@
import static org.easymock.EasyMock.*;
import static org.easymock.classextension.EasyMock.*;
-import static org.junit.Assert.*;
import java.io.IOException;
import java.util.HashMap;
@@ -60,94 +59,6 @@
}
/**
- * Test method for {@link org.apache.tiles.template.PutAttributeModel#start(Request)}.
- */
- @SuppressWarnings("unchecked")
- @Test
- public void testStart() {
- ArrayStack<Object> composeStack = createMock(ArrayStack.class);
- Attribute attribute = new Attribute();
- Request request = createMock(Request.class);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
-
- expect(request.getContext("request")).andReturn(requestScope);
- expect(composeStack.push(isA(Attribute.class))).andReturn(attribute);
-
- replay(request, composeStack);
- model.start(request);
- verify(request, composeStack);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.PutAttributeModel
- * #end(String, Object, String, String, String,
- * String, boolean, Request)}.
- */
- @Test
- public void testEnd() {
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- AttributeContext attributeContext = createMock(AttributeContext.class);
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- Attribute attribute = new Attribute();
- composeStack.push(attribute);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- expect(container.getAttributeContext(request)).andReturn(attributeContext);
- attributeContext.putAttribute("myName", attribute, false);
-
- replay(container, attributeContext, request, applicationContext);
- model.end("myName", "myValue", "myExpression", "myBody", "myRole",
- "myType", false, request);
- assertEquals("myValue", attribute.getValue());
- assertEquals("myExpression", attribute.getExpressionObject()
- .getExpression());
- assertEquals("myRole", attribute.getRole());
- assertEquals("myType", attribute.getRenderer());
- verify(container, attributeContext, request, applicationContext);
- }
-
- /**
- * Test method for {@link org.apache.tiles.template.PutAttributeModel
- * #end(String, Object, String, String, String,
- * String, boolean, Request)}.
- */
- @Test
- public void testEndBody() {
- TilesContainer container = createMock(TilesContainer.class);
- Request request = createMock(Request.class);
- AttributeContext attributeContext = createMock(AttributeContext.class);
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- Attribute attribute = new Attribute();
- composeStack.push(attribute);
- Map<String, Object> requestScope = new HashMap<String, Object>();
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
- requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
- ApplicationContext applicationContext = createMock(ApplicationContext.class);
-
- expect(request.getApplicationContext()).andReturn(applicationContext);
- expect(request.getContext("request")).andReturn(requestScope).anyTimes();
- expect(container.getAttributeContext(request)).andReturn(attributeContext);
- attributeContext.putAttribute("myName", attribute, false);
-
- replay(container, attributeContext, request, applicationContext);
- model.end("myName", "myValue", "myExpression", "myBody", "myRole",
- "myType", false, request);
- assertEquals("myValue", attribute.getValue());
- assertEquals("myExpression", attribute.getExpressionObject()
- .getExpression());
- assertEquals("myRole", attribute.getRole());
- assertEquals("myType", attribute.getRenderer());
- verify(container, attributeContext, request, applicationContext);
- }
-
- /**
* Test method for {@link org.apache.tiles.template.PutAttributeModel
* #execute(String, Object, String, String, String,
* boolean, Request, ModelBody)}.
Modified: tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutListAttributeModelTest.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutListAttributeModelTest.java?rev=912350&r1=912349&r2=912350&view=diff
==============================================================================
--- tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutListAttributeModelTest.java (original)
+++ tiles/sandbox/trunk/tiles3/tiles-template/src/test/java/org/apache/tiles/template/PutListAttributeModelTest.java Sun Feb 21 14:00:56 2010
@@ -25,6 +25,7 @@
import static org.easymock.classextension.EasyMock.*;
import static org.junit.Assert.*;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -35,6 +36,7 @@
import org.apache.tiles.access.TilesAccess;
import org.apache.tiles.request.ApplicationContext;
import org.apache.tiles.request.Request;
+import org.apache.tiles.template.body.ModelBody;
import org.junit.Before;
import org.junit.Test;
@@ -59,51 +61,32 @@
}
/**
- * Test method for {@link org.apache.tiles.template.PutListAttributeModel#start(String, boolean, Request)}.
- */
- @Test
- public void testStart() {
- ArrayStack<Object> composeStack = new ArrayStack<Object>();
- Map<String, Object> requestScope = new HashMap<String, Object>();
- Request request = createMock(Request.class);
- requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
-
- expect(request.getContext("request")).andReturn(requestScope);
-
- replay(request);
- model.start("myRole", false, request);
- assertEquals(1, composeStack.size());
- ListAttribute listAttribute = (ListAttribute) composeStack.peek();
- assertEquals("myRole", listAttribute.getRole());
- verify(request);
- }
-
- /**
* Test method for {@link org.apache.tiles.template.PutListAttributeModel
- * #end(String, boolean, Request)}.
+ * #execute(String, String, boolean, boolean, Request, ModelBody)}.
+ * @throws IOException If something goes wrong.
*/
@Test
- public void testEnd() {
+ public void testExecute() throws IOException {
TilesContainer container = createMock(TilesContainer.class);
AttributeContext attributeContext = createMock(AttributeContext.class);
Request request = createMock(Request.class);
ArrayStack<Object> composeStack = new ArrayStack<Object>();
- ListAttribute listAttribute = new ListAttribute();
- composeStack.push(listAttribute);
Map<String, Object> requestScope = new HashMap<String, Object>();
requestScope.put(ComposeStackUtil.COMPOSE_STACK_ATTRIBUTE_NAME, composeStack);
requestScope.put(TilesAccess.CURRENT_CONTAINER_ATTRIBUTE_NAME, container);
ApplicationContext applicationContext = createMock(ApplicationContext.class);
+ ModelBody modelBody = createMock(ModelBody.class);
+ modelBody.evaluateWithoutWriting();
expect(request.getApplicationContext()).andReturn(applicationContext);
expect(request.getContext("request")).andReturn(requestScope).anyTimes();
expect(container.getAttributeContext(request)).andReturn(attributeContext);
- attributeContext.putAttribute("myName", listAttribute, false);
+ attributeContext.putAttribute(eq("myName"), isA(ListAttribute.class), eq(false));
- replay(container, attributeContext, request);
- model.end("myName", false, request);
+ replay(container, attributeContext, request, modelBody);
+ model.execute("myName", "myRole", false, false, request, modelBody);
assertEquals(0, composeStack.size());
- verify(container, attributeContext, request);
+ verify(container, attributeContext, request, modelBody);
}
}