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:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -16,16 +16,20 @@
|
||||
|
||||
package org.springframework.jdbc.config;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.beans.PropertyValue;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -34,9 +38,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean;
|
||||
import org.springframework.jdbc.datasource.init.DataSourceInitializer;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Juergen Hoeller
|
||||
@@ -123,7 +124,8 @@ public class JdbcNamespaceIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testMultipleDataSourcesHaveDifferentDatabaseNames() throws Exception {
|
||||
DefaultListableBeanFactory factory = new XmlBeanFactory(new ClassPathResource(
|
||||
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(new ClassPathResource(
|
||||
"org/springframework/jdbc/config/jdbc-config-multiple-datasources.xml"));
|
||||
assertBeanPropertyValueOf("databaseName", "firstDataSource", factory);
|
||||
assertBeanPropertyValueOf("databaseName", "secondDataSource", factory);
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.jdbc.core;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.isA;
|
||||
import static org.hamcrest.Matchers.sameInstance;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
* @author Juergen Hoeller
|
||||
* @author Thomas Risberg
|
||||
*/
|
||||
@Deprecated
|
||||
public class SimpleJdbcTemplateTests {
|
||||
|
||||
private static final String SQL = "sql";
|
||||
|
||||
@@ -36,7 +36,9 @@ import javax.sql.DataSource;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jdbc.Customer;
|
||||
import org.springframework.jdbc.datasource.TestDataSourceWrapper;
|
||||
@@ -59,7 +61,8 @@ public class GenericSqlQueryTests {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.beanFactory = new XmlBeanFactory(
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(
|
||||
new ClassPathResource("org/springframework/jdbc/object/GenericSqlQueryTests-context.xml"));
|
||||
DataSource dataSource = mock(DataSource.class);
|
||||
this.connection = mock(Connection.class);
|
||||
|
||||
@@ -31,8 +31,8 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.TestDataSourceWrapper;
|
||||
@@ -46,7 +46,8 @@ public class GenericStoredProcedureTests {
|
||||
|
||||
@Test
|
||||
public void testAddInvoices() throws Exception {
|
||||
BeanFactory bf = new XmlBeanFactory(
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
new ClassPathResource("org/springframework/jdbc/object/GenericStoredProcedureTests-context.xml"));
|
||||
Connection connection = mock(Connection.class);
|
||||
DataSource dataSource = mock(DataSource.class);
|
||||
|
||||
Reference in New Issue
Block a user