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 2009/04/16 23:43:02 UTC
svn commit: r765774 [3/5] - in /tiles/framework/trunk:
tiles-freemarker/src/main/java/org/apache/tiles/freemarker/template/
tiles-freemarker/src/test/java/org/apache/tiles/freemarker/context/
tiles-freemarker/src/test/java/org/apache/tiles/freemarker/i...
Modified: tiles/framework/trunk/tiles-template/src/test/java/org/apache/tiles/template/PutAttributeModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/test/java/org/apache/tiles/template/PutAttributeModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/test/java/org/apache/tiles/template/PutAttributeModelTest.java (original)
+++ tiles/framework/trunk/tiles-template/src/test/java/org/apache/tiles/template/PutAttributeModelTest.java Thu Apr 16 21:43:00 2009
@@ -37,7 +37,6 @@
* Tests {@link PutAttributeModel}.
*
* @version $Rev$ $Date$
- * @since 2.2.0
*/
public class PutAttributeModelTest {
@@ -45,13 +44,13 @@
* The model to test.
*/
private PutAttributeModel model;
-
+
/** Sets up the test. */
@Before
public void setUp() {
model = new PutAttributeModel();
}
-
+
/**
* Test method for {@link org.apache.tiles.template.PutAttributeModel#start(Stack)}.
*/
@@ -60,16 +59,18 @@
public void testStart() {
Stack<Object> composeStack = createMock(Stack.class);
Attribute attribute = new Attribute();
-
+
expect(composeStack.push(isA(Attribute.class))).andReturn(attribute);
-
+
replay(composeStack);
model.start(composeStack);
verify(composeStack);
}
/**
- * Test method for {@link org.apache.tiles.template.PutAttributeModel#end(org.apache.tiles.TilesContainer, Stack, String, Object, String, String, String, String, boolean, Object...)}.
+ * Test method for {@link org.apache.tiles.template.PutAttributeModel
+ * #end(org.apache.tiles.TilesContainer, Stack, String, Object, String,
+ * String, String, String, boolean, Object...)}.
*/
@Test
public void testEnd() {
@@ -79,10 +80,10 @@
Attribute attribute = new Attribute();
Integer requestItem = new Integer(1);
composeStack.push(attribute);
-
+
expect(container.getAttributeContext(requestItem)).andReturn(attributeContext);
attributeContext.putAttribute("myName", attribute, false);
-
+
replay(container, attributeContext);
model.end(container, composeStack, "myName", "myValue", "myExpression",
"myBody", "myRole", "myType", false, requestItem);
@@ -94,7 +95,9 @@
}
/**
- * Test method for {@link org.apache.tiles.template.PutAttributeModel#end(org.apache.tiles.TilesContainer, Stack, String, Object, String, String, String, String, boolean, Object...)}.
+ * Test method for {@link org.apache.tiles.template.PutAttributeModel
+ * #end(org.apache.tiles.TilesContainer, Stack, String, Object, String,
+ * String, String, String, boolean, Object...)}.
*/
@Test
public void testEndBody() {
@@ -104,10 +107,10 @@
Attribute attribute = new Attribute();
Integer requestItem = new Integer(1);
composeStack.push(attribute);
-
+
expect(container.getAttributeContext(requestItem)).andReturn(attributeContext);
attributeContext.putAttribute("myName", attribute, false);
-
+
replay(container, attributeContext);
model.end(container, composeStack, "myName", "myValue", "myExpression",
"myBody", "myRole", "myType", false, requestItem);
@@ -119,7 +122,9 @@
}
/**
- * Test method for {@link org.apache.tiles.template.PutAttributeModel#execute(org.apache.tiles.TilesContainer, Stack, String, Object, String, String, String, String, boolean, Object...)}.
+ * Test method for {@link org.apache.tiles.template.PutAttributeModel
+ * #execute(org.apache.tiles.TilesContainer, Stack, String, Object, String,
+ * String, String, String, boolean, Object...)}.
*/
@Test
public void testExecuteListAttribute() {
@@ -129,10 +134,10 @@
ListAttribute listAttribute = new ListAttribute();
Integer requestItem = new Integer(1);
composeStack.push(listAttribute);
-
+
expect(container.getAttributeContext(requestItem)).andReturn(attributeContext);
attributeContext.putAttribute(eq("myName"), (Attribute) notNull(), eq(false));
-
+
replay(container, attributeContext);
model.execute(container, composeStack, "myName", "myValue",
"myExpression", "myBody", "myRole", "myType", false,
Modified: tiles/framework/trunk/tiles-template/src/test/java/org/apache/tiles/template/PutListAttributeModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-template/src/test/java/org/apache/tiles/template/PutListAttributeModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-template/src/test/java/org/apache/tiles/template/PutListAttributeModelTest.java (original)
+++ tiles/framework/trunk/tiles-template/src/test/java/org/apache/tiles/template/PutListAttributeModelTest.java Thu Apr 16 21:43:00 2009
@@ -1,6 +1,24 @@
-/**
- *
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.template;
import static org.junit.Assert.*;
@@ -15,8 +33,9 @@
import org.junit.Test;
/**
- * @author antonio
+ * Tests {@link PutListAttributeModel}.
*
+ * @version $Rev$ $Date$
*/
public class PutListAttributeModelTest {
@@ -24,12 +43,12 @@
* The model to test.
*/
private PutListAttributeModel model;
-
+
/**
- * @throws java.lang.Exception
+ * Sets up the test.
*/
@Before
- public void setUp() throws Exception {
+ public void setUp() {
model = new PutListAttributeModel();
}
@@ -46,7 +65,8 @@
}
/**
- * Test method for {@link org.apache.tiles.template.PutListAttributeModel#end(org.apache.tiles.TilesContainer, Stack, String, boolean, Object...)}.
+ * Test method for {@link org.apache.tiles.template.PutListAttributeModel
+ * #end(org.apache.tiles.TilesContainer, Stack, String, boolean, Object...)}.
*/
@Test
public void testEnd() {
@@ -56,10 +76,10 @@
ListAttribute listAttribute = new ListAttribute();
Integer requestItem = new Integer(1);
composeStack.push(listAttribute);
-
+
expect(container.getAttributeContext(requestItem)).andReturn(attributeContext);
attributeContext.putAttribute("myName", listAttribute, false);
-
+
replay(container, attributeContext);
model.end(container, composeStack, "myName", false, requestItem);
assertEquals(0, composeStack.size());
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/TilesVelocityException.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/TilesVelocityException.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/TilesVelocityException.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/TilesVelocityException.java Thu Apr 16 21:43:00 2009
@@ -25,7 +25,7 @@
/**
* Exception connected to the usage of Velocity and Tiles.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -33,7 +33,7 @@
/**
* Constructor.
- *
+ *
* @since 2.2.0
*/
public TilesVelocityException() {
@@ -41,7 +41,7 @@
/**
* Constructor.
- *
+ *
* @param message The message of the exception.
* @since 2.2.0
*/
@@ -51,7 +51,7 @@
/**
* Constructor.
- *
+ *
* @param e The cause of the exception.
* @since 2.2.0
*/
@@ -61,7 +61,7 @@
/**
* Constructor.
- *
+ *
* @param message The message of the exception.
* @param e The cause of the exception.
* @since 2.2.0
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/ExternalWriterHttpServletResponse.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/ExternalWriterHttpServletResponse.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/ExternalWriterHttpServletResponse.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/ExternalWriterHttpServletResponse.java Thu Apr 16 21:43:00 2009
@@ -29,7 +29,7 @@
/**
* Wraps an HTTP response and overrides its print writer.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -40,10 +40,10 @@
* The print writer to use, instead of the response's one.
*/
private PrintWriter writer;
-
+
/**
* Constructor.
- *
+ *
* @param response The response to wrap.
* @param writer The print writer to use, instead of the response's one.
* @since 2.2.0
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityTilesRequestContext.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityTilesRequestContext.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityTilesRequestContext.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityTilesRequestContext.java Thu Apr 16 21:43:00 2009
@@ -37,7 +37,7 @@
/**
* The implementation of the Tiles request context specific for Velocity.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -47,12 +47,12 @@
* The Velocity current context.
*/
private final Context ctx;
-
+
/**
* The request objects.
*/
private Object[] requestObjects;
-
+
/**
* The writer to use to render the response. It may be null, if not necessary.
*/
@@ -60,7 +60,7 @@
/**
* Constructor.
- *
+ *
* @param enclosedRequest The request that exposes non-Velocity specific properties
* @param ctx The Velocity current context.
* @param writer The writer to use to render the response. It may be null, if not necessary.
@@ -138,7 +138,7 @@
}
requestObjects[0] = ctx;
for (int i = 0; i < parentRequestObjects.length; i++) {
- requestObjects[i+1] = parentRequestObjects[i];
+ requestObjects[i + 1] = parentRequestObjects[i];
}
if (writer != null) {
requestObjects[parentRequestObjects.length + 1] = writer;
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextFactory.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextFactory.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextFactory.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextFactory.java Thu Apr 16 21:43:00 2009
@@ -35,30 +35,46 @@
/**
* The implementation of the Tiles request context factory specific for Velocity.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
public class VelocityTilesRequestContextFactory implements TilesRequestContextFactory, TilesRequestContextFactoryAware {
/**
+ * The position of the writer in the request objects.
+ */
+ private static final int WRITER_POSITION = 3;
+
+ /**
+ * The size of the array of the request objects with the writer.
+ */
+ private static final int SIZE_WITH_WRITER = 4;
+
+ /**
+ * The size of the array of the request objects without the writer.
+ */
+ private static final int SIZE_WITHOUT_WRITER = 3;
+ /**
* Parent Tiles context factory.
*/
private TilesRequestContextFactory parent;
/** {@inheritDoc} */
public TilesRequestContext createRequestContext(TilesApplicationContext context, Object... requestItems) {
- if ((requestItems.length == 3 || requestItems.length == 4)
+ if ((requestItems.length == SIZE_WITHOUT_WRITER || requestItems.length == SIZE_WITH_WRITER)
&& requestItems[0] instanceof Context
&& requestItems[1] instanceof HttpServletRequest
&& requestItems[2] instanceof HttpServletResponse
- && ((requestItems.length == 4 && requestItems[3] instanceof Writer) || requestItems.length == 3)) {
+ && ((requestItems.length == SIZE_WITH_WRITER
+ && requestItems[WRITER_POSITION] instanceof Writer)
+ || requestItems.length == SIZE_WITHOUT_WRITER)) {
Context ctx = (Context) requestItems[0];
HttpServletRequest request = (HttpServletRequest) requestItems[1];
HttpServletResponse response = (HttpServletResponse) requestItems[2];
Writer writer = null;
- if (requestItems.length == 4) {
- writer = (Writer) requestItems[3];
+ if (requestItems.length == SIZE_WITH_WRITER) {
+ writer = (Writer) requestItems[WRITER_POSITION];
}
TilesRequestContext enclosedRequest;
if (parent != null) {
@@ -71,7 +87,7 @@
} else if (requestItems.length == 1
&& requestItems[0] instanceof VelocityTilesRequestContext) {
// FIXME is it necessary?
-
+
VelocityTilesRequestContext ctx = (VelocityTilesRequestContext) requestItems[0];
return ctx;
}
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityUtil.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityUtil.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityUtil.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityUtil.java Thu Apr 16 21:43:00 2009
@@ -31,26 +31,23 @@
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.Renderable;
/**
* Utilities for Velocity usage in Tiles.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
-public class VelocityUtil {
-
+public final class VelocityUtil {
+
/**
* A renderable object that does not render anything.
- *
+ *
* @since 2.2.0
*/
public static final Renderable EMPTY_RENDERABLE;
-
+
static {
EMPTY_RENDERABLE = new Renderable() {
@@ -60,30 +57,29 @@
}
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException,
- ParseErrorException, ResourceNotFoundException {
+ throws IOException {
// Does nothing, really!
return true;
}
};
}
-
+
/**
* The attribute key that will be used to store the parameter map, to use across Velocity tool calls.
- *
+ *
* @since 2.2.0
*/
- private final static String PARAMETER_MAP_STACK_KEY = "org.apache.tiles.velocity.PARAMETER_MAP_STACK";
-
+ private static final String PARAMETER_MAP_STACK_KEY = "org.apache.tiles.velocity.PARAMETER_MAP_STACK";
+
/**
* Private constructor to avoid instantiation.
*/
private VelocityUtil() {
}
-
+
/**
* Null-safe conversion from Boolean to boolean.
- *
+ *
* @param obj The Boolean object.
* @param defaultValue This value will be returned if <code>obj</code> is null.
* @return The boolean value of <code>obj</code> or, if null, <code>defaultValue</code>.
@@ -92,10 +88,10 @@
public static boolean toSimpleBoolean(Boolean obj, boolean defaultValue) {
return obj != null ? obj : defaultValue;
}
-
+
/**
* Returns or creates the parameter stack to use. It is useful to store parameters across tool calls.
- *
+ *
* @param context The Velocity context.
* @return The parameter stack.
* @since 2.2.0
@@ -105,7 +101,7 @@
Stack<Map<String, Object>> stack = (Stack<Map<String, Object>>) context
.get(PARAMETER_MAP_STACK_KEY);
if (stack == null) {
- stack = new Stack<Map<String,Object>>();
+ stack = new Stack<Map<String, Object>>();
context.put(PARAMETER_MAP_STACK_KEY, stack);
}
return stack;
@@ -113,13 +109,14 @@
/**
* Sets an attribute in the desired scope.
- *
+ *
* @param velocityContext The Velocity context.
* @param request The HTTP request.
* @param servletContext The servlet context.
* @param name The name of the attribute.
* @param obj The value of the attribute.
- * @param scope The scope. It can be <code>page</code>, <code>request</code>, <code>session</code>, <code>application</code>.
+ * @param scope The scope. It can be <code>page</code>, <code>request</code>
+ * , <code>session</code>, <code>application</code>.
* @since 2.2.0
*/
public static void setAttribute(Context velocityContext,
Added: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/package.html
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/package.html?rev=765774&view=auto
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/package.html (added)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/package.html Thu Apr 16 21:43:00 2009
@@ -0,0 +1,30 @@
+<!--
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+-->
+<html>
+<head>
+ <title>Tiles Velocity support</title>
+</head>
+<body>
+Classes to support Velocity under a servlet environment in Tiles.
+</body>
+</html>
\ No newline at end of file
Propchange: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/package.html
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AbstractDefaultToStringRenderable.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AbstractDefaultToStringRenderable.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AbstractDefaultToStringRenderable.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AbstractDefaultToStringRenderable.java Thu Apr 16 21:43:00 2009
@@ -40,37 +40,37 @@
/**
* Renderable that provides a default implementation of {@link Renderable#toString()}
* and allows access to parameters and context objects.
- *
+ *
* @version $Rev: 751886 $ $Date: 2009-03-09 23:39:50 +0100 (lun, 09 mar 2009) $
* @since 2.2.0
*/
public abstract class AbstractDefaultToStringRenderable implements Renderable {
-
-
+
+
/**
* The Velocity context.
- *
+ *
* @since 2.2.0
*/
protected final Context velocityContext;
-
+
/**
* The parameters used in the current tool call.
- *
+ *
* @since 2.2.0
*/
protected final Map<String, Object> params;
-
+
/**
* The HTTP response.
- *
+ *
* @since 2.2.0
*/
protected final HttpServletResponse response;
-
+
/**
* The HTTP request.
- *
+ *
* @since 2.2.0
*/
protected final HttpServletRequest request;
@@ -82,7 +82,7 @@
/**
* Constructor.
- *
+ *
* @param velocityContext The Velocity context.
* @param params The parameters used in the current tool call.
* @param response The HTTP response.
@@ -121,4 +121,4 @@
}
return writer.toString();
}
-}
\ No newline at end of file
+}
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AddAttributeVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AddAttributeVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AddAttributeVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AddAttributeVModel.java Thu Apr 16 21:43:00 2009
@@ -37,7 +37,7 @@
* parameters, see {@link AddAttributeModel#start(java.util.Stack)},
* {@link AddAttributeModel#end(java.util.Stack, Object, String, String, String, String)}
* and {@link AddAttributeModel#execute(java.util.Stack, Object, String, String, String, String)}
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -50,7 +50,7 @@
/**
* Constructor.
- *
+ *
* @param model The template model.
* @since 2.2.0
*/
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AddListAttributeVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AddListAttributeVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AddListAttributeVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/AddListAttributeVModel.java Thu Apr 16 21:43:00 2009
@@ -37,7 +37,7 @@
* parameters, see
* {@link AddListAttributeModel#start(java.util.Stack, String)}
* and {@link AddListAttributeModel#end(java.util.Stack)}.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -47,17 +47,17 @@
* The template model.
*/
private AddListAttributeModel model;
-
+
/**
* Constructor.
- *
+ *
* @param model The template model.
* @since 2.2.0
*/
public AddListAttributeVModel(AddListAttributeModel model) {
this.model = model;
}
-
+
/** {@inheritDoc} */
public Renderable end(HttpServletRequest request, HttpServletResponse response,
Context velocityContext) {
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/BodyExecutable.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/BodyExecutable.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/BodyExecutable.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/BodyExecutable.java Thu Apr 16 21:43:00 2009
@@ -32,7 +32,7 @@
/**
* It represents an object that can be executed, with a body with "start" and
* "end" operation, under a Velocity+Servlet context.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -40,18 +40,19 @@
/**
* Starts the execution of the commands.
- *
+ *
* @param request The HTTP request.
* @param response The HTTP response-
* @param velocityContext The Velocity context.
* @param params The map of the parameters.
* @since 2.2.0
*/
- void start(HttpServletRequest request, HttpServletResponse response, Context velocityContext, Map<String, Object> params);
+ void start(HttpServletRequest request, HttpServletResponse response,
+ Context velocityContext, Map<String, Object> params);
/**
* Ends the execution of the commands.
- *
+ *
* @param request The HTTP request.
* @param response The HTTP response-
* @param velocityContext The Velocity context.
@@ -59,4 +60,4 @@
* @since 2.2.0
*/
Renderable end(HttpServletRequest request, HttpServletResponse response, Context velocityContext);
-}
\ No newline at end of file
+}
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/ContextHolder.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/ContextHolder.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/ContextHolder.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/ContextHolder.java Thu Apr 16 21:43:00 2009
@@ -29,7 +29,7 @@
/**
* An object that holds the current state of Velocity in a Servlet environment.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -39,17 +39,17 @@
* The Velocity context.
*/
private Context velocityContext;
-
+
/**
* The HTTP request.
*/
private HttpServletRequest request;
-
+
/**
* The HTTP response.
*/
private HttpServletResponse response;
-
+
/**
* The servlet context.
*/
@@ -59,7 +59,7 @@
* Sets the current {@link HttpServletRequest}. This is required for this
* tool to operate and will throw a NullPointerException if this is not set
* or is set to {@code null}.
- *
+ *
* @param request The HTTP request.
* @since 2.2.0
*/
@@ -74,7 +74,7 @@
* Sets the current {@link HttpServletResponse}. This is required for this
* tool to operate and will throw a NullPointerException if this is not set
* or is set to {@code null}.
- *
+ *
* @param response The HTTP response.
* @since 2.2.0
*/
@@ -89,7 +89,7 @@
* Sets the {@link ServletContext}. This is required for this tool to
* operate and will throw a NullPointerException if this is not set or is
* set to {@code null}.
- *
+ *
* @param application The Servlet context.
* @since 2.2.0
*/
@@ -104,7 +104,7 @@
* Sets the Velocity {@link Context}. This is required for this tool to
* operate and will throw a NullPointerException if this is not set or is
* set to {@code null}.
- *
+ *
* @param context The Velocity context.
* @since 2.2.0
*/
@@ -118,7 +118,7 @@
/**
* Returns the HTTP request.
- *
+ *
* @return The HTTP request.
* @since 2.2.0
*/
@@ -128,7 +128,7 @@
/**
* Returns the HTTP response.
- *
+ *
* @return The HTTP response.
* @since 2.2.0
*/
@@ -138,7 +138,7 @@
/**
* Returns the Servlet context.
- *
+ *
* @return The Servlet context..
* @since 2.2.0
*/
@@ -148,7 +148,7 @@
/**
* Returns the Velocity context..
- *
+ *
* @return The Velocity context.
* @since 2.2.0
*/
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/DefinitionVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/DefinitionVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/DefinitionVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/DefinitionVModel.java Thu Apr 16 21:43:00 2009
@@ -29,7 +29,6 @@
import org.apache.tiles.mgmt.MutableTilesContainer;
import org.apache.tiles.servlet.context.ServletUtil;
-import org.apache.tiles.template.AddListAttributeModel;
import org.apache.tiles.template.DefinitionModel;
import org.apache.tiles.velocity.context.VelocityUtil;
import org.apache.velocity.context.Context;
@@ -39,9 +38,10 @@
* Wraps {@link DefinitionModel} to be used in Velocity. For the list of
* parameters, see
* {@link DefinitionModel#start(java.util.Stack, String, String, String, String, String)}
- * , {@link AddListAttributeModel#end(java.util.Stack)} and
- * {@link DefinitionModel#execute(MutableTilesContainer, java.util.Stack, String, String, String, String, String, Object...)}.
- *
+ * , {@link DefinitionModel#end(MutableTilesContainer, java.util.Stack, Object...)} and
+ * {@link DefinitionModel#execute(MutableTilesContainer, java.util.Stack, String, String,
+ * String, String, String, Object...)}.
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -59,7 +59,7 @@
/**
* Constructor.
- *
+ *
* @param model The template model.
* @param servletContext The servlet context.
* @since 2.2.0
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Executable.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Executable.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Executable.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Executable.java Thu Apr 16 21:43:00 2009
@@ -31,7 +31,7 @@
/**
* It represents an object that can be executed under a Velocity+Servlet context.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -39,7 +39,7 @@
/**
* Executes the command.
- *
+ *
* @param request The HTTP request.
* @param response The HTTP response-
* @param velocityContext The Velocity context.
@@ -47,5 +47,7 @@
* @return A renderable object. It does not necessary render anything.
* @since 2.2.0
*/
- Renderable execute(HttpServletRequest request, HttpServletResponse response, Context velocityContext, Map<String, Object> params);
-}
\ No newline at end of file
+ Renderable execute(HttpServletRequest request,
+ HttpServletResponse response, Context velocityContext,
+ Map<String, Object> params);
+}
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/GetAsStringVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/GetAsStringVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/GetAsStringVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/GetAsStringVModel.java Thu Apr 16 21:43:00 2009
@@ -36,18 +36,17 @@
import org.apache.tiles.velocity.context.VelocityUtil;
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.Renderable;
/**
* Wraps {@link GetAsStringModel} to be used in Velocity. For the list of
* parameters, see
- * {@link GetAsStringModel#start(java.util.Stack, TilesContainer, boolean, String, String, Object, String, String, String, Attribute, Object...)}
+ * {@link GetAsStringModel#start(java.util.Stack, TilesContainer, boolean,
+ * String, String, Object, String, String, String, Attribute, Object...)}
* , {@link GetAsStringModel#end(java.util.Stack, TilesContainer, Writer, boolean, Object...)} and
- * {@link GetAsStringModel#execute(TilesContainer, Writer, boolean, String, String, Object, String, String, String, Attribute, Object...)}.
- *
+ * {@link GetAsStringModel#execute(TilesContainer, Writer, boolean, String,
+ * String, Object, String, String, String, Attribute, Object...)}.
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -65,7 +64,7 @@
/**
* Constructor.
- *
+ *
* @param model The template model.
* @param servletContext The servlet context.
* @since 2.2.0
@@ -84,8 +83,7 @@
response, request) {
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException,
- ParseErrorException, ResourceNotFoundException {
+ throws IOException {
TilesContainer container = ServletUtil.getCurrentContainer(
request, servletContext);
model.execute(container, writer,
@@ -122,11 +120,10 @@
Context velocityContext) {
Map<String, Object> params = VelocityUtil.getParameterStack(
velocityContext).pop();
- return new AbstractDefaultToStringRenderable(velocityContext, params, response, request){
-
+ return new AbstractDefaultToStringRenderable(velocityContext, params, response, request) {
+
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException, ParseErrorException,
- ResourceNotFoundException {
+ throws IOException {
model.end(ServletUtil.getComposeStack(request), ServletUtil
.getCurrentContainer(request, servletContext), writer,
VelocityUtil.toSimpleBoolean((Boolean) params
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/ImportAttributeVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/ImportAttributeVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/ImportAttributeVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/ImportAttributeVModel.java Thu Apr 16 21:43:00 2009
@@ -29,22 +29,19 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.tiles.TilesContainer;
import org.apache.tiles.servlet.context.ServletUtil;
import org.apache.tiles.template.ImportAttributeModel;
import org.apache.tiles.velocity.context.VelocityUtil;
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.Renderable;
/**
* Wraps {@link ImportAttributeModel} to be used in Velocity. For the list of
* parameters, see
- * {@link ImportAttributeModel#getImportedAttributes(TilesContainer, String, String, boolean, Object...)}.
- *
+ * {@link ImportAttributeModel#getImportedAttributes(org.apache.tiles.TilesContainer,
+ * String, String, boolean, Object...)}.
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -62,7 +59,7 @@
/**
* Constructor.
- *
+ *
* @param model The template model.
* @param servletContext The servlet context.
* @since 2.2.0
@@ -81,8 +78,7 @@
response, request) {
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException,
- ParseErrorException, ResourceNotFoundException {
+ throws IOException {
Map<String, Object> attributes = model.getImportedAttributes(
ServletUtil
.getCurrentContainer(request, servletContext),
@@ -96,7 +92,7 @@
servletContext, entry.getKey(), entry.getValue(),
scope);
}
-
+
return true;
}
};
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertAttributeVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertAttributeVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertAttributeVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertAttributeVModel.java Thu Apr 16 21:43:00 2009
@@ -30,24 +30,22 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.tiles.Attribute;
-import org.apache.tiles.TilesContainer;
import org.apache.tiles.servlet.context.ServletUtil;
import org.apache.tiles.template.InsertAttributeModel;
import org.apache.tiles.velocity.context.VelocityUtil;
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.Renderable;
/**
* Wraps {@link InsertAttributeModel} to be used in Velocity. For the list of
* parameters, see
- * {@link InsertAttributeModel#start(java.util.Stack, TilesContainer, boolean, String, String, Object, String, String, String, Attribute, Object...)}
- * , {@link InsertAttributeModel#end(java.util.Stack, TilesContainer, boolean, Object...)} and
- * {@link InsertAttributeModel#execute(TilesContainer, boolean, String, String, Object, String, String, String, Attribute, Object...)}.
- *
+ * {@link InsertAttributeModel#start(java.util.Stack, org.apache.tiles.TilesContainer, boolean,
+ * String, String, Object, String, String, String, Attribute, Object...)}
+ * , {@link InsertAttributeModel#end(java.util.Stack, org.apache.tiles.TilesContainer, boolean, Object...)} and
+ * {@link InsertAttributeModel#execute(org.apache.tiles.TilesContainer, boolean, String, String,
+ * Object, String, String, String, Attribute, Object...)}.
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -62,10 +60,10 @@
* The Servlet context.
*/
private ServletContext servletContext;
-
+
/**
* Constructor.
- *
+ *
* @param model The template model.
* @param servletContext The servlet context.
* @since 2.2.0
@@ -75,7 +73,7 @@
this.model = model;
this.servletContext = servletContext;
}
-
+
/** {@inheritDoc} */
public Renderable end(HttpServletRequest request, HttpServletResponse response,
Context velocityContext) {
@@ -84,8 +82,7 @@
response, request) {
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException,
- ParseErrorException, ResourceNotFoundException {
+ throws IOException {
model.end(ServletUtil.getComposeStack(request), ServletUtil
.getCurrentContainer(request, servletContext),
VelocityUtil.toSimpleBoolean((Boolean) params
@@ -106,18 +103,17 @@
params.get("defaultValue"), (String) params.get("defaultValueRole"),
(String) params.get("defaultValueType"), (String) params.get("name"),
(Attribute) params.get("value"), velocityContext, request, response);
-
+
}
/** {@inheritDoc} */
public Renderable execute(HttpServletRequest request,
HttpServletResponse response, Context velocityContext,
Map<String, Object> params) {
- return new AbstractDefaultToStringRenderable(velocityContext, params, response, request){
-
+ return new AbstractDefaultToStringRenderable(velocityContext, params, response, request) {
+
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException, ParseErrorException,
- ResourceNotFoundException {
+ throws IOException {
model.execute(ServletUtil.getCurrentContainer(request,
servletContext), VelocityUtil.toSimpleBoolean(
(Boolean) params.get("ignore"), false), (String) params
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertDefinitionVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertDefinitionVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertDefinitionVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertDefinitionVModel.java Thu Apr 16 21:43:00 2009
@@ -34,9 +34,6 @@
import org.apache.tiles.velocity.context.VelocityUtil;
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.Renderable;
/**
@@ -45,12 +42,12 @@
* {@link InsertDefinitionModel#start(org.apache.tiles.TilesContainer, Object...)}
* , {@link InsertDefinitionModel#end(org.apache.tiles.TilesContainer, String, String, String, String, Object...)} and
* {@link InsertDefinitionModel#execute(org.apache.tiles.TilesContainer, String, String, String, String, Object...)}.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
public class InsertDefinitionVModel implements Executable, BodyExecutable {
-
+
/**
* The template model.
*/
@@ -63,7 +60,7 @@
/**
* Constructor.
- *
+ *
* @param model The template model.
* @param servletContext The servlet context.
* @since 2.2.0
@@ -81,8 +78,7 @@
return new AbstractDefaultToStringRenderable(velocityContext, params, response, request) {
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException,
- ParseErrorException, ResourceNotFoundException {
+ throws IOException {
model.execute(ServletUtil.getCurrentContainer(request, servletContext),
(String) params.get("name"), (String) params.get("template"),
(String) params.get("role"), (String) params.get("preparer"),
@@ -100,8 +96,7 @@
response, request) {
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException,
- ParseErrorException, ResourceNotFoundException {
+ throws IOException {
model.end(ServletUtil.getCurrentContainer(request,
servletContext), (String) params.get("name"),
(String) params.get("template"), (String) params
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertTemplateVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertTemplateVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertTemplateVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/InsertTemplateVModel.java Thu Apr 16 21:43:00 2009
@@ -34,9 +34,6 @@
import org.apache.tiles.velocity.context.VelocityUtil;
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.Renderable;
/**
@@ -45,7 +42,7 @@
* {@link InsertTemplateModel#start(org.apache.tiles.TilesContainer, Object...)}
* , {@link InsertTemplateModel#end(org.apache.tiles.TilesContainer, String, String, String, Object...)} and
* {@link InsertTemplateModel#execute(org.apache.tiles.TilesContainer, String, String, String, Object...)}.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -63,7 +60,7 @@
/**
* Constructor.
- *
+ *
* @param model The template model.
* @param servletContext The servlet context.
* @since 2.2.0
@@ -81,8 +78,7 @@
return new AbstractDefaultToStringRenderable(velocityContext, params, response, request) {
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException,
- ParseErrorException, ResourceNotFoundException {
+ throws IOException {
model.execute(ServletUtil.getCurrentContainer(request,
servletContext), (String) params.get("template"),
(String) params.get("role"), (String) params
@@ -99,10 +95,9 @@
Map<String, Object> params = VelocityUtil.getParameterStack(
velocityContext).pop();
return new AbstractDefaultToStringRenderable(velocityContext, params, response, request) {
-
+
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException, ParseErrorException,
- ResourceNotFoundException {
+ throws IOException {
model.end(ServletUtil.getCurrentContainer(request, servletContext),
(String) params.get("template"), (String) params.get("role"),
(String) params.get("preparer"), velocityContext, request,
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/PutAttributeVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/PutAttributeVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/PutAttributeVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/PutAttributeVModel.java Thu Apr 16 21:43:00 2009
@@ -37,9 +37,11 @@
* Wraps {@link PutAttributeModel} to be used in Velocity. For the list of
* parameters, see
* {@link PutAttributeModel#start(java.util.Stack)}
- * , {@link PutAttributeModel#end(org.apache.tiles.TilesContainer, java.util.Stack, String, Object, String, String, String, String, boolean, Object...)} and
- * {@link PutAttributeModel#execute(org.apache.tiles.TilesContainer, java.util.Stack, String, Object, String, String, String, String, boolean, Object...)}.
- *
+ * , {@link PutAttributeModel#end(org.apache.tiles.TilesContainer,
+ * java.util.Stack, String, Object, String, String, String, String, boolean, Object...)} and
+ * {@link PutAttributeModel#execute(org.apache.tiles.TilesContainer,
+ * java.util.Stack, String, Object, String, String, String, String, boolean, Object...)}.
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -54,10 +56,10 @@
* The Servlet context.
*/
private ServletContext servletContext;
-
+
/**
* Constructor.
- *
+ *
* @param model The template model.
* @param servletContext The servlet context.
* @since 2.2.0
@@ -67,7 +69,7 @@
this.model = model;
this.servletContext = servletContext;
}
-
+
/** {@inheritDoc} */
public Renderable execute(HttpServletRequest request,
HttpServletResponse response, Context velocityContext,
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/PutListAttributeVModel.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/PutListAttributeVModel.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/PutListAttributeVModel.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/PutListAttributeVModel.java Thu Apr 16 21:43:00 2009
@@ -38,7 +38,7 @@
* parameters, see
* {@link PutListAttributeModel#start(java.util.Stack, String, boolean)}
* AND {@link PutListAttributeModel#end(org.apache.tiles.TilesContainer, java.util.Stack, String, boolean, Object...)}.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -56,7 +56,7 @@
/**
* Constructor.
- *
+ *
* @param model The template model.
* @param servletContext The servlet context.
* @since 2.2.0
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Tiles2Tool.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Tiles2Tool.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Tiles2Tool.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/Tiles2Tool.java Thu Apr 16 21:43:00 2009
@@ -36,7 +36,7 @@
* <li>calling methods without parameters: useful to include composition code inside a block.
* You need to call then {@link #start(Map)}, then your code in the block, and then {@link #end()}.</li>
* </ul>
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -46,20 +46,20 @@
* The key of the attribute that will be used to store the repository of "models".
*/
private static final String TILES_VELOCITY_REPOSITORY_KEY = "org.apache.tiles.velocity.TilesVelocityRepository";
-
+
/**
* The current executable object to use. Set in {@link #start(Map)} and used in {@link #end()}.
*/
private BodyExecutable currentExecutable;
-
+
/**
* The repository of Tiles+Velocity models.
*/
private TilesVelocityRepository repository;
-
+
/**
* Executes the {@link AddAttributeVModel}.
- *
+ *
* @param params The map of parameters.
* @return The tool itself.
* @since 2.2.0
@@ -73,7 +73,7 @@
/**
* Prepares the {@link AddAttributeVModel} for the execution with a block
* inside {@link #start(Map)} and {@link #end()} calls.
- *
+ *
* @return The tool itself.
* @since 2.2.0
* @see org.apache.tiles.template.AddAttributeModel
@@ -82,11 +82,11 @@
currentExecutable = getRepository().getAddAttribute();
return this;
}
-
+
/**
* Prepares the {@link AddListAttributeVModel} for the execution with a block
* inside {@link #start(Map)} and {@link #end()} calls.
- *
+ *
* @return The tool itself.
* @since 2.2.0
* @see org.apache.tiles.template.AddListAttributeModel
@@ -95,10 +95,10 @@
currentExecutable = getRepository().getAddListAttribute();
return this;
}
-
+
/**
* Executes the {@link DefinitionVModel}.
- *
+ *
* @param params The map of parameters.
* @return The tool itself.
* @since 2.2.0
@@ -108,11 +108,11 @@
execute(getRepository().getDefinition(), params);
return this;
}
-
+
/**
* Prepares the {@link DefinitionVModel} for the execution with a block
* inside {@link #start(Map)} and {@link #end()} calls.
- *
+ *
* @return The tool itself.
* @since 2.2.0
* @see org.apache.tiles.template.DefinitionModel
@@ -124,7 +124,7 @@
/**
* Executes the {@link GetAsStringVModel}.
- *
+ *
* @param params The map of parameters.
* @return A renderable object that renders an attribute as a string.
* @since 2.2.0
@@ -137,7 +137,7 @@
/**
* Prepares the {@link GetAsStringVModel} for the execution with a block
* inside {@link #start(Map)} and {@link #end()} calls.
- *
+ *
* @return The tool itself.
* @since 2.2.0
* @see org.apache.tiles.template.GetAsStringModel
@@ -146,10 +146,10 @@
currentExecutable = getRepository().getGetAsString();
return this;
}
-
+
/**
* Executes the {@link ImportAttributeVModel}.
- *
+ *
* @param params The map of parameters.
* @return A renderable object that does not write anything, but imports attribute values when invoked.
* @since 2.2.0
@@ -158,10 +158,10 @@
public Renderable importAttribute(Map<String, Object> params) {
return execute(getRepository().getImportAttribute(), params);
}
-
+
/**
* Executes the {@link InsertAttributeVModel}.
- *
+ *
* @param params The map of parameters.
* @return A renderable object that renders an attribute.
* @since 2.2.0
@@ -170,11 +170,11 @@
public Renderable insertAttribute(Map<String, Object> params) {
return execute(getRepository().getInsertAttribute(), params);
}
-
+
/**
* Prepares the {@link InsertAttributeVModel} for the execution with a block
* inside {@link #start(Map)} and {@link #end()} calls.
- *
+ *
* @return The tool itself.
* @since 2.2.0
* @see org.apache.tiles.template.InsertAttributeModel
@@ -183,10 +183,10 @@
currentExecutable = getRepository().getInsertAttribute();
return this;
}
-
+
/**
* Executes the {@link InsertDefinitionVModel}.
- *
+ *
* @param params The map of parameters.
* @return A renderable object that renders a definition.
* @since 2.2.0
@@ -195,11 +195,11 @@
public Renderable insertDefinition(Map<String, Object> params) {
return execute(getRepository().getInsertDefinition(), params);
}
-
+
/**
* Prepares the {@link InsertDefinitionVModel} for the execution with a block
* inside {@link #start(Map)} and {@link #end()} calls.
- *
+ *
* @return The tool itself.
* @since 2.2.0
* @see org.apache.tiles.template.InsertDefinitionModel
@@ -208,10 +208,10 @@
currentExecutable = getRepository().getInsertDefinition();
return this;
}
-
+
/**
* Executes the {@link InsertTemplateVModel}.
- *
+ *
* @param params The map of parameters.
* @return A renderable object that renders a template.
* @since 2.2.0
@@ -220,11 +220,11 @@
public Renderable insertTemplate(Map<String, Object> params) {
return execute(getRepository().getInsertTemplate(), params);
}
-
+
/**
* Prepares the {@link InsertTemplateVModel} for the execution with a block
* inside {@link #start(Map)} and {@link #end()} calls.
- *
+ *
* @return The tool itself.
* @since 2.2.0
* @see org.apache.tiles.template.InsertTemplateModel
@@ -233,10 +233,10 @@
currentExecutable = getRepository().getInsertTemplate();
return this;
}
-
+
/**
* Executes the {@link PutAttributeVModel}.
- *
+ *
* @param params The map of parameters.
* @return The tool itself.
* @since 2.2.0
@@ -246,11 +246,11 @@
execute(getRepository().getPutAttribute(), params);
return this;
}
-
+
/**
* Prepares the {@link PutAttributeVModel} for the execution with a block
* inside {@link #start(Map)} and {@link #end()} calls.
- *
+ *
* @return The tool itself.
* @since 2.2.0
* @see org.apache.tiles.template.PutAttributeModel
@@ -259,11 +259,11 @@
currentExecutable = getRepository().getPutAttribute();
return this;
}
-
+
/**
* Prepares the {@link PutListAttributeVModel} for the execution with a block
* inside {@link #start(Map)} and {@link #end()} calls.
- *
+ *
* @return The tool itself.
* @since 2.2.0
* @see org.apache.tiles.template.PutListAttributeModel
@@ -272,10 +272,10 @@
currentExecutable = getRepository().getPutListAttribute();
return this;
}
-
+
/**
* Sets the current container for the current request.
- *
+ *
* @param containerKey The key of the container to set as "current" for the current request.
* @return The tool itself.
* @since 2.2.0
@@ -285,10 +285,10 @@
containerKey);
return this;
}
-
+
/**
* Starts a "model" for the execution in a block.
- *
+ *
* @param params The map of parameters.
* @return The tool itself.
* @since 2.2.0
@@ -303,7 +303,7 @@
/**
* Ends a "model" after the execution of a block.
- *
+ *
* @return A renderable object. It can render actually something, or execute
* code needed to the execution of parent models.
* @since 2.2.0
@@ -320,7 +320,7 @@
/**
* Returns an attribute.
- *
+ *
* @param key The name of the attribute to get.
* @return The Attribute.
* @since 2.2.0
@@ -342,7 +342,7 @@
/**
* Gets or creates the Tiles+Velocity model repository from the servlet context.
- *
+ *
* @return The model repository.
*/
private TilesVelocityRepository getRepository() {
@@ -359,10 +359,10 @@
}
return repository;
}
-
+
/**
* Executes an "executable" model.
- *
+ *
* @param executable The object to execute.
* @param params The parameters map.
* @return A renderable object. It can render actually something, or execute
Modified: tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/TilesVelocityRepository.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/TilesVelocityRepository.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/TilesVelocityRepository.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/main/java/org/apache/tiles/velocity/template/TilesVelocityRepository.java Thu Apr 16 21:43:00 2009
@@ -38,7 +38,7 @@
/**
* Collects all Tiles+Velocity models.
- *
+ *
* @version $Rev$ $Date$
* @since 2.2.0
*/
@@ -96,7 +96,7 @@
/**
* Constructor.
- *
+ *
* @param servletContext The servlet context.
* @since 2.2.0
*/
@@ -125,7 +125,7 @@
/**
* Returns the "addAttribute" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
@@ -135,7 +135,7 @@
/**
* Returns the "addListAttribute" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
@@ -145,7 +145,7 @@
/**
* Returns the "definition" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
@@ -155,7 +155,7 @@
/**
* Returns the "getAsString" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
@@ -165,7 +165,7 @@
/**
* Returns the "importAttribute" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
@@ -175,7 +175,7 @@
/**
* Returns the "insertAttribute" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
@@ -185,7 +185,7 @@
/**
* Returns the "insertDefinition" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
@@ -195,7 +195,7 @@
/**
* Returns the "insertTemplate" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
@@ -205,7 +205,7 @@
/**
* Returns the "putAttribute" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
@@ -215,7 +215,7 @@
/**
* Returns the "putListAttribute" model.
- *
+ *
* @return The model.
* @since 2.2.0
*/
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/ExternalWriterHttpServletResponseTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/ExternalWriterHttpServletResponseTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/ExternalWriterHttpServletResponseTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/ExternalWriterHttpServletResponseTest.java Thu Apr 16 21:43:00 2009
@@ -1,6 +1,24 @@
-/**
- *
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.velocity.context;
import static org.junit.Assert.*;
@@ -16,8 +34,7 @@
import org.junit.Test;
/**
- * @author antonio
- *
+ * Tests {@link ExternalWriterHttpServletResponse}.
*/
public class ExternalWriterHttpServletResponseTest {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextFactoryTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextFactoryTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextFactoryTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextFactoryTest.java Thu Apr 16 21:43:00 2009
@@ -1,3 +1,24 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.velocity.context;
import static org.junit.Assert.*;
@@ -15,18 +36,26 @@
import org.junit.Test;
/**
- * @author antonio
- *
+ * Tests {@link VelocityTilesRequestContextFactory}.
*/
public class VelocityTilesRequestContextFactoryTest {
/**
+ * The position of the writer in the request objects array.
+ */
+ private static final int WRITER_POSITION = 3;
+
+ /**
+ * The size of the request objects array.
+ */
+ private static final int REQUEST_OBJECTS_SIZE = 4;
+ /**
* The object to test.
*/
private VelocityTilesRequestContextFactory factory;
-
+
/**
- * Tests {@link VelocityTilesRequestContextFactory#createRequestContext(TilesApplicationContext, Object...)}.
+ * Tests {@link VelocityTilesRequestContextFactory#createRequestContext(TilesApplicationContext, Object...)}.
*/
@Test
public void testCreateRequestContext() {
@@ -47,11 +76,11 @@
request, response, writer);
assertEquals(enclosedRequest, context.getWrappedRequest());
Object[] requestItems = context.getRequestObjects();
- assertEquals(4, requestItems.length);
+ assertEquals(REQUEST_OBJECTS_SIZE, requestItems.length);
assertEquals(velocityContext, requestItems[0]);
assertEquals(request, requestItems[1]);
assertEquals(response, requestItems[2]);
- assertEquals(writer, requestItems[3]);
+ assertEquals(writer, requestItems[WRITER_POSITION]);
verify(parentFactory, enclosedRequest, applicationContext, velocityContext, request, response);
}
}
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityTilesRequestContextTest.java Thu Apr 16 21:43:00 2009
@@ -1,3 +1,24 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.velocity.context;
import static org.junit.Assert.*;
@@ -18,8 +39,7 @@
import org.junit.Test;
/**
- * @author antonio
- *
+ * Tests {@link VelocityTilesRequestContext}.
*/
public class VelocityTilesRequestContextTest {
@@ -27,17 +47,17 @@
* The request context to test.
*/
private VelocityTilesRequestContext context;
-
+
/**
* The Velocity context.
*/
private Context velocityContext;
-
+
/**
* A string writer.
*/
private StringWriter writer;
-
+
/**
* @throws java.lang.Exception If something goes wrong.
*/
@@ -49,7 +69,7 @@
/**
* Tests {@link VelocityTilesRequestContext#dispatch(String)}.
- *
+ *
* @throws IOException If something goes wrong.
* @throws ServletException If something goes wrong.
*/
@@ -60,15 +80,15 @@
HttpServletRequest servletRequest = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
RequestDispatcher dispatcher = createMock(RequestDispatcher.class);
-
+
servletRequest.setAttribute(ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME, true);
expect(servletRequest.getRequestDispatcher("this way")).andReturn(dispatcher);
dispatcher.include(eq(servletRequest), isA(ExternalWriterHttpServletResponse.class));
replay(servletRequest, response, dispatcher);
Object[] requestItems = new Object[] {servletRequest, response};
-
+
expect(enclosedRequest.getRequestObjects()).andReturn(requestItems);
-
+
replay(velocityContext, enclosedRequest);
context = new VelocityTilesRequestContext(enclosedRequest, velocityContext, writer);
context.dispatch(path);
@@ -77,7 +97,7 @@
/**
* Tests {@link VelocityTilesRequestContext#include(String)}.
- *
+ *
* @throws IOException If something goes wrong.
* @throws ServletException If something goes wrong.
*/
@@ -88,15 +108,15 @@
HttpServletRequest servletRequest = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
RequestDispatcher dispatcher = createMock(RequestDispatcher.class);
-
+
servletRequest.setAttribute(ServletUtil.FORCE_INCLUDE_ATTRIBUTE_NAME, true);
expect(servletRequest.getRequestDispatcher("this way")).andReturn(dispatcher);
dispatcher.include(eq(servletRequest), isA(ExternalWriterHttpServletResponse.class));
replay(servletRequest, response, dispatcher);
Object[] requestItems = new Object[] {servletRequest, response};
-
+
expect(enclosedRequest.getRequestObjects()).andReturn(requestItems);
-
+
replay(velocityContext, enclosedRequest);
context = new VelocityTilesRequestContext(enclosedRequest, velocityContext, writer);
context.include(path);
@@ -105,7 +125,7 @@
/**
* Tests {@link VelocityTilesRequestContext#getPrintWriter()}.
- *
+ *
* @throws IOException If something goes wrong.
*/
@Test
@@ -120,7 +140,7 @@
/**
* Tests {@link VelocityTilesRequestContext#getWriter()}.
- *
+ *
* @throws IOException If something goes wrong.
*/
@Test
@@ -143,15 +163,16 @@
TilesRequestContext enclosedRequest = createMock(TilesRequestContext.class);
HttpServletRequest servletRequest = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
-
+
replay(servletRequest, response);
Object[] requestItems = new Object[] {servletRequest, response};
-
+
expect(enclosedRequest.getRequestObjects()).andReturn(requestItems);
-
+
replay(velocityContext, enclosedRequest);
context = new VelocityTilesRequestContext(enclosedRequest, velocityContext, writer);
- assertArrayEquals(new Object[] {velocityContext, servletRequest, response, writer}, context.getRequestObjects());
+ assertArrayEquals(new Object[] { velocityContext, servletRequest,
+ response, writer }, context.getRequestObjects());
verify(velocityContext, enclosedRequest, servletRequest, response);
}
}
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityUtilTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityUtilTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityUtilTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/context/VelocityUtilTest.java Thu Apr 16 21:43:00 2009
@@ -1,6 +1,24 @@
-/**
- *
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.velocity.context;
import static org.apache.tiles.velocity.context.VelocityUtil.*;
@@ -19,18 +37,23 @@
import org.junit.Test;
/**
- * @author antonio
- *
+ * Tests {@link VelocityUtil}.
*/
public class VelocityUtilTest {
-
+
+ /**
+ * A dummy value.
+ */
+ private static final Integer DUMMY_VALUE = new Integer(10);
+
/**
* The parameter stack key.
*/
- private final static String PARAMETER_MAP_STACK_KEY = "org.apache.tiles.velocity.PARAMETER_MAP_STACK";
+ private static final String PARAMETER_MAP_STACK_KEY = "org.apache.tiles.velocity.PARAMETER_MAP_STACK";
/**
- * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil#toSimpleBoolean(java.lang.Boolean, boolean)}.
+ * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil
+ * #toSimpleBoolean(java.lang.Boolean, boolean)}.
*/
@Test
public void testToSimpleBoolean() {
@@ -43,12 +66,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil#getParameterStack(org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil
+ * #getParameterStack(org.apache.velocity.context.Context)}.
*/
@Test
public void testGetParameterStack() {
Context velocityContext = createMock(Context.class);
-
+
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(null);
expect(velocityContext.put(eq(PARAMETER_MAP_STACK_KEY), isA(Stack.class))).andReturn(null);
replay(velocityContext);
@@ -56,10 +80,10 @@
assertNotNull(paramStack);
assertEquals(0, paramStack.size());
verify(velocityContext);
-
+
reset(velocityContext);
- paramStack = new Stack<Map<String,Object>>();
+ paramStack = new Stack<Map<String, Object>>();
paramStack.push(new HashMap<String, Object>());
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(paramStack);
@@ -69,14 +93,16 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil#setAttribute(org.apache.velocity.context.Context, javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext, java.lang.String, java.lang.Object, java.lang.String)}.
+ * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil
+ * #setAttribute(org.apache.velocity.context.Context, javax.servlet.http.HttpServletRequest,
+ * javax.servlet.ServletContext, java.lang.String, java.lang.Object, java.lang.String)}.
*/
@Test
public void testSetAttributePage() {
Context velocityContext = createMock(Context.class);
HttpServletRequest request = createMock(HttpServletRequest.class);
ServletContext servletContext = createMock(ServletContext.class);
- Object value = new Integer(10);
+ Object value = DUMMY_VALUE;
expect(velocityContext.put("myName", value)).andReturn(value);
replay(velocityContext, request, servletContext);
@@ -85,14 +111,16 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil#setAttribute(org.apache.velocity.context.Context, javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext, java.lang.String, java.lang.Object, java.lang.String)}.
+ * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil
+ * #setAttribute(org.apache.velocity.context.Context, javax.servlet.http.HttpServletRequest,
+ * javax.servlet.ServletContext, java.lang.String, java.lang.Object, java.lang.String)}.
*/
@Test
public void testSetAttributeRequest() {
Context velocityContext = createMock(Context.class);
HttpServletRequest request = createMock(HttpServletRequest.class);
ServletContext servletContext = createMock(ServletContext.class);
- Object value = new Integer(10);
+ Object value = DUMMY_VALUE;
request.setAttribute("myName", value);
replay(velocityContext, request, servletContext);
@@ -101,7 +129,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil#setAttribute(org.apache.velocity.context.Context, javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext, java.lang.String, java.lang.Object, java.lang.String)}.
+ * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil
+ * #setAttribute(org.apache.velocity.context.Context, javax.servlet.http.HttpServletRequest,
+ * javax.servlet.ServletContext, java.lang.String, java.lang.Object, java.lang.String)}.
*/
@Test
public void testSetAttributeSession() {
@@ -109,7 +139,7 @@
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpSession session = createMock(HttpSession.class);
ServletContext servletContext = createMock(ServletContext.class);
- Object value = new Integer(10);
+ Object value = DUMMY_VALUE;
expect(request.getSession()).andReturn(session);
session.setAttribute("myName", value);
@@ -119,14 +149,16 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil#setAttribute(org.apache.velocity.context.Context, javax.servlet.http.HttpServletRequest, javax.servlet.ServletContext, java.lang.String, java.lang.Object, java.lang.String)}.
+ * Test method for {@link org.apache.tiles.velocity.context.VelocityUtil
+ * #setAttribute(org.apache.velocity.context.Context, javax.servlet.http.HttpServletRequest,
+ * javax.servlet.ServletContext, java.lang.String, java.lang.Object, java.lang.String)}.
*/
@Test
public void testSetAttributeApplication() {
Context velocityContext = createMock(Context.class);
HttpServletRequest request = createMock(HttpServletRequest.class);
ServletContext servletContext = createMock(ServletContext.class);
- Object value = new Integer(10);
+ Object value = DUMMY_VALUE;
servletContext.setAttribute("myName", value);
replay(velocityContext, request, servletContext);