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:
@@ -19,7 +19,6 @@ package org.springframework.web.context;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
@@ -87,7 +86,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
|
||||
*/
|
||||
public void testLifecycleCallbacks() {
|
||||
LifecycleBean lb = (LifecycleBean) getBeanFactory().getBean("lifecycle");
|
||||
Assert.assertEquals("lifecycle", lb.getBeanName());
|
||||
assertEquals("lifecycle", lb.getBeanName());
|
||||
// The dummy business method will throw an exception if the
|
||||
// necessary callbacks weren't invoked in the right order.
|
||||
lb.businessMethod();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.springframework.web.context;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.springframework.beans.TestBean;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
@@ -31,24 +29,24 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
|
||||
|
||||
protected final void assertCount(int count) {
|
||||
String[] defnames = getListableBeanFactory().getBeanDefinitionNames();
|
||||
Assert.assertTrue("We should have " + count + " beans, not " + defnames.length, defnames.length == count);
|
||||
assertTrue("We should have " + count + " beans, not " + defnames.length, defnames.length == count);
|
||||
}
|
||||
|
||||
public void assertTestBeanCount(int count) {
|
||||
String[] defNames = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, false);
|
||||
Assert.assertTrue("We should have " + count + " beans for class org.springframework.beans.TestBean, not " +
|
||||
assertTrue("We should have " + count + " beans for class org.springframework.beans.TestBean, not " +
|
||||
defNames.length, defNames.length == count);
|
||||
|
||||
int countIncludingFactoryBeans = count + 2;
|
||||
String[] names = getListableBeanFactory().getBeanNamesForType(TestBean.class, true, true);
|
||||
Assert.assertTrue("We should have " + countIncludingFactoryBeans +
|
||||
assertTrue("We should have " + countIncludingFactoryBeans +
|
||||
" beans for class org.springframework.beans.TestBean, not " + names.length,
|
||||
names.length == countIncludingFactoryBeans);
|
||||
}
|
||||
|
||||
public void testGetDefinitionsForNoSuchClass() {
|
||||
String[] defnames = getListableBeanFactory().getBeanNamesForType(String.class);
|
||||
Assert.assertTrue("No string definitions", defnames.length == 0);
|
||||
assertTrue("No string definitions", defnames.length == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,18 +54,18 @@ public abstract class AbstractListableBeanFactoryTests extends AbstractBeanFacto
|
||||
* what type factories may return, and it may even change over time.)
|
||||
*/
|
||||
public void testGetCountForFactoryClass() {
|
||||
Assert.assertTrue("Should have 2 factories, not " +
|
||||
assertTrue("Should have 2 factories, not " +
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length,
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2);
|
||||
|
||||
Assert.assertTrue("Should have 2 factories, not " +
|
||||
assertTrue("Should have 2 factories, not " +
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length,
|
||||
getListableBeanFactory().getBeanNamesForType(FactoryBean.class).length == 2);
|
||||
}
|
||||
|
||||
public void testContainsBeanDefinition() {
|
||||
Assert.assertTrue(getListableBeanFactory().containsBeanDefinition("rod"));
|
||||
Assert.assertTrue(getListableBeanFactory().containsBeanDefinition("roderick"));
|
||||
assertTrue(getListableBeanFactory().containsBeanDefinition("rod"));
|
||||
assertTrue(getListableBeanFactory().containsBeanDefinition("roderick"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
@@ -38,6 +41,7 @@ import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.support.ManagedMap;
|
||||
import org.springframework.beans.factory.support.ManagedSet;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.mock.web.test.MockServletContext;
|
||||
|
||||
@@ -51,6 +55,7 @@ import org.springframework.mock.web.test.MockServletContext;
|
||||
public class ServletContextSupportTests {
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void testServletContextFactoryBean() {
|
||||
MockServletContext sc = new MockServletContext();
|
||||
|
||||
@@ -155,6 +160,7 @@ public class ServletContextSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void testServletContextPropertyPlaceholderConfigurer() {
|
||||
MockServletContext sc = new MockServletContext();
|
||||
sc.addInitParameter("key4", "mykey4");
|
||||
@@ -168,7 +174,7 @@ public class ServletContextSupportTests {
|
||||
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
|
||||
wac.registerSingleton("tb1", TestBean.class, pvs);
|
||||
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, null);
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
|
||||
|
||||
pvs = new MutablePropertyValues();
|
||||
@@ -185,6 +191,7 @@ public class ServletContextSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void testServletContextPropertyPlaceholderConfigurerWithLocalOverriding() {
|
||||
MockServletContext sc = new MockServletContext();
|
||||
sc.addInitParameter("key4", "mykey4");
|
||||
@@ -198,7 +205,7 @@ public class ServletContextSupportTests {
|
||||
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
|
||||
wac.registerSingleton("tb1", TestBean.class, pvs);
|
||||
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, null);
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
|
||||
|
||||
pvs = new MutablePropertyValues();
|
||||
@@ -215,6 +222,7 @@ public class ServletContextSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void testServletContextPropertyPlaceholderConfigurerWithContextOverride() {
|
||||
MockServletContext sc = new MockServletContext();
|
||||
sc.addInitParameter("key4", "mykey4");
|
||||
@@ -228,7 +236,7 @@ public class ServletContextSupportTests {
|
||||
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
|
||||
wac.registerSingleton("tb1", TestBean.class, pvs);
|
||||
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, null);
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
|
||||
|
||||
pvs = new MutablePropertyValues();
|
||||
@@ -246,6 +254,7 @@ public class ServletContextSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void testServletContextPropertyPlaceholderConfigurerWithContextOverrideAndAttributes() {
|
||||
MockServletContext sc = new MockServletContext();
|
||||
sc.addInitParameter("key4", "mykey4");
|
||||
@@ -260,7 +269,7 @@ public class ServletContextSupportTests {
|
||||
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
|
||||
wac.registerSingleton("tb1", TestBean.class, pvs);
|
||||
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, null);
|
||||
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
|
||||
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
|
||||
|
||||
pvs = new MutablePropertyValues();
|
||||
@@ -279,6 +288,7 @@ public class ServletContextSupportTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void testServletContextPropertyPlaceholderConfigurerWithAttributes() {
|
||||
MockServletContext sc = new MockServletContext();
|
||||
sc.addInitParameter("key4", "mykey4");
|
||||
@@ -312,7 +322,9 @@ public class ServletContextSupportTests {
|
||||
someMap.put("key2", "${age}name");
|
||||
MutablePropertyValues innerPvs = new MutablePropertyValues();
|
||||
innerPvs.add("touchy", "${os.name}");
|
||||
someMap.put("key3", new RootBeanDefinition(TestBean.class, innerPvs));
|
||||
RootBeanDefinition innerBd = new RootBeanDefinition(TestBean.class);
|
||||
innerBd.setPropertyValues(innerPvs);
|
||||
someMap.put("key3", innerBd);
|
||||
MutablePropertyValues innerPvs2 = new MutablePropertyValues(innerPvs);
|
||||
someMap.put("${key4}", new BeanDefinitionHolder(new ChildBeanDefinition("tb1", innerPvs2), "child"));
|
||||
pvs.add("someMap", someMap);
|
||||
|
||||
@@ -32,7 +32,6 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
@@ -144,7 +143,7 @@ public class DispatcherServletTests extends TestCase {
|
||||
ComplexWebApplicationContext.TestApplicationListener listener =
|
||||
(ComplexWebApplicationContext.TestApplicationListener) complexDispatcherServlet
|
||||
.getWebApplicationContext().getBean("testListener");
|
||||
Assert.assertEquals(1, listener.counter);
|
||||
assertEquals(1, listener.counter);
|
||||
}
|
||||
|
||||
public void testPublishEventsOff() throws Exception {
|
||||
@@ -155,7 +154,7 @@ public class DispatcherServletTests extends TestCase {
|
||||
ComplexWebApplicationContext.TestApplicationListener listener =
|
||||
(ComplexWebApplicationContext.TestApplicationListener) complexDispatcherServlet
|
||||
.getWebApplicationContext().getBean("testListener");
|
||||
Assert.assertEquals(0, listener.counter);
|
||||
assertEquals(0, listener.counter);
|
||||
}
|
||||
|
||||
public void testFormRequest() throws Exception {
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@Deprecated
|
||||
public class FormControllerTests extends TestCase {
|
||||
|
||||
public void testReferenceDataOnForm() throws Exception {
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
* @author Juergen Hoeller
|
||||
* @since 29.04.2003
|
||||
*/
|
||||
@Deprecated
|
||||
public class WizardFormControllerTests extends TestCase {
|
||||
|
||||
public void testNoDirtyPageChange() throws Exception {
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
* @author Arjen Poutsma
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@Deprecated
|
||||
public class AnnotationMethodHandlerExceptionResolverTests {
|
||||
|
||||
private AnnotationMethodHandlerExceptionResolver exceptionResolver;
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Deprecated
|
||||
public class RequestSpecificMappingInfoComparatorTests {
|
||||
|
||||
private AnnotationMethodHandlerAdapter.RequestSpecificMappingInfoComparator comparator;
|
||||
|
||||
@@ -30,9 +30,11 @@ import java.security.Principal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -1517,7 +1519,7 @@ public class ServletAnnotationControllerTests {
|
||||
request.setCookies(new Cookie("date", "2008-11-18"));
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
servlet.service(request, response);
|
||||
assertEquals("test-108", response.getContentAsString());
|
||||
assertEquals("test-2008", response.getContentAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -3052,8 +3054,10 @@ public class ServletAnnotationControllerTests {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public void handle(@CookieValue("date") Date date, Writer writer) throws IOException {
|
||||
assertEquals("Invalid path variable value", new Date(108, 10, 18), date);
|
||||
writer.write("test-" + date.getYear());
|
||||
assertEquals("Invalid path variable value", new GregorianCalendar(2008, 10, 18).getTime(), date);
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.setTime(date);
|
||||
writer.write("test-" + c.get(Calendar.YEAR));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,10 @@ import org.junit.Test;
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
/** @author Arjen Poutsma */
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@Deprecated
|
||||
public class ServletAnnotationMappingUtilsTests {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
|
||||
public class Spr7766Tests {
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void test() throws Exception {
|
||||
AnnotationMethodHandlerAdapter adapter = new AnnotationMethodHandlerAdapter();
|
||||
ConfigurableWebBindingInitializer binder = new ConfigurableWebBindingInitializer();
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
|
||||
|
||||
@Deprecated
|
||||
public class Spr7839Tests {
|
||||
|
||||
AnnotationMethodHandlerAdapter adapter = new AnnotationMethodHandlerAdapter();
|
||||
|
||||
@@ -20,6 +20,8 @@ import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -486,7 +488,7 @@ public class UriTemplateServletAnnotationControllerTests {
|
||||
public void handle(@PathVariable("hotel") String hotel, @PathVariable Date date, Writer writer)
|
||||
throws IOException {
|
||||
assertEquals("Invalid path variable value", "42", hotel);
|
||||
assertEquals("Invalid path variable value", new Date(108, 10, 18), date);
|
||||
assertEquals("Invalid path variable value", new GregorianCalendar(2008, 10, 18).getTime(), date);
|
||||
writer.write("test-" + hotel);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006 the original author or authors.
|
||||
* Copyright 2002-2012 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,6 +21,7 @@ import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
@Deprecated
|
||||
public class BuyForm extends SimpleFormController {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.web.servlet.mvc.method.annotation;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ import org.apache.velocity.Template;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.exception.MethodInvocationException;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.internal.matchers.TypeSafeMatcher;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.beans.TestBean;
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
* @author Juergen Hoeller
|
||||
* @since 11.03.2005
|
||||
*/
|
||||
@Deprecated
|
||||
public class TestXsltViewTests extends TestCase {
|
||||
|
||||
private TestXsltView view;
|
||||
|
||||
Reference in New Issue
Block a user