mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Early removal of 5.x-deprecated code
Closes gh-27686
This commit is contained in:
+1
-15
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.core.annotation;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Repeatable;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -36,7 +35,6 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets;
|
||||
import org.springframework.core.annotation.AnnotationTypeMapping.MirrorSets.MirrorSet;
|
||||
import org.springframework.lang.UsesSunMisc;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
@@ -60,12 +58,6 @@ class AnnotationTypeMappingsTests {
|
||||
AnnotationTypeMapping::getAnnotationType).containsExactly(SimpleAnnotation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationWhenHasSpringAnnotationReturnsFilteredMappings() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithSpringLangAnnotation.class);
|
||||
assertThat(mappings.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenMetaAnnotationsReturnsMappings() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MetaAnnotated.class);
|
||||
@@ -526,12 +518,6 @@ class AnnotationTypeMappingsTests {
|
||||
@interface SimpleAnnotation {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
@UsesSunMisc
|
||||
@interface WithSpringLangAnnotation {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface AA {
|
||||
}
|
||||
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.type.classreading;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.asm.ClassReader;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.type.AbstractAnnotationMetadataTests;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* Tests for {@link AnnotationMetadataReadingVisitor}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class AnnotationMetadataReadingVisitorTests extends AbstractAnnotationMetadataTests {
|
||||
|
||||
@Override
|
||||
protected AnnotationMetadata get(Class<?> source) {
|
||||
try {
|
||||
ClassLoader classLoader = source.getClassLoader();
|
||||
String className = source.getName();
|
||||
String resourcePath = ResourceLoader.CLASSPATH_URL_PREFIX
|
||||
+ ClassUtils.convertClassNameToResourcePath(className)
|
||||
+ ClassUtils.CLASS_FILE_SUFFIX;
|
||||
Resource resource = new DefaultResourceLoader().getResource(resourcePath);
|
||||
try (InputStream inputStream = new BufferedInputStream(
|
||||
resource.getInputStream())) {
|
||||
ClassReader classReader = new ClassReader(inputStream);
|
||||
AnnotationMetadataReadingVisitor metadata = new AnnotationMetadataReadingVisitor(
|
||||
classLoader);
|
||||
classReader.accept(metadata, ClassReader.SKIP_DEBUG);
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("equals() not implemented in deprecated AnnotationMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyEquals() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("hashCode() not implemented in deprecated AnnotationMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyHashCode() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("toString() not implemented in deprecated AnnotationMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyToString() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test
|
||||
public void getAnnotationsReturnsDirectAnnotations() {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class)
|
||||
.isThrownBy(super::getAnnotationsReturnsDirectAnnotations);
|
||||
}
|
||||
|
||||
}
|
||||
-92
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2021 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.type.classreading;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.asm.ClassReader;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.type.AbstractMethodMetadataTests;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* Tests for {@link MethodMetadataReadingVisitor}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class MethodMetadataReadingVisitorTests extends AbstractMethodMetadataTests {
|
||||
|
||||
@Override
|
||||
protected AnnotationMetadata get(Class<?> source) {
|
||||
try {
|
||||
ClassLoader classLoader = source.getClassLoader();
|
||||
String className = source.getName();
|
||||
String resourcePath = ResourceLoader.CLASSPATH_URL_PREFIX
|
||||
+ ClassUtils.convertClassNameToResourcePath(className)
|
||||
+ ClassUtils.CLASS_FILE_SUFFIX;
|
||||
Resource resource = new DefaultResourceLoader().getResource(resourcePath);
|
||||
try (InputStream inputStream = new BufferedInputStream(
|
||||
resource.getInputStream())) {
|
||||
ClassReader classReader = new ClassReader(inputStream);
|
||||
AnnotationMetadataReadingVisitor metadata = new AnnotationMetadataReadingVisitor(
|
||||
classLoader);
|
||||
classReader.accept(metadata, ClassReader.SKIP_DEBUG);
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("equals() not implemented in deprecated MethodMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyEquals() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("hashCode() not implemented in deprecated MethodMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyHashCode() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("toString() not implemented in deprecated MethodMetadataReadingVisitor")
|
||||
@Override
|
||||
public void verifyToString() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Override
|
||||
public void getAnnotationsReturnsDirectAnnotations() {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(
|
||||
super::getAnnotationsReturnsDirectAnnotations);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -233,44 +233,6 @@ class ObjectUtilsTests {
|
||||
assertThat(ObjectUtils.nullSafeEquals(new int[] {1, 2, 3}, new int[] {1, 2, 3})).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void hashCodeWithBooleanFalse() {
|
||||
int expected = Boolean.FALSE.hashCode();
|
||||
assertThat(ObjectUtils.hashCode(false)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void hashCodeWithBooleanTrue() {
|
||||
int expected = Boolean.TRUE.hashCode();
|
||||
assertThat(ObjectUtils.hashCode(true)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void hashCodeWithDouble() {
|
||||
double dbl = 9830.43;
|
||||
int expected = Double.valueOf(dbl).hashCode();
|
||||
assertThat(ObjectUtils.hashCode(dbl)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void hashCodeWithFloat() {
|
||||
float flt = 34.8f;
|
||||
int expected = (Float.valueOf(flt)).hashCode();
|
||||
assertThat(ObjectUtils.hashCode(flt)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void hashCodeWithLong() {
|
||||
long lng = 883L;
|
||||
int expected = (Long.valueOf(lng)).hashCode();
|
||||
assertThat(ObjectUtils.hashCode(lng)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
void identityToString() {
|
||||
Object obj = new Object();
|
||||
|
||||
@@ -440,21 +440,6 @@ class StringUtilsTests {
|
||||
assertThat(StringUtils.concatenateStringArrays(null, null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void mergeStringArrays() {
|
||||
String[] input1 = new String[] {"myString2"};
|
||||
String[] input2 = new String[] {"myString1", "myString2"};
|
||||
String[] result = StringUtils.mergeStringArrays(input1, input2);
|
||||
assertThat(result.length).isEqualTo(2);
|
||||
assertThat(result[0]).isEqualTo("myString2");
|
||||
assertThat(result[1]).isEqualTo("myString1");
|
||||
|
||||
assertThat(StringUtils.mergeStringArrays(input1, null)).isEqualTo(input1);
|
||||
assertThat(StringUtils.mergeStringArrays(null, input2)).isEqualTo(input2);
|
||||
assertThat(StringUtils.mergeStringArrays(null, null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void sortStringArray() {
|
||||
String[] input = new String[] {"myString2"};
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.util.comparator;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
|
||||
/**
|
||||
* Test for {@link CompoundComparator}.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Chris Beams
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Deprecated
|
||||
class CompoundComparatorTests {
|
||||
|
||||
@Test
|
||||
void shouldNeedAtLeastOneComparator() {
|
||||
Comparator<String> c = new CompoundComparator<>();
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
c.compare("foo", "bar"));
|
||||
}
|
||||
|
||||
}
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.util.comparator;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
|
||||
/**
|
||||
* Tests for {@link InvertibleComparator}.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @author Chris Beams
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Deprecated
|
||||
class InvertibleComparatorTests {
|
||||
|
||||
private final Comparator<Integer> comparator = new ComparableComparator<>();
|
||||
|
||||
|
||||
@Test
|
||||
void shouldNeedComparator() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new InvertibleComparator<>(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNeedComparatorWithAscending() throws Exception {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new InvertibleComparator<>(null, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldDefaultToAscending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator);
|
||||
assertThat(invertibleComparator.isAscending()).isTrue();
|
||||
assertThat(invertibleComparator.compare(1, 2)).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldInvert() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator);
|
||||
assertThat(invertibleComparator.isAscending()).isTrue();
|
||||
assertThat(invertibleComparator.compare(1, 2)).isEqualTo(-1);
|
||||
invertibleComparator.invertOrder();
|
||||
assertThat(invertibleComparator.isAscending()).isFalse();
|
||||
assertThat(invertibleComparator.compare(1, 2)).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCompareAscending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator, true);
|
||||
assertThat(invertibleComparator.compare(1, 2)).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldCompareDescending() throws Exception {
|
||||
InvertibleComparator<Integer> invertibleComparator = new InvertibleComparator<>(comparator, false);
|
||||
assertThat(invertibleComparator.compare(1, 2)).isEqualTo(1);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user