Browse Source

Spring cleaning: avoid deprecation warnings

pull/32412/head
Sam Brannen 2 years ago
parent
commit
b0d08fe2d4
  1. 5
      spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java
  2. 5
      spring-beans/src/test/java/org/springframework/beans/factory/aot/BeanDefinitionMethodGeneratorFactoryTests.java
  3. 5
      spring-beans/src/test/java/org/springframework/beans/factory/aot/BeanInstanceSupplierTests.java
  4. 3
      spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomCollectionEditorTests.java
  5. 1
      spring-jdbc/src/test/java/org/springframework/jdbc/core/support/LobSupportTests.java
  6. 1
      spring-jdbc/src/test/java/org/springframework/jdbc/core/support/SqlLobValueTests.java
  7. 1
      spring-jdbc/src/test/java/org/springframework/jdbc/support/DefaultLobHandlerTests.java
  8. 7
      spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java

5
spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java

@ -42,6 +42,7 @@ import org.springframework.util.MultiValueMap; @@ -42,6 +42,7 @@ import org.springframework.util.MultiValueMap;
import static java.util.Map.entry;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
/**
* @author Juergen Hoeller
@ -201,7 +202,7 @@ class BeanWrapperGenericsTests { @@ -201,7 +202,7 @@ class BeanWrapperGenericsTests {
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", 5);
assertThat(bw.getPropertyValue("listOfLists[0][0]")).isEqualTo(5);
assertThat(gb.getListOfLists()).singleElement().asList().containsExactly(5);
assertThat(gb.getListOfLists()).singleElement().asInstanceOf(LIST).containsExactly(5);
}
@Test
@ -213,7 +214,7 @@ class BeanWrapperGenericsTests { @@ -213,7 +214,7 @@ class BeanWrapperGenericsTests {
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", "5");
assertThat(bw.getPropertyValue("listOfLists[0][0]")).isEqualTo(5);
assertThat(gb.getListOfLists()).singleElement().asList().containsExactly(5);
assertThat(gb.getListOfLists()).singleElement().asInstanceOf(LIST).containsExactly(5);
}
@Test

5
spring-beans/src/test/java/org/springframework/beans/factory/aot/BeanDefinitionMethodGeneratorFactoryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -29,6 +29,7 @@ import org.springframework.lang.Nullable; @@ -29,6 +29,7 @@ import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
import static org.mockito.Mockito.mock;
/**
@ -123,7 +124,7 @@ class BeanDefinitionMethodGeneratorFactoryTests { @@ -123,7 +124,7 @@ class BeanDefinitionMethodGeneratorFactoryTests {
AotServices.factoriesAndBeans(springFactoriesLoader, beanFactory));
BeanDefinitionMethodGenerator methodGenerator = methodGeneratorFactory
.getBeanDefinitionMethodGenerator(registeredBean);
assertThat(methodGenerator).extracting("aotContributions").asList()
assertThat(methodGenerator).extracting("aotContributions").asInstanceOf(LIST)
.containsExactly(beanContribution, loaderContribution);
}

5
spring-beans/src/test/java/org/springframework/beans/factory/aot/BeanInstanceSupplierTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -64,6 +64,7 @@ import static org.assertj.core.api.Assertions.assertThat; @@ -64,6 +64,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.entry;
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
import static org.mockito.Mockito.mock;
/**
@ -375,7 +376,7 @@ class BeanInstanceSupplierTests { @@ -375,7 +376,7 @@ class BeanInstanceSupplierTests {
RegisteredBean registerBean = source.registerBean(this.beanFactory);
AutowiredArguments arguments = source.getResolver().resolveArguments(registerBean);
assertThat(arguments.toArray()).hasSize(1);
assertThat(arguments.getObject(0)).isInstanceOf(List.class).asList()
assertThat(arguments.getObject(0)).isInstanceOf(List.class).asInstanceOf(LIST)
.containsExactly("1", "2");
}

3
spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomCollectionEditorTests.java

@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test; @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
/**
* Tests for {@link CustomCollectionEditor}.
@ -60,7 +61,7 @@ class CustomCollectionEditorTests { @@ -60,7 +61,7 @@ class CustomCollectionEditorTests {
Object value = editor.getValue();
assertThat(value).isNotNull();
assertThat(value).isInstanceOf(ArrayList.class);
assertThat(value).asList().containsExactly(0, 1, 2);
assertThat(value).asInstanceOf(LIST).containsExactly(0, 1, 2);
}
@Test

1
spring-jdbc/src/test/java/org/springframework/jdbc/core/support/LobSupportTests.java

@ -37,6 +37,7 @@ import static org.mockito.Mockito.verify; @@ -37,6 +37,7 @@ import static org.mockito.Mockito.verify;
/**
* @author Alef Arendsen
*/
@SuppressWarnings("deprecation")
class LobSupportTests {
@Test

1
spring-jdbc/src/test/java/org/springframework/jdbc/core/support/SqlLobValueTests.java

@ -60,6 +60,7 @@ import static org.mockito.Mockito.verify; @@ -60,6 +60,7 @@ import static org.mockito.Mockito.verify;
*/
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
@SuppressWarnings("deprecation")
class SqlLobValueTests {
@Mock

1
spring-jdbc/src/test/java/org/springframework/jdbc/support/DefaultLobHandlerTests.java

@ -37,6 +37,7 @@ import static org.mockito.Mockito.verify; @@ -37,6 +37,7 @@ import static org.mockito.Mockito.verify;
* @author Juergen Hoeller
* @since 17.12.2003
*/
@SuppressWarnings("deprecation")
class DefaultLobHandlerTests {
private ResultSet rs = mock();

7
spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -36,7 +36,6 @@ import org.hibernate.dialect.Informix10Dialect; @@ -36,7 +36,6 @@ import org.hibernate.dialect.Informix10Dialect;
import org.hibernate.dialect.MySQL57Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle12cDialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.PostgreSQL95Dialect;
import org.hibernate.dialect.SQLServer2012Dialect;
import org.hibernate.dialect.SQLServerDialect;
@ -177,7 +176,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter { @@ -177,7 +176,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
* @param database the target database
* @return the Hibernate database dialect class, or {@code null} if none found
*/
@SuppressWarnings("deprecation") // for DerbyDialect and PostgreSQLDialect on Hibernate 6.2
@SuppressWarnings("deprecation") // for OracleDialect on Hibernate 5.6 and DerbyDialect/PostgreSQLDialect on Hibernate 6.2
@Nullable
protected Class<?> determineDatabaseDialectClass(Database database) {
if (oldDialectsPresent) { // Hibernate <6.2
@ -204,7 +203,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter { @@ -204,7 +203,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
case HANA -> HANAColumnStoreDialect.class;
case HSQL -> HSQLDialect.class;
case MYSQL -> MySQLDialect.class;
case ORACLE -> OracleDialect.class;
case ORACLE -> org.hibernate.dialect.OracleDialect.class;
case POSTGRESQL -> org.hibernate.dialect.PostgreSQLDialect.class;
case SQL_SERVER -> SQLServerDialect.class;
case SYBASE -> SybaseDialect.class;

Loading…
Cancel
Save