moving unit tests from .testsuite -> .core, .beans, .web, .web.portlet, .web.servlet
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.el.ELException;
|
||||
import javax.servlet.jsp.el.Expression;
|
||||
import javax.servlet.jsp.el.ExpressionEvaluator;
|
||||
import javax.servlet.jsp.el.FunctionMapper;
|
||||
import javax.servlet.jsp.el.VariableResolver;
|
||||
|
||||
import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
|
||||
|
||||
/**
|
||||
* Mock implementation of the JSP 2.0 {@link javax.servlet.jsp.el.ExpressionEvaluator}
|
||||
* interface, delegating to the Jakarta JSTL ExpressionEvaluatorManager.
|
||||
*
|
||||
* <p>Used for testing the web framework; only necessary for testing
|
||||
* applications when testing custom JSP tags.
|
||||
*
|
||||
* <p>Note that the Jakarta JSTL implementation (jstl.jar, standard.jar)
|
||||
* has to be available on the class path to use this expression evaluator.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.1.5
|
||||
* @see org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager
|
||||
*/
|
||||
public class MockExpressionEvaluator extends ExpressionEvaluator {
|
||||
|
||||
private final PageContext pageContext;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new MockExpressionEvaluator for the given PageContext.
|
||||
* @param pageContext the JSP PageContext to run in
|
||||
*/
|
||||
public MockExpressionEvaluator(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
public Expression parseExpression(
|
||||
final String expression, final Class expectedType, final FunctionMapper functionMapper)
|
||||
throws ELException {
|
||||
|
||||
return new Expression() {
|
||||
public Object evaluate(VariableResolver variableResolver) throws ELException {
|
||||
return doEvaluate(expression, expectedType, functionMapper);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Object evaluate(
|
||||
String expression, Class expectedType, VariableResolver variableResolver, FunctionMapper functionMapper)
|
||||
throws ELException {
|
||||
|
||||
if (variableResolver != null) {
|
||||
throw new IllegalArgumentException("Custom VariableResolver not supported");
|
||||
}
|
||||
return doEvaluate(expression, expectedType, functionMapper);
|
||||
}
|
||||
|
||||
protected Object doEvaluate(
|
||||
String expression, Class expectedType, FunctionMapper functionMapper)
|
||||
throws ELException {
|
||||
|
||||
if (functionMapper != null) {
|
||||
throw new IllegalArgumentException("Custom FunctionMapper not supported");
|
||||
}
|
||||
try {
|
||||
return ExpressionEvaluatorManager.evaluate("JSP EL expression", expression, expectedType, this.pageContext);
|
||||
}
|
||||
catch (JspException ex) {
|
||||
throw new ELException("Parsing of JSP EL expression \"" + expression + "\" failed", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.FilterConfig} interface.
|
||||
*
|
||||
* <p>Used for testing the web framework; also usefol for testing
|
||||
* custom {@link javax.servlet.Filter} implementations.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.0.2
|
||||
* @see MockFilterChain
|
||||
* @see PassThroughFilterChain
|
||||
*/
|
||||
public class MockFilterConfig implements FilterConfig {
|
||||
|
||||
private final ServletContext servletContext;
|
||||
|
||||
private final String filterName;
|
||||
|
||||
private final Map<String, String> initParameters = new LinkedHashMap<String, String>();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new MockFilterConfig with a default {@link MockServletContext}.
|
||||
*/
|
||||
public MockFilterConfig() {
|
||||
this(null, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MockFilterConfig with a default {@link MockServletContext}.
|
||||
* @param filterName the name of the filter
|
||||
*/
|
||||
public MockFilterConfig(String filterName) {
|
||||
this(null, filterName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MockFilterConfig.
|
||||
* @param servletContext the ServletContext that the servlet runs in
|
||||
*/
|
||||
public MockFilterConfig(ServletContext servletContext) {
|
||||
this(servletContext, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MockFilterConfig.
|
||||
* @param servletContext the ServletContext that the servlet runs in
|
||||
* @param filterName the name of the filter
|
||||
*/
|
||||
public MockFilterConfig(ServletContext servletContext, String filterName) {
|
||||
this.servletContext = (servletContext != null ? servletContext : new MockServletContext());
|
||||
this.filterName = filterName;
|
||||
}
|
||||
|
||||
|
||||
public String getFilterName() {
|
||||
return filterName;
|
||||
}
|
||||
|
||||
public ServletContext getServletContext() {
|
||||
return servletContext;
|
||||
}
|
||||
|
||||
public void addInitParameter(String name, String value) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.jsp.JspWriter} class.
|
||||
*
|
||||
* <p>Used for testing the web framework; only necessary for testing
|
||||
* applications when testing custom JSP tags.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.5
|
||||
*/
|
||||
public class MockJspWriter extends JspWriter {
|
||||
|
||||
private final HttpServletResponse response;
|
||||
|
||||
private PrintWriter targetWriter;
|
||||
|
||||
|
||||
/**
|
||||
* Create a MockJspWriter for the given response,
|
||||
* using the response's default Writer.
|
||||
* @param response the servlet response to wrap
|
||||
*/
|
||||
public MockJspWriter(HttpServletResponse response) {
|
||||
this(response, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MockJspWriter for the given plain Writer.
|
||||
* @param targetWriter the target Writer to wrap
|
||||
*/
|
||||
public MockJspWriter(Writer targetWriter) {
|
||||
this(null, targetWriter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MockJspWriter for the given response.
|
||||
* @param response the servlet response to wrap
|
||||
* @param targetWriter the target Writer to wrap
|
||||
*/
|
||||
public MockJspWriter(HttpServletResponse response, Writer targetWriter) {
|
||||
super(DEFAULT_BUFFER, true);
|
||||
this.response = (response != null ? response : new MockHttpServletResponse());
|
||||
if (targetWriter instanceof PrintWriter) {
|
||||
this.targetWriter = (PrintWriter) targetWriter;
|
||||
}
|
||||
else if (targetWriter != null) {
|
||||
this.targetWriter = new PrintWriter(targetWriter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazily initialize the target Writer.
|
||||
*/
|
||||
protected PrintWriter getTargetWriter() throws IOException {
|
||||
if (this.targetWriter == null) {
|
||||
this.targetWriter = this.response.getWriter();
|
||||
}
|
||||
return this.targetWriter;
|
||||
}
|
||||
|
||||
|
||||
public void clear() throws IOException {
|
||||
if (this.response.isCommitted()) {
|
||||
throw new IOException("Response already committed");
|
||||
}
|
||||
this.response.resetBuffer();
|
||||
}
|
||||
|
||||
public void clearBuffer() throws IOException {
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
this.response.flushBuffer();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
flush();
|
||||
}
|
||||
|
||||
public int getRemaining() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public void newLine() throws IOException {
|
||||
getTargetWriter().println();
|
||||
}
|
||||
|
||||
public void write(char value[], int offset, int length) throws IOException {
|
||||
getTargetWriter().write(value, offset, length);
|
||||
}
|
||||
|
||||
public void print(boolean value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
public void print(char value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
public void print(char[] value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
public void print(double value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
public void print(float value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
public void print(int value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
public void print(long value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
public void print(Object value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
public void print(String value) throws IOException {
|
||||
getTargetWriter().print(value);
|
||||
}
|
||||
|
||||
public void println() throws IOException {
|
||||
getTargetWriter().println();
|
||||
}
|
||||
|
||||
public void println(boolean value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
public void println(char value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
public void println(char[] value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
public void println(double value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
public void println(float value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
public void println(int value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
public void println(long value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
public void println(Object value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
public void println(String value) throws IOException {
|
||||
getTargetWriter().println(value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.el.ExpressionEvaluator;
|
||||
import javax.servlet.jsp.el.VariableResolver;
|
||||
import javax.el.ELContext;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.jsp.PageContext} interface.
|
||||
*
|
||||
* <p>Used for testing the web framework; only necessary for testing
|
||||
* applications when testing custom JSP tags.
|
||||
*
|
||||
* <p>Note: Expects initialization via the constructor rather than via the
|
||||
* <code>PageContext.initialize</code> method. Does not support writing to
|
||||
* a JspWriter, request dispatching, and <code>handlePageException</code> calls.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public class MockPageContext extends PageContext {
|
||||
|
||||
private final ServletContext servletContext;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
private final HttpServletResponse response;
|
||||
|
||||
private final ServletConfig servletConfig;
|
||||
|
||||
private final Map<String, Object> attributes = new HashMap<String, Object>();
|
||||
|
||||
private JspWriter out;
|
||||
|
||||
|
||||
/**
|
||||
* Create new MockPageContext with a default {@link MockServletContext},
|
||||
* {@link MockHttpServletRequest}, {@link MockHttpServletResponse},
|
||||
* {@link MockServletConfig}.
|
||||
*/
|
||||
public MockPageContext() {
|
||||
this(null, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new MockPageContext with a default {@link MockHttpServletRequest},
|
||||
* {@link MockHttpServletResponse}, {@link MockServletConfig}.
|
||||
* @param servletContext the ServletContext that the JSP page runs in
|
||||
* (only necessary when actually accessing the ServletContext)
|
||||
*/
|
||||
public MockPageContext(ServletContext servletContext) {
|
||||
this(servletContext, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new MockPageContext with a MockHttpServletResponse,
|
||||
* MockServletConfig.
|
||||
* @param servletContext the ServletContext that the JSP page runs in
|
||||
* @param request the current HttpServletRequest
|
||||
* (only necessary when actually accessing the request)
|
||||
*/
|
||||
public MockPageContext(ServletContext servletContext, HttpServletRequest request) {
|
||||
this(servletContext, request, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new MockPageContext with a MockServletConfig.
|
||||
* @param servletContext the ServletContext that the JSP page runs in
|
||||
* @param request the current HttpServletRequest
|
||||
* @param response the current HttpServletResponse
|
||||
* (only necessary when actually writing to the response)
|
||||
*/
|
||||
public MockPageContext(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) {
|
||||
this(servletContext, request, response, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new MockServletConfig.
|
||||
* @param servletContext the ServletContext that the JSP page runs in
|
||||
* @param request the current HttpServletRequest
|
||||
* @param response the current HttpServletResponse
|
||||
* @param servletConfig the ServletConfig (hardly ever accessed from within a tag)
|
||||
*/
|
||||
public MockPageContext(ServletContext servletContext, HttpServletRequest request,
|
||||
HttpServletResponse response, ServletConfig servletConfig) {
|
||||
|
||||
this.servletContext = (servletContext != null ? servletContext : new MockServletContext());
|
||||
this.request = (request != null ? request : new MockHttpServletRequest(servletContext));
|
||||
this.response = (response != null ? response : new MockHttpServletResponse());
|
||||
this.servletConfig = (servletConfig != null ? servletConfig : new MockServletConfig(servletContext));
|
||||
}
|
||||
|
||||
|
||||
public void initialize(
|
||||
Servlet servlet, ServletRequest request, ServletResponse response,
|
||||
String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush) {
|
||||
|
||||
throw new UnsupportedOperationException("Use appropriate constructor");
|
||||
}
|
||||
|
||||
public void release() {
|
||||
}
|
||||
|
||||
public void setAttribute(String name, Object value) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
if (value != null) {
|
||||
this.attributes.put(name, value);
|
||||
}
|
||||
else {
|
||||
this.attributes.remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttribute(String name, Object value, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
case PAGE_SCOPE:
|
||||
setAttribute(name, value);
|
||||
break;
|
||||
case REQUEST_SCOPE:
|
||||
this.request.setAttribute(name, value);
|
||||
break;
|
||||
case SESSION_SCOPE:
|
||||
this.request.getSession().setAttribute(name, value);
|
||||
break;
|
||||
case APPLICATION_SCOPE:
|
||||
this.servletContext.setAttribute(name, value);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid scope: " + scope);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
return this.attributes.get(name);
|
||||
}
|
||||
|
||||
public Object getAttribute(String name, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
case PAGE_SCOPE:
|
||||
return getAttribute(name);
|
||||
case REQUEST_SCOPE:
|
||||
return this.request.getAttribute(name);
|
||||
case SESSION_SCOPE:
|
||||
HttpSession session = this.request.getSession(false);
|
||||
return (session != null ? session.getAttribute(name) : null);
|
||||
case APPLICATION_SCOPE:
|
||||
return this.servletContext.getAttribute(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid scope: " + scope);
|
||||
}
|
||||
}
|
||||
|
||||
public Object findAttribute(String name) {
|
||||
Object value = getAttribute(name);
|
||||
if (value == null) {
|
||||
value = getAttribute(name, REQUEST_SCOPE);
|
||||
if (value == null) {
|
||||
value = getAttribute(name, SESSION_SCOPE);
|
||||
if (value == null) {
|
||||
value = getAttribute(name, APPLICATION_SCOPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void removeAttribute(String name) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
this.removeAttribute(name, PageContext.PAGE_SCOPE);
|
||||
this.removeAttribute(name, PageContext.REQUEST_SCOPE);
|
||||
this.removeAttribute(name, PageContext.SESSION_SCOPE);
|
||||
this.removeAttribute(name, PageContext.APPLICATION_SCOPE);
|
||||
}
|
||||
|
||||
public void removeAttribute(String name, int scope) {
|
||||
Assert.notNull(name, "Attribute name must not be null");
|
||||
switch (scope) {
|
||||
case PAGE_SCOPE:
|
||||
this.attributes.remove(name);
|
||||
break;
|
||||
case REQUEST_SCOPE:
|
||||
this.request.removeAttribute(name);
|
||||
break;
|
||||
case SESSION_SCOPE:
|
||||
this.request.getSession().removeAttribute(name);
|
||||
break;
|
||||
case APPLICATION_SCOPE:
|
||||
this.servletContext.removeAttribute(name);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid scope: " + scope);
|
||||
}
|
||||
}
|
||||
|
||||
public int getAttributesScope(String name) {
|
||||
if (getAttribute(name) != null) {
|
||||
return PAGE_SCOPE;
|
||||
}
|
||||
else if (getAttribute(name, REQUEST_SCOPE) != null) {
|
||||
return REQUEST_SCOPE;
|
||||
}
|
||||
else if (getAttribute(name, SESSION_SCOPE) != null) {
|
||||
return SESSION_SCOPE;
|
||||
}
|
||||
else if (getAttribute(name, APPLICATION_SCOPE) != null) {
|
||||
return APPLICATION_SCOPE;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Enumeration<String> getAttributeNames() {
|
||||
return Collections.enumeration(this.attributes.keySet());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Enumeration<String> getAttributeNamesInScope(int scope) {
|
||||
switch (scope) {
|
||||
case PAGE_SCOPE:
|
||||
return getAttributeNames();
|
||||
case REQUEST_SCOPE:
|
||||
return this.request.getAttributeNames();
|
||||
case SESSION_SCOPE:
|
||||
HttpSession session = this.request.getSession(false);
|
||||
return (session != null ? session.getAttributeNames() : null);
|
||||
case APPLICATION_SCOPE:
|
||||
return this.servletContext.getAttributeNames();
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid scope: " + scope);
|
||||
}
|
||||
}
|
||||
|
||||
public JspWriter getOut() {
|
||||
if (this.out == null) {
|
||||
this.out = new MockJspWriter(this.response);
|
||||
}
|
||||
return this.out;
|
||||
}
|
||||
|
||||
public ExpressionEvaluator getExpressionEvaluator() {
|
||||
return new MockExpressionEvaluator(this);
|
||||
}
|
||||
|
||||
public ELContext getELContext() {
|
||||
throw new UnsupportedOperationException("getELContext");
|
||||
}
|
||||
|
||||
public VariableResolver getVariableResolver() {
|
||||
throw new UnsupportedOperationException("getVariableResolver");
|
||||
}
|
||||
|
||||
public HttpSession getSession() {
|
||||
return this.request.getSession();
|
||||
}
|
||||
|
||||
public Object getPage() {
|
||||
throw new UnsupportedOperationException("getPage");
|
||||
}
|
||||
|
||||
public ServletRequest getRequest() {
|
||||
return this.request;
|
||||
}
|
||||
|
||||
public ServletResponse getResponse() {
|
||||
return this.response;
|
||||
}
|
||||
|
||||
public Exception getException() {
|
||||
throw new UnsupportedOperationException("getException");
|
||||
}
|
||||
|
||||
public ServletConfig getServletConfig() {
|
||||
return this.servletConfig;
|
||||
}
|
||||
|
||||
public ServletContext getServletContext() {
|
||||
return this.servletContext;
|
||||
}
|
||||
|
||||
public void forward(String url) throws ServletException, IOException {
|
||||
throw new UnsupportedOperationException("forward");
|
||||
}
|
||||
|
||||
public void include(String url) throws ServletException, IOException {
|
||||
throw new UnsupportedOperationException("include");
|
||||
}
|
||||
|
||||
public void include(String url, boolean flush) throws ServletException, IOException {
|
||||
throw new UnsupportedOperationException("include");
|
||||
}
|
||||
|
||||
public void handlePageException(Exception ex) throws ServletException, IOException {
|
||||
throw new UnsupportedOperationException("handlePageException");
|
||||
}
|
||||
|
||||
public void handlePageException(Throwable ex) throws ServletException, IOException {
|
||||
throw new UnsupportedOperationException("handlePageException");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.ServletConfig} interface.
|
||||
*
|
||||
* <p>Used for testing the web framework; typically not necessary for
|
||||
* testing application controllers.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.0.2
|
||||
*/
|
||||
public class MockServletConfig implements ServletConfig {
|
||||
|
||||
private final ServletContext servletContext;
|
||||
|
||||
private final String servletName;
|
||||
|
||||
private final Map<String, String> initParameters = new LinkedHashMap<String, String>();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new MockServletConfig with a default {@link MockServletContext}.
|
||||
*/
|
||||
public MockServletConfig() {
|
||||
this(null, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MockServletConfig with a default {@link MockServletContext}.
|
||||
* @param servletName the name of the servlet
|
||||
*/
|
||||
public MockServletConfig(String servletName) {
|
||||
this(null, servletName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MockServletConfig.
|
||||
* @param servletContext the ServletContext that the servlet runs in
|
||||
*/
|
||||
public MockServletConfig(ServletContext servletContext) {
|
||||
this(servletContext, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new MockServletConfig.
|
||||
* @param servletContext the ServletContext that the servlet runs in
|
||||
* @param servletName the name of the servlet
|
||||
*/
|
||||
public MockServletConfig(ServletContext servletContext, String servletName) {
|
||||
this.servletContext = (servletContext != null ? servletContext : new MockServletContext());
|
||||
this.servletName = servletName;
|
||||
}
|
||||
|
||||
|
||||
public String getServletName() {
|
||||
return this.servletName;
|
||||
}
|
||||
|
||||
public ServletContext getServletContext() {
|
||||
return this.servletContext;
|
||||
}
|
||||
|
||||
public void addInitParameter(String name, String value) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
this.initParameters.put(name, value);
|
||||
}
|
||||
|
||||
public String getInitParameter(String name) {
|
||||
Assert.notNull(name, "Parameter name must not be null");
|
||||
return this.initParameters.get(name);
|
||||
}
|
||||
|
||||
public Enumeration<String> getInitParameterNames() {
|
||||
return Collections.enumeration(this.initParameters.keySet());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.filter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
import org.springframework.mock.web.MockFilterConfig;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class CharacterEncodingFilterTests extends TestCase {
|
||||
|
||||
private static final String FILTER_NAME = "boot";
|
||||
|
||||
private static final String ENCODING = "UTF-8";
|
||||
|
||||
|
||||
public void testForceAlwaysSetsEncoding() throws Exception {
|
||||
MockControl mockRequest = MockControl.createControl(HttpServletRequest.class);
|
||||
HttpServletRequest request = (HttpServletRequest) mockRequest.getMock();
|
||||
request.setCharacterEncoding(ENCODING);
|
||||
mockRequest.setVoidCallable();
|
||||
request.getAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setReturnValue(null);
|
||||
request.setAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
|
||||
mockRequest.setVoidCallable();
|
||||
request.removeAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setVoidCallable();
|
||||
mockRequest.replay();
|
||||
|
||||
MockControl mockResponse = MockControl.createControl(HttpServletResponse.class);
|
||||
HttpServletResponse response = (HttpServletResponse) mockResponse.getMock();
|
||||
response.setCharacterEncoding(ENCODING);
|
||||
mockResponse.setVoidCallable();
|
||||
mockResponse.replay();
|
||||
|
||||
MockControl mockFilter = MockControl.createControl(FilterChain.class);
|
||||
FilterChain filterChain = (FilterChain) mockFilter.getMock();
|
||||
filterChain.doFilter(request, response);
|
||||
mockFilter.replay();
|
||||
|
||||
CharacterEncodingFilter filter = new CharacterEncodingFilter();
|
||||
filter.setForceEncoding(true);
|
||||
filter.setEncoding(ENCODING);
|
||||
filter.init(new MockFilterConfig(FILTER_NAME));
|
||||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
mockRequest.verify();
|
||||
mockResponse.verify();
|
||||
mockFilter.verify();
|
||||
}
|
||||
|
||||
public void testEncodingIfEmptyAndNotForced() throws Exception {
|
||||
MockControl mockRequest = MockControl.createControl(HttpServletRequest.class);
|
||||
HttpServletRequest request = (HttpServletRequest) mockRequest.getMock();
|
||||
request.getCharacterEncoding();
|
||||
mockRequest.setReturnValue(null);
|
||||
request.setCharacterEncoding(ENCODING);
|
||||
mockRequest.setVoidCallable();
|
||||
request.getAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setReturnValue(null);
|
||||
request.setAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
|
||||
mockRequest.setVoidCallable();
|
||||
request.removeAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setVoidCallable();
|
||||
mockRequest.replay();
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
MockControl mockFilter = MockControl.createControl(FilterChain.class);
|
||||
FilterChain filterChain = (FilterChain) mockFilter.getMock();
|
||||
filterChain.doFilter(request, response);
|
||||
mockFilter.replay();
|
||||
|
||||
CharacterEncodingFilter filter = new CharacterEncodingFilter();
|
||||
filter.setForceEncoding(false);
|
||||
filter.setEncoding(ENCODING);
|
||||
filter.init(new MockFilterConfig(FILTER_NAME));
|
||||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
mockRequest.verify();
|
||||
mockFilter.verify();
|
||||
}
|
||||
|
||||
public void testDoesNowtIfEncodingIsNotEmptyAndNotForced() throws Exception {
|
||||
MockControl mockRequest = MockControl.createControl(HttpServletRequest.class);
|
||||
HttpServletRequest request = (HttpServletRequest) mockRequest.getMock();
|
||||
request.getCharacterEncoding();
|
||||
mockRequest.setReturnValue(ENCODING);
|
||||
request.getAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setReturnValue(null);
|
||||
request.setAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
|
||||
mockRequest.setVoidCallable();
|
||||
request.removeAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setVoidCallable();
|
||||
mockRequest.replay();
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
MockControl mockFilter = MockControl.createControl(FilterChain.class);
|
||||
FilterChain filterChain = (FilterChain) mockFilter.getMock();
|
||||
filterChain.doFilter(request, response);
|
||||
mockFilter.replay();
|
||||
|
||||
CharacterEncodingFilter filter = new CharacterEncodingFilter();
|
||||
filter.setEncoding(ENCODING);
|
||||
filter.init(new MockFilterConfig(FILTER_NAME));
|
||||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
mockRequest.verify();
|
||||
mockFilter.verify();
|
||||
}
|
||||
|
||||
public void testWithBeanInitialization() throws Exception {
|
||||
MockControl mockRequest = MockControl.createControl(HttpServletRequest.class);
|
||||
HttpServletRequest request = (HttpServletRequest) mockRequest.getMock();
|
||||
request.getCharacterEncoding();
|
||||
mockRequest.setReturnValue(null);
|
||||
request.setCharacterEncoding(ENCODING);
|
||||
mockRequest.setVoidCallable();
|
||||
request.getAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setReturnValue(null);
|
||||
request.setAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
|
||||
mockRequest.setVoidCallable();
|
||||
request.removeAttribute(FILTER_NAME + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setVoidCallable();
|
||||
mockRequest.replay();
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
MockControl mockFilter = MockControl.createControl(FilterChain.class);
|
||||
FilterChain filterChain = (FilterChain) mockFilter.getMock();
|
||||
filterChain.doFilter(request, response);
|
||||
mockFilter.replay();
|
||||
|
||||
CharacterEncodingFilter filter = new CharacterEncodingFilter();
|
||||
filter.setEncoding(ENCODING);
|
||||
filter.setBeanName(FILTER_NAME);
|
||||
filter.setServletContext(new MockServletContext());
|
||||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
mockRequest.verify();
|
||||
mockFilter.verify();
|
||||
}
|
||||
|
||||
public void testWithIncompleteInitialization() throws Exception {
|
||||
MockControl mockRequest = MockControl.createControl(HttpServletRequest.class);
|
||||
HttpServletRequest request = (HttpServletRequest) mockRequest.getMock();
|
||||
request.getCharacterEncoding();
|
||||
mockRequest.setReturnValue(null);
|
||||
request.setCharacterEncoding(ENCODING);
|
||||
mockRequest.setVoidCallable();
|
||||
request.getAttribute(CharacterEncodingFilter.class.getName() + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setReturnValue(null);
|
||||
request.setAttribute(CharacterEncodingFilter.class.getName() + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX, Boolean.TRUE);
|
||||
mockRequest.setVoidCallable();
|
||||
request.removeAttribute(CharacterEncodingFilter.class.getName() + OncePerRequestFilter.ALREADY_FILTERED_SUFFIX);
|
||||
mockRequest.setVoidCallable();
|
||||
mockRequest.replay();
|
||||
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
MockControl mockFilter = MockControl.createControl(FilterChain.class);
|
||||
FilterChain filterChain = (FilterChain) mockFilter.getMock();
|
||||
filterChain.doFilter(request, response);
|
||||
mockFilter.replay();
|
||||
|
||||
CharacterEncodingFilter filter = new CharacterEncodingFilter();
|
||||
filter.setEncoding(ENCODING);
|
||||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
mockRequest.verify();
|
||||
mockFilter.verify();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.MockFilterConfig;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.StaticWebApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @since 08.05.2005
|
||||
*/
|
||||
public class DelegatingFilterProxyTests extends TestCase {
|
||||
|
||||
public void testDelegatingFilterProxy() throws ServletException, IOException {
|
||||
ServletContext sc = new MockServletContext();
|
||||
|
||||
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
||||
wac.setServletContext(sc);
|
||||
wac.registerSingleton("targetFilter", MockFilter.class);
|
||||
wac.refresh();
|
||||
sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||
|
||||
MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
|
||||
|
||||
MockFilterConfig proxyConfig = new MockFilterConfig(sc);
|
||||
proxyConfig.addInitParameter("targetBeanName", "targetFilter");
|
||||
DelegatingFilterProxy filterProxy = new DelegatingFilterProxy();
|
||||
filterProxy.init(proxyConfig);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
filterProxy.doFilter(request, response, null);
|
||||
|
||||
assertNull(targetFilter.filterConfig);
|
||||
assertEquals(Boolean.TRUE, request.getAttribute("called"));
|
||||
|
||||
filterProxy.destroy();
|
||||
assertNull(targetFilter.filterConfig);
|
||||
}
|
||||
|
||||
public void testDelegatingFilterProxyWithFilterName() throws ServletException, IOException {
|
||||
ServletContext sc = new MockServletContext();
|
||||
|
||||
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
||||
wac.setServletContext(sc);
|
||||
wac.registerSingleton("targetFilter", MockFilter.class);
|
||||
wac.refresh();
|
||||
sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||
|
||||
MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
|
||||
|
||||
MockFilterConfig proxyConfig = new MockFilterConfig(sc, "targetFilter");
|
||||
DelegatingFilterProxy filterProxy = new DelegatingFilterProxy();
|
||||
filterProxy.init(proxyConfig);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
filterProxy.doFilter(request, response, null);
|
||||
|
||||
assertNull(targetFilter.filterConfig);
|
||||
assertEquals(Boolean.TRUE, request.getAttribute("called"));
|
||||
|
||||
filterProxy.destroy();
|
||||
assertNull(targetFilter.filterConfig);
|
||||
}
|
||||
|
||||
public void testDelegatingFilterProxyWithLazyContextStartup() throws ServletException, IOException {
|
||||
ServletContext sc = new MockServletContext();
|
||||
|
||||
MockFilterConfig proxyConfig = new MockFilterConfig(sc);
|
||||
proxyConfig.addInitParameter("targetBeanName", "targetFilter");
|
||||
DelegatingFilterProxy filterProxy = new DelegatingFilterProxy();
|
||||
filterProxy.init(proxyConfig);
|
||||
|
||||
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
||||
wac.setServletContext(sc);
|
||||
wac.registerSingleton("targetFilter", MockFilter.class);
|
||||
wac.refresh();
|
||||
sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||
|
||||
MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
filterProxy.doFilter(request, response, null);
|
||||
|
||||
assertNull(targetFilter.filterConfig);
|
||||
assertEquals(Boolean.TRUE, request.getAttribute("called"));
|
||||
|
||||
filterProxy.destroy();
|
||||
assertNull(targetFilter.filterConfig);
|
||||
}
|
||||
|
||||
public void testDelegatingFilterProxyWithTargetFilterLifecycle() throws ServletException, IOException {
|
||||
ServletContext sc = new MockServletContext();
|
||||
|
||||
StaticWebApplicationContext wac = new StaticWebApplicationContext();
|
||||
wac.setServletContext(sc);
|
||||
wac.registerSingleton("targetFilter", MockFilter.class);
|
||||
wac.refresh();
|
||||
sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
|
||||
|
||||
MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
|
||||
|
||||
MockFilterConfig proxyConfig = new MockFilterConfig(sc);
|
||||
proxyConfig.addInitParameter("targetBeanName", "targetFilter");
|
||||
proxyConfig.addInitParameter("targetFilterLifecycle", "true");
|
||||
DelegatingFilterProxy filterProxy = new DelegatingFilterProxy();
|
||||
filterProxy.init(proxyConfig);
|
||||
assertEquals(proxyConfig, targetFilter.filterConfig);
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
filterProxy.doFilter(request, response, null);
|
||||
|
||||
assertEquals(proxyConfig, targetFilter.filterConfig);
|
||||
assertEquals(Boolean.TRUE, request.getAttribute("called"));
|
||||
|
||||
filterProxy.destroy();
|
||||
assertNull(targetFilter.filterConfig);
|
||||
}
|
||||
|
||||
|
||||
public static class MockFilter implements Filter {
|
||||
|
||||
public FilterConfig filterConfig;
|
||||
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
this.filterConfig = filterConfig;
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
|
||||
request.setAttribute("called", Boolean.TRUE);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
this.filterConfig = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.MockFilterConfig;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class RequestContextFilterTests extends TestCase {
|
||||
|
||||
public void testHappyPath() throws Exception {
|
||||
testFilterInvocation(null);
|
||||
}
|
||||
|
||||
public void testWithException() throws Exception {
|
||||
testFilterInvocation(new ServletException());
|
||||
}
|
||||
|
||||
public void testFilterInvocation(final ServletException sex) throws Exception {
|
||||
final MockHttpServletRequest req = new MockHttpServletRequest();
|
||||
req.setAttribute("myAttr", "myValue");
|
||||
final MockHttpServletResponse resp = new MockHttpServletResponse();
|
||||
|
||||
// Expect one invocation by the filter being tested
|
||||
class DummyFilterChain implements FilterChain {
|
||||
public int invocations = 0;
|
||||
public void doFilter(ServletRequest req, ServletResponse resp) throws IOException, ServletException {
|
||||
++invocations;
|
||||
if (invocations == 1) {
|
||||
assertSame("myValue",
|
||||
RequestContextHolder.currentRequestAttributes().getAttribute("myAttr", RequestAttributes.SCOPE_REQUEST));
|
||||
if (sex != null) {
|
||||
throw sex;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("Too many invocations");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DummyFilterChain fc = new DummyFilterChain();
|
||||
MockFilterConfig mfc = new MockFilterConfig(new MockServletContext(), "foo");
|
||||
|
||||
RequestContextFilter rbf = new RequestContextFilter();
|
||||
rbf.init(mfc);
|
||||
|
||||
try {
|
||||
rbf.doFilter(req, resp, fc);
|
||||
if (sex != null) {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
catch (ServletException ex) {
|
||||
assertNotNull(sex);
|
||||
}
|
||||
|
||||
try {
|
||||
RequestContextHolder.currentRequestAttributes();
|
||||
fail();
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
// Ok
|
||||
}
|
||||
|
||||
assertEquals(1, fc.invocations);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright ${YEAR} the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
public class ShallowEtagHeaderFilterTest {
|
||||
|
||||
private ShallowEtagHeaderFilter filter;
|
||||
|
||||
@Before
|
||||
public void createFilter() throws Exception {
|
||||
filter = new ShallowEtagHeaderFilter();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterNoMatch() throws Exception {
|
||||
final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hotels");
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
final byte[] responseBody = "Hello World".getBytes("UTF-8");
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
assertEquals("Invalid request passed", request, filterRequest);
|
||||
((HttpServletResponse) filterResponse).setStatus(HttpServletResponse.SC_OK);
|
||||
FileCopyUtils.copy(responseBody, filterResponse.getOutputStream());
|
||||
}
|
||||
};
|
||||
|
||||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
assertEquals("Invalid status", 200, response.getStatus());
|
||||
assertEquals("Invalid ETag header", "\"0b10a8db164e0754105b7a99be72e3fe5\"", response.getHeader("ETag"));
|
||||
assertTrue("Invalid Content-Length header", response.getContentLength() > 0);
|
||||
assertArrayEquals("Invalid content", responseBody, response.getContentAsByteArray());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterMatch() throws Exception {
|
||||
final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hotels");
|
||||
String etag = "\"0b10a8db164e0754105b7a99be72e3fe5\"";
|
||||
request.addHeader("If-None-Match", etag);
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
FilterChain filterChain = new FilterChain() {
|
||||
|
||||
public void doFilter(ServletRequest filterRequest, ServletResponse filterResponse)
|
||||
throws IOException, ServletException {
|
||||
assertEquals("Invalid request passed", request, filterRequest);
|
||||
((HttpServletResponse) filterResponse).setStatus(HttpServletResponse.SC_OK);
|
||||
byte[] responseBody = "Hello World".getBytes("UTF-8");
|
||||
FileCopyUtils.copy(responseBody, filterResponse.getOutputStream());
|
||||
}
|
||||
};
|
||||
|
||||
filter.doFilter(request, response, filterChain);
|
||||
|
||||
assertEquals("Invalid status", 304, response.getStatus());
|
||||
assertEquals("Invalid ETag header", "\"0b10a8db164e0754105b7a99be72e3fe5\"", response.getHeader("ETag"));
|
||||
assertEquals("Invalid Content-Length header", 0, response.getContentLength());
|
||||
assertArrayEquals("Invalid content", new byte[0], response.getContentAsByteArray());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.util;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import javax.servlet.jsp.el.ELException;
|
||||
import javax.servlet.jsp.el.Expression;
|
||||
import javax.servlet.jsp.el.ExpressionEvaluator;
|
||||
import javax.servlet.jsp.el.FunctionMapper;
|
||||
import javax.servlet.jsp.el.VariableResolver;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.springframework.mock.web.MockExpressionEvaluator;
|
||||
import org.springframework.mock.web.MockPageContext;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
|
||||
/**
|
||||
* @author Aled Arendsen
|
||||
* @author Juergen Hoeller
|
||||
* @since 16.09.2003
|
||||
*/
|
||||
@Ignore // calls to deprecated getVariableResolver() are throwing UOEs
|
||||
public class ExpressionEvaluationUtilsTests extends TestCase {
|
||||
|
||||
public void testIsExpressionLanguage() {
|
||||
assertTrue(ExpressionEvaluationUtils.isExpressionLanguage("${bla}"));
|
||||
assertTrue(ExpressionEvaluationUtils.isExpressionLanguage("bla${bla}"));
|
||||
assertFalse(ExpressionEvaluationUtils.isExpressionLanguage("bla{bla"));
|
||||
assertFalse(ExpressionEvaluationUtils.isExpressionLanguage("bla$b{"));
|
||||
}
|
||||
|
||||
public void testEvaluate() throws Exception {
|
||||
PageContext ctx = new MockPageContext();
|
||||
ctx.setAttribute("bla", "blie");
|
||||
|
||||
assertEquals("blie", ExpressionEvaluationUtils.evaluate("test", "${bla}", String.class, ctx));
|
||||
assertEquals("test", ExpressionEvaluationUtils.evaluate("test", "test", String.class, ctx));
|
||||
|
||||
try {
|
||||
ExpressionEvaluationUtils.evaluate("test", "test", Float.class, ctx);
|
||||
fail("Should have thrown JspException");
|
||||
}
|
||||
catch (JspException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testEvaluateWithConcatenation() throws Exception {
|
||||
PageContext ctx = new MockPageContext();
|
||||
ctx.setAttribute("bla", "blie");
|
||||
|
||||
String expr = "text${bla}text${bla}text";
|
||||
Object o = ExpressionEvaluationUtils.evaluate("test", expr, String.class, ctx);
|
||||
assertEquals("textblietextblietext", o);
|
||||
|
||||
expr = "${bla}text${bla}text";
|
||||
o = ExpressionEvaluationUtils.evaluate("test", expr, String.class, ctx);
|
||||
assertEquals("blietextblietext", o);
|
||||
|
||||
expr = "${bla}text${bla}";
|
||||
o = ExpressionEvaluationUtils.evaluate("test", expr, String.class, ctx);
|
||||
assertEquals("blietextblie", o);
|
||||
|
||||
expr = "${bla}text${bla}";
|
||||
o = ExpressionEvaluationUtils.evaluate("test", expr, Object.class, ctx);
|
||||
assertEquals("blietextblie", o);
|
||||
|
||||
try {
|
||||
expr = "${bla}text${bla";
|
||||
ExpressionEvaluationUtils.evaluate("test", expr, Object.class, ctx);
|
||||
fail("Should have thrown JspException");
|
||||
}
|
||||
catch (JspException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
try {
|
||||
expr = "${bla}text${bla}";
|
||||
ExpressionEvaluationUtils.evaluate("test", expr, Float.class, ctx);
|
||||
fail("Should have thrown JspException");
|
||||
}
|
||||
catch (JspException ex) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testEvaluateString() throws Exception {
|
||||
PageContext ctx = new MockPageContext();
|
||||
ctx.setAttribute("bla", "blie");
|
||||
|
||||
assertEquals("blie", ExpressionEvaluationUtils.evaluateString("test", "${bla}", ctx));
|
||||
assertEquals("blie", ExpressionEvaluationUtils.evaluateString("test", "blie", ctx));
|
||||
}
|
||||
|
||||
public void testEvaluateStringWithConcatenation() throws Exception {
|
||||
PageContext ctx = new MockPageContext();
|
||||
ctx.setAttribute("bla", "blie");
|
||||
|
||||
String expr = "text${bla}text${bla}text";
|
||||
String s = ExpressionEvaluationUtils.evaluateString("test", expr, ctx);
|
||||
assertEquals("textblietextblietext", s);
|
||||
|
||||
expr = "${bla}text${bla}text";
|
||||
s = ExpressionEvaluationUtils.evaluateString("test", expr, ctx);
|
||||
assertEquals("blietextblietext", s);
|
||||
|
||||
expr = "${bla}text${bla}";
|
||||
s = ExpressionEvaluationUtils.evaluateString("test", expr, ctx);
|
||||
assertEquals("blietextblie", s);
|
||||
|
||||
expr = "${bla}text${bla}";
|
||||
s = ExpressionEvaluationUtils.evaluateString("test", expr, ctx);
|
||||
assertEquals("blietextblie", s);
|
||||
|
||||
try {
|
||||
expr = "${bla}text${bla";
|
||||
ExpressionEvaluationUtils.evaluateString("test", expr, ctx);
|
||||
fail("Should have thrown JspException");
|
||||
}
|
||||
catch (JspException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testEvaluateInteger() throws Exception {
|
||||
PageContext ctx = new MockPageContext();
|
||||
ctx.setAttribute("bla", new Integer(1));
|
||||
|
||||
assertEquals(1, ExpressionEvaluationUtils.evaluateInteger("test", "${bla}", ctx));
|
||||
assertEquals(21, ExpressionEvaluationUtils.evaluateInteger("test", "21", ctx));
|
||||
}
|
||||
|
||||
public void testEvaluateBoolean() throws Exception {
|
||||
PageContext ctx = new MockPageContext();
|
||||
ctx.setAttribute("bla", new Boolean(true));
|
||||
|
||||
assertTrue(ExpressionEvaluationUtils.evaluateBoolean("test", "${bla}", ctx));
|
||||
assertTrue(ExpressionEvaluationUtils.evaluateBoolean("test", "true", ctx));
|
||||
}
|
||||
|
||||
public void testEvaluateWithoutCaching() throws Exception {
|
||||
PageContext ctx = new CountingMockPageContext();
|
||||
CountingMockExpressionEvaluator eval = (CountingMockExpressionEvaluator) ctx.getExpressionEvaluator();
|
||||
ctx.setAttribute("bla", "blie");
|
||||
ctx.setAttribute("blo", "blue");
|
||||
|
||||
assertEquals("blie", ExpressionEvaluationUtils.evaluate("test", "${bla}", String.class, ctx));
|
||||
assertEquals(1, eval.evaluateCount);
|
||||
|
||||
assertEquals("blue", ExpressionEvaluationUtils.evaluate("test", "${blo}", String.class, ctx));
|
||||
assertEquals(2, eval.evaluateCount);
|
||||
|
||||
assertEquals("blie", ExpressionEvaluationUtils.evaluate("test", "${bla}", String.class, ctx));
|
||||
assertEquals(3, eval.evaluateCount);
|
||||
|
||||
assertEquals("blue", ExpressionEvaluationUtils.evaluate("test", "${blo}", String.class, ctx));
|
||||
assertEquals(4, eval.evaluateCount);
|
||||
}
|
||||
|
||||
public void testEvaluateWithCaching() throws Exception {
|
||||
PageContext ctx = new CountingMockPageContext();
|
||||
CountingMockExpressionEvaluator eval = (CountingMockExpressionEvaluator) ctx.getExpressionEvaluator();
|
||||
ctx.setAttribute("bla", "blie");
|
||||
ctx.setAttribute("blo", "blue");
|
||||
|
||||
MockServletContext sc = (MockServletContext) ctx.getServletContext();
|
||||
sc.addInitParameter(ExpressionEvaluationUtils.EXPRESSION_CACHE_CONTEXT_PARAM, "true");
|
||||
|
||||
assertEquals("blie", ExpressionEvaluationUtils.evaluate("test", "${bla}", String.class, ctx));
|
||||
assertEquals(1, eval.parseExpressionCount);
|
||||
|
||||
assertEquals("blue", ExpressionEvaluationUtils.evaluate("test", "${blo}", String.class, ctx));
|
||||
assertEquals(2, eval.parseExpressionCount);
|
||||
|
||||
assertEquals("blie", ExpressionEvaluationUtils.evaluate("test", "${bla}", String.class, ctx));
|
||||
assertEquals(2, eval.parseExpressionCount);
|
||||
|
||||
assertEquals("blue", ExpressionEvaluationUtils.evaluate("test", "${blo}", String.class, ctx));
|
||||
assertEquals(2, eval.parseExpressionCount);
|
||||
}
|
||||
|
||||
public void testEvaluateWithConcatenationWithoutCaching() throws Exception {
|
||||
PageContext ctx = new CountingMockPageContext();
|
||||
CountingMockExpressionEvaluator eval = (CountingMockExpressionEvaluator) ctx.getExpressionEvaluator();
|
||||
ctx.setAttribute("bla", "blie");
|
||||
ctx.setAttribute("blo", "blue");
|
||||
|
||||
String expr = "text${bla}text${blo}text";
|
||||
Object o = ExpressionEvaluationUtils.evaluate("test", expr, String.class, ctx);
|
||||
assertEquals("textblietextbluetext", o);
|
||||
assertEquals(2, eval.evaluateCount);
|
||||
|
||||
expr = "${bla}text${blo}text";
|
||||
o = ExpressionEvaluationUtils.evaluate("test", expr, String.class, ctx);
|
||||
assertEquals("blietextbluetext", o);
|
||||
assertEquals(4, eval.evaluateCount);
|
||||
|
||||
expr = "${bla}text${blo}";
|
||||
o = ExpressionEvaluationUtils.evaluate("test", expr, String.class, ctx);
|
||||
assertEquals("blietextblue", o);
|
||||
assertEquals(6, eval.evaluateCount);
|
||||
|
||||
expr = "${bla}text${blo}";
|
||||
o = ExpressionEvaluationUtils.evaluate("test", expr, Object.class, ctx);
|
||||
assertEquals("blietextblue", o);
|
||||
assertEquals(8, eval.evaluateCount);
|
||||
}
|
||||
|
||||
public void testEvaluateWithConcatenationWithCaching() throws Exception {
|
||||
PageContext ctx = new CountingMockPageContext();
|
||||
CountingMockExpressionEvaluator eval = (CountingMockExpressionEvaluator) ctx.getExpressionEvaluator();
|
||||
ctx.setAttribute("bla", "blie");
|
||||
ctx.setAttribute("blo", "blue");
|
||||
|
||||
MockServletContext sc = (MockServletContext) ctx.getServletContext();
|
||||
sc.addInitParameter(ExpressionEvaluationUtils.EXPRESSION_CACHE_CONTEXT_PARAM, "true");
|
||||
|
||||
String expr = "text${bla}text${blo}text";
|
||||
Object o = ExpressionEvaluationUtils.evaluate("test", expr, String.class, ctx);
|
||||
assertEquals("textblietextbluetext", o);
|
||||
assertEquals(2, eval.parseExpressionCount);
|
||||
|
||||
expr = "${bla}text${blo}text";
|
||||
o = ExpressionEvaluationUtils.evaluate("test", expr, String.class, ctx);
|
||||
assertEquals("blietextbluetext", o);
|
||||
assertEquals(2, eval.parseExpressionCount);
|
||||
|
||||
expr = "${bla}text${blo}";
|
||||
o = ExpressionEvaluationUtils.evaluate("test", expr, String.class, ctx);
|
||||
assertEquals("blietextblue", o);
|
||||
assertEquals(2, eval.parseExpressionCount);
|
||||
|
||||
expr = "${bla}text${blo}";
|
||||
o = ExpressionEvaluationUtils.evaluate("test", expr, Object.class, ctx);
|
||||
assertEquals("blietextblue", o);
|
||||
assertEquals(2, eval.parseExpressionCount);
|
||||
}
|
||||
|
||||
|
||||
private static class CountingMockPageContext extends MockPageContext {
|
||||
|
||||
private ExpressionEvaluator eval = new CountingMockExpressionEvaluator(this);
|
||||
|
||||
public ExpressionEvaluator getExpressionEvaluator() {
|
||||
return eval;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class CountingMockExpressionEvaluator extends MockExpressionEvaluator {
|
||||
|
||||
public int parseExpressionCount = 0;
|
||||
|
||||
public int evaluateCount = 0;
|
||||
|
||||
public CountingMockExpressionEvaluator(PageContext pageContext) {
|
||||
super(pageContext);
|
||||
}
|
||||
|
||||
public Expression parseExpression(String expression, Class expectedType, FunctionMapper functionMapper) throws ELException {
|
||||
this.parseExpressionCount++;
|
||||
return super.parseExpression(expression, expectedType, functionMapper);
|
||||
}
|
||||
|
||||
public Object evaluate(String expression, Class expectedType, VariableResolver variableResolver, FunctionMapper functionMapper) throws ELException {
|
||||
this.evaluateCount++;
|
||||
return super.evaluate(expression, expectedType, variableResolver, functionMapper);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,523 @@
|
||||
<!-- File containing all charcter entity references definied
|
||||
by the HTML 4.0 standard. -->
|
||||
<!-- Valuable informations and a complete description of the
|
||||
HTML 4.0 character set can be found at
|
||||
http://www.w3.org/TR/html4/charset.html.
|
||||
-->
|
||||
|
||||
|
||||
<!-- Portions © International Organization for Standardization 1986
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
ISO 8879, provided this notice is included in all copies.
|
||||
-->
|
||||
<!-- Character entity set. Typical invocation:
|
||||
<!ENTITY % HTMLlat1 PUBLIC
|
||||
"-//W3C//ENTITIES Latin 1//EN//HTML">
|
||||
%HTMLlat1; -->
|
||||
|
||||
<!ENTITY nbsp CDATA " " -- no-break space = non-breaking space,
|
||||
U+00A0 ISOnum -->
|
||||
<!ENTITY iexcl CDATA "¡" -- inverted exclamation mark, U+00A1 ISOnum -->
|
||||
<!ENTITY cent CDATA "¢" -- cent sign, U+00A2 ISOnum -->
|
||||
<!ENTITY pound CDATA "£" -- pound sign, U+00A3 ISOnum -->
|
||||
<!ENTITY curren CDATA "¤" -- currency sign, U+00A4 ISOnum -->
|
||||
<!ENTITY yen CDATA "¥" -- yen sign = yuan sign, U+00A5 ISOnum -->
|
||||
<!ENTITY brvbar CDATA "¦" -- broken bar = broken vertical bar,
|
||||
U+00A6 ISOnum -->
|
||||
<!ENTITY sect CDATA "§" -- section sign, U+00A7 ISOnum -->
|
||||
<!ENTITY uml CDATA "¨" -- diaeresis = spacing diaeresis,
|
||||
U+00A8 ISOdia -->
|
||||
<!ENTITY copy CDATA "©" -- copyright sign, U+00A9 ISOnum -->
|
||||
<!ENTITY ordf CDATA "ª" -- feminine ordinal indicator, U+00AA ISOnum -->
|
||||
<!ENTITY laquo CDATA "«" -- left-pointing double angle quotation mark
|
||||
= left pointing guillemet, U+00AB ISOnum -->
|
||||
<!ENTITY not CDATA "¬" -- not sign, U+00AC ISOnum -->
|
||||
<!ENTITY shy CDATA "­" -- soft hyphen = discretionary hyphen,
|
||||
U+00AD ISOnum -->
|
||||
<!ENTITY reg CDATA "®" -- registered sign = registered trade mark sign,
|
||||
U+00AE ISOnum -->
|
||||
<!ENTITY macr CDATA "¯" -- macron = spacing macron = overline
|
||||
= APL overbar, U+00AF ISOdia -->
|
||||
<!ENTITY deg CDATA "°" -- degree sign, U+00B0 ISOnum -->
|
||||
<!ENTITY plusmn CDATA "±" -- plus-minus sign = plus-or-minus sign,
|
||||
U+00B1 ISOnum -->
|
||||
<!ENTITY sup2 CDATA "²" -- superscript two = superscript digit two
|
||||
= squared, U+00B2 ISOnum -->
|
||||
<!ENTITY sup3 CDATA "³" -- superscript three = superscript digit three
|
||||
= cubed, U+00B3 ISOnum -->
|
||||
<!ENTITY acute CDATA "´" -- acute accent = spacing acute,
|
||||
U+00B4 ISOdia -->
|
||||
<!ENTITY micro CDATA "µ" -- micro sign, U+00B5 ISOnum -->
|
||||
<!ENTITY para CDATA "¶" -- pilcrow sign = paragraph sign,
|
||||
U+00B6 ISOnum -->
|
||||
<!ENTITY middot CDATA "·" -- middle dot = Georgian comma
|
||||
= Greek middle dot, U+00B7 ISOnum -->
|
||||
<!ENTITY cedil CDATA "¸" -- cedilla = spacing cedilla, U+00B8 ISOdia -->
|
||||
<!ENTITY sup1 CDATA "¹" -- superscript one = superscript digit one,
|
||||
U+00B9 ISOnum -->
|
||||
<!ENTITY ordm CDATA "º" -- masculine ordinal indicator,
|
||||
U+00BA ISOnum -->
|
||||
<!ENTITY raquo CDATA "»" -- right-pointing double angle quotation mark
|
||||
= right pointing guillemet, U+00BB ISOnum -->
|
||||
<!ENTITY frac14 CDATA "¼" -- vulgar fraction one quarter
|
||||
= fraction one quarter, U+00BC ISOnum -->
|
||||
<!ENTITY frac12 CDATA "½" -- vulgar fraction one half
|
||||
= fraction one half, U+00BD ISOnum -->
|
||||
<!ENTITY frac34 CDATA "¾" -- vulgar fraction three quarters
|
||||
= fraction three quarters, U+00BE ISOnum -->
|
||||
<!ENTITY iquest CDATA "¿" -- inverted question mark
|
||||
= turned question mark, U+00BF ISOnum -->
|
||||
<!ENTITY Agrave CDATA "À" -- latin capital letter A with grave
|
||||
= latin capital letter A grave,
|
||||
U+00C0 ISOlat1 -->
|
||||
<!ENTITY Aacute CDATA "Á" -- latin capital letter A with acute,
|
||||
U+00C1 ISOlat1 -->
|
||||
<!ENTITY Acirc CDATA "Â" -- latin capital letter A with circumflex,
|
||||
U+00C2 ISOlat1 -->
|
||||
<!ENTITY Atilde CDATA "Ã" -- latin capital letter A with tilde,
|
||||
U+00C3 ISOlat1 -->
|
||||
<!ENTITY Auml CDATA "Ä" -- latin capital letter A with diaeresis,
|
||||
U+00C4 ISOlat1 -->
|
||||
<!ENTITY Aring CDATA "Å" -- latin capital letter A with ring above
|
||||
= latin capital letter A ring,
|
||||
U+00C5 ISOlat1 -->
|
||||
<!ENTITY AElig CDATA "Æ" -- latin capital letter AE
|
||||
= latin capital ligature AE,
|
||||
U+00C6 ISOlat1 -->
|
||||
<!ENTITY Ccedil CDATA "Ç" -- latin capital letter C with cedilla,
|
||||
U+00C7 ISOlat1 -->
|
||||
<!ENTITY Egrave CDATA "È" -- latin capital letter E with grave,
|
||||
U+00C8 ISOlat1 -->
|
||||
<!ENTITY Eacute CDATA "É" -- latin capital letter E with acute,
|
||||
U+00C9 ISOlat1 -->
|
||||
<!ENTITY Ecirc CDATA "Ê" -- latin capital letter E with circumflex,
|
||||
U+00CA ISOlat1 -->
|
||||
<!ENTITY Euml CDATA "Ë" -- latin capital letter E with diaeresis,
|
||||
U+00CB ISOlat1 -->
|
||||
<!ENTITY Igrave CDATA "Ì" -- latin capital letter I with grave,
|
||||
U+00CC ISOlat1 -->
|
||||
<!ENTITY Iacute CDATA "Í" -- latin capital letter I with acute,
|
||||
U+00CD ISOlat1 -->
|
||||
<!ENTITY Icirc CDATA "Î" -- latin capital letter I with circumflex,
|
||||
U+00CE ISOlat1 -->
|
||||
<!ENTITY Iuml CDATA "Ï" -- latin capital letter I with diaeresis,
|
||||
U+00CF ISOlat1 -->
|
||||
<!ENTITY ETH CDATA "Ð" -- latin capital letter ETH, U+00D0 ISOlat1 -->
|
||||
<!ENTITY Ntilde CDATA "Ñ" -- latin capital letter N with tilde,
|
||||
U+00D1 ISOlat1 -->
|
||||
<!ENTITY Ograve CDATA "Ò" -- latin capital letter O with grave,
|
||||
U+00D2 ISOlat1 -->
|
||||
<!ENTITY Oacute CDATA "Ó" -- latin capital letter O with acute,
|
||||
U+00D3 ISOlat1 -->
|
||||
<!ENTITY Ocirc CDATA "Ô" -- latin capital letter O with circumflex,
|
||||
U+00D4 ISOlat1 -->
|
||||
<!ENTITY Otilde CDATA "Õ" -- latin capital letter O with tilde,
|
||||
U+00D5 ISOlat1 -->
|
||||
<!ENTITY Ouml CDATA "Ö" -- latin capital letter O with diaeresis,
|
||||
U+00D6 ISOlat1 -->
|
||||
<!ENTITY times CDATA "×" -- multiplication sign, U+00D7 ISOnum -->
|
||||
<!ENTITY Oslash CDATA "Ø" -- latin capital letter O with stroke
|
||||
= latin capital letter O slash,
|
||||
U+00D8 ISOlat1 -->
|
||||
<!ENTITY Ugrave CDATA "Ù" -- latin capital letter U with grave,
|
||||
U+00D9 ISOlat1 -->
|
||||
<!ENTITY Uacute CDATA "Ú" -- latin capital letter U with acute,
|
||||
U+00DA ISOlat1 -->
|
||||
<!ENTITY Ucirc CDATA "Û" -- latin capital letter U with circumflex,
|
||||
U+00DB ISOlat1 -->
|
||||
<!ENTITY Uuml CDATA "Ü" -- latin capital letter U with diaeresis,
|
||||
U+00DC ISOlat1 -->
|
||||
<!ENTITY Yacute CDATA "Ý" -- latin capital letter Y with acute,
|
||||
U+00DD ISOlat1 -->
|
||||
<!ENTITY THORN CDATA "Þ" -- latin capital letter THORN,
|
||||
U+00DE ISOlat1 -->
|
||||
<!ENTITY szlig CDATA "ß" -- latin small letter sharp s = ess-zed,
|
||||
U+00DF ISOlat1 -->
|
||||
<!ENTITY agrave CDATA "à" -- latin small letter a with grave
|
||||
= latin small letter a grave,
|
||||
U+00E0 ISOlat1 -->
|
||||
<!ENTITY aacute CDATA "á" -- latin small letter a with acute,
|
||||
U+00E1 ISOlat1 -->
|
||||
<!ENTITY acirc CDATA "â" -- latin small letter a with circumflex,
|
||||
U+00E2 ISOlat1 -->
|
||||
<!ENTITY atilde CDATA "ã" -- latin small letter a with tilde,
|
||||
U+00E3 ISOlat1 -->
|
||||
<!ENTITY auml CDATA "ä" -- latin small letter a with diaeresis,
|
||||
U+00E4 ISOlat1 -->
|
||||
<!ENTITY aring CDATA "å" -- latin small letter a with ring above
|
||||
= latin small letter a ring,
|
||||
U+00E5 ISOlat1 -->
|
||||
<!ENTITY aelig CDATA "æ" -- latin small letter ae
|
||||
= latin small ligature ae, U+00E6 ISOlat1 -->
|
||||
<!ENTITY ccedil CDATA "ç" -- latin small letter c with cedilla,
|
||||
U+00E7 ISOlat1 -->
|
||||
<!ENTITY egrave CDATA "è" -- latin small letter e with grave,
|
||||
U+00E8 ISOlat1 -->
|
||||
<!ENTITY eacute CDATA "é" -- latin small letter e with acute,
|
||||
U+00E9 ISOlat1 -->
|
||||
<!ENTITY ecirc CDATA "ê" -- latin small letter e with circumflex,
|
||||
U+00EA ISOlat1 -->
|
||||
<!ENTITY euml CDATA "ë" -- latin small letter e with diaeresis,
|
||||
U+00EB ISOlat1 -->
|
||||
<!ENTITY igrave CDATA "ì" -- latin small letter i with grave,
|
||||
U+00EC ISOlat1 -->
|
||||
<!ENTITY iacute CDATA "í" -- latin small letter i with acute,
|
||||
U+00ED ISOlat1 -->
|
||||
<!ENTITY icirc CDATA "î" -- latin small letter i with circumflex,
|
||||
U+00EE ISOlat1 -->
|
||||
<!ENTITY iuml CDATA "ï" -- latin small letter i with diaeresis,
|
||||
U+00EF ISOlat1 -->
|
||||
<!ENTITY eth CDATA "ð" -- latin small letter eth, U+00F0 ISOlat1 -->
|
||||
<!ENTITY ntilde CDATA "ñ" -- latin small letter n with tilde,
|
||||
U+00F1 ISOlat1 -->
|
||||
<!ENTITY ograve CDATA "ò" -- latin small letter o with grave,
|
||||
U+00F2 ISOlat1 -->
|
||||
<!ENTITY oacute CDATA "ó" -- latin small letter o with acute,
|
||||
U+00F3 ISOlat1 -->
|
||||
<!ENTITY ocirc CDATA "ô" -- latin small letter o with circumflex,
|
||||
U+00F4 ISOlat1 -->
|
||||
<!ENTITY otilde CDATA "õ" -- latin small letter o with tilde,
|
||||
U+00F5 ISOlat1 -->
|
||||
<!ENTITY ouml CDATA "ö" -- latin small letter o with diaeresis,
|
||||
U+00F6 ISOlat1 -->
|
||||
<!ENTITY divide CDATA "÷" -- division sign, U+00F7 ISOnum -->
|
||||
<!ENTITY oslash CDATA "ø" -- latin small letter o with stroke,
|
||||
= latin small letter o slash,
|
||||
U+00F8 ISOlat1 -->
|
||||
<!ENTITY ugrave CDATA "ù" -- latin small letter u with grave,
|
||||
U+00F9 ISOlat1 -->
|
||||
<!ENTITY uacute CDATA "ú" -- latin small letter u with acute,
|
||||
U+00FA ISOlat1 -->
|
||||
<!ENTITY ucirc CDATA "û" -- latin small letter u with circumflex,
|
||||
U+00FB ISOlat1 -->
|
||||
<!ENTITY uuml CDATA "ü" -- latin small letter u with diaeresis,
|
||||
U+00FC ISOlat1 -->
|
||||
<!ENTITY yacute CDATA "ý" -- latin small letter y with acute,
|
||||
U+00FD ISOlat1 -->
|
||||
<!ENTITY thorn CDATA "þ" -- latin small letter thorn,
|
||||
U+00FE ISOlat1 -->
|
||||
<!ENTITY yuml CDATA "ÿ" -- latin small letter y with diaeresis,
|
||||
U+00FF ISOlat1 -->
|
||||
|
||||
|
||||
<!-- Mathematical, Greek and Symbolic characters for HTML -->
|
||||
|
||||
<!-- Character entity set. Typical invocation:
|
||||
<!ENTITY % HTMLsymbol PUBLIC
|
||||
"-//W3C//ENTITIES Symbols//EN//HTML">
|
||||
%HTMLsymbol; -->
|
||||
|
||||
<!-- Portions © International Organization for Standardization 1986:
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
ISO 8879, provided this notice is included in all copies.
|
||||
-->
|
||||
|
||||
<!-- Relevant ISO entity set is given unless names are newly introduced.
|
||||
New names (i.e., not in ISO 8879 list) do not clash with any
|
||||
existing ISO 8879 entity names. ISO 10646 character numbers
|
||||
are given for each character, in hex. CDATA values are decimal
|
||||
conversions of the ISO 10646 values and refer to the document
|
||||
character set. Names are ISO 10646 names.
|
||||
|
||||
-->
|
||||
|
||||
<!-- Latin Extended-B -->
|
||||
<!ENTITY fnof CDATA "ƒ" -- latin small f with hook = function
|
||||
= florin, U+0192 ISOtech -->
|
||||
|
||||
<!-- Greek -->
|
||||
<!ENTITY Alpha CDATA "Α" -- greek capital letter alpha, U+0391 -->
|
||||
<!ENTITY Beta CDATA "Β" -- greek capital letter beta, U+0392 -->
|
||||
<!ENTITY Gamma CDATA "Γ" -- greek capital letter gamma,
|
||||
U+0393 ISOgrk3 -->
|
||||
<!ENTITY Delta CDATA "Δ" -- greek capital letter delta,
|
||||
U+0394 ISOgrk3 -->
|
||||
<!ENTITY Epsilon CDATA "Ε" -- greek capital letter epsilon, U+0395 -->
|
||||
<!ENTITY Zeta CDATA "Ζ" -- greek capital letter zeta, U+0396 -->
|
||||
<!ENTITY Eta CDATA "Η" -- greek capital letter eta, U+0397 -->
|
||||
<!ENTITY Theta CDATA "Θ" -- greek capital letter theta,
|
||||
U+0398 ISOgrk3 -->
|
||||
<!ENTITY Iota CDATA "Ι" -- greek capital letter iota, U+0399 -->
|
||||
<!ENTITY Kappa CDATA "Κ" -- greek capital letter kappa, U+039A -->
|
||||
<!ENTITY Lambda CDATA "Λ" -- greek capital letter lambda,
|
||||
U+039B ISOgrk3 -->
|
||||
<!ENTITY Mu CDATA "Μ" -- greek capital letter mu, U+039C -->
|
||||
<!ENTITY Nu CDATA "Ν" -- greek capital letter nu, U+039D -->
|
||||
<!ENTITY Xi CDATA "Ξ" -- greek capital letter xi, U+039E ISOgrk3 -->
|
||||
<!ENTITY Omicron CDATA "Ο" -- greek capital letter omicron, U+039F -->
|
||||
<!ENTITY Pi CDATA "Π" -- greek capital letter pi, U+03A0 ISOgrk3 -->
|
||||
<!ENTITY Rho CDATA "Ρ" -- greek capital letter rho, U+03A1 -->
|
||||
<!-- there is no Sigmaf, and no U+03A2 character either -->
|
||||
<!ENTITY Sigma CDATA "Σ" -- greek capital letter sigma,
|
||||
U+03A3 ISOgrk3 -->
|
||||
<!ENTITY Tau CDATA "Τ" -- greek capital letter tau, U+03A4 -->
|
||||
<!ENTITY Upsilon CDATA "Υ" -- greek capital letter upsilon,
|
||||
U+03A5 ISOgrk3 -->
|
||||
<!ENTITY Phi CDATA "Φ" -- greek capital letter phi,
|
||||
U+03A6 ISOgrk3 -->
|
||||
<!ENTITY Chi CDATA "Χ" -- greek capital letter chi, U+03A7 -->
|
||||
<!ENTITY Psi CDATA "Ψ" -- greek capital letter psi,
|
||||
U+03A8 ISOgrk3 -->
|
||||
<!ENTITY Omega CDATA "Ω" -- greek capital letter omega,
|
||||
U+03A9 ISOgrk3 -->
|
||||
|
||||
<!ENTITY alpha CDATA "α" -- greek small letter alpha,
|
||||
U+03B1 ISOgrk3 -->
|
||||
<!ENTITY beta CDATA "β" -- greek small letter beta, U+03B2 ISOgrk3 -->
|
||||
<!ENTITY gamma CDATA "γ" -- greek small letter gamma,
|
||||
U+03B3 ISOgrk3 -->
|
||||
<!ENTITY delta CDATA "δ" -- greek small letter delta,
|
||||
U+03B4 ISOgrk3 -->
|
||||
<!ENTITY epsilon CDATA "ε" -- greek small letter epsilon,
|
||||
U+03B5 ISOgrk3 -->
|
||||
<!ENTITY zeta CDATA "ζ" -- greek small letter zeta, U+03B6 ISOgrk3 -->
|
||||
<!ENTITY eta CDATA "η" -- greek small letter eta, U+03B7 ISOgrk3 -->
|
||||
<!ENTITY theta CDATA "θ" -- greek small letter theta,
|
||||
U+03B8 ISOgrk3 -->
|
||||
<!ENTITY iota CDATA "ι" -- greek small letter iota, U+03B9 ISOgrk3 -->
|
||||
<!ENTITY kappa CDATA "κ" -- greek small letter kappa,
|
||||
U+03BA ISOgrk3 -->
|
||||
<!ENTITY lambda CDATA "λ" -- greek small letter lambda,
|
||||
U+03BB ISOgrk3 -->
|
||||
<!ENTITY mu CDATA "μ" -- greek small letter mu, U+03BC ISOgrk3 -->
|
||||
<!ENTITY nu CDATA "ν" -- greek small letter nu, U+03BD ISOgrk3 -->
|
||||
<!ENTITY xi CDATA "ξ" -- greek small letter xi, U+03BE ISOgrk3 -->
|
||||
<!ENTITY omicron CDATA "ο" -- greek small letter omicron, U+03BF NEW -->
|
||||
<!ENTITY pi CDATA "π" -- greek small letter pi, U+03C0 ISOgrk3 -->
|
||||
<!ENTITY rho CDATA "ρ" -- greek small letter rho, U+03C1 ISOgrk3 -->
|
||||
<!ENTITY sigmaf CDATA "ς" -- greek small letter final sigma,
|
||||
U+03C2 ISOgrk3 -->
|
||||
<!ENTITY sigma CDATA "σ" -- greek small letter sigma,
|
||||
U+03C3 ISOgrk3 -->
|
||||
<!ENTITY tau CDATA "τ" -- greek small letter tau, U+03C4 ISOgrk3 -->
|
||||
<!ENTITY upsilon CDATA "υ" -- greek small letter upsilon,
|
||||
U+03C5 ISOgrk3 -->
|
||||
<!ENTITY phi CDATA "φ" -- greek small letter phi, U+03C6 ISOgrk3 -->
|
||||
<!ENTITY chi CDATA "χ" -- greek small letter chi, U+03C7 ISOgrk3 -->
|
||||
<!ENTITY psi CDATA "ψ" -- greek small letter psi, U+03C8 ISOgrk3 -->
|
||||
<!ENTITY omega CDATA "ω" -- greek small letter omega,
|
||||
U+03C9 ISOgrk3 -->
|
||||
<!ENTITY thetasym CDATA "ϑ" -- greek small letter theta symbol,
|
||||
U+03D1 NEW -->
|
||||
<!ENTITY upsih CDATA "ϒ" -- greek upsilon with hook symbol,
|
||||
U+03D2 NEW -->
|
||||
<!ENTITY piv CDATA "ϖ" -- greek pi symbol, U+03D6 ISOgrk3 -->
|
||||
|
||||
<!-- General Punctuation -->
|
||||
<!ENTITY bull CDATA "•" -- bullet = black small circle,
|
||||
U+2022 ISOpub -->
|
||||
<!-- bullet is NOT the same as bullet operator, U+2219 -->
|
||||
<!ENTITY hellip CDATA "…" -- horizontal ellipsis = three dot leader,
|
||||
U+2026 ISOpub -->
|
||||
<!ENTITY prime CDATA "′" -- prime = minutes = feet, U+2032 ISOtech -->
|
||||
<!ENTITY Prime CDATA "″" -- double prime = seconds = inches,
|
||||
U+2033 ISOtech -->
|
||||
<!ENTITY oline CDATA "‾" -- overline = spacing overscore,
|
||||
U+203E NEW -->
|
||||
<!ENTITY frasl CDATA "⁄" -- fraction slash, U+2044 NEW -->
|
||||
|
||||
<!-- Letterlike Symbols -->
|
||||
<!ENTITY weierp CDATA "℘" -- script capital P = power set
|
||||
= Weierstrass p, U+2118 ISOamso -->
|
||||
<!ENTITY image CDATA "ℑ" -- blackletter capital I = imaginary part,
|
||||
U+2111 ISOamso -->
|
||||
<!ENTITY real CDATA "ℜ" -- blackletter capital R = real part symbol,
|
||||
U+211C ISOamso -->
|
||||
<!ENTITY trade CDATA "™" -- trade mark sign, U+2122 ISOnum -->
|
||||
<!ENTITY alefsym CDATA "ℵ" -- alef symbol = first transfinite cardinal,
|
||||
U+2135 NEW -->
|
||||
<!-- alef symbol is NOT the same as hebrew letter alef,
|
||||
U+05D0 although the same glyph could be used to depict both characters -->
|
||||
|
||||
<!-- Arrows -->
|
||||
<!ENTITY larr CDATA "←" -- leftwards arrow, U+2190 ISOnum -->
|
||||
<!ENTITY uarr CDATA "↑" -- upwards arrow, U+2191 ISOnum-->
|
||||
<!ENTITY rarr CDATA "→" -- rightwards arrow, U+2192 ISOnum -->
|
||||
<!ENTITY darr CDATA "↓" -- downwards arrow, U+2193 ISOnum -->
|
||||
<!ENTITY harr CDATA "↔" -- left right arrow, U+2194 ISOamsa -->
|
||||
<!ENTITY crarr CDATA "↵" -- downwards arrow with corner leftwards
|
||||
= carriage return, U+21B5 NEW -->
|
||||
<!ENTITY lArr CDATA "⇐" -- leftwards double arrow, U+21D0 ISOtech -->
|
||||
<!-- ISO 10646 does not say that lArr is the same as the 'is implied by' arrow
|
||||
but also does not have any other character for that function. So ? lArr can
|
||||
be used for 'is implied by' as ISOtech suggests -->
|
||||
<!ENTITY uArr CDATA "⇑" -- upwards double arrow, U+21D1 ISOamsa -->
|
||||
<!ENTITY rArr CDATA "⇒" -- rightwards double arrow,
|
||||
U+21D2 ISOtech -->
|
||||
<!-- ISO 10646 does not say this is the 'implies' character but does not have
|
||||
another character with this function so ?
|
||||
rArr can be used for 'implies' as ISOtech suggests -->
|
||||
<!ENTITY dArr CDATA "⇓" -- downwards double arrow, U+21D3 ISOamsa -->
|
||||
<!ENTITY hArr CDATA "⇔" -- left right double arrow,
|
||||
U+21D4 ISOamsa -->
|
||||
|
||||
<!-- Mathematical Operators -->
|
||||
<!ENTITY forall CDATA "∀" -- for all, U+2200 ISOtech -->
|
||||
<!ENTITY part CDATA "∂" -- partial differential, U+2202 ISOtech -->
|
||||
<!ENTITY exist CDATA "∃" -- there exists, U+2203 ISOtech -->
|
||||
<!ENTITY empty CDATA "∅" -- empty set = null set = diameter,
|
||||
U+2205 ISOamso -->
|
||||
<!ENTITY nabla CDATA "∇" -- nabla = backward difference,
|
||||
U+2207 ISOtech -->
|
||||
<!ENTITY isin CDATA "∈" -- element of, U+2208 ISOtech -->
|
||||
<!ENTITY notin CDATA "∉" -- not an element of, U+2209 ISOtech -->
|
||||
<!ENTITY ni CDATA "∋" -- contains as member, U+220B ISOtech -->
|
||||
<!-- should there be a more memorable name than 'ni'? -->
|
||||
<!ENTITY prod CDATA "∏" -- n-ary product = product sign,
|
||||
U+220F ISOamsb -->
|
||||
<!-- prod is NOT the same character as U+03A0 'greek capital letter pi' though
|
||||
the same glyph might be used for both -->
|
||||
<!ENTITY sum CDATA "∑" -- n-ary sumation, U+2211 ISOamsb -->
|
||||
<!-- sum is NOT the same character as U+03A3 'greek capital letter sigma'
|
||||
though the same glyph might be used for both -->
|
||||
<!ENTITY minus CDATA "−" -- minus sign, U+2212 ISOtech -->
|
||||
<!ENTITY lowast CDATA "∗" -- asterisk operator, U+2217 ISOtech -->
|
||||
<!ENTITY radic CDATA "√" -- square root = radical sign,
|
||||
U+221A ISOtech -->
|
||||
<!ENTITY prop CDATA "∝" -- proportional to, U+221D ISOtech -->
|
||||
<!ENTITY infin CDATA "∞" -- infinity, U+221E ISOtech -->
|
||||
<!ENTITY ang CDATA "∠" -- angle, U+2220 ISOamso -->
|
||||
<!ENTITY and CDATA "∧" -- logical and = wedge, U+2227 ISOtech -->
|
||||
<!ENTITY or CDATA "∨" -- logical or = vee, U+2228 ISOtech -->
|
||||
<!ENTITY cap CDATA "∩" -- intersection = cap, U+2229 ISOtech -->
|
||||
<!ENTITY cup CDATA "∪" -- union = cup, U+222A ISOtech -->
|
||||
<!ENTITY int CDATA "∫" -- integral, U+222B ISOtech -->
|
||||
<!ENTITY there4 CDATA "∴" -- therefore, U+2234 ISOtech -->
|
||||
<!ENTITY sim CDATA "∼" -- tilde operator = varies with = similar to,
|
||||
U+223C ISOtech -->
|
||||
<!-- tilde operator is NOT the same character as the tilde, U+007E,
|
||||
although the same glyph might be used to represent both -->
|
||||
<!ENTITY cong CDATA "≅" -- approximately equal to, U+2245 ISOtech -->
|
||||
<!ENTITY asymp CDATA "≈" -- almost equal to = asymptotic to,
|
||||
U+2248 ISOamsr -->
|
||||
<!ENTITY ne CDATA "≠" -- not equal to, U+2260 ISOtech -->
|
||||
<!ENTITY equiv CDATA "≡" -- identical to, U+2261 ISOtech -->
|
||||
<!ENTITY le CDATA "≤" -- less-than or equal to, U+2264 ISOtech -->
|
||||
<!ENTITY ge CDATA "≥" -- greater-than or equal to,
|
||||
U+2265 ISOtech -->
|
||||
<!ENTITY sub CDATA "⊂" -- subset of, U+2282 ISOtech -->
|
||||
<!ENTITY sup CDATA "⊃" -- superset of, U+2283 ISOtech -->
|
||||
<!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol
|
||||
font encoding and is not included. Should it be, for symmetry?
|
||||
It is in ISOamsn -->
|
||||
<!ENTITY nsub CDATA "⊄" -- not a subset of, U+2284 ISOamsn -->
|
||||
<!ENTITY sube CDATA "⊆" -- subset of or equal to, U+2286 ISOtech -->
|
||||
<!ENTITY supe CDATA "⊇" -- superset of or equal to,
|
||||
U+2287 ISOtech -->
|
||||
<!ENTITY oplus CDATA "⊕" -- circled plus = direct sum,
|
||||
U+2295 ISOamsb -->
|
||||
<!ENTITY otimes CDATA "⊗" -- circled times = vector product,
|
||||
U+2297 ISOamsb -->
|
||||
<!ENTITY perp CDATA "⊥" -- up tack = orthogonal to = perpendicular,
|
||||
U+22A5 ISOtech -->
|
||||
<!ENTITY sdot CDATA "⋅" -- dot operator, U+22C5 ISOamsb -->
|
||||
<!-- dot operator is NOT the same character as U+00B7 middle dot -->
|
||||
|
||||
<!-- Miscellaneous Technical -->
|
||||
<!ENTITY lceil CDATA "⌈" -- left ceiling = apl upstile,
|
||||
U+2308 ISOamsc -->
|
||||
<!ENTITY rceil CDATA "⌉" -- right ceiling, U+2309 ISOamsc -->
|
||||
<!ENTITY lfloor CDATA "⌊" -- left floor = apl downstile,
|
||||
U+230A ISOamsc -->
|
||||
<!ENTITY rfloor CDATA "⌋" -- right floor, U+230B ISOamsc -->
|
||||
<!ENTITY lang CDATA "〈" -- left-pointing angle bracket = bra,
|
||||
U+2329 ISOtech -->
|
||||
<!-- lang is NOT the same character as U+003C 'less than'
|
||||
or U+2039 'single left-pointing angle quotation mark' -->
|
||||
<!ENTITY rang CDATA "〉" -- right-pointing angle bracket = ket,
|
||||
U+232A ISOtech -->
|
||||
<!-- rang is NOT the same character as U+003E 'greater than'
|
||||
or U+203A 'single right-pointing angle quotation mark' -->
|
||||
|
||||
<!-- Geometric Shapes -->
|
||||
<!ENTITY loz CDATA "◊" -- lozenge, U+25CA ISOpub -->
|
||||
|
||||
<!-- Miscellaneous Symbols -->
|
||||
<!ENTITY spades CDATA "♠" -- black spade suit, U+2660 ISOpub -->
|
||||
<!-- black here seems to mean filled as opposed to hollow -->
|
||||
<!ENTITY clubs CDATA "♣" -- black club suit = shamrock,
|
||||
U+2663 ISOpub -->
|
||||
<!ENTITY hearts CDATA "♥" -- black heart suit = valentine,
|
||||
U+2665 ISOpub -->
|
||||
<!ENTITY diams CDATA "♦" -- black diamond suit, U+2666 ISOpub -->
|
||||
|
||||
|
||||
<!-- Special characters for HTML -->
|
||||
|
||||
<!-- Character entity set. Typical invocation:
|
||||
<!ENTITY % HTMLspecial PUBLIC
|
||||
"-//W3C//ENTITIES Special//EN//HTML">
|
||||
%HTMLspecial; -->
|
||||
|
||||
<!-- Portions © International Organization for Standardization 1986:
|
||||
Permission to copy in any form is granted for use with
|
||||
conforming SGML systems and applications as defined in
|
||||
ISO 8879, provided this notice is included in all copies.
|
||||
-->
|
||||
|
||||
<!-- Relevant ISO entity set is given unless names are newly introduced.
|
||||
New names (i.e., not in ISO 8879 list) do not clash with any
|
||||
existing ISO 8879 entity names. ISO 10646 character numbers
|
||||
are given for each character, in hex. CDATA values are decimal
|
||||
conversions of the ISO 10646 values and refer to the document
|
||||
character set. Names are ISO 10646 names.
|
||||
|
||||
-->
|
||||
|
||||
<!-- C0 Controls and Basic Latin -->
|
||||
<!ENTITY quot CDATA """ -- quotation mark = APL quote,
|
||||
U+0022 ISOnum -->
|
||||
<!ENTITY amp CDATA "&" -- ampersand, U+0026 ISOnum -->
|
||||
<!ENTITY lt CDATA "<" -- less-than sign, U+003C ISOnum -->
|
||||
<!ENTITY gt CDATA ">" -- greater-than sign, U+003E ISOnum -->
|
||||
|
||||
<!-- Latin Extended-A -->
|
||||
<!ENTITY OElig CDATA "Œ" -- latin capital ligature OE,
|
||||
U+0152 ISOlat2 -->
|
||||
<!ENTITY oelig CDATA "œ" -- latin small ligature oe, U+0153 ISOlat2 -->
|
||||
<!-- ligature is a misnomer, this is a separate character in some languages -->
|
||||
<!ENTITY Scaron CDATA "Š" -- latin capital letter S with caron,
|
||||
U+0160 ISOlat2 -->
|
||||
<!ENTITY scaron CDATA "š" -- latin small letter s with caron,
|
||||
U+0161 ISOlat2 -->
|
||||
<!ENTITY Yuml CDATA "Ÿ" -- latin capital letter Y with diaeresis,
|
||||
U+0178 ISOlat2 -->
|
||||
|
||||
<!-- Spacing Modifier Letters -->
|
||||
<!ENTITY circ CDATA "ˆ" -- modifier letter circumflex accent,
|
||||
U+02C6 ISOpub -->
|
||||
<!ENTITY tilde CDATA "˜" -- small tilde, U+02DC ISOdia -->
|
||||
|
||||
<!-- General Punctuation -->
|
||||
<!ENTITY ensp CDATA " " -- en space, U+2002 ISOpub -->
|
||||
<!ENTITY emsp CDATA " " -- em space, U+2003 ISOpub -->
|
||||
<!ENTITY thinsp CDATA " " -- thin space, U+2009 ISOpub -->
|
||||
<!ENTITY zwnj CDATA "‌" -- zero width non-joiner,
|
||||
U+200C NEW RFC 2070 -->
|
||||
<!ENTITY zwj CDATA "‍" -- zero width joiner, U+200D NEW RFC 2070 -->
|
||||
<!ENTITY lrm CDATA "‎" -- left-to-right mark, U+200E NEW RFC 2070 -->
|
||||
<!ENTITY rlm CDATA "‏" -- right-to-left mark, U+200F NEW RFC 2070 -->
|
||||
<!ENTITY ndash CDATA "–" -- en dash, U+2013 ISOpub -->
|
||||
<!ENTITY mdash CDATA "—" -- em dash, U+2014 ISOpub -->
|
||||
<!ENTITY lsquo CDATA "‘" -- left single quotation mark,
|
||||
U+2018 ISOnum -->
|
||||
<!ENTITY rsquo CDATA "’" -- right single quotation mark,
|
||||
U+2019 ISOnum -->
|
||||
<!ENTITY sbquo CDATA "‚" -- single low-9 quotation mark, U+201A NEW -->
|
||||
<!ENTITY ldquo CDATA "“" -- left double quotation mark,
|
||||
U+201C ISOnum -->
|
||||
<!ENTITY rdquo CDATA "”" -- right double quotation mark,
|
||||
U+201D ISOnum -->
|
||||
<!ENTITY bdquo CDATA "„" -- double low-9 quotation mark, U+201E NEW -->
|
||||
<!ENTITY dagger CDATA "†" -- dagger, U+2020 ISOpub -->
|
||||
<!ENTITY Dagger CDATA "‡" -- double dagger, U+2021 ISOpub -->
|
||||
<!ENTITY permil CDATA "‰" -- per mille sign, U+2030 ISOtech -->
|
||||
<!ENTITY lsaquo CDATA "‹" -- single left-pointing angle quotation mark,
|
||||
U+2039 ISO proposed -->
|
||||
<!-- lsaquo is proposed but not yet ISO standardized -->
|
||||
<!ENTITY rsaquo CDATA "›" -- single right-pointing angle quotation mark,
|
||||
U+203A ISO proposed -->
|
||||
<!-- rsaquo is proposed but not yet ISO standardized -->
|
||||
<!ENTITY euro CDATA "€" -- euro sign, U+20AC NEW -->
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.util;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import org.springframework.core.io.FileSystemResourceLoader;
|
||||
import org.springframework.mock.web.MockServletConfig;
|
||||
import org.springframework.mock.web.MockServletContext;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @since 21.02.2005
|
||||
*/
|
||||
@Ignore
|
||||
public class Log4jWebConfigurerTests extends TestCase {
|
||||
|
||||
public void testInitLoggingWithClasspath() throws FileNotFoundException {
|
||||
doTestInitLogging("classpath:org/springframework/util/testlog4j.properties", false);
|
||||
}
|
||||
|
||||
public void testInitLoggingWithRelativeFilePath() throws FileNotFoundException {
|
||||
doTestInitLogging("test/org/springframework/util/testlog4j.properties", false);
|
||||
}
|
||||
|
||||
public void testInitLoggingWithAbsoluteFilePath() throws FileNotFoundException {
|
||||
URL url = Log4jWebConfigurerTests.class.getResource("testlog4j.properties");
|
||||
doTestInitLogging(url.toString(), false);
|
||||
}
|
||||
|
||||
public void testInitLoggingWithClasspathAndRefreshInterval() throws FileNotFoundException {
|
||||
doTestInitLogging("classpath:org/springframework/util/testlog4j.properties", true);
|
||||
}
|
||||
|
||||
public void testInitLoggingWithRelativeFilePathAndRefreshInterval() throws FileNotFoundException {
|
||||
doTestInitLogging("test/org/springframework/util/testlog4j.properties", true);
|
||||
}
|
||||
|
||||
/* only works on Windows
|
||||
public void testInitLoggingWithAbsoluteFilePathAndRefreshInterval() throws FileNotFoundException {
|
||||
URL url = Log4jConfigurerTests.class.getResource("testlog4j.properties");
|
||||
doTestInitLogging(url.getFile(), true);
|
||||
}
|
||||
*/
|
||||
|
||||
public void testInitLoggingWithFileUrlAndRefreshInterval() throws FileNotFoundException {
|
||||
URL url = Log4jWebConfigurerTests.class.getResource("testlog4j.properties");
|
||||
doTestInitLogging(url.toString(), true);
|
||||
}
|
||||
|
||||
private void doTestInitLogging(String location, boolean refreshInterval) {
|
||||
MockServletContext sc = new MockServletContext("", new FileSystemResourceLoader());
|
||||
sc.addInitParameter(Log4jWebConfigurer.CONFIG_LOCATION_PARAM, location);
|
||||
if (refreshInterval) {
|
||||
sc.addInitParameter(Log4jWebConfigurer.REFRESH_INTERVAL_PARAM, "10");
|
||||
}
|
||||
Log4jWebConfigurer.initLogging(sc);
|
||||
|
||||
try {
|
||||
doTestLogOutput();
|
||||
}
|
||||
finally {
|
||||
Log4jWebConfigurer.shutdownLogging(sc);
|
||||
}
|
||||
assertTrue(MockLog4jAppender.closeCalled);
|
||||
}
|
||||
|
||||
private void doTestLogOutput() {
|
||||
Log log = LogFactory.getLog(this.getClass());
|
||||
log.debug("debug");
|
||||
log.info("info");
|
||||
log.warn("warn");
|
||||
log.error("error");
|
||||
log.fatal("fatal");
|
||||
|
||||
assertTrue(MockLog4jAppender.loggingStrings.contains("debug"));
|
||||
assertTrue(MockLog4jAppender.loggingStrings.contains("info"));
|
||||
assertTrue(MockLog4jAppender.loggingStrings.contains("warn"));
|
||||
assertTrue(MockLog4jAppender.loggingStrings.contains("error"));
|
||||
assertTrue(MockLog4jAppender.loggingStrings.contains("fatal"));
|
||||
}
|
||||
|
||||
public void testLog4jConfigListener() {
|
||||
Log4jConfigListener listener = new Log4jConfigListener();
|
||||
|
||||
MockServletContext sc = new MockServletContext("", new FileSystemResourceLoader());
|
||||
sc.addInitParameter(Log4jWebConfigurer.CONFIG_LOCATION_PARAM,
|
||||
"test/org/springframework/util/testlog4j.properties");
|
||||
listener.contextInitialized(new ServletContextEvent(sc));
|
||||
|
||||
try {
|
||||
doTestLogOutput();
|
||||
}
|
||||
finally {
|
||||
listener.contextDestroyed(new ServletContextEvent(sc));
|
||||
}
|
||||
assertTrue(MockLog4jAppender.closeCalled);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.AppenderSkeleton;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
|
||||
/**
|
||||
* @author Alef Arendsen
|
||||
*/
|
||||
public class MockLog4jAppender extends AppenderSkeleton {
|
||||
|
||||
public static final List loggingStrings = new ArrayList();
|
||||
|
||||
public static boolean closeCalled = false;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.log4j.AppenderSkeleton#append(org.apache.log4j.spi.LoggingEvent)
|
||||
*/
|
||||
protected void append(LoggingEvent evt) {
|
||||
//System.out.println("Adding " + evt.getMessage());
|
||||
loggingStrings.add(evt.getMessage());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.log4j.Appender#close()
|
||||
*/
|
||||
public void close() {
|
||||
closeCalled = true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.log4j.Appender#requiresLayout()
|
||||
*/
|
||||
public boolean requiresLayout() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.util;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class UrlPathHelperTests extends TestCase {
|
||||
|
||||
public void testGetPathWithinApplication() {
|
||||
UrlPathHelper helper = new UrlPathHelper();
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setContextPath("/petclinic");
|
||||
request.setRequestURI("/petclinic/welcome.html");
|
||||
|
||||
assertEquals("Incorrect path returned", "/welcome.html", helper.getPathWithinApplication(request));
|
||||
}
|
||||
|
||||
public void testGetPathWithinApplicationForRootWithNoLeadingSlash() {
|
||||
UrlPathHelper helper = new UrlPathHelper();
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setContextPath("/petclinic");
|
||||
request.setRequestURI("/petclinic");
|
||||
|
||||
assertEquals("Incorrect root path returned", "/", helper.getPathWithinApplication(request));
|
||||
}
|
||||
|
||||
public void testGetPathWithinApplicationForSlashContextPath() {
|
||||
UrlPathHelper helper = new UrlPathHelper();
|
||||
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setContextPath("/");
|
||||
request.setRequestURI("/welcome.html");
|
||||
|
||||
assertEquals("Incorrect path returned", "/welcome.html", helper.getPathWithinApplication(request));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user