Fix [deprecation] compiler warnings

Fix deprecation compiler warnings by refactoring code or applying
@SuppressWarnings("deprecation") annotations. JUnit tests of
internally deprecated classes are now themselves marked as
@Deprecated.

Numerous EasyMock deprecation warnings will remain until the
migration to mockito can be completed.
This commit is contained in:
Phillip Webb
2012-12-31 13:08:39 -08:00
parent 9364043a64
commit 6626a38730
153 changed files with 1665 additions and 1188 deletions

View File

@@ -21,6 +21,7 @@ import java.net.URI;
import org.junit.Test;
import org.springframework.http.HttpMethod;
@Deprecated
public class CommonsHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {
@Override

View File

@@ -16,9 +16,14 @@
package org.springframework.http.converter.xml;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.InputStreamReader;
import java.io.StringReader;
import java.nio.charset.Charset;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
@@ -27,19 +32,17 @@ import javax.xml.transform.stream.StreamSource;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import org.springframework.http.MediaType;
import org.springframework.http.MockHttpInputMessage;
import org.springframework.http.MockHttpOutputMessage;
import org.springframework.util.FileCopyUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import static org.custommonkey.xmlunit.XMLAssert.*;
/** @author Arjen Poutsma */
@SuppressWarnings("unchecked")
/**
* @author Arjen Poutsma
*/
public class SourceHttpMessageConverterTests {
private SourceHttpMessageConverter<Source> converter;

View File

@@ -40,6 +40,7 @@ import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
* @since 1.1.5
* @see org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager
*/
@Deprecated
public class MockExpressionEvaluator extends ExpressionEvaluator {
private final PageContext pageContext;

View File

@@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.el.ELContext;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
@@ -262,7 +263,6 @@ public class MockPageContext extends PageContext {
}
@Override
@SuppressWarnings("unchecked")
public Enumeration<String> getAttributeNamesInScope(int scope) {
switch (scope) {
case PAGE_SCOPE:
@@ -288,6 +288,7 @@ public class MockPageContext extends PageContext {
}
@Override
@Deprecated
public ExpressionEvaluator getExpressionEvaluator() {
return new MockExpressionEvaluator(this);
}
@@ -298,6 +299,7 @@ public class MockPageContext extends PageContext {
}
@Override
@Deprecated
public VariableResolver getVariableResolver() {
return null;
}

View File

@@ -45,6 +45,7 @@ import org.springframework.util.ObjectUtils;
* @author Juergen Hoeller
* @since 18.12.2003
*/
@Deprecated
public class JaxRpcSupportTests extends TestCase {
public void testLocalJaxRpcServiceFactoryBeanWithServiceNameAndNamespace() throws Exception {

View File

@@ -30,6 +30,7 @@ import org.springframework.web.context.support.StaticWebApplicationContext;
* @author Juergen Hoeller
* @since 02.08.2004
*/
@Deprecated
public class DelegatingVariableResolverTests extends TestCase {
public void testDelegatingVariableResolver() {

View File

@@ -16,6 +16,10 @@
package org.springframework.web.multipart.commons;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
@@ -30,6 +34,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
@@ -41,9 +46,7 @@ import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.mock.web.test.MockFilterConfig;
import org.springframework.mock.web.test.MockHttpServletRequest;
@@ -220,7 +223,7 @@ public class CommonsMultipartResolverTests {
MultipartHttpServletRequest request) throws UnsupportedEncodingException {
MultipartTestBean1 mtb1 = new MultipartTestBean1();
assertEquals(null, mtb1.getField1());
assertArrayEquals(null, mtb1.getField1());
assertEquals(null, mtb1.getField2());
ServletRequestDataBinder binder = new ServletRequestDataBinder(mtb1, "mybean");
binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
@@ -234,7 +237,7 @@ public class CommonsMultipartResolverTests {
assertEquals(new String(file2.getBytes()), new String(mtb1.getField2()));
MultipartTestBean2 mtb2 = new MultipartTestBean2();
assertEquals(null, mtb2.getField1());
assertArrayEquals(null, mtb2.getField1());
assertEquals(null, mtb2.getField2());
binder = new ServletRequestDataBinder(mtb2, "mybean");
binder.registerCustomEditor(String.class, "field1", new StringMultipartFileEditor());

View File

@@ -38,6 +38,7 @@ import static org.junit.Assert.*;
* @author Juergen Hoeller
* @since 16.09.2003
*/
@Deprecated
public class ExpressionEvaluationUtilsTests {
@Test

View File

@@ -106,6 +106,7 @@ public class UriUtilsTests {
}
@Test
@Deprecated
public void encodeUri() throws UnsupportedEncodingException {
assertEquals("Invalid encoded URI", "http://www.ietf.org/rfc/rfc3986.txt",
UriUtils.encodeUri("http://www.ietf.org/rfc/rfc3986.txt", ENC));
@@ -134,6 +135,7 @@ public class UriUtilsTests {
}
@Test
@Deprecated
public void encodeHttpUrl() throws UnsupportedEncodingException {
assertEquals("Invalid encoded HTTP URL", "http://www.ietf.org/rfc/rfc3986.txt",
UriUtils.encodeHttpUrl("http://www.ietf.org/rfc/rfc3986.txt", ENC));
@@ -156,6 +158,7 @@ public class UriUtilsTests {
}
@Test(expected = IllegalArgumentException.class)
@Deprecated
public void encodeHttpUrlMail() throws UnsupportedEncodingException {
UriUtils.encodeHttpUrl("mailto:java-net@java.sun.com", ENC);
}