You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by cb...@apache.org on 2026/06/15 18:59:21 UTC
(velocity-tools) 02/03: Remove module velocity-tools-view-jsp from 4.0 (will be deprecated in 3.2)
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/velocity-tools.git
commit 2600d1dcd7adaaed88958eb1f0b85cf30696c8a5
Author: Claude Brisson <cl...@renegat.net>
AuthorDate: Mon Jun 15 20:53:32 2026 +0200
Remove module velocity-tools-view-jsp from 4.0 (will be deprecated in 3.2)
---
README.md | 1 -
pom.xml | 11 -
.../src/main/resources/resources.properties | 1 -
.../src/main/webapp/toolmenu.vm | 1 -
.../velocity-tools-examples-simple/pom.xml | 11 -
.../src/main/webapp/index.vm | 5 -
velocity-tools-view-jsp/pom.xml | 72 ----
.../velocity/tools/view/jsp/JspToolContext.java | 81 ----
.../velocity/tools/view/jsp/VelocityViewTag.java | 375 ----------------
.../jspimpl/ExternalWriterHttpServletResponse.java | 62 ---
.../velocity/tools/view/jsp/jspimpl/JspUtils.java | 146 -------
.../tools/view/jsp/jspimpl/JspWriterImpl.java | 394 -----------------
.../view/jsp/jspimpl/VelocityBodyContent.java | 259 -----------
.../view/jsp/jspimpl/VelocityJspFragment.java | 82 ----
.../view/jsp/jspimpl/VelocityPageContext.java | 434 -------------------
.../jsp/jspimpl/VelocityToolsJspException.java | 72 ----
.../tools/view/jsp/jspimpl/package-info.java | 26 --
.../velocity/tools/view/jsp/package-info.java | 25 --
.../src/main/resources/META-INF/velocity-view.tld | 74 ----
.../ExternalWriterHttpServletResponseTest.java | 57 ---
.../tools/view/jsp/jspimpl/JspUtilsTest.java | 140 ------
.../tools/view/jsp/jspimpl/JspWriterImplTest.java | 478 ---------------------
.../view/jsp/jspimpl/VelocityBodyContentTest.java | 444 -------------------
.../view/jsp/jspimpl/VelocityJspFragmentTest.java | 84 ----
.../view/jsp/jspimpl/VelocityPageContextTest.java | 442 -------------------
.../velocity/tools/view/VelocityViewFilter.java | 3 +-
.../velocity/tools/view/VelocityViewServlet.java | 7 +-
27 files changed, 4 insertions(+), 3783 deletions(-)
diff --git a/README.md b/README.md
index a5d69964..6045b928 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,6 @@ The VelocityTools project contains several subprojects:
velocity-tools-generic/ A collection of general purpose tools
velocity-tools-view/ Tools servlets and filters for use in a webapp
- velocity-tools-jsp/ Tools for a JEE JSP context
velocity-tools-examples/
velocity-tools-examples-simple/ Simple examples
velocity-tools-examples-showcase/ A full webapp demonstrating tools
diff --git a/pom.xml b/pom.xml
index ca73f3b7..7947d5d1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,6 @@
<modules>
<module>velocity-tools-generic</module>
<module>velocity-tools-view</module>
- <module>velocity-tools-view-jsp</module>
<module>velocity-tools-examples</module>
</modules>
@@ -163,16 +162,6 @@
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
</dependency>
- <dependency>
- <groupId>jakarta.servlet.jsp</groupId>
- <artifactId>jakarta.servlet.jsp-api</artifactId>
- <version>3.1.1</version>
- </dependency>
- <dependency>
- <groupId>jakarta.el</groupId>
- <artifactId>jakarta.el-api</artifactId>
- <version>5.0.1</version>
- </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/resources.properties b/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/resources.properties
index 6f7bcd33..12820ccb 100644
--- a/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/resources.properties
+++ b/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/resources.properties
@@ -77,7 +77,6 @@ tools.field = FieldTool
tools.include = IncludeTool
tools.import = ImportTool
tools.json = JsonTool
-tools.jsp = JSP taglib
tools.link = LinkTool
tools.lists = ListTool
tools.math = MathTool
diff --git a/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/toolmenu.vm b/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/toolmenu.vm
index eba83eb0..e460a22c 100644
--- a/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/toolmenu.vm
+++ b/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/toolmenu.vm
@@ -36,7 +36,6 @@
#toolMenuItem( $llink 'import' )
#toolMenuItem( $llink 'include' )
#toolMenuItem( $llink 'json' )
-#toolMenuItem( $llink 'jsp' )
#toolMenuItem( $llink 'link' )
#toolMenuItem( $llink 'loop' )
#toolMenuItem( $llink 'math' )
diff --git a/velocity-tools-examples/velocity-tools-examples-simple/pom.xml b/velocity-tools-examples/velocity-tools-examples-simple/pom.xml
index 499448c2..026fab41 100644
--- a/velocity-tools-examples/velocity-tools-examples-simple/pom.xml
+++ b/velocity-tools-examples/velocity-tools-examples-simple/pom.xml
@@ -40,23 +40,12 @@
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>jakarta.servlet.jsp</groupId>
- <artifactId>jakarta.servlet.jsp-api</artifactId>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.apache.velocity.tools</groupId>
<artifactId>velocity-tools-view</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.apache.velocity.tools</groupId>
- <artifactId>velocity-tools-view-jsp</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
diff --git a/velocity-tools-examples/velocity-tools-examples-simple/src/main/webapp/index.vm b/velocity-tools-examples/velocity-tools-examples-simple/src/main/webapp/index.vm
index 9fd49d7b..0cfb4fc9 100644
--- a/velocity-tools-examples/velocity-tools-examples-simple/src/main/webapp/index.vm
+++ b/velocity-tools-examples/velocity-tools-examples-simple/src/main/webapp/index.vm
@@ -57,10 +57,5 @@ $br
This is simple#if( $XHTML ) xhtml#end app version ${version}.
#end
-$br
-$br
-
-Click <a href="index.jsp">here</a> to see the VelocityViewTag handle the same VTL markup.
-
</body>
</html>
diff --git a/velocity-tools-view-jsp/pom.xml b/velocity-tools-view-jsp/pom.xml
deleted file mode 100644
index b64782a7..00000000
--- a/velocity-tools-view-jsp/pom.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.velocity.tools</groupId>
- <artifactId>velocity-tools-parent</artifactId>
- <version>3.3-SNAPSHOT</version>
- </parent>
-
- <artifactId>velocity-tools-view-jsp</artifactId>
-
- <name>Apache Velocity Tools - JSP support</name>
- <description>Enables the use of Velocity under a JSP environment.</description>
-
- <dependencies>
- <dependency>
- <groupId>jakarta.servlet</groupId>
- <artifactId>jakarta.servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>jakarta.servlet.jsp</groupId>
- <artifactId>jakarta.servlet.jsp-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>jakarta.el</groupId>
- <artifactId>jakarta.el-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-engine-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity.tools</groupId>
- <artifactId>velocity-tools-view</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/JspToolContext.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/JspToolContext.java
deleted file mode 100644
index 8be1dc81..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/JspToolContext.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.apache.velocity.tools.view.jsp;
-
-/*
- * 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.
- */
-
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.jsp.PageContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.tools.view.ViewToolContext;
-
-/**
- * <p>Velocity context implementation specific to the JSP environment.</p>
- *
- * @author Nathan Bubna
- * @version $Id: ViewContext.java 514727 2007-03-05 16:49:03Z nbubna $
- */
-public class JspToolContext extends ViewToolContext
-{
- public static final String PAGE_CONTEXT_KEY = "pageContext";
-
- private final PageContext pageContext;
-
- public JspToolContext(VelocityEngine velocity,
- PageContext pageContext)
- {
- super(velocity,
- (HttpServletRequest)pageContext.getRequest(),
- (HttpServletResponse)pageContext.getResponse(),
- pageContext.getServletContext());
-
- this.pageContext = pageContext;
- }
-
- protected void putToolProperties()
- {
- putToolProperty(PAGE_CONTEXT_KEY, getPageContext());
-
- super.putToolProperties();
- }
-
- public PageContext getPageContext()
- {
- return this.pageContext;
- }
-
- protected Object getServletApi(String key)
- {
- if (key.equals(PAGE_CONTEXT_KEY))
- {
- return getPageContext();
- }
- return super.getServletApi(key);
- }
-
- public Object getAttribute(String key)
- {
- Object o = getPageContext().getAttribute(key);
- if (o == null)
- {
- o = super.getAttribute(key);
- }
- return o;
- }
-}
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java
deleted file mode 100644
index b00abae1..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/VelocityViewTag.java
+++ /dev/null
@@ -1,375 +0,0 @@
-package org.apache.velocity.tools.view.jsp;
-
-/*
- * 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.
- */
-
-import java.io.StringWriter;
-import java.io.Writer;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.jsp.JspException;
-import jakarta.servlet.jsp.PageContext;
-import jakarta.servlet.jsp.tagext.BodyTagSupport;
-import org.apache.velocity.Template;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
-import org.apache.velocity.runtime.resource.util.StringResourceRepository;
-import org.apache.velocity.tools.view.ServletUtils;
-import org.apache.velocity.tools.view.ViewToolContext;
-import org.apache.velocity.tools.view.VelocityView;
-
-/**
- * <p>This tag enables use of Velocity and VelocityTools within JSP files and tags.
- * This makes it trivial to render embedded VTL (Velocity Template Language)
- * or include a separate Velocity template within a JSP using the current
- * page context. This also automatically provides the typical
- * {@link VelocityView} toolbox support, much like the VelocityViewServlet
- * and VelocityLayoutServlets have. In fact, this will by default share
- * the {@link VelocityView} instance used with those servlets. This allows
- * for consistent configuration and shared resources (better performance).
- * </p>
- *
- * @author Nathan Bubna
- * @version $Id: VelocityViewTag.java,v 1.1 2001/08/14 00:07:39 geirm Exp $
- * @since VelocityTools 2.0
- */
-public class VelocityViewTag extends BodyTagSupport
-{
- public static final String DEFAULT_BODY_CONTENT_KEY = "bodyContent";
- private static final long serialVersionUID = -3329444102562079189L;
-
- protected transient VelocityView view;
- protected transient ViewToolContext context;
- protected transient StringResourceRepository repository;
-
- protected String var;
- protected String scope;
- protected String template;
- protected String bodyContentKey = DEFAULT_BODY_CONTENT_KEY;
- private boolean cache = false;
-
- /**
- * Release any per-invocation resources, resetting any resources or state
- * that should be cleared between successive invocations of
- * {@link jakarta.servlet.jsp.tagext.Tag#doEndTag()} and
- * {@link jakarta.servlet.jsp.tagext.Tag#doStartTag()}.
- */
- protected void reset()
- {
- super.setId(null);
- var = null;
- scope = null;
- template = null;
- bodyContentKey = DEFAULT_BODY_CONTENT_KEY;
- cache = false;
- }
-
- public void setId(String id)
- {
- if (id == null)
- {
- throw new NullPointerException("id cannot be null");
- }
- super.setId(id);
- // assume they want this cached
- cache = true;
- }
-
- protected String getLogId()
- {
- String id = super.getId();
- if (id == null)
- {
- id = getClass().getSimpleName();
- }
- return id;
- }
-
- public void setVar(String var)
- {
- this.var = var;
- }
-
- public String getVar()
- {
- return this.var;
- }
-
- public void setScope(String scope)
- {
- this.scope = scope;
- }
-
- public String getScope()
- {
- return this.scope;
- }
-
- public void setTemplate(String template)
- {
- this.template = template;
- }
-
- public String getTemplate()
- {
- return this.template;
- }
-
- public void setBodyContentKey(String key)
- {
- this.bodyContentKey = DEFAULT_BODY_CONTENT_KEY;
- }
-
- public String getBodyContentKey()
- {
- return this.bodyContentKey;
- }
-
- public void setCache(String s)
- {
- this.cache = "true".equalsIgnoreCase(s);
- }
-
- public String getCache()
- {
- return String.valueOf(this.cache);
- }
-
- public VelocityView getVelocityView()
- {
- return this.view;
- }
-
- public void setVelocityView(VelocityView view)
- {
- this.view = view;
- }
-
- public ViewToolContext getViewToolContext()
- {
- return this.context;
- }
-
- public void setViewToolContext(ViewToolContext context)
- {
- this.context = context;
- }
-
- public StringResourceRepository getRepository()
- {
- if (this.repository == null)
- {
- setRepository(StringResourceLoader.getRepository());
- }
- return this.repository;
- }
-
- public void setRepository(StringResourceRepository repo)
- {
- this.repository = repo;
- }
-
- public int doStartTag() throws JspException
- {
- initializeView();
-
- return EVAL_BODY_BUFFERED;
- }
-
- public int doEndTag() throws JspException
- {
- if (hasContent())
- {
- try
- {
- // check for a var attribute
- String varname = getVar();
- if (varname == null)
- {
- // if none, render into the pageout
- renderContent(this.pageContext.getOut());
- }
- else
- {
- // if we have a var, render into a string
- StringWriter out = new StringWriter();
- renderContent(out);
-
- // and insert the string into the specified scope
- // if none specified, default is PAGE_SCOPE
- this.pageContext.setAttribute(varname,
- out.toString(),
- toScopeInt(getScope()));
- }
- }
- catch (Exception e)
- {
- throw new JspException("Failed to render " + getClass() +
- ": "+getLogId(), e);
- }
- }
- return EVAL_PAGE;
- }
-
-
- protected void initializeView()
- {
- // get the VelocityView for this app
- VelocityView view =
- ServletUtils.getVelocityView(this.pageContext.getServletConfig());
-
- // now make a Context
- ViewToolContext context =
- new JspToolContext(view.getVelocityEngine(), this.pageContext);
-
- view.prepareContext(context, (HttpServletRequest)this.pageContext.getRequest());
-
- setVelocityView(view);
- setViewToolContext(context);
- }
-
- protected boolean hasContent()
- {
- return (getBodyContent() != null || getTemplate() != null);
- }
-
- protected void renderContent(Writer out) throws Exception
- {
- if (getTemplate() != null)
- {
- VelocityView view = getVelocityView();
- ViewToolContext context = getViewToolContext();
-
- // get the actual Template
- Template template = view.getTemplate(getTemplate());
-
- if (getBodyContent() != null)
- {
- context.put(getBodyContentKey(), getRenderedBody());
- }
-
- // render the template into the writer
- template.merge(context, out);
- }
- else
- {
- // render the body into the writer
- renderBody(out);
- }
- }
-
- protected String getRenderedBody() throws Exception
- {
- // render the body into a string
- StringWriter out = new StringWriter();
- renderBody(out);
- return out.toString();
- }
-
- protected boolean isCached()
- {
- return getRepository().getStringResource(getId()) != null;
- }
-
- protected void renderBody(Writer out) throws Exception
- {
- String name = getId();
- // if it hasn't been cached, try that
- if (cache && !isCached())
- {
- String template = getBodyContent().getString();
- // if no id was set, use the template as the id
- if (name == null)
- {
- name = template;
- }
- cache(name, template);
- }
- // if it can't be cached, eval it
- if (!cache)
- {
- evalBody(out);
- }
- else
- {
- // load template from cache
- Template template = getVelocityView().getTemplate(name);
- template.merge(getViewToolContext(), out);
- }
- }
-
- protected void evalBody(Writer out) throws Exception
- {
- VelocityEngine engine = getVelocityView().getVelocityEngine();
- engine.evaluate(getViewToolContext(), out, getLogId(),
- getBodyContent().getReader());
- }
-
- protected static int toScopeInt(String scope)
- {
- if (scope == null)
- {
- return PageContext.PAGE_SCOPE;
- }
- if (scope.equalsIgnoreCase("request"))
- {
- return PageContext.REQUEST_SCOPE;
- }
- if (scope.equalsIgnoreCase("session"))
- {
- return PageContext.SESSION_SCOPE;
- }
- if (scope.equalsIgnoreCase("application"))
- {
- return PageContext.APPLICATION_SCOPE;
- }
- if (scope.equalsIgnoreCase("page"))
- {
- return PageContext.PAGE_SCOPE;
- }
- throw new IllegalArgumentException("Unknown scope: "+scope);
- }
-
- protected void cache(String name, String template)
- {
- try
- {
- getRepository().putStringResource(name, template);
- }
- catch (Exception cnfe)
- {
- getVelocityView().getLog()
- .error("Could not cache body in a StringResourceRepository", cnfe);
- cache = false;
- }
- }
-
- /**
- * Release any per-instance resources, releasing any resources or state
- * before this tag instance is disposed.
- *
- * @see jakarta.servlet.jsp.tagext.Tag#release()
- */
- @Override
- public void release()
- {
- super.release();
- reset();
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponse.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponse.java
deleted file mode 100644
index 9151145e..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponse.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * $Id: ExternalWriterHttpServletResponse.java 892369 2009-12-18 20:21:36Z apetrelli $
- *
- * 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.velocity.tools.view.jsp.jspimpl;
-
-import java.io.PrintWriter;
-
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.HttpServletResponseWrapper;
-
-/**
- * Copied from Tiles Request sandbox.
- *
- * Wraps an HTTP response and overrides its print writer.
- *
- * @version $Rev: 892369 $ $Date: 2009-12-18 21:21:36 +0100 (ven, 18 dic 2009) $
- * @since 2.2.0
- */
-public class ExternalWriterHttpServletResponse extends
- HttpServletResponseWrapper {
-
- /**
- * 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
- */
- public ExternalWriterHttpServletResponse(HttpServletResponse response, PrintWriter writer) {
- super(response);
- this.writer = writer;
- }
-
- /** {@inheritDoc} */
- @Override
- public PrintWriter getWriter() {
- return writer;
- }
-}
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtils.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtils.java
deleted file mode 100644
index 94c56afc..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtils.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-/*
- * 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.
- */
-
-import java.io.IOException;
-
-import jakarta.servlet.jsp.JspException;
-import jakarta.servlet.jsp.PageContext;
-import jakarta.servlet.jsp.tagext.BodyContent;
-import jakarta.servlet.jsp.tagext.BodyTag;
-import jakarta.servlet.jsp.tagext.JspTag;
-import jakarta.servlet.jsp.tagext.SimpleTag;
-import jakarta.servlet.jsp.tagext.Tag;
-import jakarta.servlet.jsp.tagext.TagAdapter;
-
-import org.apache.velocity.context.Context;
-import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.runtime.parser.node.ASTBlock;
-import org.apache.velocity.runtime.parser.node.Node;
-
-/**
- * Some utilities to work with JSP.
- */
-public class JspUtils
-{
- /**
- * The attribute name under which the latest encountered tag is put.
- */
- private final static String LATEST_TAG_ATTRIBUTE_NAME = "org.apache.velocity.tools.view.jsp.taglib.jspimpl.LATEST_TAG";
-
- /**
- * Sets the latest tag encountered.
- *
- * @param context The Velocity context.
- * @param tag The tag.
- */
- public static void setLatestTag(Context context, JspTag tag) {
- context.put(LATEST_TAG_ATTRIBUTE_NAME, tag);
- }
-
- /**
- * Returns the latest tag encountered.
- *
- * @param context The Velocity context.
- * @return The latest tag.
- */
- public static JspTag getLatestJspTag(Context context) {
- return (JspTag) context.get(LATEST_TAG_ATTRIBUTE_NAME);
- }
-
- /**
- * If necessary, wraps a {@link SimpleTag} into a {@link Tag}.
- *
- * @param tag The tag to (possibly) wrap.
- * @return The wrapped tag, or the tag passed as parameter if it was not necessary.
- */
- public static Tag wrapTag(JspTag tag) {
- if (tag == null) {
- return null;
- }
- if (tag instanceof Tag)
- {
- return (Tag) tag;
- }
- if (tag instanceof SimpleTag)
- {
- return new TagAdapter((SimpleTag) tag);
- }
- throw new VelocityToolsJspException(
- "Cannot get tag that is not a Tag nor a SimpleTag, class "
- + tag.getClass().getCanonicalName());
- }
-
- /**
- * Executes a {@link SimpleTag}.
- *
- * @param context The directive context.
- * @param node The main node of the directive.
- * @param pageContext The page context.
- * @param tag The tag to execute.
- * @throws JspException If something goes wrong.
- * @throws IOException If something goes wrong.
- */
- public static void executeSimpleTag(InternalContextAdapter context,
- Node node, PageContext pageContext, SimpleTag tag)
- throws JspException, IOException
- {
- tag.setJspBody(new VelocityJspFragment(pageContext, (ASTBlock) node
- .jjtGetChild(1), context));
- tag.doTag();
- }
-
- /**
- * Executes a {@link Tag}.
- *
- * @param context The directive context.
- * @param node The main node of the directive.
- * @param pageContext The page context.
- * @param tag The tag to execute.
- * @throws JspException If something goes wrong.
- */
- public static void executeTag(InternalContextAdapter context, Node node,
- PageContext pageContext, Tag tag) throws JspException
- {
- int result = tag.doStartTag();
- if (tag instanceof BodyTag)
- {
- BodyTag bodyTag = (BodyTag) tag;
- BodyContent bodyContent = new VelocityBodyContent(
- pageContext.getOut(), (ASTBlock) node.jjtGetChild(1),
- context);
- switch (result)
- {
- case BodyTag.EVAL_BODY_BUFFERED:
- bodyTag.setBodyContent(bodyContent);
- bodyTag.doInitBody();
- case BodyTag.EVAL_BODY_INCLUDE:
- bodyContent.getString();
- default:
- break;
- }
- while (bodyTag.doAfterBody() == BodyTag.EVAL_BODY_AGAIN) {
- bodyContent.getString();
- }
- }
- tag.doEndTag();
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImpl.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImpl.java
deleted file mode 100644
index bea72b9c..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImpl.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * 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.velocity.tools.view.jsp.jspimpl;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import jakarta.servlet.jsp.JspWriter;
-
-/**
- * Copied and modified from Tomcat 6.0.x source.
- *
- * Write text to a character-output stream, buffering characters so as
- * to provide for the efficient writing of single characters, arrays,
- * and strings.
- *
- * Provide support for discarding for the output that has been
- * buffered.
- *
- * This needs revisiting when the buffering problems in the JSP spec
- * are fixed -akv
- *
- * @author Anil K. Vijendran
- */
-public class JspWriterImpl extends JspWriter {
-
- private Writer out;
-
- /**
- * Create a buffered character-output stream that uses a default-sized
- * output buffer.
- *
- * @param out The writer.
- */
- public JspWriterImpl(Writer out) {
- super(0, true);
- this.out = out;
- }
-
- /**
- * Discard the output buffer.
- */
- public final void clear() throws IOException {
- throw new IllegalStateException("Cannot clear after an unbuffered output");
- }
-
- public void clearBuffer() throws IOException {
- throw new IllegalStateException("Cannot clear after an unbuffered output");
- }
-
- /**
- * Flush the stream.
- *
- */
- public void flush() throws IOException {
- out.flush();
- }
-
- /**
- * Close the stream.
- *
- */
- public void close() throws IOException {
- out.close();
- }
-
- /**
- * @return the number of bytes unused in the buffer
- */
- public int getRemaining() {
- return 0;
- }
-
-
- /**
- * Write a single character.
- */
- public void write(int c) throws IOException {
- out.write(c);
- }
-
- /**
- * Write a portion of an array of characters.
- *
- * <p> Ordinarily this method stores characters from the given array into
- * this stream's buffer, flushing the buffer to the underlying stream as
- * needed. If the requested length is at least as large as the buffer,
- * however, then this method will flush the buffer and write the characters
- * directly to the underlying stream. Thus redundant
- * <code>DiscardableBufferedWriter</code>s will not copy data unnecessarily.
- *
- * @param cbuf A character array
- * @param off Offset from which to start reading characters
- * @param len Number of characters to write
- */
- public void write(char cbuf[], int off, int len)
- throws IOException
- {
- out.write(cbuf, off, len);
- }
-
- /**
- * Write an array of characters. This method cannot be inherited from the
- * Writer class because it must suppress I/O exceptions.
- */
- public void write(char buf[]) throws IOException {
- write(buf, 0, buf.length);
- }
-
- /**
- * Write a portion of a String.
- *
- * @param s String to be written
- * @param off Offset from which to start reading characters
- * @param len Number of characters to be written
- */
- public void write(String s, int off, int len) throws IOException {
- out.write(s, off, len);
- }
-
- /**
- * Write a string. This method cannot be inherited from the Writer class
- * because it must suppress I/O exceptions.
- */
- public void write(String s) throws IOException {
- // Simple fix for Bugzilla 35410
- // Calling the other write function so as to init the buffer anyways
- if(s == null) {
- write(s, 0, 0);
- } else {
- write(s, 0, s.length());
- }
- }
-
-
- static String lineSeparator = System.getProperty("line.separator");
-
- /**
- * Write a line separator. The line separator string is defined by the
- * system property <tt>line.separator</tt>, and is not necessarily a single
- * newline ('\n') character.
- *
- * @exception IOException If an I/O error occurs
- */
-
- public void newLine() throws IOException {
- write(lineSeparator);
- }
-
-
- /* Methods that do not terminate lines */
-
- /**
- * Print a boolean value. The string produced by <code>{@link
- * java.lang.String#valueOf(boolean)}</code> is translated into bytes
- * according to the platform's default character encoding, and these bytes
- * are written in exactly the manner of the <code>{@link
- * #write(int)}</code> method.
- *
- * @param b The <code>boolean</code> to be printed
- */
- public void print(boolean b) throws IOException {
- write(b ? "true" : "false");
- }
-
- /**
- * Print a character. The character is translated into one or more bytes
- * according to the platform's default character encoding, and these bytes
- * are written in exactly the manner of the <code>{@link
- * #write(int)}</code> method.
- *
- * @param c The <code>char</code> to be printed
- */
- public void print(char c) throws IOException {
- write(String.valueOf(c));
- }
-
- /**
- * Print an integer. The string produced by <code>{@link
- * java.lang.String#valueOf(int)}</code> is translated into bytes according
- * to the platform's default character encoding, and these bytes are
- * written in exactly the manner of the <code>{@link #write(int)}</code>
- * method.
- *
- * @param i The <code>int</code> to be printed
- */
- public void print(int i) throws IOException {
- write(String.valueOf(i));
- }
-
- /**
- * Print a long integer. The string produced by <code>{@link
- * java.lang.String#valueOf(long)}</code> is translated into bytes
- * according to the platform's default character encoding, and these bytes
- * are written in exactly the manner of the <code>{@link #write(int)}</code>
- * method.
- *
- * @param l The <code>long</code> to be printed
- */
- public void print(long l) throws IOException {
- write(String.valueOf(l));
- }
-
- /**
- * Print a floating-point number. The string produced by <code>{@link
- * java.lang.String#valueOf(float)}</code> is translated into bytes
- * according to the platform's default character encoding, and these bytes
- * are written in exactly the manner of the <code>{@link #write(int)}</code>
- * method.
- *
- * @param f The <code>float</code> to be printed
- */
- public void print(float f) throws IOException {
- write(String.valueOf(f));
- }
-
- /**
- * Print a double-precision floating-point number. The string produced by
- * <code>{@link java.lang.String#valueOf(double)}</code> is translated into
- * bytes according to the platform's default character encoding, and these
- * bytes are written in exactly the manner of the <code>{@link
- * #write(int)}</code> method.
- *
- * @param d The <code>double</code> to be printed
- */
- public void print(double d) throws IOException {
- write(String.valueOf(d));
- }
-
- /**
- * Print an array of characters. The characters are converted into bytes
- * according to the platform's default character encoding, and these bytes
- * are written in exactly the manner of the <code>{@link #write(int)}</code>
- * method.
- *
- * @param s The array of chars to be printed
- *
- * @throws NullPointerException If <code>s</code> is <code>null</code>
- */
- public void print(char s[]) throws IOException {
- write(s);
- }
-
- /**
- * Print a string. If the argument is <code>null</code> then the string
- * <code>"null"</code> is printed. Otherwise, the string's characters are
- * converted into bytes according to the platform's default character
- * encoding, and these bytes are written in exactly the manner of the
- * <code>{@link #write(int)}</code> method.
- *
- * @param s The <code>String</code> to be printed
- */
- public void print(String s) throws IOException {
- if (s == null) {
- s = "null";
- }
- write(s);
- }
-
- /**
- * Print an object. The string produced by the <code>{@link
- * java.lang.String#valueOf(Object)}</code> method is translated into bytes
- * according to the platform's default character encoding, and these bytes
- * are written in exactly the manner of the <code>{@link #write(int)}</code>
- * method.
- *
- * @param obj The <code>Object</code> to be printed
- */
- public void print(Object obj) throws IOException {
- write(String.valueOf(obj));
- }
-
- /* Methods that do terminate lines */
-
- /**
- * Terminate the current line by writing the line separator string. The
- * line separator string is defined by the system property
- * <code>line.separator</code>, and is not necessarily a single newline
- * character (<code>'\n'</code>).
- *
- * Need to change this from PrintWriter because the default
- * println() writes to the sink directly instead of through the
- * write method...
- */
- public void println() throws IOException {
- newLine();
- }
-
- /**
- * Print a boolean value and then terminate the line. This method behaves
- * as though it invokes <code>{@link #print(boolean)}</code> and then
- * <code>{@link #println()}</code>.
- */
- public void println(boolean x) throws IOException {
- print(x);
- println();
- }
-
- /**
- * Print a character and then terminate the line. This method behaves as
- * though it invokes <code>{@link #print(char)}</code> and then <code>{@link
- * #println()}</code>.
- */
- public void println(char x) throws IOException {
- print(x);
- println();
- }
-
- /**
- * Print an integer and then terminate the line. This method behaves as
- * though it invokes <code>{@link #print(int)}</code> and then <code>{@link
- * #println()}</code>.
- */
- public void println(int x) throws IOException {
- print(x);
- println();
- }
-
- /**
- * Print a long integer and then terminate the line. This method behaves
- * as though it invokes <code>{@link #print(long)}</code> and then
- * <code>{@link #println()}</code>.
- */
- public void println(long x) throws IOException {
- print(x);
- println();
- }
-
- /**
- * Print a floating-point number and then terminate the line. This method
- * behaves as though it invokes <code>{@link #print(float)}</code> and then
- * <code>{@link #println()}</code>.
- */
- public void println(float x) throws IOException {
- print(x);
- println();
- }
-
- /**
- * Print a double-precision floating-point number and then terminate the
- * line. This method behaves as though it invokes <code>{@link
- * #print(double)}</code> and then <code>{@link #println()}</code>.
- */
- public void println(double x) throws IOException {
- print(x);
- println();
- }
-
- /**
- * Print an array of characters and then terminate the line. This method
- * behaves as though it invokes <code>{@link #print(char[])}</code> and then
- * <code>{@link #println()}</code>.
- */
- public void println(char x[]) throws IOException {
- print(x);
- println();
- }
-
- /**
- * Print a String and then terminate the line. This method behaves as
- * though it invokes <code>{@link #print(String)}</code> and then
- * <code>{@link #println()}</code>.
- */
- public void println(String x) throws IOException {
- print(x);
- println();
- }
-
- /**
- * Print an Object and then terminate the line. This method behaves as
- * though it invokes <code>{@link #print(Object)}</code> and then
- * <code>{@link #println()}</code>.
- */
- public void println(Object x) throws IOException {
- print(x);
- println();
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContent.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContent.java
deleted file mode 100644
index d3fe99cc..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContent.java
+++ /dev/null
@@ -1,259 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-/*
- * 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.
- */
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import jakarta.servlet.jsp.JspWriter;
-import jakarta.servlet.jsp.tagext.BodyContent;
-
-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.parser.node.ASTBlock;
-
-/**
- * Publishes a block inside a Velocity directive as a {@link BodyContent}.
- *
- */
-public class VelocityBodyContent extends BodyContent
-{
-
- /**
- * The block to expose.
- */
- private ASTBlock block;
-
- /**
- * The directive context.
- */
- private InternalContextAdapter context;
-
- /**
- * Constructor.
- *
- * @param jspWriter The JSP writer to be used by default.
- * @param block The block to wrap.
- * @param context The directive context.
- */
- public VelocityBodyContent(JspWriter jspWriter, ASTBlock block,
- InternalContextAdapter context)
- {
- super(jspWriter);
- this.block = block;
- this.context = context;
- }
-
- @Override
- public Reader getReader()
- {
- return new StringReader(getString());
- }
-
- @Override
- public String getString()
- {
- StringWriter stringWriter = new StringWriter();
- try
- {
- block.render(context, stringWriter);
- stringWriter.close();
- return stringWriter.toString();
- } catch (MethodInvocationException e)
- {
- throw new VelocityToolsJspException(
- "Cannot invoke a method while rendering a body", e);
- } catch (ResourceNotFoundException e)
- {
- throw new VelocityToolsJspException(
- "Cannot find a resource while rendering a body", e);
- } catch (ParseErrorException e)
- {
- throw new VelocityToolsJspException(
- "Cannot parse while rendering a body", e);
- } catch (IOException e)
- {
- throw new VelocityToolsJspException(
- "I/O exception while rendering a body", e);
- }
- }
-
- @Override
- public void writeOut(Writer out) throws IOException
- {
- block.render(context, out);
- }
-
- @Override
- public void newLine() throws IOException
- {
- getEnclosingWriter().newLine();
- }
-
- @Override
- public void print(boolean b) throws IOException
- {
- getEnclosingWriter().print(b);
- }
-
- @Override
- public void print(char c) throws IOException
- {
- getEnclosingWriter().print(c);
- }
-
- @Override
- public void print(int i) throws IOException
- {
- getEnclosingWriter().print(i);
- }
-
- @Override
- public void print(long l) throws IOException
- {
- getEnclosingWriter().print(l);
- }
-
- @Override
- public void print(float f) throws IOException
- {
- getEnclosingWriter().print(f);
- }
-
- @Override
- public void print(double d) throws IOException
- {
- getEnclosingWriter().print(d);
- }
-
- @Override
- public void print(char[] s) throws IOException
- {
- getEnclosingWriter().print(s);
- }
-
- @Override
- public void print(String s) throws IOException
- {
- getEnclosingWriter().print(s);
- }
-
- @Override
- public void print(Object obj) throws IOException
- {
- getEnclosingWriter().print(obj);
- }
-
- @Override
- public void println() throws IOException
- {
- getEnclosingWriter().println();
- }
-
- @Override
- public void println(boolean x) throws IOException
- {
- getEnclosingWriter().println(x);
- }
-
- @Override
- public void println(char x) throws IOException
- {
- getEnclosingWriter().println(x);
- }
-
- @Override
- public void println(int x) throws IOException
- {
- getEnclosingWriter().println(x);
- }
-
- @Override
- public void println(long x) throws IOException
- {
- getEnclosingWriter().println(x);
- }
-
- @Override
- public void println(float x) throws IOException
- {
- getEnclosingWriter().println(x);
- }
-
- @Override
- public void println(double x) throws IOException
- {
- getEnclosingWriter().println(x);
- }
-
- @Override
- public void println(char[] x) throws IOException
- {
- getEnclosingWriter().println(x);
- }
-
- @Override
- public void println(String x) throws IOException
- {
- getEnclosingWriter().println(x);
- }
-
- @Override
- public void println(Object x) throws IOException
- {
- getEnclosingWriter().println(x);
- }
-
- @Override
- public void clear() throws IOException
- {
- getEnclosingWriter().clear();
- }
-
- @Override
- public void clearBuffer() throws IOException
- {
- getEnclosingWriter().clearBuffer();
- }
-
- @Override
- public void close() throws IOException
- {
- getEnclosingWriter().close();
- }
-
- @Override
- public int getRemaining()
- {
- return getEnclosingWriter().getRemaining();
- }
-
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException
- {
- getEnclosingWriter().write(cbuf, off, len);
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragment.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragment.java
deleted file mode 100644
index 11acddf0..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragment.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-/*
- * 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.
- */
-
-import java.io.IOException;
-import java.io.Writer;
-
-import jakarta.servlet.jsp.JspContext;
-import jakarta.servlet.jsp.JspException;
-import jakarta.servlet.jsp.PageContext;
-import jakarta.servlet.jsp.tagext.JspFragment;
-
-import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.runtime.parser.node.ASTBlock;
-
-/**
- * Exposes a directive body block as a {@link JspFragment}, i.e. the body of SimpleTag.
- *
- */
-public class VelocityJspFragment extends JspFragment
-{
-
- /**
- * The JSP page context.
- */
- private PageContext pageContext;
-
- /**
- * The block to wrap.
- */
- private ASTBlock block;
-
- /**
- * The directive context.
- */
- private InternalContextAdapter context;
-
- /**
- * Constructor.
- *
- * @param pageContext The page context to use.
- * @param block The block to wrap.
- * @param context The directive context.
- */
- public VelocityJspFragment(PageContext pageContext, ASTBlock block,
- InternalContextAdapter context)
- {
- this.pageContext = pageContext;
- this.block = block;
- this.context = context;
- }
-
- @Override
- public void invoke(Writer out) throws JspException, IOException
- {
- block.render(context, out);
- }
-
- @Override
- public JspContext getJspContext()
- {
- return pageContext;
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContext.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContext.java
deleted file mode 100644
index 8e221d96..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContext.java
+++ /dev/null
@@ -1,434 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-/*
- * 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.
- */
-
-import jakarta.el.ELContext;
-import jakarta.servlet.RequestDispatcher;
-import jakarta.servlet.Servlet;
-import jakarta.servlet.ServletConfig;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.ServletRequest;
-import jakarta.servlet.ServletResponse;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.HttpSession;
-import jakarta.servlet.jsp.JspWriter;
-import jakarta.servlet.jsp.PageContext;
-import jakarta.servlet.jsp.el.ExpressionEvaluator;
-import jakarta.servlet.jsp.el.VariableResolver;
-import org.apache.velocity.context.Context;
-import org.apache.velocity.tools.view.ViewContext;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-/**
- * Exposes a Velocity {@link Context}, a request and a response as a {@link PageContext}.
- *
- */
-public class VelocityPageContext extends PageContext {
-
- /**
- * The Velocity context.
- */
- private Context velocityContext;
-
- /**
- * The writer to use when writing content.
- */
- private Writer velocityWriter;
-
- /**
- * The view context.
- */
- private ViewContext viewContext;
-
- /**
- * The JSP writer, simulated.
- */
- private JspWriter jspWriter;
-
- /**
- * The HTTP request.
- */
- private HttpServletRequest request;
-
- /**
- * The HTTP response.
- */
- private HttpServletResponse response;
-
- /**
- * Constructor.
- *
- * @param velocityContext The Velocity context.
- * @param velocityWriter The writer to be used when writing content.
- * @param viewContext The View context.
- */
- public VelocityPageContext(Context velocityContext, Writer velocityWriter, ViewContext viewContext)
- {
- this.velocityContext = velocityContext;
- this.velocityWriter = velocityWriter;
- this.viewContext = viewContext;
- this.request = viewContext.getRequest();
- this.response = viewContext.getResponse();
- jspWriter = new JspWriterImpl(velocityWriter);
- velocityContext.put("out", jspWriter);
- }
-
- @Override
- public void initialize(Servlet servlet, ServletRequest request,
- ServletResponse response, String errorPageURL,
- boolean needsSession, int bufferSize, boolean autoFlush)
- throws IOException, IllegalStateException, IllegalArgumentException {
- // We never call it and we discard this object at the end of the page call.
- }
-
- @Override
- public void release() {
- // We never call it and we discard this object at the end of the page call.
- }
-
- @Override
- public HttpSession getSession() {
- return request.getSession(false);
- }
-
- @Override
- public Object getPage() {
- return viewContext;
- }
-
- @Override
- public ServletRequest getRequest() {
- return request;
- }
-
- @Override
- public ServletResponse getResponse() {
- return response;
- }
-
- @Override
- public Exception getException() {
- return null;
- }
-
- @Override
- public ServletConfig getServletConfig() {
- throw new UnsupportedOperationException("Servlet config is not supported");
- }
-
- @Override
- public ServletContext getServletContext() {
- return viewContext.getServletContext();
- }
-
- @Override
- public void forward(String relativeUrlPath) throws ServletException,
- IOException {
- RequestDispatcher dispatcher = request.getRequestDispatcher(relativeUrlPath);
- if (dispatcher == null) {
- throw new IllegalArgumentException("Cannot forward to '" +relativeUrlPath + "'");
- }
- dispatcher.forward(request, new ExternalWriterHttpServletResponse(response, new PrintWriter(velocityWriter)));
-
- }
-
- @Override
- public void include(String relativeUrlPath) throws ServletException,
- IOException {
- include(relativeUrlPath, true);
- }
-
- @Override
- public void include(String relativeUrlPath, boolean flush)
- throws ServletException, IOException {
- if (flush) {
- velocityWriter.flush();
- }
- RequestDispatcher dispatcher = request.getRequestDispatcher(relativeUrlPath);
- if (dispatcher == null) {
- throw new IllegalArgumentException("Cannot include '" +relativeUrlPath + "'");
- }
- dispatcher.include(request, new ExternalWriterHttpServletResponse(response, new PrintWriter(velocityWriter)));
- }
-
- @Override
- public void handlePageException(Exception e) throws ServletException,
- IOException {
- handlePageException((Throwable) e);
- }
-
- @Override
- public void handlePageException(Throwable t) throws ServletException,
- IOException {
- if (t instanceof RuntimeException)
- {
- throw (RuntimeException) t;
- }
- if (t instanceof Error)
- {
- throw (Error) t;
- }
- throw new ServletException("Rethrowing unmanaged exception", t);
- }
-
- @Override
- public void setAttribute(String name, Object value) {
- if (name == null) {
- throw new NullPointerException("The attribute name is null");
- }
- velocityContext.put(name, value);
- }
-
- @Override
- public void setAttribute(String name, Object value, int scope) {
- if (name == null) {
- throw new NullPointerException("The attribute name is null");
- }
- switch (scope)
- {
- case PAGE_SCOPE:
- velocityContext.put(name, value);
- break;
- case REQUEST_SCOPE:
- request.setAttribute(name, value);
- break;
- case SESSION_SCOPE:
- if (value == null) {
- HttpSession session = request.getSession(false);
- if (session != null) {
- session.removeAttribute(name);
- }
- } else {
- HttpSession session = request.getSession();
- session.setAttribute(name, value);
- }
- break;
- case APPLICATION_SCOPE:
- viewContext.getServletContext().setAttribute(name, value);
- break;
- default:
- throw new IllegalArgumentException("Invalid scope constant value: " + scope);
- }
- }
-
- @Override
- public Object getAttribute(String name) {
- if (name == null) {
- throw new NullPointerException("The attribute name is null");
- }
- return velocityContext.get(name);
- }
-
- @Override
- public Object getAttribute(String name, int scope) {
- if (name == null) {
- throw new NullPointerException("The attribute name is null");
- }
- switch (scope)
- {
- case PAGE_SCOPE:
- return velocityContext.get(name);
- case REQUEST_SCOPE:
- return request.getAttribute(name);
- case SESSION_SCOPE:
- HttpSession session = request.getSession(false);
- if (session != null) {
- return session.getAttribute(name);
- } else {
- return null;
- }
- case APPLICATION_SCOPE:
- return viewContext.getServletContext().getAttribute(name);
- default:
- throw new IllegalArgumentException("Invalid scope constant value: " + scope);
- }
- }
-
- @Override
- public Object findAttribute(String name) {
- if (name == null) {
- throw new NullPointerException("The attribute name is null");
- }
- Object candidate = velocityContext.get(name);
- if (candidate == null) {
- candidate = request.getAttribute(name);
- if (candidate == null) {
- HttpSession session = request.getSession(false);
- if (session != null) {
- candidate = session.getAttribute(name);
- }
- if (candidate == null) {
- candidate = viewContext.getServletContext().getAttribute(name);
- }
- }
- }
- return candidate;
- }
-
- @Override
- public void removeAttribute(String name) {
- if (name == null) {
- throw new NullPointerException("The attribute name is null");
- }
- velocityContext.remove(name);
- request.removeAttribute(name);
- HttpSession session = request.getSession(false);
- if (session != null) {
- session.removeAttribute(name);
- }
- viewContext.getServletContext().removeAttribute(name);
- }
-
- @Override
- public void removeAttribute(String name, int scope) {
- if (name == null) {
- throw new NullPointerException("The attribute name is null");
- }
- switch (scope)
- {
- case PAGE_SCOPE:
- velocityContext.remove(name);
- break;
- case REQUEST_SCOPE:
- request.removeAttribute(name);
- break;
- case SESSION_SCOPE:
- HttpSession session = request.getSession(false);
- if (session != null) {
- session.removeAttribute(name);
- }
- break;
- case APPLICATION_SCOPE:
- viewContext.getServletContext().removeAttribute(name);
- break;
- default:
- throw new IllegalArgumentException("Invalid scope constant value: " + scope);
- }
- }
-
- @Override
- public int getAttributesScope(String name) {
- if (name == null) {
- throw new NullPointerException("The attribute name is null");
- }
- if (velocityContext.get(name) != null) {
- return PAGE_SCOPE;
- }
- if (request.getAttribute(name) != null) {
- return REQUEST_SCOPE;
- }
- HttpSession session = request.getSession(false);
- if (session != null) {
- if (session.getAttribute(name) != null) {
- return SESSION_SCOPE;
- }
- }
- if (viewContext.getServletContext().getAttribute(name) != null) {
- return APPLICATION_SCOPE;
- }
- return 0;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Enumeration<String> getAttributeNamesInScope(int scope) {
- switch (scope)
- {
- case PAGE_SCOPE:
- return new Enumeration<String>()
- {
-
- private int index = 0;
-
- private Object[] keys = velocityContext.getKeys();
-
- public boolean hasMoreElements()
- {
- return index < keys.length;
- }
-
- public String nextElement()
- {
- String retValue = (String) keys[index];
- index++;
- return retValue;
- }
- };
- case REQUEST_SCOPE:
- return request.getAttributeNames();
- case SESSION_SCOPE:
- HttpSession session = request.getSession(false);
- if (session != null) {
- return session.getAttributeNames();
- }
- return new Enumeration<String>()
- {
-
- public boolean hasMoreElements()
- {
- return false;
- }
-
- public String nextElement()
- {
- throw new NoSuchElementException("This is an empty enumeration");
- }
- };
- case APPLICATION_SCOPE:
- return viewContext.getServletContext().getAttributeNames();
- default:
- throw new IllegalArgumentException("Invalid scope constant value: " + scope);
- }
- }
-
- @Override
- public JspWriter getOut() {
- return jspWriter;
- }
-
- @SuppressWarnings("deprecation")
- @Override
- @Deprecated(forRemoval = true)
- public jakarta.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator() {
- // Really, who cares?
- throw new UnsupportedOperationException("This method is removed in jsp api version 4");
- }
-
- @SuppressWarnings("deprecation")
- @Override
- @Deprecated(forRemoval = true)
- public jakarta.servlet.jsp.el.VariableResolver getVariableResolver() {
- // Really, who cares?
- throw new UnsupportedOperationException("This method is removed in jsp api version 4");
- }
-
- @Override
- public ELContext getELContext() {
- // Really, who cares?
- throw new UnsupportedOperationException("EL not available at this point");
- }
-}
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityToolsJspException.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityToolsJspException.java
deleted file mode 100644
index 65e19c9d..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityToolsJspException.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-/*
- * 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.
- */
-
-/**
- * An exception thrown when something bad happens in JSP support for Velocity.
- *
- */
-public class VelocityToolsJspException extends RuntimeException
-{
-
- /**
- * The serial version UID.
- */
- private static final long serialVersionUID = 7627800888526325645L;
-
- /**
- * Constructor.
- */
- public VelocityToolsJspException()
- {
- }
-
- /**
- * Constructor.
- *
- * @param message The message of the exception.
- */
- public VelocityToolsJspException(String message)
- {
- super(message);
- }
-
- /**
- * Constructor.
- *
- * @param cause The cause.
- */
- public VelocityToolsJspException(Throwable cause)
- {
- super(cause);
- }
-
- /**
- * Constructor.
- *
- * @param message The message of the exception.
- * @param cause The cause.
- */
- public VelocityToolsJspException(String message, Throwable cause)
- {
- super(message, cause);
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/package-info.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/package-info.java
deleted file mode 100644
index b61c18f3..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/jspimpl/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * $Id: package-info.java 1044659 2010-12-11 14:16:04Z apetrelli $
- *
- * 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.
- */
-/**
- * Contains JSP-simulating classes that allows the use of a Velocity environment
- * under JSP specific classes, like tags.
- */
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
diff --git a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/package-info.java b/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/package-info.java
deleted file mode 100644
index 8f36248f..00000000
--- a/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * $Id: package-info.java 1044659 2010-12-11 14:16:04Z apetrelli $
- *
- * 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.
- */
-/**
- * JSP support of Velocity (and vice-versa).
- */
-package org.apache.velocity.tools.view.jsp;
-
diff --git a/velocity-tools-view-jsp/src/main/resources/META-INF/velocity-view.tld b/velocity-tools-view-jsp/src/main/resources/META-INF/velocity-view.tld
deleted file mode 100644
index 59dff944..00000000
--- a/velocity-tools-view-jsp/src/main/resources/META-INF/velocity-view.tld
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
-<!--
- 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.
--->
-<taglib>
- <tlib-version>1.0</tlib-version>
- <jsp-version>1.2</jsp-version>
- <short-name>velocity</short-name>
- <uri>http://velocity.apache.org/velocity-view</uri>
- <display-name>VelocityView Tag</display-name>
- <description><![CDATA[Support for using Velocity and VelocityTools within JSP files and tags.
- This makes it trivial to render VTL (Velocity Template Language)
- or process a Velocity template from within JSP using the current
- context. This also provides the typical VelocityView support
- for accessing and configuring both custom and provided
- VelocityTools.]]></description>
- <tag>
- <name>view</name>
- <tag-class>org.apache.velocity.tools.view.jsp.VelocityViewTag</tag-class>
- <body-content>tagdependent</body-content>
- <attribute>
- <name>id</name>
- <required>false</required>
- <rtexprvalue>true</rtexprvalue>
- <description><![CDATA[An id unique to this particular usage of the VelocityViewTag in the application. This id will then be used to cache the body in a StringResourceLoader repository and will also identify it in log messages. Setting this automatically sets the cache attribute to "true".]]></description>
- </attribute>
- <attribute>
- <name>cache</name>
- <required>false</required>
- <rtexprvalue>true</rtexprvalue>
- <description><![CDATA[Either "true" or "false" to indicate whether the body content template should be cached by the StringResourceLoader. This is automatically set to true if an id is set. If set to true without an id value, then the template will be used as its own id. It is false by default.]]></description>
- </attribute>
- <attribute>
- <name>var</name>
- <required>false</required>
- <rtexprvalue>true</rtexprvalue>
- <description><![CDATA[A variable name whose value should be set to the rendered result of this tag.]]></description>
- </attribute>
- <attribute>
- <name>scope</name>
- <required>false</required>
- <rtexprvalue>true</rtexprvalue>
- <description><![CDATA[This property is meaningless unless a 'var' attribute is also set. When it is, this determines the scope into which the resulting variable is set.]]></description>
- </attribute>
- <attribute>
- <name>template</name>
- <required>false</required>
- <rtexprvalue>true</rtexprvalue>
- <description><![CDATA[The name of a template to be requested from the configured Velocity resource loaders and rendered into the page (or variable if the 'var' attribute is set) using the current context. If this tag also has body content, then the body will be rendered first and placed into the context used to render the template as '$bodyContent'; this approximates the "two-pass render" used by the VelocityLayoutServlet.]]></description>
- </attribute>
- <attribute>
- <name>bodyContentKey</name>
- <required>false</required>
- <rtexprvalue>true</rtexprvalue>
- <description><![CDATA[This property is meaningless unless a 'template' attribute is set and the tag has body content in it. When it is, this changes the key under which the rendered result of the body content is placed into the context for use by the specified template. The default value is "bodyContent" and should be sufficient for nearly all users.]]></description>
- </attribute>
- </tag>
-</taglib>
diff --git a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponseTest.java b/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponseTest.java
deleted file mode 100644
index 33f31c3b..00000000
--- a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/ExternalWriterHttpServletResponseTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * $Id: ExternalWriterHttpServletResponseTest.java 892369 2009-12-18 20:21:36Z apetrelli $
- *
- * 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.velocity.tools.view.jsp.jspimpl;
-
-import static org.junit.Assert.*;
-import static org.easymock.EasyMock.*;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import jakarta.servlet.http.HttpServletResponse;
-
-import org.junit.Test;
-
-/**
- * Tests {@link ExternalWriterHttpServletResponse}.
- */
-public class ExternalWriterHttpServletResponseTest {
-
- /**
- * Test method for {@link org.apache.tiles.request.servlet.ExternalWriterHttpServletResponse#getWriter()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testGetWriter() {
- HttpServletResponse wrappedResponse = createMock(HttpServletResponse.class);
- Writer writer = new StringWriter();
- PrintWriter printWriter = new PrintWriter(writer);
- replay(wrappedResponse);
- ExternalWriterHttpServletResponse response = new ExternalWriterHttpServletResponse(
- wrappedResponse, printWriter);
- assertEquals(printWriter, response.getWriter());
- verify(wrappedResponse);
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtilsTest.java b/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtilsTest.java
deleted file mode 100644
index 88fd0a4a..00000000
--- a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspUtilsTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.io.StringWriter;
-
-import jakarta.servlet.jsp.JspException;
-import jakarta.servlet.jsp.JspWriter;
-import jakarta.servlet.jsp.PageContext;
-import jakarta.servlet.jsp.tagext.BodyTag;
-import jakarta.servlet.jsp.tagext.JspTag;
-import jakarta.servlet.jsp.tagext.SimpleTag;
-import jakarta.servlet.jsp.tagext.Tag;
-import jakarta.servlet.jsp.tagext.TagAdapter;
-
-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.parser.node.ASTBlock;
-import org.apache.velocity.runtime.parser.node.Node;
-import org.junit.Test;
-
-/**
- * Tests {@link JspUtils}.
- *
- */
-public class JspUtilsTest
-{
- /**
- * The attribute name under which the latest encountered tag is put.
- */
- private final static String LATEST_TAG_ATTRIBUTE_NAME = "org.apache.velocity.tools.view.jsp.taglib.jspimpl.LATEST_TAG";
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#setLatestTag(org.apache.velocity.context.Context, jakarta.servlet.jsp.tagext.JspTag)}.
- */
- @Test
- public void testSetLatestTag()
- {
- Context context = createMock(Context.class);
- JspTag tag = createMock(JspTag.class);
-
- expect(context.put(LATEST_TAG_ATTRIBUTE_NAME, tag)).andReturn(null);
-
- replay(context, tag);
- JspUtils.setLatestTag(context, tag);
- verify(context, tag);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#getLatestJspTag(org.apache.velocity.context.Context)}.
- */
- @Test
- public void testGetLatestJspTag()
- {
- Context context = createMock(Context.class);
- JspTag tag = createMock(JspTag.class);
-
- expect(context.get(LATEST_TAG_ATTRIBUTE_NAME)).andReturn(tag);
-
- replay(context, tag);
- assertSame(tag, JspUtils.getLatestJspTag(context));
- verify(context, tag);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#wrapTag(jakarta.servlet.jsp.tagext.JspTag)}.
- */
- @Test
- public void testWrapTag()
- {
- Tag tag = createMock(Tag.class);
- SimpleTag simpleTag = createMock(SimpleTag.class);
-
- replay(tag, simpleTag);
- assertSame(tag, JspUtils.wrapTag(tag));
- assertSame(simpleTag, ((TagAdapter) JspUtils.wrapTag(simpleTag)).getAdaptee());
- verify(tag, simpleTag);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#executeSimpleTag(org.apache.velocity.context.InternalContextAdapter, org.apache.velocity.runtime.parser.node.Node, jakarta.servlet.jsp.PageContext, jakarta.servlet.jsp.tagext.SimpleTag)}.
- * @throws IOException If something goes wrong.
- * @throws JspException If something goes wrong.
- */
- @Test
- public void testExecuteSimpleTag() throws JspException, IOException
- {
- InternalContextAdapter context = createMock(InternalContextAdapter.class);
- Node node = createMock(Node.class);
- PageContext pageContext = createMock(PageContext.class);
- SimpleTag tag = createMock(SimpleTag.class);
- ASTBlock block = createMock(ASTBlock.class);
-
- tag.setJspBody(isA(VelocityJspFragment.class));
- expect(node.jjtGetChild(1)).andReturn(block);
- tag.doTag();
-
- replay(context, node, pageContext, block, tag);
- JspUtils.executeSimpleTag(context, node, pageContext, tag);
- verify(context, node, pageContext, block, tag);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspUtils#executeTag(org.apache.velocity.context.InternalContextAdapter, org.apache.velocity.runtime.parser.node.Node, jakarta.servlet.jsp.PageContext, jakarta.servlet.jsp.tagext.Tag)}.
- * @throws JspException If something goes wrong.
- * @throws IOException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
- */
- @Test
- public void testExecuteTag() throws JspException, MethodInvocationException, ResourceNotFoundException, ParseErrorException, IOException
- {
- InternalContextAdapter context = createMock(InternalContextAdapter.class);
- Node node = createMock(Node.class);
- PageContext pageContext = createMock(PageContext.class);
- BodyTag tag = createMock(BodyTag.class);
- ASTBlock block = createMock(ASTBlock.class);
- JspWriter writer = createMock(JspWriter.class);
-
- expect(tag.doStartTag()).andReturn(BodyTag.EVAL_BODY_BUFFERED);
- tag.setBodyContent(isA(VelocityBodyContent.class));
- tag.doInitBody();
- expect(node.jjtGetChild(1)).andReturn(block);
- expect(tag.doAfterBody()).andReturn(BodyTag.SKIP_BODY);
- expect(tag.doEndTag()).andReturn(BodyTag.EVAL_PAGE);
- expect(pageContext.getOut()).andReturn(writer);
- expect(block.render(eq(context), isA(StringWriter.class))).andReturn(true);
-
- replay(context, node, pageContext, block, tag, writer);
- JspUtils.executeTag(context, node, pageContext, tag);
- verify(context, node, pageContext, block, tag, writer);
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImplTest.java b/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImplTest.java
deleted file mode 100644
index 6502b070..00000000
--- a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/JspWriterImplTest.java
+++ /dev/null
@@ -1,478 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests {@link JspWriterImpl}.
- *
- */
-public class JspWriterImplTest
-{
-
- private Writer writer;
-
- private JspWriterImpl jspWriter;
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception
- {
- writer = createMock(Writer.class);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(int)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testWriteInt() throws IOException
- {
- writer.write(10);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.write(10);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(char[])}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testWriteCharArray() throws IOException
- {
- writer.write(aryEq("hello".toCharArray()), eq(0), eq(5));
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.write("hello".toCharArray());
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(char[], int, int)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testWriteCharArrayIntInt() throws IOException
- {
- writer.write(aryEq("hello".toCharArray()), eq(2), eq(3));
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.write("hello".toCharArray(), 2, 3);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#flush()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testFlush() throws IOException
- {
- writer.flush();
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.flush();
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#close()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testClose() throws IOException
- {
- writer.close();
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.close();
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#newLine()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testNewLine() throws IOException
- {
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.newLine();
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(boolean)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintBoolean() throws IOException
- {
- writer.write("true", 0, 4);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.print(true);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(char)}.
- * @throws IOException
- */
- @Test
- public void testPrintChar() throws IOException
- {
- writer.write("x", 0, 1);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.print('x');
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(int)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintInt() throws IOException
- {
- writer.write("152", 0, 3);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.print(152);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(long)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintLong() throws IOException
- {
- writer.write("152", 0, 3);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.print(152l);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(float)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintFloat() throws IOException
- {
- writer.write("0.5", 0, 3);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.print(0.5f);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(double)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintDouble() throws IOException
- {
- writer.write("0.5", 0, 3);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.print(0.5d);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(char[])}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintCharArray() throws IOException
- {
- writer.write(aryEq("hello".toCharArray()), eq(0), eq(5));
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.print("hello".toCharArray());
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintln() throws IOException
- {
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println();
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(boolean)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnBoolean() throws IOException
- {
- writer.write("true", 0, 4);
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println(true);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(char)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnChar() throws IOException
- {
- writer.write("x", 0, 1);
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println('x');
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(int)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnInt() throws IOException
- {
- writer.write("152", 0, 3);
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println(152);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(long)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnLong() throws IOException
- {
- writer.write("152", 0, 3);
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println(152l);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(float)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnFloat() throws IOException
- {
- writer.write("0.5", 0, 3);
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println(0.5f);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(double)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnDouble() throws IOException
- {
- writer.write("0.5", 0, 3);
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println(0.5d);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(char[])}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnCharArray() throws IOException
- {
- writer.write(aryEq("hello".toCharArray()), eq(0), eq(5));
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println("hello".toCharArray());
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#clear()}.
- * @throws IOException If something goes wrong.
- */
- @Test(expected = IllegalStateException.class)
- public void testClear() throws IOException
- {
- jspWriter = new JspWriterImpl(writer);
- jspWriter.clear();
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#clearBuffer()}.
- * @throws IOException If something goes wrong.
- */
- @Test(expected = IllegalStateException.class)
- public void testClearBuffer() throws IOException
- {
- jspWriter = new JspWriterImpl(writer);
- jspWriter.clearBuffer();
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#getRemaining()}.
- */
- @Test
- public void testGetRemaining()
- {
- jspWriter = new JspWriterImpl(writer);
- assertEquals(0, jspWriter.getRemaining());
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(java.lang.String, int, int)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testWriteStringIntInt() throws IOException
- {
- writer.write("hello", 0, 3);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.write("hello", 0, 3);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#write(java.lang.String)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testWriteString() throws IOException
- {
- writer.write("hello", 0, 5);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.write("hello");
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(java.lang.String)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintString() throws IOException
- {
- writer.write("hello", 0, 5);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.print("hello");
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#print(java.lang.Object)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintObject() throws IOException
- {
- writer.write("null", 0, 4);
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.print((Object) null);
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(java.lang.String)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnString() throws IOException
- {
- writer.write("hello", 0, 5);
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println("hello");
- verify(writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.JspWriterImpl#println(java.lang.Object)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnObject() throws IOException
- {
- writer.write("null", 0, 4);
- writer.write(JspWriterImpl.lineSeparator, 0, JspWriterImpl.lineSeparator.length());
-
- replay(writer);
- jspWriter = new JspWriterImpl(writer);
- jspWriter.println((Object) null);
- verify(writer);
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContentTest.java b/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContentTest.java
deleted file mode 100644
index ca443f8e..00000000
--- a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityBodyContentTest.java
+++ /dev/null
@@ -1,444 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-/*
- * 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.
- */
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import jakarta.servlet.jsp.JspWriter;
-
-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.parser.node.ASTBlock;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests {@link VelocityBodyContent}.
- *
- */
-public class VelocityBodyContentTest
-{
-
- /**
- * The object to test.
- */
- private VelocityBodyContent content;
-
- private JspWriter jspWriter;
-
- private ASTBlock block;
-
- private InternalContextAdapter context;
-
- /**
- * Sets up the test.
- *
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception
- {
- jspWriter = createMock(JspWriter.class);
- block = createMock(ASTBlock.class);
- context = createMock(InternalContextAdapter.class);
- content = new VelocityBodyContent(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#write(char[], int, int)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testWriteCharArrayIntInt() throws IOException
- {
- jspWriter.write(aryEq("hello".toCharArray()), eq(1), eq(3));
- replay(jspWriter, block, context);
- content.write("hello".toCharArray(), 1, 3);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#close()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testClose() throws IOException
- {
- jspWriter.close();
- replay(jspWriter, block, context);
- content.close();
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#newLine()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testNewLine() throws IOException
- {
- jspWriter.newLine();
- replay(jspWriter, block, context);
- content.newLine();
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#print(boolean)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintBoolean() throws IOException
- {
- jspWriter.print(true);
- replay(jspWriter, block, context);
- content.print(true);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#print(char)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintChar() throws IOException
- {
- jspWriter.print('c');
- replay(jspWriter, block, context);
- content.print('c');
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#print(int)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintInt() throws IOException
- {
- jspWriter.print(42);
- replay(jspWriter, block, context);
- content.print(42);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#print(long)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintLong() throws IOException
- {
- jspWriter.print(42l);
- replay(jspWriter, block, context);
- content.print(42l);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#print(float)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintFloat() throws IOException
- {
- jspWriter.print(0.2f);
- replay(jspWriter, block, context);
- content.print(0.2f);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#print(double)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintDouble() throws IOException
- {
- jspWriter.print(0.2d);
- replay(jspWriter, block, context);
- content.print(0.2d);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#print(char[])}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintCharArray() throws IOException
- {
- jspWriter.print(aryEq("hello".toCharArray()));
- replay(jspWriter, block, context);
- content.print("hello".toCharArray());
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintln() throws IOException
- {
- jspWriter.println();
- replay(jspWriter, block, context);
- content.println();
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println(boolean)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnBoolean() throws IOException
- {
- jspWriter.println(true);
- replay(jspWriter, block, context);
- content.println(true);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println(char)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnChar() throws IOException
- {
- jspWriter.println('c');
- replay(jspWriter, block, context);
- content.println('c');
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println(int)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnInt() throws IOException
- {
- jspWriter.println(42);
- replay(jspWriter, block, context);
- content.println(42);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println(long)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnLong() throws IOException
- {
- jspWriter.println(42l);
- replay(jspWriter, block, context);
- content.println(42l);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println(float)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnFloat() throws IOException
- {
- jspWriter.println(0.2f);
- replay(jspWriter, block, context);
- content.println(0.2f);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println(double)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnDouble() throws IOException
- {
- jspWriter.println(0.2d);
- replay(jspWriter, block, context);
- content.println(0.2d);
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println(char[])}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnCharArray() throws IOException
- {
- jspWriter.println(aryEq("hello".toCharArray()));
- replay(jspWriter, block, context);
- content.println("hello".toCharArray());
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#clear()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testClear() throws IOException
- {
- jspWriter.clear();
- replay(jspWriter, block, context);
- content.clear();
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#clearBuffer()}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testClearBuffer() throws IOException
- {
- jspWriter.clearBuffer();
- replay(jspWriter, block, context);
- content.clearBuffer();
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#getRemaining()}.
- */
- @Test
- public void testGetRemaining()
- {
- expect(jspWriter.getRemaining()).andReturn(42);
- replay(jspWriter, block, context);
- assertEquals(42, content.getRemaining());
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#getReader()}.
- * @throws IOException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
- */
- @Test
- public void testGetReader() throws MethodInvocationException, ResourceNotFoundException, ParseErrorException, IOException
- {
- expect(block.render(eq(context), isA(StringWriter.class))).andReturn(true);
- replay(jspWriter, block, context);
- assertNotNull(content.getReader());
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#getString()}.
- * @throws IOException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
- */
- @Test
- public void testGetString() throws MethodInvocationException, ResourceNotFoundException, ParseErrorException, IOException
- {
- expect(block.render(eq(context), isA(StringWriter.class))).andReturn(true);
- replay(jspWriter, block, context);
- assertEquals("", content.getString());
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#writeOut(java.io.Writer)}.
- * @throws IOException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
- */
- @Test
- public void testWriteOutWriter() throws MethodInvocationException, ResourceNotFoundException, ParseErrorException, IOException
- {
- Writer writer = createMock(Writer.class);
- expect(block.render(context, writer)).andReturn(true);
- replay(jspWriter, block, context, writer);
- content.writeOut(writer);
- verify(jspWriter, block, context, writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#print(java.lang.String)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintString() throws IOException
- {
- jspWriter.print("hello");
- replay(jspWriter, block, context);
- content.print("hello");
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#print(java.lang.Object)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintObject() throws IOException
- {
- jspWriter.print((Object) new Integer(42));
- replay(jspWriter, block, context);
- content.print((Object) new Integer(42));
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println(java.lang.String)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnString() throws IOException
- {
- jspWriter.println("hello");
- replay(jspWriter, block, context);
- content.println("hello");
- verify(jspWriter, block, context);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityBodyContent#println(java.lang.Object)}.
- * @throws IOException If something goes wrong.
- */
- @Test
- public void testPrintlnObject() throws IOException
- {
- jspWriter.println((Object) new Integer(42));
- replay(jspWriter, block, context);
- content.println((Object) new Integer(42));
- verify(jspWriter, block, context);
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragmentTest.java b/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragmentTest.java
deleted file mode 100644
index 9df6e14a..00000000
--- a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityJspFragmentTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-/*
- * 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.
- */
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import jakarta.servlet.jsp.JspException;
-import jakarta.servlet.jsp.PageContext;
-
-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.parser.node.ASTBlock;
-import org.junit.Test;
-
-/**
- * Tests {@link VelocityJspFragment}.
- *
- */
-public class VelocityJspFragmentTest
-{
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityJspFragment#invoke(java.io.Writer)}.
- * @throws IOException If something goes wrong.
- * @throws ParseErrorException If something goes wrong.
- * @throws ResourceNotFoundException If something goes wrong.
- * @throws MethodInvocationException If something goes wrong.
- * @throws JspException If something goes wrong.
- */
- @Test
- public void testInvokeWriter() throws MethodInvocationException, ResourceNotFoundException, ParseErrorException, IOException, JspException
- {
- PageContext pageContext = createMock(PageContext.class);
- ASTBlock block = createMock(ASTBlock.class);
- InternalContextAdapter context = createMock(InternalContextAdapter.class);
- Writer writer = createMock(Writer.class);
- expect(block.render(context, writer)).andReturn(true);
-
- replay(pageContext, block, context, writer);
- VelocityJspFragment fragment = new VelocityJspFragment(pageContext, block, context);
- fragment.invoke(writer);
- verify(pageContext, block, context, writer);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityJspFragment#getJspContext()}.
- */
- @Test
- public void testGetJspContext()
- {
- PageContext pageContext = createMock(PageContext.class);
- ASTBlock block = createMock(ASTBlock.class);
- InternalContextAdapter context = createMock(InternalContextAdapter.class);
-
- replay(pageContext, block, context);
- VelocityJspFragment fragment = new VelocityJspFragment(pageContext, block, context);
- assertSame(pageContext, fragment.getJspContext());
- verify(pageContext, block, context);
- }
-
-}
diff --git a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContextTest.java b/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContextTest.java
deleted file mode 100644
index 0084c70e..00000000
--- a/velocity-tools-view-jsp/src/test/java/org/apache/velocity/tools/view/jsp/jspimpl/VelocityPageContextTest.java
+++ /dev/null
@@ -1,442 +0,0 @@
-package org.apache.velocity.tools.view.jsp.jspimpl;
-
-/*
- * 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.
- */
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Enumeration;
-
-import jakarta.servlet.RequestDispatcher;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.HttpSession;
-import jakarta.servlet.jsp.PageContext;
-
-import org.apache.velocity.context.Context;
-import org.apache.velocity.tools.view.ViewContext;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests {@link VelocityPageContext}.
- *
- */
-public class VelocityPageContextTest
-{
-
- private VelocityPageContext pageContext;
-
- private Context velocityContext;
-
- private Writer velocityWriter;
-
- private ViewContext viewContext;
-
- private HttpServletRequest request;
-
- private HttpServletResponse response;
-
- private ServletContext servletContext;
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception
- {
- velocityContext = createMock(Context.class);
- velocityWriter = createMock(Writer.class);
- viewContext = createMock(ViewContext.class);
- request = createMock(HttpServletRequest.class);
- response = createMock(HttpServletResponse.class);
- servletContext = createMock(ServletContext.class);
-
- expect(viewContext.getRequest()).andReturn(request);
- expect(viewContext.getResponse()).andReturn(response);
- expect(viewContext.getServletContext()).andReturn(servletContext).anyTimes();
- expect(velocityContext.put(eq("out"), isA(JspWriterImpl.class))).andReturn(null);
-
- replay(viewContext, velocityContext);
- pageContext = new VelocityPageContext(velocityContext, velocityWriter, viewContext);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getSession()}.
- */
- @Test
- public void testGetSession()
- {
- HttpSession session = createMock(HttpSession.class);
-
- expect(request.getSession(false)).andReturn(session);
-
- replay(velocityWriter, request, response, servletContext, session);
- assertSame(session, pageContext.getSession());
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, session);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getPage()}.
- */
- @Test
- public void testGetPage()
- {
- replay(velocityWriter, request, response, servletContext);
- assertSame(viewContext, pageContext.getPage());
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getRequest()}.
- */
- @Test
- public void testGetRequest()
- {
- replay(velocityWriter, request, response, servletContext);
- assertSame(request, pageContext.getRequest());
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getResponse()}.
- */
- @Test
- public void testGetResponse()
- {
- replay(velocityWriter, request, response, servletContext);
- assertSame(response, pageContext.getResponse());
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getException()}.
- */
- @Test
- public void testGetException()
- {
- replay(velocityWriter, request, response, servletContext);
- assertNull(pageContext.getException());
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getServletConfig()}.
- */
- @Test(expected=UnsupportedOperationException.class)
- public void testGetServletConfig()
- {
- replay(velocityWriter, request, response, servletContext);
- try {
- pageContext.getServletConfig();
- } finally {
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getServletContext()}.
- */
- @Test
- public void testGetServletContext()
- {
- replay(velocityWriter, request, response, servletContext);
- assertSame(servletContext, pageContext.getServletContext());
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#forward(java.lang.String)}.
- * @throws IOException If something goes wrong.
- * @throws ServletException If something goes wrong.
- */
- @Test
- public void testForwardString() throws ServletException, IOException
- {
- RequestDispatcher dispatcher = createMock(RequestDispatcher.class);
-
- expect(request.getRequestDispatcher("/my/path")).andReturn(dispatcher);
- dispatcher.forward(eq(request), isA(ExternalWriterHttpServletResponse.class));
-
- replay(velocityWriter, request, response, servletContext, dispatcher);
- pageContext.forward("/my/path");
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, dispatcher);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#include(java.lang.String)}.
- * @throws IOException If something goes wrong.
- * @throws ServletException If something goes wrong.
- */
- @Test
- public void testIncludeString() throws ServletException, IOException
- {
- RequestDispatcher dispatcher = createMock(RequestDispatcher.class);
-
- velocityWriter.flush();
- expect(request.getRequestDispatcher("/my/path")).andReturn(dispatcher);
- dispatcher.include(eq(request), isA(ExternalWriterHttpServletResponse.class));
-
- replay(velocityWriter, request, response, servletContext, dispatcher);
- pageContext.include("/my/path");
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, dispatcher);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#include(java.lang.String, boolean)}.
- * @throws IOException If something goes wrong.
- * @throws ServletException If something goes wrong.
- */
- @Test
- public void testIncludeStringBoolean() throws ServletException, IOException
- {
- RequestDispatcher dispatcher = createMock(RequestDispatcher.class);
-
- expect(request.getRequestDispatcher("/my/path")).andReturn(dispatcher);
- dispatcher.include(eq(request), isA(ExternalWriterHttpServletResponse.class));
-
- replay(velocityWriter, request, response, servletContext, dispatcher);
- pageContext.include("/my/path", false);
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, dispatcher);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#setAttribute(java.lang.String, java.lang.Object)}.
- */
- @Test
- public void testSetAttributeStringObject()
- {
- verify(velocityContext);
- reset(velocityContext);
-
- expect(velocityContext.put("name", "value")).andReturn(null);
-
- replay(velocityWriter, request, response, servletContext, velocityContext);
- pageContext.setAttribute("name", "value");
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#setAttribute(java.lang.String, java.lang.Object, int)}.
- */
- @Test
- public void testSetAttributeStringObjectInt()
- {
- verify(velocityContext);
- reset(velocityContext);
- HttpSession session = createMock(HttpSession.class);
-
- expect(velocityContext.put("name", "value")).andReturn(null);
- request.setAttribute("name", "value");
- expect(request.getSession()).andReturn(session);
- session.setAttribute("name", "value");
- servletContext.setAttribute("name", "value");
-
- replay(velocityWriter, request, response, servletContext, velocityContext, session);
- pageContext.setAttribute("name", "value", PageContext.PAGE_SCOPE);
- pageContext.setAttribute("name", "value", PageContext.REQUEST_SCOPE);
- pageContext.setAttribute("name", "value", PageContext.SESSION_SCOPE);
- pageContext.setAttribute("name", "value", PageContext.APPLICATION_SCOPE);
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, session);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getAttribute(java.lang.String)}.
- */
- @Test
- public void testGetAttributeString()
- {
- verify(velocityContext);
- reset(velocityContext);
-
- expect(velocityContext.get("name")).andReturn("value");
-
- replay(velocityWriter, request, response, servletContext, velocityContext);
- assertEquals("value", pageContext.getAttribute("name"));
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getAttribute(java.lang.String, int)}.
- */
- @Test
- public void testGetAttributeStringInt()
- {
- verify(velocityContext);
- reset(velocityContext);
- HttpSession session = createMock(HttpSession.class);
-
- expect(velocityContext.get("name")).andReturn("value");
- expect(request.getAttribute("name")).andReturn("value");
- expect(request.getSession(false)).andReturn(session);
- expect(session.getAttribute("name")).andReturn("value");
- expect(servletContext.getAttribute("name")).andReturn("value");
-
- replay(velocityWriter, request, response, servletContext, velocityContext, session);
- assertEquals("value", pageContext.getAttribute("name", PageContext.PAGE_SCOPE));
- assertEquals("value", pageContext.getAttribute("name", PageContext.REQUEST_SCOPE));
- assertEquals("value", pageContext.getAttribute("name", PageContext.SESSION_SCOPE));
- assertEquals("value", pageContext.getAttribute("name", PageContext.APPLICATION_SCOPE));
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, session);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#findAttribute(java.lang.String)}.
- */
- @Test
- public void testFindAttributeString()
- {
- verify(velocityContext);
- reset(velocityContext);
- HttpSession session = createMock(HttpSession.class);
-
- expect(velocityContext.get("name")).andReturn(null);
- expect(request.getAttribute("name")).andReturn(null);
- expect(request.getSession(false)).andReturn(session);
- expect(session.getAttribute("name")).andReturn(null);
- expect(servletContext.getAttribute("name")).andReturn("value");
-
- replay(velocityWriter, request, response, servletContext, velocityContext, session);
- assertEquals("value", pageContext.findAttribute("name"));
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, session);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#removeAttribute(java.lang.String)}.
- */
- @Test
- public void testRemoveAttributeString()
- {
- verify(velocityContext);
- reset(velocityContext);
- HttpSession session = createMock(HttpSession.class);
-
- expect(velocityContext.remove("name")).andReturn(null);
- request.removeAttribute("name");
- expect(request.getSession(false)).andReturn(session);
- session.removeAttribute("name");
- servletContext.removeAttribute("name");
-
- replay(velocityWriter, request, response, servletContext, velocityContext, session);
- pageContext.removeAttribute("name");
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, session);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#removeAttribute(java.lang.String, int)}.
- */
- @Test
- public void testRemoveAttributeStringInt()
- {
- verify(velocityContext);
- reset(velocityContext);
- HttpSession session = createMock(HttpSession.class);
-
- expect(velocityContext.remove("name")).andReturn(null);
- request.removeAttribute("name");
- expect(request.getSession(false)).andReturn(session);
- session.removeAttribute("name");
- servletContext.removeAttribute("name");
-
- replay(velocityWriter, request, response, servletContext, velocityContext, session);
- pageContext.removeAttribute("name", PageContext.PAGE_SCOPE);
- pageContext.removeAttribute("name", PageContext.REQUEST_SCOPE);
- pageContext.removeAttribute("name", PageContext.SESSION_SCOPE);
- pageContext.removeAttribute("name", PageContext.APPLICATION_SCOPE);
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, session);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getAttributesScope(java.lang.String)}.
- */
- @Test
- public void testGetAttributesScopeString()
- {
- verify(velocityContext);
- reset(velocityContext);
- HttpSession session = createMock(HttpSession.class);
-
- expect(velocityContext.get("name")).andReturn(null);
- expect(request.getAttribute("name")).andReturn(null);
- expect(request.getSession(false)).andReturn(session);
- expect(session.getAttribute("name")).andReturn(null);
- expect(servletContext.getAttribute("name")).andReturn("value");
-
- replay(velocityWriter, request, response, servletContext, velocityContext, session);
- assertEquals(PageContext.APPLICATION_SCOPE, pageContext.getAttributesScope("name"));
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, session);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getAttributeNamesInScope(int)}.
- */
- @Test
- public void testGetAttributeNamesInScopeInt()
- {
- verify(velocityContext);
- reset(velocityContext);
- HttpSession session = createMock(HttpSession.class);
- @SuppressWarnings("unchecked")
- Enumeration<String> keys = createMock(Enumeration.class);
-
- expect(velocityContext.getKeys()).andReturn(new String[] {"one", "two", "three"});
- expect(request.getAttributeNames()).andReturn(keys);
- expect(request.getSession(false)).andReturn(session);
- expect(session.getAttributeNames()).andReturn(keys);
- expect(servletContext.getAttributeNames()).andReturn(keys);
-
- replay(velocityWriter, request, response, servletContext, velocityContext, session);
- assertNotNull(pageContext.getAttributeNamesInScope(PageContext.PAGE_SCOPE));
- assertSame(keys, pageContext.getAttributeNamesInScope(PageContext.REQUEST_SCOPE));
- assertSame(keys, pageContext.getAttributeNamesInScope(PageContext.SESSION_SCOPE));
- assertSame(keys, pageContext.getAttributeNamesInScope(PageContext.APPLICATION_SCOPE));
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext, session);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getOut()}.
- */
- @Test
- public void testGetOut()
- {
- replay(velocityWriter, request, response, servletContext);
- assertNotNull(pageContext.getOut());
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
-
- /**
- * Test method for {@link org.apache.velocity.tools.view.jsp.jspimpl.VelocityPageContext#getELContext()}.
- */
- @Test(expected=UnsupportedOperationException.class)
- public void testGetELContext()
- {
- replay(velocityWriter, request, response, servletContext);
- try {
- pageContext.getELContext();
- } finally {
- verify(velocityContext, velocityWriter, request, response, servletContext, viewContext);
- }
- }
-
-}
diff --git a/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/VelocityViewFilter.java b/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/VelocityViewFilter.java
index d4aaefcf..c629637c 100644
--- a/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/VelocityViewFilter.java
+++ b/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/VelocityViewFilter.java
@@ -64,8 +64,7 @@ import org.apache.velocity.tools.Toolbox;
* <dt>org.apache.velocity.tools.shared.config</dt>
* <dd>By default, this is {@code true}. If set to {@code false}, then
* the {@link VelocityView} used by this filter will not be shared
- * with other VelocityViewFilters, {@link VelocityViewServlet}s or
- * org.apache.velocity.tools.view.jsp.VelocityViewTag's in the
+ * with other VelocityViewFilters or {@link VelocityViewServlet}s in the
* application.</dd>
* <dt>org.apache.velocity.tools.context.key</dt>
* <dd>If you set a value for this property, this filter will create
diff --git a/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java b/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
index 88dc9432..566823bb 100644
--- a/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
+++ b/velocity-tools-view/src/main/java/org/apache/velocity/tools/view/VelocityViewServlet.java
@@ -41,8 +41,8 @@ import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.commons.lang3.StringEscapeUtils;
/**
- * <p>A servlet to process Velocity templates. This is comparable to the
- * the JspServlet for JSP-based applications.</p>
+ * <p>A servlet to process Velocity templates. Its default behavior is to map
+ * URIs to templates.</p>
*
* <p>The servlet provides the following features:</p>
* <ul>
@@ -72,8 +72,7 @@ import org.apache.commons.lang3.StringEscapeUtils;
* <dt>org.apache.velocity.tools.shared.config</dt>
* <dd>By default, this is {@code true}. If set to {@code false}, then
* the {@link VelocityView} used by this servlet will not be shared
- * with {@link VelocityViewFilter}s, other VelocityViewServlets or
- * org.apache.velocity.tools.view.jsp.VelocityViewTag's in the
+ * with {@link VelocityViewFilter}s or other VelocityViewServlets in the
* application.</dd>
* <dt>org.apache.velocity.tools.loadDefaults</dt>
* <dd>By default, this is {@code true}. If set to {@code false}, then