diff --git a/org.springframework.test/src/main/java/org/springframework/mock/web/MockExpressionEvaluator.java b/org.springframework.test/src/main/java/org/springframework/mock/web/MockExpressionEvaluator.java
index bb0ab8aa5987f4f519b9923fb6d12aa5af0057c5..6748f5e7e04faef9f677215df5f7c0b5e71e1d46 100644
--- a/org.springframework.test/src/main/java/org/springframework/mock/web/MockExpressionEvaluator.java
+++ b/org.springframework.test/src/main/java/org/springframework/mock/web/MockExpressionEvaluator.java
@@ -27,19 +27,21 @@ 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.
- *
- *
Used for testing the web framework; only necessary for testing
- * applications when testing custom JSP tags.
- *
- *
Note that the Jakarta JSTL implementation (jstl.jar, standard.jar)
- * has to be available on the class path to use this expression evaluator.
- *
+ * Mock implementation of the JSP 2.0
+ * {@link javax.servlet.jsp.el.ExpressionEvaluator} interface, delegating to the
+ * Jakarta JSTL ExpressionEvaluatorManager.
+ *
+ * Used for testing the web framework; only necessary for testing applications
+ * when testing custom JSP tags.
+ *
+ * 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
*/
+@SuppressWarnings("deprecation")
public class MockExpressionEvaluator extends ExpressionEvaluator {
private final PageContext pageContext;
@@ -47,26 +49,28 @@ public class MockExpressionEvaluator extends ExpressionEvaluator {
/**
* 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 {
+ @SuppressWarnings("rawtypes")
+ 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 {
+ @SuppressWarnings("rawtypes")
+ public Object evaluate(String expression, Class expectedType, VariableResolver variableResolver,
+ FunctionMapper functionMapper) throws ELException {
if (variableResolver != null) {
throw new IllegalArgumentException("Custom VariableResolver not supported");
@@ -74,8 +78,8 @@ public class MockExpressionEvaluator extends ExpressionEvaluator {
return doEvaluate(expression, expectedType, functionMapper);
}
- protected Object doEvaluate(
- String expression, Class expectedType, FunctionMapper functionMapper)
+ @SuppressWarnings("rawtypes")
+ protected Object doEvaluate(String expression, Class expectedType, FunctionMapper functionMapper)
throws ELException {
if (functionMapper != null) {
diff --git a/org.springframework.test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java b/org.springframework.test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java
index 9f2cdbebab319502144fb25d34ee16b5a2cebe93..c19cbc67b8685a91136472a39e13968a330eefe9 100644
--- a/org.springframework.test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java
+++ b/org.springframework.test/src/main/java/org/springframework/mock/web/MockHttpServletRequest.java
@@ -35,6 +35,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
+
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletInputStream;
@@ -48,10 +49,10 @@ import org.springframework.util.LinkedCaseInsensitiveMap;
/**
* Mock implementation of the {@link javax.servlet.http.HttpServletRequest}
* interface. Supports the Servlet 2.5 API level.
- *
- *
Used for testing the web framework; also useful for testing
- * application controllers.
- *
+ *
+ * Used for testing the web framework; also useful for testing application
+ * controllers.
+ *
* @author Juergen Hoeller
* @author Rod Johnson
* @author Rick Evans
@@ -90,13 +91,11 @@ public class MockHttpServletRequest implements HttpServletRequest {
*/
public static final String DEFAULT_REMOTE_HOST = "localhost";
-
private boolean active = true;
-
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// ServletRequest properties
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
private final Map attributes = new LinkedHashMap();
@@ -135,10 +134,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
private int localPort = DEFAULT_SERVER_PORT;
-
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// HttpServletRequest properties
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
private String authType;
@@ -175,13 +173,14 @@ public class MockHttpServletRequest implements HttpServletRequest {
private boolean requestedSessionIdFromURL = false;
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// Constructors
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
/**
* Create a new MockHttpServletRequest with a default
* {@link MockServletContext}.
+ *
* @see MockServletContext
*/
public MockHttpServletRequest() {
@@ -191,6 +190,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
/**
* Create a new MockHttpServletRequest with a default
* {@link MockServletContext}.
+ *
* @param method the request method (may be null
)
* @param requestURI the request URI (may be null
)
* @see #setMethod
@@ -203,8 +203,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
/**
* Create a new MockHttpServletRequest.
- * @param servletContext the ServletContext that the request runs in
- * (may be null
to use a default MockServletContext)
+ *
+ * @param servletContext the ServletContext that the request runs in (may be
+ * null
to use a default MockServletContext)
* @see MockServletContext
*/
public MockHttpServletRequest(ServletContext servletContext) {
@@ -213,8 +214,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
/**
* Create a new MockHttpServletRequest.
- * @param servletContext the ServletContext that the request runs in
- * (may be null
to use a default MockServletContext)
+ *
+ * @param servletContext the ServletContext that the request runs in (may be
+ * null
to use a default MockServletContext)
* @param method the request method (may be null
)
* @param requestURI the request URI (may be null
)
* @see #setMethod
@@ -228,14 +230,13 @@ public class MockHttpServletRequest implements HttpServletRequest {
this.locales.add(Locale.ENGLISH);
}
-
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// Lifecycle methods
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
/**
- * Return the ServletContext that this request is associated with.
- * (Not available in the standard HttpServletRequest interface for some reason.)
+ * Return the ServletContext that this request is associated with. (Not
+ * available in the standard HttpServletRequest interface for some reason.)
*/
public ServletContext getServletContext() {
return this.servletContext;
@@ -273,10 +274,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
}
}
-
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// ServletRequest interface
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
public Object getAttribute(String name) {
checkActive();
@@ -323,16 +323,18 @@ public class MockHttpServletRequest implements HttpServletRequest {
/**
* Set a single value for the specified HTTP parameter.
- * If there are already one or more values registered for the given
+ *
+ * If there are already one or more values registered for the given
* parameter name, they will be replaced.
*/
public void setParameter(String name, String value) {
- setParameter(name, new String[] {value});
+ setParameter(name, new String[] { value });
}
/**
* Set an array of values for the specified HTTP parameter.
- *
If there are already one or more values registered for the given
+ *
+ * If there are already one or more values registered for the given
* parameter name, they will be replaced.
*/
public void setParameter(String name, String[] values) {
@@ -341,15 +343,15 @@ public class MockHttpServletRequest implements HttpServletRequest {
}
/**
- * Sets all provided parameters replacing any
- * existing values for the provided parameter names. To add without
- * replacing existing values, use {@link #addParameters(java.util.Map)}.
+ * Sets all provided parameters replacing any existing
+ * values for the provided parameter names. To add without replacing
+ * existing values, use {@link #addParameters(java.util.Map)}.
*/
+ @SuppressWarnings("rawtypes")
public void setParameters(Map params) {
Assert.notNull(params, "Parameter map must not be null");
for (Object key : params.keySet()) {
- Assert.isInstanceOf(String.class, key,
- "Parameter map key must be of type [" + String.class.getName() + "]");
+ Assert.isInstanceOf(String.class, key, "Parameter map key must be of type [" + String.class.getName() + "]");
Object value = params.get(key);
if (value instanceof String) {
this.setParameter((String) key, (String) value);
@@ -358,25 +360,26 @@ public class MockHttpServletRequest implements HttpServletRequest {
this.setParameter((String) key, (String[]) value);
}
else {
- throw new IllegalArgumentException(
- "Parameter map value must be single value " + " or array of type [" + String.class.getName() +
- "]");
+ throw new IllegalArgumentException("Parameter map value must be single value " + " or array of type ["
+ + String.class.getName() + "]");
}
}
}
/**
* Add a single value for the specified HTTP parameter.
- *
If there are already one or more values registered for the given
+ *
+ * If there are already one or more values registered for the given
* parameter name, the given value will be added to the end of the list.
*/
public void addParameter(String name, String value) {
- addParameter(name, new String[] {value});
+ addParameter(name, new String[] { value });
}
/**
* Add an array of values for the specified HTTP parameter.
- *
If there are already one or more values registered for the given
+ *
+ * If there are already one or more values registered for the given
* parameter name, the given values will be added to the end of the list.
*/
public void addParameter(String name, String[] values) {
@@ -394,15 +397,15 @@ public class MockHttpServletRequest implements HttpServletRequest {
}
/**
- * Adds all provided parameters without replacing
- * any existing values. To replace existing values, use
+ * Adds all provided parameters without replacing any
+ * existing values. To replace existing values, use
* {@link #setParameters(java.util.Map)}.
*/
+ @SuppressWarnings("rawtypes")
public void addParameters(Map params) {
Assert.notNull(params, "Parameter map must not be null");
for (Object key : params.keySet()) {
- Assert.isInstanceOf(String.class, key,
- "Parameter map key must be of type [" + String.class.getName() + "]");
+ Assert.isInstanceOf(String.class, key, "Parameter map key must be of type [" + String.class.getName() + "]");
Object value = params.get(key);
if (value instanceof String) {
this.addParameter((String) key, (String) value);
@@ -411,14 +414,15 @@ public class MockHttpServletRequest implements HttpServletRequest {
this.addParameter((String) key, (String[]) value);
}
else {
- throw new IllegalArgumentException("Parameter map value must be single value " +
- " or array of type [" + String.class.getName() + "]");
+ throw new IllegalArgumentException("Parameter map value must be single value " + " or array of type ["
+ + String.class.getName() + "]");
}
}
}
/**
- * Remove already registered values for the specified HTTP parameter, if any.
+ * Remove already registered values for the specified HTTP parameter, if
+ * any.
*/
public void removeParameter(String name) {
Assert.notNull(name, "Parameter name must not be null");
@@ -486,8 +490,8 @@ public class MockHttpServletRequest implements HttpServletRequest {
public BufferedReader getReader() throws UnsupportedEncodingException {
if (this.content != null) {
InputStream sourceStream = new ByteArrayInputStream(this.content);
- Reader sourceReader = (this.characterEncoding != null) ?
- new InputStreamReader(sourceStream, this.characterEncoding) : new InputStreamReader(sourceStream);
+ Reader sourceReader = (this.characterEncoding != null) ? new InputStreamReader(sourceStream,
+ this.characterEncoding) : new InputStreamReader(sourceStream);
return new BufferedReader(sourceReader);
}
else {
@@ -599,10 +603,9 @@ public class MockHttpServletRequest implements HttpServletRequest {
return this.localPort;
}
-
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// HttpServletRequest interface
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
public void setAuthType(String authType) {
this.authType = authType;
@@ -622,21 +625,25 @@ public class MockHttpServletRequest implements HttpServletRequest {
/**
* Add a header entry for the given name.
- *
If there was no entry for that header name before,
- * the value will be used as-is. In case of an existing entry,
- * a String array will be created, adding the given value (more
- * specifically, its toString representation) as further element.
- *
Multiple values can only be stored as list of Strings,
- * following the Servlet spec (see getHeaders
accessor).
- * As alternative to repeated addHeader
calls for
- * individual elements, you can use a single call with an entire
- * array or Collection of values as parameter.
+ *
+ * If there was no entry for that header name before, the value will be used
+ * as-is. In case of an existing entry, a String array will be created,
+ * adding the given value (more specifically, its toString representation)
+ * as further element.
+ *
+ * Multiple values can only be stored as list of Strings, following the
+ * Servlet spec (see getHeaders
accessor). As alternative to
+ * repeated addHeader
calls for individual elements, you can
+ * use a single call with an entire array or Collection of values as
+ * parameter.
+ *
* @see #getHeaderNames
* @see #getHeader
* @see #getHeaders
* @see #getDateHeader
* @see #getIntHeader
*/
+ @SuppressWarnings("rawtypes")
public void addHeader(String name, Object value) {
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
Assert.notNull(value, "Header value must not be null");
@@ -665,8 +672,8 @@ public class MockHttpServletRequest implements HttpServletRequest {
return ((Number) value).longValue();
}
else if (value != null) {
- throw new IllegalArgumentException(
- "Value for header '" + name + "' is neither a Date nor a Number: " + value);
+ throw new IllegalArgumentException("Value for header '" + name + "' is neither a Date nor a Number: "
+ + value);
}
else {
return -1L;
diff --git a/org.springframework.test/src/main/java/org/springframework/mock/web/MockHttpSession.java b/org.springframework.test/src/main/java/org/springframework/mock/web/MockHttpSession.java
index e32f7fd5cd1068bfe826f34f2b95a28ec21e2f16..dc8a913a3466f2f9c3b24b5bb3155c47e21c86f9 100644
--- a/org.springframework.test/src/main/java/org/springframework/mock/web/MockHttpSession.java
+++ b/org.springframework.test/src/main/java/org/springframework/mock/web/MockHttpSession.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Vector;
+
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
@@ -34,22 +35,22 @@ import org.springframework.util.Assert;
/**
* Mock implementation of the {@link javax.servlet.http.HttpSession} interface.
* Supports the Servlet 2.4 API level.
- *
- *
Used for testing the web framework; also useful for testing
- * application controllers.
- *
+ *
+ * Used for testing the web framework; also useful for testing application
+ * controllers.
+ *
* @author Juergen Hoeller
* @author Rod Johnson
* @author Mark Fisher
* @since 1.0.2
*/
+@SuppressWarnings("deprecation")
public class MockHttpSession implements HttpSession {
public static final String SESSION_COOKIE_NAME = "JSESSION";
private static int nextId = 1;
-
private final String id;
private final long creationTime = System.currentTimeMillis();
@@ -69,6 +70,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession with a default {@link MockServletContext}.
+ *
* @see MockServletContext
*/
public MockHttpSession() {
@@ -77,6 +79,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession.
+ *
* @param servletContext the ServletContext that the session runs in
*/
public MockHttpSession(ServletContext servletContext) {
@@ -85,6 +88,7 @@ public class MockHttpSession implements HttpSession {
/**
* Create a new MockHttpSession.
+ *
* @param servletContext the ServletContext that the session runs in
* @param id a unique identifier for this session
*/
@@ -93,7 +97,6 @@ public class MockHttpSession implements HttpSession {
this.id = (id != null ? id : Integer.toString(nextId++));
}
-
public long getCreationTime() {
return this.creationTime;
}
@@ -205,10 +208,10 @@ public class MockHttpSession implements HttpSession {
return this.isNew;
}
-
/**
- * Serialize the attributes of this session into an object that can
- * be turned into a byte array with standard Java serialization.
+ * Serialize the attributes of this session into an object that can be
+ * turned into a byte array with standard Java serialization.
+ *
* @return a representation of this session's serialized state
*/
public Serializable serializeState() {
@@ -233,8 +236,9 @@ public class MockHttpSession implements HttpSession {
}
/**
- * Deserialize the attributes of this session from a state object
- * created by {@link #serializeState()}.
+ * Deserialize the attributes of this session from a state object created by
+ * {@link #serializeState()}.
+ *
* @param state a representation of this session's serialized state
*/
@SuppressWarnings("unchecked")
diff --git a/org.springframework.test/src/main/java/org/springframework/mock/web/MockPageContext.java b/org.springframework.test/src/main/java/org/springframework/mock/web/MockPageContext.java
index fa8c16f1694534c43e87f54c6b974d60cbb0d770..81cf9179a485498f0b775e24a5dff00de9c972ab 100644
--- a/org.springframework.test/src/main/java/org/springframework/mock/web/MockPageContext.java
+++ b/org.springframework.test/src/main/java/org/springframework/mock/web/MockPageContext.java
@@ -21,6 +21,7 @@ import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Vector;
+
import javax.el.ELContext;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
@@ -40,17 +41,18 @@ import org.springframework.util.Assert;
/**
* Mock implementation of the {@link javax.servlet.jsp.PageContext} interface.
- *
- *
Used for testing the web framework; only necessary for testing
- * applications when testing custom JSP tags.
- *
- *
Note: Expects initialization via the constructor rather than via the
- * PageContext.initialize
method. Does not support writing to
- * a JspWriter, request dispatching, and handlePageException
calls.
- *
+ *
+ * Used for testing the web framework; only necessary for testing applications
+ * when testing custom JSP tags.
+ *
+ * Note: Expects initialization via the constructor rather than via the
+ * PageContext.initialize
method. Does not support writing to a
+ * JspWriter, request dispatching, and handlePageException
calls.
+ *
* @author Juergen Hoeller
* @since 1.0.2
*/
+@SuppressWarnings("deprecation")
public class MockPageContext extends PageContext {
private final ServletContext servletContext;
@@ -78,8 +80,9 @@ public class MockPageContext extends PageContext {
/**
* 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)
+ *
+ * @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);
@@ -88,9 +91,10 @@ public class MockPageContext extends PageContext {
/**
* 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)
+ * @param request the current HttpServletRequest (only necessary when
+ * actually accessing the request)
*/
public MockPageContext(ServletContext servletContext, HttpServletRequest request) {
this(servletContext, request, null, null);
@@ -98,10 +102,11 @@ public class MockPageContext extends PageContext {
/**
* 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)
+ * @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);
@@ -109,13 +114,15 @@ public class MockPageContext extends PageContext {
/**
* 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)
+ * @param servletConfig the ServletConfig (hardly ever accessed from within
+ * a tag)
*/
- public MockPageContext(ServletContext servletContext, HttpServletRequest request,
- HttpServletResponse response, ServletConfig servletConfig) {
+ 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));
@@ -123,10 +130,8 @@ public class MockPageContext extends PageContext {
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) {
+ public void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL,
+ boolean needsSession, int bufferSize, boolean autoFlush) {
throw new UnsupportedOperationException("Use appropriate constructor");
}
diff --git a/org.springframework.test/src/main/java/org/springframework/mock/web/portlet/MockPortletRequest.java b/org.springframework.test/src/main/java/org/springframework/mock/web/portlet/MockPortletRequest.java
index 74419dcfbd20ba5bdfe6e511dc3b41b1d6973f06..e302a86e77ade785fac3b94c2a8bf56489174225 100644
--- a/org.springframework.test/src/main/java/org/springframework/mock/web/portlet/MockPortletRequest.java
+++ b/org.springframework.test/src/main/java/org/springframework/mock/web/portlet/MockPortletRequest.java
@@ -27,6 +27,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
+
import javax.portlet.PortalContext;
import javax.portlet.PortletContext;
import javax.portlet.PortletMode;
@@ -41,7 +42,7 @@ import org.springframework.util.CollectionUtils;
/**
* Mock implementation of the {@link javax.portlet.PortletRequest} interface.
- *
+ *
* @author John A. Lewis
* @author Juergen Hoeller
* @since 2.0
@@ -102,6 +103,7 @@ public class MockPortletRequest implements PortletRequest {
/**
* Create a new MockPortletRequest with a default {@link MockPortalContext}
* and a default {@link MockPortletContext}.
+ *
* @see MockPortalContext
* @see MockPortletContext
*/
@@ -111,6 +113,7 @@ public class MockPortletRequest implements PortletRequest {
/**
* Create a new MockPortletRequest with a default {@link MockPortalContext}.
+ *
* @param portletContext the PortletContext that the request runs in
* @see MockPortalContext
*/
@@ -120,6 +123,7 @@ public class MockPortletRequest implements PortletRequest {
/**
* Create a new MockPortletRequest.
+ *
* @param portalContext the PortalContext that the request runs in
* @param portletContext the PortletContext that the request runs in
*/
@@ -131,10 +135,9 @@ public class MockPortletRequest implements PortletRequest {
this.attributes.put(LIFECYCLE_PHASE, getLifecyclePhase());
}
-
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// Lifecycle methods
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
/**
* Return the Portlet 2.0 lifecycle id for the current phase.
@@ -167,10 +170,9 @@ public class MockPortletRequest implements PortletRequest {
}
}
-
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
// PortletRequest methods
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
public boolean isWindowStateAllowed(WindowState windowState) {
return CollectionUtils.contains(this.portalContext.getSupportedWindowStates(), windowState);
@@ -234,8 +236,9 @@ public class MockPortletRequest implements PortletRequest {
/**
* Set a single value for the specified property.
- *
If there are already one or more values registered for the given
- * property key, they will be replaced.
+ *
+ * If there are already one or more values registered for the given property
+ * key, they will be replaced.
*/
public void setProperty(String key, String value) {
Assert.notNull(key, "Property key must not be null");
@@ -246,8 +249,9 @@ public class MockPortletRequest implements PortletRequest {
/**
* Add a single value for the specified property.
- *
If there are already one or more values registered for the given
- * property key, the given value will be added to the end of the list.
+ *
+ * If there are already one or more values registered for the given property
+ * key, the given value will be added to the end of the list.
*/
public void addProperty(String key, String value) {
Assert.notNull(key, "Property key must not be null");
@@ -264,7 +268,7 @@ public class MockPortletRequest implements PortletRequest {
public String getProperty(String key) {
Assert.notNull(key, "Property key must not be null");
- List list = this.properties.get(key);
+ List list = this.properties.get(key);
return (list != null && list.size() > 0 ? (String) list.get(0) : null);
}
@@ -340,7 +344,7 @@ public class MockPortletRequest implements PortletRequest {
public void setParameter(String key, String value) {
Assert.notNull(key, "Parameter key must be null");
Assert.notNull(value, "Parameter value must not be null");
- this.parameters.put(key, new String[] {value});
+ this.parameters.put(key, new String[] { value });
}
public void setParameter(String key, String[] values) {
@@ -350,7 +354,7 @@ public class MockPortletRequest implements PortletRequest {
}
public void addParameter(String name, String value) {
- addParameter(name, new String[] {value});
+ addParameter(name, new String[] { value });
}
public void addParameter(String name, String[] values) {
diff --git a/org.springframework.test/src/main/java/org/springframework/test/AbstractDependencyInjectionSpringContextTests.java b/org.springframework.test/src/main/java/org/springframework/test/AbstractDependencyInjectionSpringContextTests.java
index 90d70e1cb6a3999f5531755630365c44b58d2866..f57179e6a7e9055b177f325fa2126b09db9b2e04 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/AbstractDependencyInjectionSpringContextTests.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/AbstractDependencyInjectionSpringContextTests.java
@@ -63,6 +63,7 @@ import org.springframework.util.Assert;
* ({@link org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests})
*/
@Deprecated
+@SuppressWarnings({ "unchecked", "rawtypes" })
public abstract class AbstractDependencyInjectionSpringContextTests extends AbstractSingleSpringContextTests {
/**
diff --git a/org.springframework.test/src/main/java/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.java b/org.springframework.test/src/main/java/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.java
index 6641a9b213f5191e3fa9ef0396b8508cc6ba51d4..c1d388301e25801843217320808a55d3aa653473 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/AbstractTransactionalDataSourceSpringContextTests.java
@@ -29,7 +29,6 @@ import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.jdbc.JdbcTestUtils;
-import org.springframework.util.StringUtils;
/**
* Subclass of AbstractTransactionalSpringContextTests that adds some convenience
@@ -49,6 +48,7 @@ import org.springframework.util.StringUtils;
* ({@link org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests})
*/
@Deprecated
+@SuppressWarnings({ "unchecked", "rawtypes" })
public abstract class AbstractTransactionalDataSourceSpringContextTests
extends AbstractTransactionalSpringContextTests {
diff --git a/org.springframework.test/src/main/java/org/springframework/test/AssertThrows.java b/org.springframework.test/src/main/java/org/springframework/test/AssertThrows.java
index 164dc9a58f274ebd20e3ca1134caa713451a6621..97012e5ddd31e5369d3a91dcfa7155a8cb7e14be 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/AssertThrows.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/AssertThrows.java
@@ -84,6 +84,7 @@ package org.springframework.test;
* @deprecated favor use of JUnit 4's {@code @Test(expected=...)} support
*/
@Deprecated
+@SuppressWarnings({ "unchecked", "rawtypes" })
public abstract class AssertThrows {
private final Class expectedException;
diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/junit38/package-info.java b/org.springframework.test/src/main/java/org/springframework/test/context/junit38/package-info.java
index 78ad1f7c1c972d79da9bec05ec4e5cfbbdf88186..22ead8d513451c27db37e5a5c54738b329ce00ed 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/junit38/package-info.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/junit38/package-info.java
@@ -1,9 +1,7 @@
-
/**
- *
* Support classes for ApplicationContext-based and transactional
* tests run with JUnit 3.8 and the Spring TestContext Framework.
- *
*/
+
package org.springframework.test.context.junit38;
diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java b/org.springframework.test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java
index 26d2d9340fa3e15ccf0928e474e904da808fe47d..f2220c6a790987b2a60529e4a7200fdee68c17f1 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.java
@@ -462,6 +462,7 @@ public class SpringJUnit4ClassRunner extends BlockJUnit4ClassRunner {
* @see RunBeforeTestMethodCallbacks
*/
@Override
+ @SuppressWarnings("deprecation")
protected Statement withBefores(FrameworkMethod frameworkMethod, Object testInstance, Statement statement) {
Statement junitBefores = super.withBefores(frameworkMethod, testInstance, statement);
return new RunBeforeTestMethodCallbacks(junitBefores, testInstance, frameworkMethod.getMethod(),
@@ -477,6 +478,7 @@ public class SpringJUnit4ClassRunner extends BlockJUnit4ClassRunner {
* @see RunAfterTestMethodCallbacks
*/
@Override
+ @SuppressWarnings("deprecation")
protected Statement withAfters(FrameworkMethod frameworkMethod, Object testInstance, Statement statement) {
Statement junitAfters = super.withAfters(frameworkMethod, testInstance, statement);
return new RunAfterTestMethodCallbacks(junitAfters, testInstance, frameworkMethod.getMethod(),
diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/support/package-info.java b/org.springframework.test/src/main/java/org/springframework/test/context/support/package-info.java
index cab2ecd74aaeea32e7cbafe97a6cd7536267661b..0212c4a0729539f827a6dd8bdbd8f83cb6c32d83 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/support/package-info.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/support/package-info.java
@@ -1,8 +1,6 @@
-
/**
- *
* Support classes for the Spring TestContext Framework.
- *
*/
+
package org.springframework.test.context.support;
diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/testng/package-info.java b/org.springframework.test/src/main/java/org/springframework/test/context/testng/package-info.java
index 21c522fd13596f2e0e71579805ce7a365640d3c2..3d2045a45bdafd8e5e5b67219f917885e78718c0 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/testng/package-info.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/testng/package-info.java
@@ -1,9 +1,7 @@
-
/**
- *
* Support classes for ApplicationContext-based and transactional
* tests run with TestNG and the Spring TestContext Framework.
- *
*/
+
package org.springframework.test.context.testng;
diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java b/org.springframework.test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java
index c44aaf7c0a3d9a32ecb860410491e446cbafa543..38747808cff256399cae1ee4b3517a37d1b70a01 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java
@@ -52,8 +52,8 @@ import org.springframework.util.StringUtils;
*
* TestExecutionListener
which provides support for executing
* tests within transactions by using
- * {@link org.springframework.transaction.annotation.Transactional @Transactional}
- * and {@link NotTransactional @NotTransactional} annotations.
+ * {@link org.springframework.transaction.annotation.Transactional @Transactional}
+ * and {@link NotTransactional @NotTransactional} annotations.
*
*
* Changes to the database during a test run with @Transactional will be
@@ -66,9 +66,9 @@ import org.springframework.util.StringUtils;
*
*
* Transactional commit and rollback behavior can be configured via the
- * class-level {@link TransactionConfiguration @TransactionConfiguration} and
- * method-level {@link Rollback @Rollback} annotations.
- * {@link TransactionConfiguration @TransactionConfiguration} also provides
+ * class-level {@link TransactionConfiguration @TransactionConfiguration} and
+ * method-level {@link Rollback @Rollback} annotations.
+ * {@link TransactionConfiguration @TransactionConfiguration} also provides
* configuration of the bean name of the {@link PlatformTransactionManager} that
* is to be used to drive transactions.
*
@@ -77,8 +77,8 @@ import org.springframework.util.StringUtils;
* certain set up or tear down code outside of a
* transaction. TransactionalTestExecutionListener
provides such
* support for methods annotated with
- * {@link BeforeTransaction @BeforeTransaction} and
- * {@link AfterTransaction @AfterTransaction}.
+ * {@link BeforeTransaction @BeforeTransaction} and
+ * {@link AfterTransaction @AfterTransaction}.
*
*
* @author Sam Brannen
@@ -91,6 +91,7 @@ import org.springframework.util.StringUtils;
* @see BeforeTransaction
* @see AfterTransaction
*/
+@SuppressWarnings("deprecation")
public class TransactionalTestExecutionListener extends AbstractTestExecutionListener {
private static final Log logger = LogFactory.getLog(TransactionalTestExecutionListener.class);
@@ -107,10 +108,10 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
/**
* If the test method of the supplied {@link TestContext test context} is
* configured to run within a transaction, this method will run
- * {@link BeforeTransaction @BeforeTransaction methods} and start a new
+ * {@link BeforeTransaction @BeforeTransaction methods} and start a new
* transaction.
- * Note that if a {@link BeforeTransaction @BeforeTransaction method} fails,
- * remaining {@link BeforeTransaction @BeforeTransaction methods} will not
+ *
Note that if a {@link BeforeTransaction @BeforeTransaction method} fails,
+ * remaining {@link BeforeTransaction @BeforeTransaction methods} will not
* be invoked, and a transaction will not be started.
* @see org.springframework.transaction.annotation.Transactional
* @see org.springframework.test.annotation.NotTransactional
@@ -167,8 +168,8 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
/**
* If a transaction is currently active for the test method of the supplied
* {@link TestContext test context}, this method will end the transaction
- * and run {@link AfterTransaction @AfterTransaction methods}.
- *
{@link AfterTransaction @AfterTransaction methods} are guaranteed to be
+ * and run {@link AfterTransaction @AfterTransaction methods}.
+ *
{@link AfterTransaction @AfterTransaction methods} are guaranteed to be
* invoked even if an error occurs while ending the transaction.
*/
@Override
@@ -189,7 +190,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
}
/**
- * Run all {@link BeforeTransaction @BeforeTransaction methods} for the
+ * Run all {@link BeforeTransaction @BeforeTransaction methods} for the
* specified {@link TestContext test context}. If one of the methods fails,
* however, the caught exception will be rethrown in a wrapped
* {@link RuntimeException}, and the remaining methods will not
@@ -216,7 +217,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
}
/**
- * Run all {@link AfterTransaction @AfterTransaction methods} for the
+ * Run all {@link AfterTransaction @AfterTransaction methods} for the
* specified {@link TestContext test context}. If one of the methods fails,
* the caught exception will be logged as an error, and the remaining
* methods will be given a chance to execute. After all methods have
@@ -449,7 +450,7 @@ public class TransactionalTestExecutionListener extends AbstractTestExecutionLis
/**
* Retrieves the {@link TransactionConfigurationAttributes} for the
* specified {@link Class class} which may optionally declare or inherit a
- * {@link TransactionConfiguration @TransactionConfiguration}. If a
+ * {@link TransactionConfiguration @TransactionConfiguration}. If a
* {@link TransactionConfiguration} annotation is not present for the
* supplied class, the default values for attributes defined in
* {@link TransactionConfiguration} will be used instead.
diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/transaction/package-info.java b/org.springframework.test/src/main/java/org/springframework/test/context/transaction/package-info.java
index 57704cc07ae9b0842a720119211370cf5d02f8bf..3c685db13a44b91eed3dd472a925954ddac37e5c 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/transaction/package-info.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/transaction/package-info.java
@@ -1,9 +1,7 @@
-
/**
- *
*
Transactional support classes for the Spring TestContext
* Framework.
- *
*/
+
package org.springframework.test.context.transaction;
diff --git a/org.springframework.test/src/main/java/org/springframework/test/jdbc/package-info.java b/org.springframework.test/src/main/java/org/springframework/test/jdbc/package-info.java
index f1340d68fc089a2f3888cfce70e21c71512da575..4587aa4640356092e831035de1dc2c2d0911e4c8 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/jdbc/package-info.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/jdbc/package-info.java
@@ -1,8 +1,6 @@
-
/**
- *
* Support classes for tests based on JDBC.
- *
*/
+
package org.springframework.test.jdbc;
diff --git a/org.springframework.test/src/main/java/org/springframework/test/jpa/AbstractJpaTests.java b/org.springframework.test/src/main/java/org/springframework/test/jpa/AbstractJpaTests.java
index 05b2f3cd69385fc36da80070bf99aacb1f19ecc3..f58d91c8eb1c1a572ac1308a4eb38f25122bb82c 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/jpa/AbstractJpaTests.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/jpa/AbstractJpaTests.java
@@ -161,6 +161,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
@Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public void runBare() throws Throwable {
if (!shouldUseShadowLoader()) {
super.runBare();
@@ -308,6 +309,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
private final LoadTimeWeaver ltw;
+ @SuppressWarnings("unused")
public LoadTimeWeaverInjectingBeanPostProcessor(LoadTimeWeaver ltw) {
this.ltw = ltw;
}
@@ -328,6 +330,7 @@ public abstract class AbstractJpaTests extends AbstractAnnotationAwareTransactio
private final ClassLoader shadowingClassLoader;
+ @SuppressWarnings("unused")
public ShadowingLoadTimeWeaver(ClassLoader shadowingClassLoader) {
this.shadowingClassLoader = shadowingClassLoader;
}
diff --git a/org.springframework.test/src/main/java/org/springframework/test/util/package-info.java b/org.springframework.test/src/main/java/org/springframework/test/util/package-info.java
index f0dfa5bb8e1eba3d1d7834f6372e4066ce4763cd..3e08d2c2631d4a773e42f38469f00cf1c3d76bc4 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/util/package-info.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/util/package-info.java
@@ -1,8 +1,6 @@
-
/**
- *
* Helper classes for unit tests with reflective needs.
- *
*/
+
package org.springframework.test.util;
diff --git a/org.springframework.test/src/main/java/org/springframework/test/web/AbstractModelAndViewTests.java b/org.springframework.test/src/main/java/org/springframework/test/web/AbstractModelAndViewTests.java
index 88580b3a052ded5c874ee4d179392b7cd878fd4b..e3392456b4a323685c4f62d9d59dece126e9861f 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/web/AbstractModelAndViewTests.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/web/AbstractModelAndViewTests.java
@@ -72,6 +72,7 @@ public abstract class AbstractModelAndViewTests extends TestCase {
* null
)
* @param expectedList the expected list
*/
+ @SuppressWarnings("rawtypes")
protected void assertCompareListModelAttribute(ModelAndView mav, String modelName, List expectedList) {
try {
ModelAndViewAssert.assertCompareListModelAttribute(mav, modelName, expectedList);
@@ -139,6 +140,7 @@ public abstract class AbstractModelAndViewTests extends TestCase {
* not specifying the comparator, both lists will be sorted not using
* any comparator.
*/
+ @SuppressWarnings("rawtypes")
protected void assertSortAndCompareListModelAttribute(
ModelAndView mav, String modelName, List expectedList, Comparator comparator) {
try {
diff --git a/org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java b/org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java
index 5f5930ffcf9930a450061b5678a83be35323c7b0..d6496148ff0a1b7a556388b7ab92941b84b01650 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java
@@ -27,13 +27,13 @@ import org.springframework.util.ObjectUtils;
import org.springframework.web.servlet.ModelAndView;
/**
- * A collection of assertions intended to simplify testing scenarios
- * dealing with Spring Web MVC
- * {@link org.springframework.web.servlet.ModelAndView ModelAndView} objects.
- *
- * Intended for use with JUnit 4 and TestNG.
- * All assert*()
methods throw {@link AssertionError}s.
- *
+ * A collection of assertions intended to simplify testing scenarios dealing
+ * with Spring Web MVC {@link org.springframework.web.servlet.ModelAndView
+ * ModelAndView} objects.
+ *
+ * Intended for use with JUnit 4 and TestNG. All assert*()
methods
+ * throw {@link AssertionError}s.
+ *
* @author Sam Brannen
* @author Alef Arendsen
* @author Bram Smeets
@@ -44,8 +44,9 @@ public abstract class ModelAndViewAssert {
/**
* Checks whether the model value under the given modelName
- * exists and checks it type, based on the expectedType
. If
- * the model entry exists and the type matches, the model value is returned.
+ * exists and checks it type, based on the expectedType
. If the
+ * model entry exists and the type matches, the model value is returned.
+ *
* @param mav ModelAndView to test against (never null
)
* @param modelName name of the object to add to the model (never
* null
)
@@ -58,29 +59,32 @@ public abstract class ModelAndViewAssert {
assertCondition(mav.getModel() != null, "Model is null");
Object obj = mav.getModel().get(modelName);
assertCondition(obj != null, "Model attribute with name '" + modelName + "' is null");
- assertCondition(expectedType.isAssignableFrom(obj.getClass()), "Model attribute is not of expected type '" +
- expectedType.getName() + "' but rather of type '" + obj.getClass().getName() + "'");
+ assertCondition(expectedType.isAssignableFrom(obj.getClass()), "Model attribute is not of expected type '"
+ + expectedType.getName() + "' but rather of type '" + obj.getClass().getName() + "'");
return (T) obj;
}
/**
* Compare each individual entry in a list, without first sorting the lists.
+ *
* @param mav ModelAndView to test against (never null
)
* @param modelName name of the object to add to the model (never
* null
)
* @param expectedList the expected list
*/
+ @SuppressWarnings("rawtypes")
public static void assertCompareListModelAttribute(ModelAndView mav, String modelName, List expectedList) {
assertCondition(mav != null, "ModelAndView is null");
List modelList = assertAndReturnModelAttributeOfType(mav, modelName, List.class);
- assertCondition(expectedList.size() == modelList.size(), "Size of model list is '" + modelList.size() +
- "' while size of expected list is '" + expectedList.size() + "'");
- assertCondition(expectedList.equals(modelList), "List in model under name '" + modelName +
- "' is not equal to the expected list.");
+ assertCondition(expectedList.size() == modelList.size(), "Size of model list is '" + modelList.size()
+ + "' while size of expected list is '" + expectedList.size() + "'");
+ assertCondition(expectedList.equals(modelList), "List in model under name '" + modelName
+ + "' is not equal to the expected list.");
}
/**
* Assert whether or not a model attribute is available.
+ *
* @param mav ModelAndView to test against (never null
)
* @param modelName name of the object to add to the model (never
* null
)
@@ -88,13 +92,14 @@ public abstract class ModelAndViewAssert {
public static void assertModelAttributeAvailable(ModelAndView mav, String modelName) {
assertCondition(mav != null, "ModelAndView is null");
assertCondition(mav.getModel() != null, "Model is null");
- assertCondition(mav.getModel().containsKey(modelName), "Model attribute with name '" + modelName +
- "' is not available");
+ assertCondition(mav.getModel().containsKey(modelName), "Model attribute with name '" + modelName
+ + "' is not available");
}
/**
* Compare a given expectedValue
to the value from the model
* bound under the given modelName
.
+ *
* @param mav ModelAndView to test against (never null
)
* @param modelName name of the object to add to the model (never
* null
)
@@ -103,13 +108,14 @@ public abstract class ModelAndViewAssert {
public static void assertModelAttributeValue(ModelAndView mav, String modelName, Object expectedValue) {
assertCondition(mav != null, "ModelAndView is null");
Object modelValue = assertAndReturnModelAttributeOfType(mav, modelName, Object.class);
- assertCondition(modelValue.equals(expectedValue), "Model value with name '" + modelName +
- "' is not the same as the expected value which was '" + expectedValue + "'");
+ assertCondition(modelValue.equals(expectedValue), "Model value with name '" + modelName
+ + "' is not the same as the expected value which was '" + expectedValue + "'");
}
/**
* Inspect the expectedModel
to see if all elements in the
* model appear and are equal.
+ *
* @param mav ModelAndView to test against (never null
)
* @param expectedModel the expected model
*/
@@ -128,8 +134,8 @@ public abstract class ModelAndViewAssert {
Object assertionValue = expectedModel.get(modelName);
Object mavValue = mav.getModel().get(modelName);
if (!assertionValue.equals(mavValue)) {
- sb.append("Value under name '").append(modelName).append("' differs, should have been '")
- .append(assertionValue).append("' but was '").append(mavValue).append("'\n");
+ sb.append("Value under name '").append(modelName).append("' differs, should have been '").append(
+ assertionValue).append("' but was '").append(mavValue).append("'\n");
}
}
@@ -142,23 +148,24 @@ public abstract class ModelAndViewAssert {
/**
* Compare each individual entry in a list after having sorted both lists
* (optionally using a comparator).
+ *
* @param mav ModelAndView to test against (never null
)
- * @param modelName name of the object to add to the model
- * (never null
)
+ * @param modelName name of the object to add to the model (never
+ * null
)
* @param expectedList the expected list
- * @param comparator the comparator to use (may be null
).
- * If not specifying the comparator, both lists will be sorted not using
- * any comparator.
+ * @param comparator the comparator to use (may be null
). If
+ * not specifying the comparator, both lists will be sorted not using any
+ * comparator.
*/
- @SuppressWarnings("unchecked")
- public static void assertSortAndCompareListModelAttribute(
- ModelAndView mav, String modelName, List expectedList, Comparator comparator) {
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public static void assertSortAndCompareListModelAttribute(ModelAndView mav, String modelName, List expectedList,
+ Comparator comparator) {
assertCondition(mav != null, "ModelAndView is null");
List modelList = assertAndReturnModelAttributeOfType(mav, modelName, List.class);
- assertCondition(expectedList.size() == modelList.size(), "Size of model list is '" + modelList.size() +
- "' while size of expected list is '" + expectedList.size() + "'");
+ assertCondition(expectedList.size() == modelList.size(), "Size of model list is '" + modelList.size()
+ + "' while size of expected list is '" + expectedList.size() + "'");
if (comparator != null) {
Collections.sort(modelList, comparator);
@@ -169,26 +176,27 @@ public abstract class ModelAndViewAssert {
Collections.sort(expectedList);
}
- assertCondition(expectedList.equals(modelList), "List in model under name '" + modelName +
- "' is not equal to the expected list.");
+ assertCondition(expectedList.equals(modelList), "List in model under name '" + modelName
+ + "' is not equal to the expected list.");
}
/**
* Check to see if the view name in the ModelAndView matches the given
* expectedName
.
+ *
* @param mav ModelAndView to test against (never null
)
* @param expectedName the name of the model value
*/
public static void assertViewName(ModelAndView mav, String expectedName) {
assertCondition(mav != null, "ModelAndView is null");
- assertCondition(ObjectUtils.nullSafeEquals(expectedName, mav.getViewName()),
- "View name is not equal to '" + expectedName + "' but was '" + mav.getViewName() + "'");
+ assertCondition(ObjectUtils.nullSafeEquals(expectedName, mav.getViewName()), "View name is not equal to '"
+ + expectedName + "' but was '" + mav.getViewName() + "'");
}
-
/**
* Fails by throwing an AssertionError
with the supplied
* message
.
+ *
* @param message the exception message to use
* @see #assertCondition(boolean,String)
*/
@@ -198,8 +206,9 @@ public abstract class ModelAndViewAssert {
/**
* Assert the provided boolean condition
, throwing
- * AssertionError
with the supplied message
if
- * the test result is false
.
+ * AssertionError
with the supplied message
if the
+ * test result is false
.
+ *
* @param condition a boolean expression
* @param message the exception message to use if the assertion fails
* @see #fail(String)
@@ -210,8 +219,8 @@ public abstract class ModelAndViewAssert {
}
}
- private static void appendNonMatchingSetsErrorMessage(
- Set assertionSet, Set incorrectSet, StringBuilder sb) {
+ private static void appendNonMatchingSetsErrorMessage(Set assertionSet, Set incorrectSet,
+ StringBuilder sb) {
Set tempSet = new HashSet();
tempSet.addAll(incorrectSet);
diff --git a/org.springframework.test/src/main/java/org/springframework/test/web/package-info.java b/org.springframework.test/src/main/java/org/springframework/test/web/package-info.java
index e6f3db1db89f1c6d2ca77263ce0637aca83bd106..008532081af61d63c9f40f98c922b0221d884f70 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/web/package-info.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/web/package-info.java
@@ -1,8 +1,6 @@
-
/**
- *
* Helper classes for unit tests based on Spring's web support.
- *
*/
+
package org.springframework.test.web;
diff --git a/org.springframework.test/src/test/java/org/springframework/beans/Colour.java b/org.springframework.test/src/test/java/org/springframework/beans/Colour.java
index 60dc333e0b4729cc44e7f3c851bcd68049f7e0ee..194e0037973758b341302e7a0611161b57d9efc3 100644
--- a/org.springframework.test/src/test/java/org/springframework/beans/Colour.java
+++ b/org.springframework.test/src/test/java/org/springframework/beans/Colour.java
@@ -21,6 +21,7 @@ import org.springframework.core.enums.ShortCodedLabeledEnum;
/**
* @author Rob Harrop
*/
+@SuppressWarnings({ "serial", "deprecation" })
public class Colour extends ShortCodedLabeledEnum {
public static final Colour RED = new Colour(0, "RED");
@@ -28,6 +29,7 @@ public class Colour extends ShortCodedLabeledEnum {
public static final Colour GREEN = new Colour(2, "GREEN");
public static final Colour PURPLE = new Colour(3, "PURPLE");
+
private Colour(int code, String label) {
super(code, label);
}
diff --git a/org.springframework.test/src/test/java/org/springframework/beans/IndexedTestBean.java b/org.springframework.test/src/test/java/org/springframework/beans/IndexedTestBean.java
index ddb091770ee7032aca974e4b4dbe032f018d22c0..cd1724f2645f33b96bc3084304bdbc441ba00c68 100644
--- a/org.springframework.test/src/test/java/org/springframework/beans/IndexedTestBean.java
+++ b/org.springframework.test/src/test/java/org/springframework/beans/IndexedTestBean.java
@@ -30,6 +30,7 @@ import java.util.TreeSet;
* @author Juergen Hoeller
* @since 11.11.2003
*/
+@SuppressWarnings("rawtypes")
public class IndexedTestBean {
private TestBean[] array;
@@ -57,6 +58,7 @@ public class IndexedTestBean {
}
}
+ @SuppressWarnings("unchecked")
public void populate() {
TestBean tb0 = new TestBean("name0", 0);
TestBean tb1 = new TestBean("name1", 0);
@@ -68,7 +70,7 @@ public class IndexedTestBean {
TestBean tb7 = new TestBean("name7", 0);
TestBean tbX = new TestBean("nameX", 0);
TestBean tbY = new TestBean("nameY", 0);
- this.array = new TestBean[] {tb0, tb1};
+ this.array = new TestBean[] { tb0, tb1 };
this.list = new ArrayList();
this.list.add(tb2);
this.list.add(tb3);
@@ -85,7 +87,6 @@ public class IndexedTestBean {
this.map.put("key4", list);
}
-
public TestBean[] getArray() {
return array;
}
diff --git a/org.springframework.test/src/test/java/org/springframework/beans/TestBean.java b/org.springframework.test/src/test/java/org/springframework/beans/TestBean.java
index ef4aef309eaddd999703d58a9612f3b19f27fa56..a56bab7e33ec11f48ed603417ebefba7046d7347 100644
--- a/org.springframework.test/src/test/java/org/springframework/beans/TestBean.java
+++ b/org.springframework.test/src/test/java/org/springframework/beans/TestBean.java
@@ -35,11 +35,12 @@ import org.springframework.util.ObjectUtils;
/**
* Simple test bean used for testing bean factories, the AOP framework etc.
- *
+ *
* @author Rod Johnson
* @author Juergen Hoeller
* @since 15 April 2001
*/
+@SuppressWarnings("rawtypes")
public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOther, Comparable {
private String beanName;
@@ -107,7 +108,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
}
public TestBean(ITestBean spouse) {
- this.spouses = new ITestBean[] {spouse};
+ this.spouses = new ITestBean[] { spouse };
}
public TestBean(String name, int age) {
@@ -116,7 +117,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
}
public TestBean(ITestBean spouse, Properties someProperties) {
- this.spouses = new ITestBean[] {spouse};
+ this.spouses = new ITestBean[] { spouse };
this.someProperties = someProperties;
}
@@ -136,7 +137,6 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.someProperties = someProperties;
}
-
public void setBeanName(String beanName) {
this.beanName = beanName;
}
@@ -201,7 +201,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
}
public void setSpouse(ITestBean spouse) {
- this.spouses = new ITestBean[] {spouse};
+ this.spouses = new ITestBean[] { spouse };
}
public ITestBean[] getSpouses() {
@@ -366,7 +366,6 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.pets = pets;
}
-
/**
* @see ITestBean#exceptional(Throwable)
*/
@@ -379,6 +378,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
public void unreliableFileOperation() throws IOException {
throw new IOException();
}
+
/**
* @see ITestBean#returnsThis()
*/
@@ -396,7 +396,6 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
return age++;
}
-
public void destroy() {
this.destroyed = true;
}
@@ -405,7 +404,6 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
return destroyed;
}
-
public boolean equals(Object other) {
if (this == other) {
return true;
diff --git a/org.springframework.test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java b/org.springframework.test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java
index 0f6d11ad00c8617f1e5fc55e0f52b98296b62f3e..78f6325a03053c3dcc4344f751dab7c2ba85e1c3 100644
--- a/org.springframework.test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java
@@ -32,7 +32,7 @@ public class MockHttpServletRequestTests extends TestCase {
String headerName = "Header1";
MockHttpServletRequest request = new MockHttpServletRequest();
request.addHeader(headerName, "value1");
- Enumeration requestHeaders = request.getHeaderNames();
+ Enumeration requestHeaders = request.getHeaderNames();
assertNotNull(requestHeaders);
assertEquals("HTTP header casing not being preserved", headerName, requestHeaders.nextElement());
}
@@ -41,7 +41,7 @@ public class MockHttpServletRequestTests extends TestCase {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setParameter("key1", "value1");
request.setParameter("key2", "value2");
- Map params = new HashMap(2);
+ Map params = new HashMap(2);
params.put("key1", "newValue1");
params.put("key3", new String[] { "value3A", "value3B" });
request.setParameters(params);
@@ -59,7 +59,7 @@ public class MockHttpServletRequestTests extends TestCase {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setParameter("key1", "value1");
request.setParameter("key2", "value2");
- Map params = new HashMap(2);
+ Map params = new HashMap(2);
params.put("key1", "newValue1");
params.put("key3", new String[] { "value3A", "value3B" });
request.addParameters(params);
@@ -77,7 +77,7 @@ public class MockHttpServletRequestTests extends TestCase {
public void testRemoveAllParameters() {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setParameter("key1", "value1");
- Map params = new HashMap(2);
+ Map params = new HashMap(2);
params.put("key2", "value2");
params.put("key3", new String[] { "value3A", "value3B" });
request.addParameters(params);
diff --git a/org.springframework.test/src/test/java/org/springframework/mock/web/MockHttpServletResponseTests.java b/org.springframework.test/src/test/java/org/springframework/mock/web/MockHttpServletResponseTests.java
index e2b31f07ed7a39ac6377604837d6c715e1ab6927..9b2869649d2c62dc1401ed65d2b015239ae43421 100644
--- a/org.springframework.test/src/test/java/org/springframework/mock/web/MockHttpServletResponseTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/mock/web/MockHttpServletResponseTests.java
@@ -34,8 +34,8 @@ public class MockHttpServletResponseTests extends TestCase {
public void testSetContentTypeWithNoEncoding() {
MockHttpServletResponse response = new MockHttpServletResponse();
response.setContentType("test/plain");
- assertEquals("Character encoding should be the default",
- WebUtils.DEFAULT_CHARACTER_ENCODING, response.getCharacterEncoding());
+ assertEquals("Character encoding should be the default", WebUtils.DEFAULT_CHARACTER_ENCODING,
+ response.getCharacterEncoding());
}
public void testSetContentTypeWithUTF8() {
@@ -49,7 +49,7 @@ public class MockHttpServletResponseTests extends TestCase {
MockHttpServletResponse response = new MockHttpServletResponse();
response.addHeader(headerName, "value1");
- Set responseHeaders = response.getHeaderNames();
+ Set responseHeaders = response.getHeaderNames();
assertNotNull(responseHeaders);
assertEquals(1, responseHeaders.size());
assertEquals("HTTP header casing not being preserved", headerName, responseHeaders.iterator().next());
diff --git a/org.springframework.test/src/test/java/org/springframework/test/AbstractSpr3350SingleSpringContextTests.java b/org.springframework.test/src/test/java/org/springframework/test/AbstractSpr3350SingleSpringContextTests.java
index 1bc157cba606d2d6b8b7934ca420fd441a769510..c60037cf74957830a546835267c73904ca12e5a6 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/AbstractSpr3350SingleSpringContextTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/AbstractSpr3350SingleSpringContextTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 the original author or authors.
+ * Copyright 2007-2011 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.
@@ -24,10 +24,11 @@ import org.springframework.context.ApplicationContext;
* Abstract JUnit 3.8 based unit test which verifies new functionality requested
* in SPR-3350.
- *
+ *
* @author Sam Brannen
* @since 2.5
*/
+@SuppressWarnings("deprecation")
public abstract class AbstractSpr3350SingleSpringContextTests extends AbstractDependencyInjectionSpringContextTests {
private Pet cat;
@@ -48,8 +49,9 @@ public abstract class AbstractSpr3350SingleSpringContextTests extends AbstractDe
/**
* Forcing concrete subclasses to provide a config path appropriate to the
* configured
- * {@link #createBeanDefinitionReader(org.springframework.context.support.GenericApplicationContext) BeanDefinitionReader}.
- *
+ * {@link #createBeanDefinitionReader(org.springframework.context.support.GenericApplicationContext)
+ * BeanDefinitionReader}.
+ *
* @see org.springframework.test.AbstractSingleSpringContextTests#getConfigPath()
*/
protected abstract String getConfigPath();
@@ -62,12 +64,11 @@ public abstract class AbstractSpr3350SingleSpringContextTests extends AbstractDe
* {@link AbstractSingleSpringContextTests} always uses an
* {@link XmlBeanDefinitionReader} internally when creating the
* {@link ApplicationContext} inside
- * {@link #createApplicationContext(String[])}. It would be nice to have
- * the bean definition reader creation in a separate method so that
- * subclasses can choose that individually without having to copy-n-paste
- * code from createApplicationContext() to do the context creation and
- * refresh. Consider JavaConfig where an Annotation based reader can be
- * plugged in.
+ * {@link #createApplicationContext(String[])}. It would be nice to have the
+ * bean definition reader creation in a separate method so that subclasses
+ * can choose that individually without having to copy-n-paste code from
+ * createApplicationContext() to do the context creation and refresh.
+ * Consider JavaConfig where an Annotation based reader can be plugged in.
*
*/
public final void testApplicationContextNotAutoCreated() {
diff --git a/org.springframework.test/src/test/java/org/springframework/test/Spr3264DependencyInjectionSpringContextTests.java b/org.springframework.test/src/test/java/org/springframework/test/Spr3264DependencyInjectionSpringContextTests.java
index 7cf3e27b328a536d3f57b107acb4feec1b79df24..9636d46a97df5a3a0cc40a8e8c2a41e84dffbd4c 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/Spr3264DependencyInjectionSpringContextTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/Spr3264DependencyInjectionSpringContextTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 the original author or authors.
+ * Copyright 2007-2011 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.
@@ -20,11 +20,12 @@ package org.springframework.test;
* JUnit 3.8 based unit test which verifies new functionality requested in SPR-3264.
- *
+ *
* @author Sam Brannen
* @since 2.5
* @see Spr3264SingleSpringContextTests
*/
+@SuppressWarnings("deprecation")
public class Spr3264DependencyInjectionSpringContextTests extends AbstractDependencyInjectionSpringContextTests {
public Spr3264DependencyInjectionSpringContextTests() {
@@ -50,7 +51,7 @@ public class Spr3264DependencyInjectionSpringContextTests extends AbstractDepend
// Re-assert issues covered by Spr3264SingleSpringContextTests as a
// safety net.
assertNull("The ApplicationContext should NOT be automatically created if no 'locations' are defined.",
- this.applicationContext);
+ this.applicationContext);
assertEquals("Verifying the ApplicationContext load count.", 0, super.getLoadCount());
// Assert changes to AbstractDependencyInjectionSpringContextTests:
diff --git a/org.springframework.test/src/test/java/org/springframework/test/Spr3264SingleSpringContextTests.java b/org.springframework.test/src/test/java/org/springframework/test/Spr3264SingleSpringContextTests.java
index d6286ecd1cbc85da5e9bd8f978ac8a3a5dc4538d..6496cdb07e0fb22663d3873940360c12fa5d0e82 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/Spr3264SingleSpringContextTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/Spr3264SingleSpringContextTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 the original author or authors.
+ * Copyright 2007-2011 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.
@@ -20,11 +20,12 @@ package org.springframework.test;
* JUnit 3.8 based unit test which verifies new functionality requested in SPR-3264.
- *
+ *
* @author Sam Brannen
* @since 2.5
* @see Spr3264DependencyInjectionSpringContextTests
*/
+@SuppressWarnings("deprecation")
public class Spr3264SingleSpringContextTests extends AbstractSingleSpringContextTests {
public Spr3264SingleSpringContextTests() {
@@ -47,7 +48,7 @@ public class Spr3264SingleSpringContextTests extends AbstractSingleSpringContext
*/
public void testApplicationContextNotAutoCreated() {
assertNull("The ApplicationContext should NOT be automatically created if no 'locations' are defined.",
- super.applicationContext);
+ super.applicationContext);
assertEquals("Verifying the ApplicationContext load count.", 0, super.getLoadCount());
}
diff --git a/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueAnnotationAwareTransactionalTests.java b/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueAnnotationAwareTransactionalTests.java
index e92bfe3353a91439487fc71144499d1c832cfed8..639d155b35bb54bef7c6e15fdfc08c339a064fb2 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueAnnotationAwareTransactionalTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueAnnotationAwareTransactionalTests.java
@@ -23,7 +23,7 @@ import junit.framework.TestResult;
* Verifies proper handling of {@link IfProfileValue @IfProfileValue} and
* {@link ProfileValueSourceConfiguration @ProfileValueSourceConfiguration} in
* conjunction with {@link AbstractAnnotationAwareTransactionalTests}.
- *
+ *
* @author Sam Brannen
* @since 2.5
*/
@@ -46,11 +46,11 @@ public class ProfileValueAnnotationAwareTransactionalTests extends TestCase {
testCase.setName(testName);
TestResult testResult = testCase.run();
assertEquals("Verifying number of invocations for test method [" + testName + "].", expectedInvocationCount,
- testCase.invocationCount);
+ testCase.invocationCount);
assertEquals("Verifying number of errors for test method [" + testName + "].", expectedErrorCount,
- testResult.errorCount());
+ testResult.errorCount());
assertEquals("Verifying number of failures for test method [" + testName + "].", expectedFailureCount,
- testResult.failureCount());
+ testResult.failureCount());
}
private void runTests(Class extends DefaultProfileValueSourceTestCase> testCaseType) throws Exception {
@@ -64,21 +64,23 @@ public class ProfileValueAnnotationAwareTransactionalTests extends TestCase {
public void testDefaultProfileValueSource() throws Exception {
assertEquals("Verifying the type of the configured ProfileValueSource.", SystemProfileValueSource.class,
- new DefaultProfileValueSourceTestCase().getProfileValueSource().getClass());
+ new DefaultProfileValueSourceTestCase().getProfileValueSource().getClass());
runTests(DefaultProfileValueSourceTestCase.class);
}
public void testHardCodedProfileValueSource() throws Exception {
assertEquals("Verifying the type of the configured ProfileValueSource.", HardCodedProfileValueSource.class,
- new HardCodedProfileValueSourceTestCase().getProfileValueSource().getClass());
+ new HardCodedProfileValueSourceTestCase().getProfileValueSource().getClass());
runTests(HardCodedProfileValueSourceTestCase.class);
}
+ @SuppressWarnings("deprecation")
protected static class DefaultProfileValueSourceTestCase extends AbstractAnnotationAwareTransactionalTests {
int invocationCount = 0;
+
public DefaultProfileValueSourceTestCase() {
}
@@ -130,12 +132,10 @@ public class ProfileValueAnnotationAwareTransactionalTests extends TestCase {
}
}
-
@ProfileValueSourceConfiguration(HardCodedProfileValueSource.class)
protected static class HardCodedProfileValueSourceTestCase extends DefaultProfileValueSourceTestCase {
}
-
public static class HardCodedProfileValueSource implements ProfileValueSource {
public String get(String key) {
diff --git a/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java b/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java
index 8a66fde60ea73fe314a0a3986c2d32d7c7c79b7f..092bc751acc7133308ce57194f4e1a3a8056e6e1 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/annotation/ProfileValueUtilsTests.java
@@ -23,8 +23,6 @@ import java.lang.reflect.Method;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
/**
* Unit tests for {@link ProfileValueUtils}.
@@ -32,7 +30,6 @@ import org.junit.runners.JUnit4;
* @author Sam Brannen
* @since 3.0
*/
-@RunWith(JUnit4.class)
public class ProfileValueUtilsTests {
private static final String NON_ANNOTATED_METHOD = "nonAnnotatedMethod";
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/junit38/ConcreteTransactionalJUnit38SpringContextTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/junit38/ConcreteTransactionalJUnit38SpringContextTests.java
index aeb961df3178beb533d28da121a17a8492b966af..f18ccd9083cfe2ac76ddc29a4f83455c381a19b4 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/junit38/ConcreteTransactionalJUnit38SpringContextTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/junit38/ConcreteTransactionalJUnit38SpringContextTests.java
@@ -23,7 +23,6 @@ import javax.sql.DataSource;
import org.junit.internal.runners.JUnit38ClassRunner;
import org.junit.runner.RunWith;
-
import org.springframework.beans.Employee;
import org.springframework.beans.Pet;
import org.springframework.beans.factory.BeanNameAware;
@@ -42,10 +41,11 @@ import org.springframework.test.jdbc.SimpleJdbcTestUtils;
/**
* Combined unit test for {@link AbstractJUnit38SpringContextTests} and
* {@link AbstractTransactionalJUnit38SpringContextTests}.
- *
+ *
* @author Sam Brannen
* @since 2.5
*/
+@SuppressWarnings("deprecation")
@RunWith(JUnit38ClassRunner.class)
@ContextConfiguration
public class ConcreteTransactionalJUnit38SpringContextTests extends AbstractTransactionalJUnit38SpringContextTests
@@ -142,13 +142,13 @@ public class ConcreteTransactionalJUnit38SpringContextTests extends AbstractTran
@NotTransactional
public void testApplicationContextSet() {
assertNotNull("The application context should have been set due to ApplicationContextAware semantics.",
- super.applicationContext);
+ super.applicationContext);
}
@NotTransactional
public void testBeanInitialized() {
assertTrue("This test bean should have been initialized due to InitializingBean semantics.",
- this.beanInitialized);
+ this.beanInitialized);
}
@NotTransactional
@@ -184,7 +184,7 @@ public class ConcreteTransactionalJUnit38SpringContextTests extends AbstractTran
public void beforeTransaction() {
this.inTransaction = true;
assertEquals("Verifying the number of rows in the person table before a transactional test method.", 1,
- countRowsInPersonTable(super.simpleJdbcTemplate));
+ countRowsInPersonTable(super.simpleJdbcTemplate));
assertEquals("Adding yoda", 1, addPerson(super.simpleJdbcTemplate, YODA));
}
@@ -198,7 +198,7 @@ public class ConcreteTransactionalJUnit38SpringContextTests extends AbstractTran
assertEquals("Adding jane", 1, addPerson(super.simpleJdbcTemplate, JANE));
assertEquals("Adding sue", 1, addPerson(super.simpleJdbcTemplate, SUE));
assertEquals("Verifying the number of rows in the person table within transactionalMethod2().", 4,
- countRowsInPersonTable(super.simpleJdbcTemplate));
+ countRowsInPersonTable(super.simpleJdbcTemplate));
}
@Override
@@ -211,7 +211,7 @@ public class ConcreteTransactionalJUnit38SpringContextTests extends AbstractTran
public void afterTransaction() {
assertEquals("Deleting yoda", 1, deletePerson(super.simpleJdbcTemplate, YODA));
assertEquals("Verifying the number of rows in the person table after a transactional test method.", 1,
- countRowsInPersonTable(super.simpleJdbcTemplate));
+ countRowsInPersonTable(super.simpleJdbcTemplate));
}
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/AbstractTransactionalSpringRunnerTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/AbstractTransactionalSpringRunnerTests.java
index 7491de80d102c6fb0d25a41b18d2faea830e89e9..4b36e3ed3756ee78e521ef8fe1911256234332e2 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/AbstractTransactionalSpringRunnerTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/AbstractTransactionalSpringRunnerTests.java
@@ -23,10 +23,10 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.transaction.annotation.Transactional;
/**
- * Abstract base class for verifying support of Spring's
- * {@link Transactional @Transactional} and
- * {@link NotTransactional @NotTransactional} annotations.
- *
+ * Abstract base class for verifying support of Spring's {@link Transactional
+ * @Transactional} and {@link NotTransactional @NotTransactional}
+ * annotations.
+ *
* @author Sam Brannen
* @since 2.5
* @see ClassLevelTransactionalSpringRunnerTests
@@ -34,7 +34,8 @@ import org.springframework.transaction.annotation.Transactional;
* @see Transactional
* @see NotTransactional
*/
-@ContextConfiguration(locations = {"transactionalTests-context.xml"})
+@SuppressWarnings("deprecation")
+@ContextConfiguration("transactionalTests-context.xml")
public abstract class AbstractTransactionalSpringRunnerTests {
protected static final String BOB = "bob";
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/ClassLevelTransactionalSpringRunnerTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/ClassLevelTransactionalSpringRunnerTests.java
index 0007c9bbee4176236a5056e87f975d5a265c1475..f6e16ca48b20e4f2f66910011c884393c4f61070 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/ClassLevelTransactionalSpringRunnerTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/ClassLevelTransactionalSpringRunnerTests.java
@@ -26,7 +26,6 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.test.annotation.NotTransactional;
import org.springframework.test.context.ContextConfiguration;
@@ -40,11 +39,11 @@ import org.springframework.transaction.annotation.Transactional;
/**
*
* JUnit 4 based unit test which verifies support of Spring's
- * {@link Transactional @Transactional},
- * {@link NotTransactional @NotTransactional},
- * {@link TestExecutionListeners @TestExecutionListeners}, and
- * {@link ContextConfiguration @ContextConfiguration} annotations in conjunction
- * with the {@link SpringJUnit4ClassRunner} and the following
+ * {@link Transactional @Transactional}, {@link NotTransactional
+ * @NotTransactional}, {@link TestExecutionListeners
+ * @TestExecutionListeners}, and {@link ContextConfiguration
+ * @ContextConfiguration} annotations in conjunction with the
+ * {@link SpringJUnit4ClassRunner} and the following
* {@link TestExecutionListener TestExecutionListeners}:
*
*
@@ -56,11 +55,12 @@ import org.springframework.transaction.annotation.Transactional;
* This class specifically tests usage of @Transactional
* defined at the class level.
*
- *
+ *
* @author Sam Brannen
* @since 2.5
* @see MethodLevelTransactionalSpringRunnerTests
*/
+@SuppressWarnings("deprecation")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@Transactional
@@ -72,7 +72,7 @@ public class ClassLevelTransactionalSpringRunnerTests extends AbstractTransactio
@AfterClass
public static void verifyFinalTestData() {
assertEquals("Verifying the final number of rows in the person table after all tests.", 4,
- countRowsInPersonTable(simpleJdbcTemplate));
+ countRowsInPersonTable(simpleJdbcTemplate));
}
@Before
@@ -80,10 +80,9 @@ public class ClassLevelTransactionalSpringRunnerTests extends AbstractTransactio
clearPersonTable(simpleJdbcTemplate);
assertEquals("Adding bob", 1, addPerson(simpleJdbcTemplate, BOB));
assertEquals("Verifying the initial number of rows in the person table.", 1,
- countRowsInPersonTable(simpleJdbcTemplate));
+ countRowsInPersonTable(simpleJdbcTemplate));
}
-
@Test
public void modifyTestDataWithinTransaction() {
assertInTransaction(true);
@@ -91,7 +90,7 @@ public class ClassLevelTransactionalSpringRunnerTests extends AbstractTransactio
assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE));
assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE));
assertEquals("Verifying the number of rows in the person table within a transaction.", 2,
- countRowsInPersonTable(simpleJdbcTemplate));
+ countRowsInPersonTable(simpleJdbcTemplate));
}
@Test
@@ -102,7 +101,7 @@ public class ClassLevelTransactionalSpringRunnerTests extends AbstractTransactio
assertEquals("Adding leia", 1, addPerson(simpleJdbcTemplate, LEIA));
assertEquals("Adding yoda", 1, addPerson(simpleJdbcTemplate, YODA));
assertEquals("Verifying the number of rows in the person table without a transaction.", 4,
- countRowsInPersonTable(simpleJdbcTemplate));
+ countRowsInPersonTable(simpleJdbcTemplate));
}
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java
index 21e4a76860f596d0d44e2b88405b44ba9ac20842..3fcee7536ca148b37ff3d6f564b6820ca0683087 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/ConcreteTransactionalJUnit4SpringContextTests.java
@@ -29,7 +29,6 @@ import javax.sql.DataSource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-
import org.springframework.beans.Employee;
import org.springframework.beans.Pet;
import org.springframework.beans.factory.BeanNameAware;
@@ -46,10 +45,11 @@ import org.springframework.test.jdbc.SimpleJdbcTestUtils;
/**
* Combined unit test for {@link AbstractJUnit4SpringContextTests} and
* {@link AbstractTransactionalJUnit4SpringContextTests}.
- *
+ *
* @author Sam Brannen
* @since 2.5
*/
+@SuppressWarnings("deprecation")
@ContextConfiguration
public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTransactionalJUnit4SpringContextTests
implements BeanNameAware, InitializingBean {
@@ -61,7 +61,6 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
protected static final String LEIA = "leia";
protected static final String YODA = "yoda";
-
private boolean beanInitialized = false;
private String beanName = "replace me with [" + getClass().getName() + "]";
@@ -105,7 +104,6 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
return simpleJdbcTemplate.update("DELETE FROM person WHERE name=?", name);
}
-
@Resource
public void setDataSource(DataSource dataSource) {
super.setDataSource(dataSource);
@@ -129,13 +127,12 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
this.beanInitialized = true;
}
-
@Test
@NotTransactional
public final void verifyApplicationContext() {
assertInTransaction(false);
assertNotNull("The application context should have been set due to ApplicationContextAware semantics.",
- super.applicationContext);
+ super.applicationContext);
}
@Test
@@ -143,7 +140,7 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
public final void verifyBeanInitialized() {
assertInTransaction(false);
assertTrue("This test bean should have been initialized due to InitializingBean semantics.",
- this.beanInitialized);
+ this.beanInitialized);
}
@Test
@@ -185,18 +182,17 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
assertEquals("The bar method should have been wired via @Resource.", "Bar", this.bar);
}
-
@BeforeTransaction
public void beforeTransaction() {
assertEquals("Verifying the number of rows in the person table before a transactional test method.", 1,
- countRowsInPersonTable(super.simpleJdbcTemplate));
+ countRowsInPersonTable(super.simpleJdbcTemplate));
assertEquals("Adding yoda", 1, addPerson(super.simpleJdbcTemplate, YODA));
}
@Before
public void setUp() throws Exception {
assertEquals("Verifying the number of rows in the person table before a test method.",
- (inTransaction() ? 2 : 1), countRowsInPersonTable(super.simpleJdbcTemplate));
+ (inTransaction() ? 2 : 1), countRowsInPersonTable(super.simpleJdbcTemplate));
}
@Test
@@ -205,20 +201,20 @@ public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTrans
assertEquals("Adding jane", 1, addPerson(super.simpleJdbcTemplate, JANE));
assertEquals("Adding sue", 1, addPerson(super.simpleJdbcTemplate, SUE));
assertEquals("Verifying the number of rows in the person table in modifyTestDataWithinTransaction().", 4,
- countRowsInPersonTable(super.simpleJdbcTemplate));
+ countRowsInPersonTable(super.simpleJdbcTemplate));
}
@After
public void tearDown() throws Exception {
assertEquals("Verifying the number of rows in the person table after a test method.",
- (inTransaction() ? 4 : 1), countRowsInPersonTable(super.simpleJdbcTemplate));
+ (inTransaction() ? 4 : 1), countRowsInPersonTable(super.simpleJdbcTemplate));
}
@AfterTransaction
public void afterTransaction() {
assertEquals("Deleting yoda", 1, deletePerson(super.simpleJdbcTemplate, YODA));
assertEquals("Verifying the number of rows in the person table after a transactional test method.", 1,
- countRowsInPersonTable(super.simpleJdbcTemplate));
+ countRowsInPersonTable(super.simpleJdbcTemplate));
}
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java
index 21c8eb62a7f76544d89ba05813e6b0f4bf5697af..8cd6a80c7f73be7ea4cf3aa8b4d4c6b6f02998d0 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java
@@ -16,15 +16,16 @@
package org.springframework.test.context.junit4;
+import static org.junit.Assert.assertEquals;
+import static org.springframework.test.transaction.TransactionTestUtils.assertInTransaction;
+
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.junit.AfterClass;
-import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListener;
@@ -32,17 +33,15 @@ import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
-import org.springframework.test.context.transaction.TransactionConfiguration;
-import static org.springframework.test.transaction.TransactionTestUtils.*;
import org.springframework.transaction.annotation.Transactional;
/**
*
* JUnit 4 based unit test which verifies support of Spring's
- * {@link Transactional @Transactional},
- * {@link TestExecutionListeners @TestExecutionListeners}, and
- * {@link ContextConfiguration @ContextConfiguration} annotations in conjunction
- * with the {@link SpringJUnit4ClassRunner} and the following
+ * {@link Transactional @Transactional}, {@link TestExecutionListeners
+ * @TestExecutionListeners}, and {@link ContextConfiguration
+ * @ContextConfiguration} annotations in conjunction with the
+ * {@link SpringJUnit4ClassRunner} and the following
* {@link TestExecutionListener TestExecutionListeners}:
*
*
@@ -56,15 +55,15 @@ import org.springframework.transaction.annotation.Transactional;
* {@link ClassLevelTransactionalSpringRunnerTests}, this class omits usage of
* @NotTransactional
.
*
- *
+ *
* @author Sam Brannen
* @since 2.5
* @see ClassLevelTransactionalSpringRunnerTests
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-@TestExecutionListeners({DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class,
- TransactionalTestExecutionListener.class})
+@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class,
+ TransactionalTestExecutionListener.class })
public class MethodLevelTransactionalSpringRunnerTests extends AbstractTransactionalSpringRunnerTests {
protected static SimpleJdbcTemplate simpleJdbcTemplate;
@@ -73,7 +72,7 @@ public class MethodLevelTransactionalSpringRunnerTests extends AbstractTransacti
@AfterClass
public static void verifyFinalTestData() {
assertEquals("Verifying the final number of rows in the person table after all tests.", 4,
- countRowsInPersonTable(simpleJdbcTemplate));
+ countRowsInPersonTable(simpleJdbcTemplate));
}
@Before
@@ -81,7 +80,7 @@ public class MethodLevelTransactionalSpringRunnerTests extends AbstractTransacti
clearPersonTable(simpleJdbcTemplate);
assertEquals("Adding bob", 1, addPerson(simpleJdbcTemplate, BOB));
assertEquals("Verifying the initial number of rows in the person table.", 1,
- countRowsInPersonTable(simpleJdbcTemplate));
+ countRowsInPersonTable(simpleJdbcTemplate));
}
@Test
@@ -92,7 +91,7 @@ public class MethodLevelTransactionalSpringRunnerTests extends AbstractTransacti
assertEquals("Adding jane", 1, addPerson(simpleJdbcTemplate, JANE));
assertEquals("Adding sue", 1, addPerson(simpleJdbcTemplate, SUE));
assertEquals("Verifying the number of rows in the person table within a transaction.", 2,
- countRowsInPersonTable(simpleJdbcTemplate));
+ countRowsInPersonTable(simpleJdbcTemplate));
}
@Test
@@ -102,7 +101,7 @@ public class MethodLevelTransactionalSpringRunnerTests extends AbstractTransacti
assertEquals("Adding leia", 1, addPerson(simpleJdbcTemplate, LEIA));
assertEquals("Adding yoda", 1, addPerson(simpleJdbcTemplate, YODA));
assertEquals("Verifying the number of rows in the person table without a transaction.", 4,
- countRowsInPersonTable(simpleJdbcTemplate));
+ countRowsInPersonTable(simpleJdbcTemplate));
}
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/TimedTransactionalSpringRunnerTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/TimedTransactionalSpringRunnerTests.java
index e9df6b3ceae473f138f6c47321d57505a83b6275..7e4254edeaa4ad7971c2b7c6a9155913e8b45770 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/TimedTransactionalSpringRunnerTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/TimedTransactionalSpringRunnerTests.java
@@ -20,7 +20,6 @@ import static org.springframework.test.transaction.TransactionTestUtils.assertIn
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.springframework.test.annotation.NotTransactional;
import org.springframework.test.annotation.Repeat;
import org.springframework.test.annotation.Timed;
@@ -29,16 +28,17 @@ import org.springframework.transaction.annotation.Transactional;
/**
* JUnit 4 based unit test which verifies support of Spring's
- * {@link Transactional @Transactional} and
- * {@link NotTransactional @NotTransactional} annotations in conjunction with
- * {@link Timed @Timed} and JUnit 4's {@link Test#timeout() timeout} attribute.
- *
+ * {@link Transactional @Transactional} and {@link NotTransactional
+ * @NotTransactional} annotations in conjunction with {@link Timed
+ * @Timed} and JUnit 4's {@link Test#timeout() timeout} attribute.
+ *
* @author Sam Brannen
* @since 2.5
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"transactionalTests-context.xml"})
+@ContextConfiguration("transactionalTests-context.xml")
@Transactional
+@SuppressWarnings("deprecation")
public class TimedTransactionalSpringRunnerTests {
@Test
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java
index 27adaef7efd90acbdb95acd11ee4f18facf8a8a0..052a7082f296be5bec99b19db693a89f4a0c9208 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/testng/ConcreteTransactionalTestNGSpringContextTests.java
@@ -51,6 +51,7 @@ import org.testng.annotations.Test;
* @author Sam Brannen
* @since 2.5
*/
+@SuppressWarnings("deprecation")
@ContextConfiguration
public class ConcreteTransactionalTestNGSpringContextTests extends AbstractTransactionalTestNGSpringContextTests
implements BeanNameAware, InitializingBean {
diff --git a/org.springframework.test/src/test/java/org/springframework/test/jdbc/JdbcTestUtilsTests.java b/org.springframework.test/src/test/java/org/springframework/test/jdbc/JdbcTestUtilsTests.java
index 35346bc253eb2ca8031207efa2d1cd46782e28f7..4817c7127b10b703162838485ac7eaaac4de7891 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/jdbc/JdbcTestUtilsTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/jdbc/JdbcTestUtilsTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2011 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.
@@ -16,59 +16,62 @@
package org.springframework.test.jdbc;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
/**
* Unit tests for {@link JdbcTestUtils}.
- *
+ *
* @author Thomas Risberg
* @since 2.5.4
*/
-public class JdbcTestUtilsTests extends TestCase {
+public class JdbcTestUtilsTests {
- public void testContainsDelimiters() {
- assertTrue("test with ';' is wrong", !JdbcTestUtils.containsSqlScriptDelimiters("select 1\n select ';'", ';'));
- assertTrue("test with delimiter ; is wrong", JdbcTestUtils.containsSqlScriptDelimiters("select 1; select 2", ';'));
- assertTrue("test with '\\n' is wrong", !JdbcTestUtils.containsSqlScriptDelimiters("select 1; select '\\n\n';", '\n'));
- assertTrue("test with delimiter \\n is wrong", JdbcTestUtils.containsSqlScriptDelimiters("select 1\n select 2", '\n'));
+ @Test
+ public void containsDelimiters() {
+ assertTrue("test with ';' is wrong", !JdbcTestUtils.containsSqlScriptDelimiters("select 1\n select ';'", ';'));
+ assertTrue("test with delimiter ; is wrong",
+ JdbcTestUtils.containsSqlScriptDelimiters("select 1; select 2", ';'));
+ assertTrue("test with '\\n' is wrong",
+ !JdbcTestUtils.containsSqlScriptDelimiters("select 1; select '\\n\n';", '\n'));
+ assertTrue("test with delimiter \\n is wrong",
+ JdbcTestUtils.containsSqlScriptDelimiters("select 1\n select 2", '\n'));
}
- public void testSplitSqlScriptDelimitedWithSemicolon() {
- String statement1 = "insert into customer (id, name) \n" +
- "values (1, 'Rod ; Johnson'), (2, 'Adrian \n Collier')";
- String statement2 = "insert into orders(id, order_date, customer_id) \n" +
- "values (1, '2008-01-02', 2)";
- String statement3 = "insert into orders(id, order_date, customer_id) " +
- "values (1, '2008-01-02', 2)";
+ @Test
+ public void splitSqlScriptDelimitedWithSemicolon() {
+ String statement1 = "insert into customer (id, name) \n"
+ + "values (1, 'Rod ; Johnson'), (2, 'Adrian \n Collier')";
+ String statement2 = "insert into orders(id, order_date, customer_id) \n" + "values (1, '2008-01-02', 2)";
+ String statement3 = "insert into orders(id, order_date, customer_id) " + "values (1, '2008-01-02', 2)";
char delim = ';';
String script = statement1 + delim + statement2 + delim + statement3;
- List statements = new ArrayList();
+ List statements = new ArrayList();
JdbcTestUtils.splitSqlScript(script, delim, statements);
assertEquals("wrong number of statements", 3, statements.size());
assertEquals("statement 1 not split correctly", statement1, statements.get(0));
assertEquals("statement 2 not split correctly", statement2, statements.get(1));
assertEquals("statement 3 not split correctly", statement3, statements.get(2));
-
}
- public void testSplitSqlScriptDelimitedWithNewLine() {
- String statement1 = "insert into customer (id, name) " +
- "values (1, 'Rod ; Johnson'), (2, 'Adrian ; Collier')";
- String statement2 = "insert into orders(id, order_date, customer_id) " +
- "values (1, '2008-01-02', 2)";
- String statement3 = "insert into orders(id, order_date, customer_id) " +
- "values (1, '2008-01-02', 2)";
+ @Test
+ public void splitSqlScriptDelimitedWithNewLine() {
+ String statement1 = "insert into customer (id, name) " + "values (1, 'Rod ; Johnson'), (2, 'Adrian ; Collier')";
+ String statement2 = "insert into orders(id, order_date, customer_id) " + "values (1, '2008-01-02', 2)";
+ String statement3 = "insert into orders(id, order_date, customer_id) " + "values (1, '2008-01-02', 2)";
char delim = '\n';
String script = statement1 + delim + statement2 + delim + statement3;
- List statements = new ArrayList();
+ List statements = new ArrayList();
JdbcTestUtils.splitSqlScript(script, delim, statements);
assertEquals("wrong number of statements", 3, statements.size());
assertEquals("statement 1 not split correctly", statement1, statements.get(0));
assertEquals("statement 2 not split correctly", statement2, statements.get(1));
assertEquals("statement 3 not split correctly", statement3, statements.get(2));
-
}
+
}
diff --git a/org.springframework.test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java b/org.springframework.test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java
index 41b98ce8df74203924b00900f665dbc7ad66e619..58c0ce45e11ec4851876ff1454152e82f6c0dd11 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2011 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.
@@ -23,10 +23,11 @@ import org.springframework.test.util.subpackage.Person;
/**
* JUnit 3.8 based unit tests for {@link ReflectionTestUtils}.
- *
+ *
* @author Sam Brannen
* @author Juergen Hoeller
*/
+@SuppressWarnings("deprecation")
public class ReflectionTestUtilsTests extends TestCase {
protected static final Float PI = new Float((float) 22 / 7);
@@ -48,11 +49,11 @@ public class ReflectionTestUtilsTests extends TestCase {
assertEquals("Verifying that the person's name (protected field) was set.", "Tom", person.getName());
assertEquals("Verifying that the person's age (private field) was set.", 42, person.getAge());
assertEquals("Verifying that the person's eye color (package private field) was set.", "blue",
- person.getEyeColor());
+ person.getEyeColor());
assertEquals("Verifying that the person's 'likes pets' flag (package private boolean field) was set.", true,
- person.likesPets());
+ person.likesPets());
assertEquals("Verifying that the person's 'favorite number' (package field) was set.", PI,
- person.getFavoriteNumber());
+ person.getFavoriteNumber());
assertEquals(new Long(99), ReflectionTestUtils.getField(person, "id"));
assertEquals("Tom", ReflectionTestUtils.getField(person, "name"));
@@ -74,7 +75,7 @@ public class ReflectionTestUtilsTests extends TestCase {
// Null - primitives
new AssertThrows(IllegalArgumentException.class,
- "Calling setField() with NULL for a primitive type should throw an IllegalArgumentException.") {
+ "Calling setField() with NULL for a primitive type should throw an IllegalArgumentException.") {
public void test() throws Exception {
ReflectionTestUtils.setField(person, "id", null, long.class);
@@ -82,7 +83,7 @@ public class ReflectionTestUtilsTests extends TestCase {
}.runTest();
new AssertThrows(IllegalArgumentException.class,
- "Calling setField() with NULL for a primitive type should throw an IllegalArgumentException.") {
+ "Calling setField() with NULL for a primitive type should throw an IllegalArgumentException.") {
public void test() throws Exception {
ReflectionTestUtils.setField(person, "age", null, int.class);
@@ -90,7 +91,7 @@ public class ReflectionTestUtilsTests extends TestCase {
}.runTest();
new AssertThrows(IllegalArgumentException.class,
- "Calling setField() with NULL for a primitive type should throw an IllegalArgumentException.") {
+ "Calling setField() with NULL for a primitive type should throw an IllegalArgumentException.") {
public void test() throws Exception {
ReflectionTestUtils.setField(person, "likesPets", null, boolean.class);
@@ -114,11 +115,11 @@ public class ReflectionTestUtilsTests extends TestCase {
assertEquals("Verifying that the person's name (private method) was set.", "Tom", person.getName());
assertEquals("Verifying that the person's age (protected method) was set.", 42, person.getAge());
assertEquals("Verifying that the person's eye color (package private method) was set.", "blue",
- person.getEyeColor());
+ person.getEyeColor());
assertEquals("Verifying that the person's 'likes pets' flag (protected method for a boolean) was set.", true,
- person.likesPets());
+ person.likesPets());
assertEquals("Verifying that the person's 'favorite number' (protected method for a Number) was set.", PI,
- person.getFavoriteNumber());
+ person.getFavoriteNumber());
assertEquals(new Long(99), ReflectionTestUtils.invokeGetterMethod(person, "id"));
assertEquals("Tom", ReflectionTestUtils.invokeGetterMethod(person, "name"));
@@ -140,11 +141,11 @@ public class ReflectionTestUtilsTests extends TestCase {
assertEquals("Verifying that the person's name (private method) was set.", "Jerry", person.getName());
assertEquals("Verifying that the person's age (protected method) was set.", 33, person.getAge());
assertEquals("Verifying that the person's eye color (package private method) was set.", "green",
- person.getEyeColor());
+ person.getEyeColor());
assertEquals("Verifying that the person's 'likes pets' flag (protected method for a boolean) was set.", false,
- person.likesPets());
+ person.likesPets());
assertEquals("Verifying that the person's 'favorite number' (protected method for a Number) was set.",
- new Integer(42), person.getFavoriteNumber());
+ new Integer(42), person.getFavoriteNumber());
assertEquals(new Long(1), ReflectionTestUtils.invokeGetterMethod(person, "getId"));
assertEquals("Jerry", ReflectionTestUtils.invokeGetterMethod(person, "getName"));
@@ -162,12 +163,12 @@ public class ReflectionTestUtilsTests extends TestCase {
assertNull("Verifying that the person's name (private method) was set.", person.getName());
assertNull("Verifying that the person's eye color (package private method) was set.", person.getEyeColor());
assertNull("Verifying that the person's 'favorite number' (protected method for a Number) was set.",
- person.getFavoriteNumber());
+ person.getFavoriteNumber());
// Null - primitives
new AssertThrows(RuntimeException.class,
- "Calling invokeSetterMethod() with NULL for a primitive type should throw an IllegalArgumentException.") {
+ "Calling invokeSetterMethod() with NULL for a primitive type should throw an IllegalArgumentException.") {
public void test() throws Exception {
ReflectionTestUtils.invokeSetterMethod(person, "id", null, long.class);
@@ -175,7 +176,7 @@ public class ReflectionTestUtilsTests extends TestCase {
}.runTest();
new AssertThrows(RuntimeException.class,
- "Calling invokeSetterMethod() with NULL for a primitive type should throw an IllegalArgumentException.") {
+ "Calling invokeSetterMethod() with NULL for a primitive type should throw an IllegalArgumentException.") {
public void test() throws Exception {
ReflectionTestUtils.invokeSetterMethod(person, "age", null, int.class);
@@ -183,7 +184,7 @@ public class ReflectionTestUtilsTests extends TestCase {
}.runTest();
new AssertThrows(RuntimeException.class,
- "Calling invokeSetterMethod() with NULL for a primitive type should throw an IllegalArgumentException.") {
+ "Calling invokeSetterMethod() with NULL for a primitive type should throw an IllegalArgumentException.") {
public void test() throws Exception {
ReflectionTestUtils.invokeSetterMethod(person, "likesPets", null, boolean.class);
diff --git a/org.springframework.test/src/test/java/org/springframework/test/util/subpackage/Person.java b/org.springframework.test/src/test/java/org/springframework/test/util/subpackage/Person.java
index 0fec1a026ea5891eeec48bb6b16de090f5f12d07..4eb84791f529815868fc418a5a8e8b5def6fb1ea 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/util/subpackage/Person.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/util/subpackage/Person.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007 the original author or authors.
+ * Copyright 2007-2011 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.
@@ -21,7 +21,7 @@ import org.springframework.core.style.ToStringCreator;
/**
* Concrete subclass of {@link PersistentEntity} representing a person
* entity; intended for use in unit tests.
- *
+ *
* @author Sam Brannen
* @since 2.5
*/
@@ -42,6 +42,7 @@ public class Person extends PersistentEntity {
return this.name;
}
+ @SuppressWarnings("unused")
private final void setName(final String name) {
this.name = name;
}
diff --git a/org.springframework.test/src/test/java/org/springframework/web/multipart/MockMultipartHttpServletRequestTests.java b/org.springframework.test/src/test/java/org/springframework/web/multipart/MockMultipartHttpServletRequestTests.java
index 6352a08bf0487d3bbc5918a7f1ad289eb575682f..029f584c1fea81d23e1e9eac3593ccb8e824b1f4 100644
--- a/org.springframework.test/src/test/java/org/springframework/web/multipart/MockMultipartHttpServletRequestTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/web/multipart/MockMultipartHttpServletRequestTests.java
@@ -16,6 +16,11 @@
package org.springframework.web.multipart;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.HashSet;
@@ -25,8 +30,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.mock.web.MockMultipartHttpServletRequest;
import org.springframework.util.FileCopyUtils;
@@ -35,9 +39,10 @@ import org.springframework.util.ObjectUtils;
/**
* @author Juergen Hoeller
*/
-public class MockMultipartHttpServletRequestTests extends TestCase {
+public class MockMultipartHttpServletRequestTests {
- public void testMockMultipartHttpServletRequestWithByteArray() throws IOException {
+ @Test
+ public void mockMultipartHttpServletRequestWithByteArray() throws IOException {
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
assertFalse(request.getFileNames().hasNext());
assertNull(request.getFile("file1"));
@@ -49,16 +54,18 @@ public class MockMultipartHttpServletRequestTests extends TestCase {
doTestMultipartHttpServletRequest(request);
}
- public void testMockMultipartHttpServletRequestWithInputStream() throws IOException {
+ @Test
+ public void mockMultipartHttpServletRequestWithInputStream() throws IOException {
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
request.addFile(new MockMultipartFile("file1", new ByteArrayInputStream("myContent1".getBytes())));
- request.addFile(new MockMultipartFile("file2", "myOrigFilename", "text/plain", new ByteArrayInputStream("myContent2".getBytes())));
+ request.addFile(new MockMultipartFile("file2", "myOrigFilename", "text/plain", new ByteArrayInputStream(
+ "myContent2".getBytes())));
doTestMultipartHttpServletRequest(request);
}
private void doTestMultipartHttpServletRequest(MultipartHttpServletRequest request) throws IOException {
- Set fileNames = new HashSet();
- Iterator fileIter = request.getFileNames();
+ Set fileNames = new HashSet();
+ Iterator fileIter = request.getFileNames();
while (fileIter.hasNext()) {
fileNames.add(fileIter.next());
}
@@ -67,8 +74,8 @@ public class MockMultipartHttpServletRequestTests extends TestCase {
assertTrue(fileNames.contains("file2"));
MultipartFile file1 = request.getFile("file1");
MultipartFile file2 = request.getFile("file2");
- Map fileMap = request.getFileMap();
- List fileMapKeys = new LinkedList(fileMap.keySet());
+ Map fileMap = request.getFileMap();
+ List fileMapKeys = new LinkedList(fileMap.keySet());
assertEquals(2, fileMapKeys.size());
assertEquals(file1, fileMap.get("file1"));
assertEquals(file2, fileMap.get("file2"));
@@ -77,12 +84,14 @@ public class MockMultipartHttpServletRequestTests extends TestCase {
assertEquals("", file1.getOriginalFilename());
assertNull(file1.getContentType());
assertTrue(ObjectUtils.nullSafeEquals("myContent1".getBytes(), file1.getBytes()));
- assertTrue(ObjectUtils.nullSafeEquals("myContent1".getBytes(), FileCopyUtils.copyToByteArray(file1.getInputStream())));
+ assertTrue(ObjectUtils.nullSafeEquals("myContent1".getBytes(),
+ FileCopyUtils.copyToByteArray(file1.getInputStream())));
assertEquals("file2", file2.getName());
assertEquals("myOrigFilename", file2.getOriginalFilename());
assertEquals("text/plain", file2.getContentType());
assertTrue(ObjectUtils.nullSafeEquals("myContent2".getBytes(), file2.getBytes()));
- assertTrue(ObjectUtils.nullSafeEquals("myContent2".getBytes(), FileCopyUtils.copyToByteArray(file2.getInputStream())));
+ assertTrue(ObjectUtils.nullSafeEquals("myContent2".getBytes(),
+ FileCopyUtils.copyToByteArray(file2.getInputStream())));
}
}