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 [4/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-velocity/src/test/java/org/apache/tiles/velocity/template/AbstractDefaultToStringRenderableTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AbstractDefaultToStringRenderableTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AbstractDefaultToStringRenderableTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AbstractDefaultToStringRenderableTest.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.template;
import static org.junit.Assert.*;
@@ -17,19 +35,17 @@
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.junit.Test;
/**
- * @author antonio
- *
+ * Tests {@link AbstractDefaultToStringRenderable}.
*/
public class AbstractDefaultToStringRenderableTest {
-
+
/**
- * Test method for {@link org.apache.tiles.velocity.template.AbstractDefaultToStringRenderable#AbstractDefaultToStringRenderable(org.apache.velocity.context.Context, java.util.Map, javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpServletRequest)}.
+ * Test method for {@link org.apache.tiles.velocity.template.AbstractDefaultToStringRenderable
+ * #AbstractDefaultToStringRenderable(org.apache.velocity.context.Context,
+ * java.util.Map, javax.servlet.http.HttpServletResponse, javax.servlet.http.HttpServletRequest)}.
*/
@Test
public void testAbstractDefaultToStringRenderable() {
@@ -37,7 +53,7 @@
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Map<String, Object> params = new HashMap<String, Object>();
-
+
replay(velociContext, request, response);
DefaultRenderable renderable = new DefaultRenderable(velociContext,
params, response, request);
@@ -58,11 +74,11 @@
HttpServletResponse response = createMock(HttpServletResponse.class);
Map<String, Object> params = new HashMap<String, Object>();
params.put("one", "value1");
-
+
replay(velociContext, request, response);
DefaultRenderable renderable = new DefaultRenderable(velociContext,
params, response, request);
-
+
assertEquals("Hello!", renderable.toString());
assertTrue(renderable.getWriter() instanceof StringWriter);
assertNull(renderable.getInternalContextAdapter());
@@ -78,15 +94,15 @@
* The internal context.
*/
private InternalContextAdapter internalContextAdapter;
-
+
/**
* The writer.
*/
private Writer writer;
-
+
/**
* Constructor.
- *
+ *
* @param velocityContext The Velocity context.
* @param params The parameters used in the current tool call.
* @param response The HTTP response.
@@ -100,44 +116,43 @@
/** {@inheritDoc} */
public boolean render(InternalContextAdapter context, Writer writer)
- throws IOException, MethodInvocationException,
- ParseErrorException, ResourceNotFoundException {
+ throws IOException {
this.internalContextAdapter = context;
this.writer = writer;
writer.write("Hello!");
return true;
}
-
+
/**
- * Returns the Velocity context.
- *
+ * Returns the Velocity context.
+ *
* @return The velocity context.
*/
public Context getVelocityContext() {
return velocityContext;
}
-
+
/**
* Returns the parameters.
- *
+ *
* @return The parameters.
*/
public Map<String, Object> getParams() {
return params;
}
-
+
/**
* Returns the request.
- *
+ *
* @return The request.
*/
public HttpServletRequest getRequest() {
return request;
}
-
+
/**
* Returns the respnse.
- *
+ *
* @return The response.
*/
public HttpServletResponse getResponse() {
@@ -146,7 +161,7 @@
/**
* Returns the internal context.
- *
+ *
* @return The internal context.
*/
public InternalContextAdapter getInternalContextAdapter() {
@@ -155,7 +170,7 @@
/**
* Returns the writer.
- *
+ *
* @return The writer.
*/
public Writer getWriter() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AddAttributeVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AddAttributeVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AddAttributeVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AddAttributeVModelTest.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.template;
import static org.junit.Assert.*;
@@ -24,22 +42,22 @@
* Tests {@link AddAttributeVModel}.
*/
public class AddAttributeVModelTest {
-
+
/**
* The attribute key that will be used to store the parameter map, to use across Velocity tool calls.
*/
- 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";
/**
* The model to test.
*/
private AddAttributeVModel model;
-
+
/**
* The template model.
*/
private AddAttributeModel tModel;
-
+
/**
* Sets up the model to test.
*/
@@ -50,7 +68,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.AddAttributeVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.AddAttributeVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testExecute() {
@@ -59,18 +79,20 @@
Context velocityContext = createMock(Context.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
-
+
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
tModel.execute(composeStack, "myValue", "myExpression", null, "myRole", "myType");
-
+
replay(tModel, request, response, velocityContext);
assertEquals(VelocityUtil.EMPTY_RENDERABLE, model.execute(request, response, velocityContext, params));
verify(tModel, request, response, velocityContext);
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.AddAttributeVModel#start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.AddAttributeVModel
+ * #start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testStart() {
@@ -79,13 +101,13 @@
Context velocityContext = createMock(Context.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
- Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String, Object>>();
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(parameterMapStack);
tModel.start(composeStack);
-
+
replay(tModel, request, response, velocityContext);
model.start(request, response, velocityContext, params);
assertEquals(1, parameterMapStack.size());
@@ -94,7 +116,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.AddAttributeVModel#end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.template.AddAttributeVModel
+ * #end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context)}.
*/
@Test
public void testEnd() {
@@ -103,14 +127,14 @@
Context velocityContext = createMock(Context.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
- Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String, Object>>();
parameterMapStack.push(params);
-
+
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(parameterMapStack);
tModel.end(composeStack, "myValue", "myExpression", null, "myRole", "myType");
-
+
replay(tModel, request, response, velocityContext);
assertEquals(VelocityUtil.EMPTY_RENDERABLE, model.end(request, response, velocityContext));
assertTrue(parameterMapStack.isEmpty());
@@ -119,7 +143,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AddListAttributeVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AddListAttributeVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AddListAttributeVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/AddListAttributeVModelTest.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.template;
import static org.junit.Assert.*;
@@ -29,12 +47,12 @@
* The model to test.
*/
private AddListAttributeVModel model;
-
+
/**
* The template model.
*/
private AddListAttributeModel tModel;
-
+
/**
* Sets up the model to test.
*/
@@ -45,7 +63,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.AddListAttributeVModel#start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.AddListAttributeVModel
+ * #start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testStart() {
@@ -58,14 +78,16 @@
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
tModel.start(composeStack, "myRole");
-
+
replay(tModel, request, response, velocityContext);
model.start(request, response, velocityContext, params);
verify(tModel, request, response, velocityContext);
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.AddListAttributeVModel#end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.template.AddListAttributeVModel
+ * #end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context)}.
*/
@Test
public void testEnd() {
@@ -73,11 +95,11 @@
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
Stack<Object> composeStack = new Stack<Object>();
-
+
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
tModel.end(composeStack);
-
+
replay(tModel, request, response, velocityContext);
assertEquals(VelocityUtil.EMPTY_RENDERABLE, model.end(request, response, velocityContext));
verify(tModel, request, response, velocityContext);
@@ -85,7 +107,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/DefinitionVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/DefinitionVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/DefinitionVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/DefinitionVModelTest.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.template;
import static org.junit.Assert.*;
@@ -20,9 +38,6 @@
import org.apache.tiles.template.DefinitionModel;
import org.apache.tiles.velocity.context.VelocityUtil;
import org.apache.velocity.context.Context;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.junit.Before;
import org.junit.Test;
@@ -35,17 +50,17 @@
* The model to test.
*/
private DefinitionVModel model;
-
+
/**
* The template model.
*/
private DefinitionModel tModel;
-
+
/**
* The servlet context.
*/
private ServletContext servletContext;
-
+
/**
* Sets up the model to test.
*/
@@ -56,27 +71,26 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.DefinitionVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.DefinitionVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testExecute() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testExecute() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
MutableTilesContainer container = createMock(MutableTilesContainer.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
tModel.execute(container, composeStack, "myName", "myTemplate", "myRole", "myExtends", "myPreparer",
velocityContext, request, response);
-
+
replay(tModel, servletContext, request, response, velocityContext, container);
initializeModel();
assertEquals(VelocityUtil.EMPTY_RENDERABLE, model.execute(request, response, velocityContext, params));
@@ -84,7 +98,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.DefinitionVModel#start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.DefinitionVModel
+ * #start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testStart() {
@@ -97,7 +113,7 @@
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
tModel.start(composeStack, "myName", "myTemplate", "myRole", "myExtends", "myPreparer");
-
+
replay(tModel, servletContext, request, response, velocityContext);
initializeModel();
model.start(request, response, velocityContext, params);
@@ -105,25 +121,24 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.DefinitionVModel#end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.template.DefinitionVModel
+ * #end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testEnd() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testEnd() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
MutableTilesContainer container = createMock(MutableTilesContainer.class);
Stack<Object> composeStack = new Stack<Object>();
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
tModel.end(container, composeStack, velocityContext, request, response);
-
+
replay(tModel, servletContext, request, response, velocityContext, container);
initializeModel();
assertEquals(VelocityUtil.EMPTY_RENDERABLE, model.end(request, response, velocityContext));
@@ -139,7 +154,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/GetAsStringVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/GetAsStringVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/GetAsStringVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/GetAsStringVModelTest.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.template;
import static org.junit.Assert.*;
@@ -23,9 +41,6 @@
import org.apache.tiles.template.GetAsStringModel;
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;
import org.junit.Before;
import org.junit.Test;
@@ -34,22 +49,22 @@
* Tests {@link GetAsStringVModel}.
*/
public class GetAsStringVModelTest {
-
+
/**
* The attribute key that will be used to store the parameter map, to use across Velocity tool calls.
*/
- 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";
/**
* The model to test.
*/
private GetAsStringVModel model;
-
+
/**
* The template model.
*/
private GetAsStringModel tModel;
-
+
/**
* The servlet context.
*/
@@ -59,7 +74,7 @@
* The attribute value.
*/
private Attribute attribute;
-
+
/**
* Sets up the model to test.
*/
@@ -71,14 +86,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.GetAsStringVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.GetAsStringVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testExecute() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testExecute() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -87,12 +101,12 @@
Writer writer = new StringWriter();
attribute = new Attribute("myAttributeValue");
Map<String, Object> params = createParams();
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
tModel.execute(container, writer, false, "myPreparer", "myRole", "myDefaultValue",
- "myDefaultValueRole", "myDefaultValueType", "myName", attribute,
+ "myDefaultValueRole", "myDefaultValueType", "myName", attribute,
velocityContext, request, response, writer);
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.execute(request, response, velocityContext, params);
@@ -101,7 +115,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.GetAsStringVModel#start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.GetAsStringVModel
+ * #start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testStart() {
@@ -111,7 +127,7 @@
TilesContainer container = createMock(TilesContainer.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
- Stack<Map<String, Object>> paramStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> paramStack = new Stack<Map<String, Object>>();
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
@@ -120,7 +136,7 @@
tModel.start(composeStack, container, false, "myPreparer", "myRole", "myDefaultValue",
"myDefaultValueRole", "myDefaultValueType", "myName", attribute,
velocityContext, request, response);
-
+
replay(tModel, servletContext, container, request, response, velocityContext);
initializeModel();
model.start(request, response, velocityContext, params);
@@ -130,14 +146,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.GetAsStringVModel#end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.template.GetAsStringVModel
+ * #end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testEnd() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testEnd() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -146,15 +161,15 @@
Writer writer = new StringWriter();
Stack<Object> composeStack = new Stack<Object>();
Map<String, Object> params = createParams();
- Stack<Map<String, Object>> paramStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> paramStack = new Stack<Map<String, Object>>();
paramStack.push(params);
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(paramStack);
tModel.end(composeStack, container, writer, false, velocityContext, request, response, writer);
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.end(request, response, velocityContext);
@@ -172,7 +187,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/ImportAttributeVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/ImportAttributeVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/ImportAttributeVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/ImportAttributeVModelTest.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.template;
import static org.easymock.classextension.EasyMock.*;
@@ -21,9 +39,6 @@
import org.apache.tiles.template.ImportAttributeModel;
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;
import org.junit.Before;
import org.junit.Test;
@@ -37,17 +52,17 @@
* The model to test.
*/
private ImportAttributeVModel model;
-
+
/**
* The template model.
*/
private ImportAttributeModel tModel;
-
+
/**
* The servlet context.
*/
private ServletContext servletContext;
-
+
/**
* Sets up the model to test.
*/
@@ -58,14 +73,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.ImportAttributeVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.ImportAttributeVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testExecutePage() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testExecutePage() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -76,13 +90,13 @@
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("one", "value1");
attributes.put("two", "value2");
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(tModel.getImportedAttributes(container, "myName", "myToName", false,
velocityContext, request, response)).andReturn(attributes);
expect(internalContextAdapter.put("one", "value1")).andReturn("value1");
expect(internalContextAdapter.put("two", "value2")).andReturn("value2");
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.execute(request, response, velocityContext, params);
@@ -91,14 +105,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.ImportAttributeVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.ImportAttributeVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testExecuteRequest() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testExecuteRequest() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -110,13 +123,13 @@
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("one", "value1");
attributes.put("two", "value2");
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(tModel.getImportedAttributes(container, "myName", "myToName", false,
velocityContext, request, response)).andReturn(attributes);
request.setAttribute("one", "value1");
request.setAttribute("two", "value2");
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.execute(request, response, velocityContext, params);
@@ -125,14 +138,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.ImportAttributeVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.ImportAttributeVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testExecuteSession() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testExecuteSession() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
HttpSession session = createMock(HttpSession.class);
@@ -145,14 +157,14 @@
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("one", "value1");
attributes.put("two", "value2");
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(tModel.getImportedAttributes(container, "myName", "myToName", false,
velocityContext, request, response)).andReturn(attributes);
expect(request.getSession()).andReturn(session).times(2);
session.setAttribute("one", "value1");
session.setAttribute("two", "value2");
-
+
replay(tModel, servletContext, request, response, session, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.execute(request, response, velocityContext, params);
@@ -161,14 +173,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.ImportAttributeVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.ImportAttributeVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testExecuteApplication() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testExecuteApplication() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -180,13 +191,13 @@
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("one", "value1");
attributes.put("two", "value2");
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(tModel.getImportedAttributes(container, "myName", "myToName", false,
velocityContext, request, response)).andReturn(attributes);
servletContext.setAttribute("one", "value1");
servletContext.setAttribute("two", "value2");
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.execute(request, response, velocityContext, params);
@@ -203,7 +214,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertAttributeVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertAttributeVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertAttributeVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertAttributeVModelTest.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.template;
import static org.junit.Assert.*;
@@ -23,9 +41,6 @@
import org.apache.tiles.template.InsertAttributeModel;
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;
import org.junit.Before;
import org.junit.Test;
@@ -34,22 +49,22 @@
* Tests {@link InsertAttributeVModel}.
*/
public class InsertAttributeVModelTest {
-
+
/**
* The attribute key that will be used to store the parameter map, to use across Velocity tool calls.
*/
- 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";
/**
* The model to test.
*/
private InsertAttributeVModel model;
-
+
/**
* The template model.
*/
private InsertAttributeModel tModel;
-
+
/**
* The servlet context.
*/
@@ -59,7 +74,7 @@
* The attribute value.
*/
private Attribute attribute;
-
+
/**
* Sets up the model to test.
*/
@@ -71,14 +86,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.InsertAttributeVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.InsertAttributeVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testExecute() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testExecute() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -87,12 +101,12 @@
Writer writer = new StringWriter();
attribute = new Attribute("myAttributeValue");
Map<String, Object> params = createParams();
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
tModel.execute(container, false, "myPreparer", "myRole", "myDefaultValue",
- "myDefaultValueRole", "myDefaultValueType", "myName", attribute,
+ "myDefaultValueRole", "myDefaultValueType", "myName", attribute,
velocityContext, request, response, writer);
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.execute(request, response, velocityContext, params);
@@ -101,7 +115,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.InsertAttributeVModel#start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.InsertAttributeVModel
+ * #start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testStart() {
@@ -111,7 +127,7 @@
TilesContainer container = createMock(TilesContainer.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
- Stack<Map<String, Object>> paramStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> paramStack = new Stack<Map<String, Object>>();
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
@@ -120,7 +136,7 @@
tModel.start(composeStack, container, false, "myPreparer", "myRole", "myDefaultValue",
"myDefaultValueRole", "myDefaultValueType", "myName", attribute,
velocityContext, request, response);
-
+
replay(tModel, servletContext, container, request, response, velocityContext);
initializeModel();
model.start(request, response, velocityContext, params);
@@ -130,14 +146,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.InsertAttributeVModel#end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.template.InsertAttributeVModel
+ * #end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testEnd() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testEnd() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -146,15 +161,15 @@
Writer writer = new StringWriter();
Stack<Object> composeStack = new Stack<Object>();
Map<String, Object> params = createParams();
- Stack<Map<String, Object>> paramStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> paramStack = new Stack<Map<String, Object>>();
paramStack.push(params);
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(paramStack);
tModel.end(composeStack, container, false, velocityContext, request, response, writer);
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.end(request, response, velocityContext);
@@ -172,7 +187,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertDefinitionVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertDefinitionVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertDefinitionVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertDefinitionVModelTest.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.template;
import static org.junit.Assert.*;
@@ -22,9 +40,6 @@
import org.apache.tiles.template.InsertDefinitionModel;
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;
import org.junit.Before;
import org.junit.Test;
@@ -33,27 +48,27 @@
* Tests {@link InsertDefinitionVModel}.
*/
public class InsertDefinitionVModelTest {
-
+
/**
* The attribute key that will be used to store the parameter map, to use across Velocity tool calls.
*/
- 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";
/**
* The model to test.
*/
private InsertDefinitionVModel model;
-
+
/**
* The template model.
*/
private InsertDefinitionModel tModel;
-
+
/**
* The servlet context.
*/
private ServletContext servletContext;
-
+
/**
* Sets up the model to test.
*/
@@ -64,14 +79,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.InsertDefinitionVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.InsertDefinitionVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testExecute() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testExecute() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -79,11 +93,11 @@
InternalContextAdapter internalContextAdapter = createMock(InternalContextAdapter.class);
Writer writer = new StringWriter();
Map<String, Object> params = createParams();
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
- tModel.execute(container, "myDefinitionName", "myTemplate", "myRole", "myPreparer",
+ tModel.execute(container, "myDefinitionName", "myTemplate", "myRole", "myPreparer",
velocityContext, request, response, writer);
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.execute(request, response, velocityContext, params);
@@ -92,7 +106,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.InsertDefinitionVModel#start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.InsertDefinitionVModel
+ * #start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testStart() {
@@ -101,12 +117,12 @@
Context velocityContext = createMock(Context.class);
TilesContainer container = createMock(TilesContainer.class);
Map<String, Object> params = createParams();
- Stack<Map<String, Object>> paramStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> paramStack = new Stack<Map<String, Object>>();
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(paramStack);
tModel.start(container, velocityContext, request, response);
-
+
replay(tModel, servletContext, container, request, response, velocityContext);
initializeModel();
model.start(request, response, velocityContext, params);
@@ -116,14 +132,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.InsertDefinitionVModel#end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.template.InsertDefinitionVModel
+ * #end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testEnd() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testEnd() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -131,14 +146,14 @@
InternalContextAdapter internalContextAdapter = createMock(InternalContextAdapter.class);
Writer writer = new StringWriter();
Map<String, Object> params = createParams();
- Stack<Map<String, Object>> paramStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> paramStack = new Stack<Map<String, Object>>();
paramStack.push(params);
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(paramStack);
- tModel.end(container, "myDefinitionName", "myTemplate", "myRole", "myPreparer",
+ tModel.end(container, "myDefinitionName", "myTemplate", "myRole", "myPreparer",
velocityContext, request, response, writer);
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.end(request, response, velocityContext);
@@ -156,7 +171,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertTemplateVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertTemplateVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertTemplateVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/InsertTemplateVModelTest.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.template;
import static org.junit.Assert.*;
@@ -22,9 +40,6 @@
import org.apache.tiles.template.InsertTemplateModel;
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;
import org.junit.Before;
import org.junit.Test;
@@ -33,27 +48,27 @@
* Tests {@link InsertTemplateVModel}.
*/
public class InsertTemplateVModelTest {
-
+
/**
* The attribute key that will be used to store the parameter map, to use across Velocity tool calls.
*/
- 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";
/**
* The model to test.
*/
private InsertTemplateVModel model;
-
+
/**
* The template model.
*/
private InsertTemplateModel tModel;
-
+
/**
* The servlet context.
*/
private ServletContext servletContext;
-
+
/**
* Sets up the model to test.
*/
@@ -64,14 +79,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.InsertTemplateVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.InsertTemplateVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testExecute() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testExecute() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -79,11 +93,11 @@
InternalContextAdapter internalContextAdapter = createMock(InternalContextAdapter.class);
Writer writer = new StringWriter();
Map<String, Object> params = createParams();
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
tModel.execute(container, "myTemplate", "myRole", "myPreparer",
velocityContext, request, response, writer);
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.execute(request, response, velocityContext, params);
@@ -92,7 +106,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.InsertTemplateVModel#start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.InsertTemplateVModel
+ * #start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testStart() {
@@ -101,12 +117,12 @@
Context velocityContext = createMock(Context.class);
TilesContainer container = createMock(TilesContainer.class);
Map<String, Object> params = createParams();
- Stack<Map<String, Object>> paramStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> paramStack = new Stack<Map<String, Object>>();
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(paramStack);
tModel.start(container, velocityContext, request, response);
-
+
replay(tModel, servletContext, container, request, response, velocityContext);
initializeModel();
model.start(request, response, velocityContext, params);
@@ -116,14 +132,13 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.InsertTemplateVModel#end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.template.InsertTemplateVModel
+ * #end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context)}.
* @throws IOException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
*/
@Test
- public void testEnd() throws MethodInvocationException, ParseErrorException, ResourceNotFoundException, IOException {
+ public void testEnd() throws IOException {
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
Context velocityContext = createMock(Context.class);
@@ -131,14 +146,14 @@
InternalContextAdapter internalContextAdapter = createMock(InternalContextAdapter.class);
Writer writer = new StringWriter();
Map<String, Object> params = createParams();
- Stack<Map<String, Object>> paramStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> paramStack = new Stack<Map<String, Object>>();
paramStack.push(params);
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(paramStack);
tModel.end(container, "myTemplate", "myRole", "myPreparer",
velocityContext, request, response, writer);
-
+
replay(tModel, servletContext, request, response, velocityContext, container, internalContextAdapter);
initializeModel();
Renderable renderable = model.end(request, response, velocityContext);
@@ -156,7 +171,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/PutAttributeVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/PutAttributeVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/PutAttributeVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/PutAttributeVModelTest.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.template;
import static org.junit.Assert.*;
@@ -26,27 +44,27 @@
* Tests {@link PutAttributeVModel}.
*/
public class PutAttributeVModelTest {
-
+
/**
* The attribute key that will be used to store the parameter map, to use across Velocity tool calls.
*/
- 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";
/**
* The model to test.
*/
private PutAttributeVModel model;
-
+
/**
* The template model.
*/
private PutAttributeModel tModel;
-
+
/**
* The servlet context.
*/
private ServletContext servletContext;
-
+
/**
* Sets up the model to test.
*/
@@ -57,7 +75,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.PutAttributeVModel#execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.PutAttributeVModel
+ * #execute(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testExecute() {
@@ -67,13 +87,13 @@
TilesContainer container = createMock(TilesContainer.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
tModel.execute(container, composeStack, "myName", "myValue", "myExpression", null, "myRole", "myType",
false, velocityContext, request, response);
-
+
replay(tModel, container, servletContext, request, response, velocityContext);
initializeModel();
assertEquals(VelocityUtil.EMPTY_RENDERABLE, model.execute(request, response, velocityContext, params));
@@ -81,7 +101,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.PutAttributeVModel#start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.PutAttributeVModel
+ * #start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testStart() {
@@ -90,13 +112,13 @@
Context velocityContext = createMock(Context.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
- Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String, Object>>();
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(parameterMapStack);
tModel.start(composeStack);
-
+
replay(tModel, servletContext, request, response, velocityContext);
initializeModel();
model.start(request, response, velocityContext, params);
@@ -106,7 +128,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.PutAttributeVModel#end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.template.PutAttributeVModel
+ * #end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context)}.
*/
@Test
public void testEnd() {
@@ -116,9 +140,9 @@
TilesContainer container = createMock(TilesContainer.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
- Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String, Object>>();
parameterMapStack.push(params);
-
+
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
@@ -126,7 +150,7 @@
tModel.end(container, composeStack, "myName", "myValue",
"myExpression", null, "myRole", "myType", false,
velocityContext, request, response);
-
+
replay(tModel, container, servletContext, request, response, velocityContext);
initializeModel();
assertEquals(VelocityUtil.EMPTY_RENDERABLE, model.end(request, response, velocityContext));
@@ -136,7 +160,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {
Modified: tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/PutListAttributeVModelTest.java
URL: http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/PutListAttributeVModelTest.java?rev=765774&r1=765773&r2=765774&view=diff
==============================================================================
--- tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/PutListAttributeVModelTest.java (original)
+++ tiles/framework/trunk/tiles-velocity/src/test/java/org/apache/tiles/velocity/template/PutListAttributeVModelTest.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.template;
import static org.junit.Assert.*;
@@ -26,27 +44,27 @@
* Tests {@link PutListAttributeVModel}.
*/
public class PutListAttributeVModelTest {
-
+
/**
* The attribute key that will be used to store the parameter map, to use across Velocity tool calls.
*/
- 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";
/**
* The model to test.
*/
private PutListAttributeVModel model;
-
+
/**
* The template model.
*/
private PutListAttributeModel tModel;
-
+
/**
* The servlet context.
*/
private ServletContext servletContext;
-
+
/**
* Sets up the model to test.
*/
@@ -57,7 +75,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.PutListAttributeVModel#start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context, java.util.Map)}.
+ * Test method for {@link org.apache.tiles.velocity.template.PutListAttributeVModel
+ * #start(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context, java.util.Map)}.
*/
@Test
public void testStart() {
@@ -66,13 +86,13 @@
Context velocityContext = createMock(Context.class);
Map<String, Object> params = createParams();
Stack<Object> composeStack = new Stack<Object>();
- Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String, Object>>();
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(parameterMapStack);
tModel.start(composeStack, "myRole", false);
-
+
replay(tModel, servletContext, request, response, velocityContext);
initializeModel();
model.start(request, response, velocityContext, params);
@@ -82,7 +102,9 @@
}
/**
- * Test method for {@link org.apache.tiles.velocity.template.PutListAttributeVModel#end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)}.
+ * Test method for {@link org.apache.tiles.velocity.template.PutListAttributeVModel
+ * #end(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
+ * org.apache.velocity.context.Context)}.
*/
@Test
public void testEnd() {
@@ -92,15 +114,15 @@
TilesContainer container = createMock(TilesContainer.class);
Stack<Object> composeStack = new Stack<Object>();
Map<String, Object> params = createParams();
- Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String,Object>>();
+ Stack<Map<String, Object>> parameterMapStack = new Stack<Map<String, Object>>();
parameterMapStack.push(params);
-
+
expect(request.getAttribute(ServletUtil.COMPOSE_STACK_ATTRIBUTE_NAME))
.andReturn(composeStack);
expect(velocityContext.get(PARAMETER_MAP_STACK_KEY)).andReturn(parameterMapStack);
expect(request.getAttribute(ServletUtil.CURRENT_CONTAINER_ATTRIBUTE_NAME)).andReturn(container);
tModel.end(container, composeStack, "myName", false, velocityContext, request, response);
-
+
replay(tModel, servletContext, container, request, response, velocityContext);
initializeModel();
assertEquals(VelocityUtil.EMPTY_RENDERABLE, model.end(request, response, velocityContext));
@@ -110,7 +132,7 @@
/**
* Creates the parameters to work with the model.
- *
+ *
* @return The parameters.
*/
private Map<String, Object> createParams() {