Browse Source

Clean up warnings and dead code in spring-core module

pull/999/merge
Sam Brannen 7 years ago
parent
commit
42b4f6e1ff
  1. 1
      spring-core/src/main/java/org/springframework/core/codec/ResourceEncoder.java
  2. 3
      spring-core/src/main/java/org/springframework/core/codec/ResourceRegionEncoder.java
  3. 4
      spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java
  4. 78
      spring-core/src/test/java/org/springframework/core/ConstantsTests.java
  5. 7
      spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java
  6. 10
      spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java
  7. 4
      spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java
  8. 72
      spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java
  9. 6
      spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java
  10. 16
      spring-core/src/test/java/org/springframework/core/convert/support/ReactiveAdapterRegistryTests.java
  11. 2
      spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java
  12. 14
      spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java
  13. 72
      spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java
  14. 4
      spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java
  15. 4
      spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java
  16. 2
      spring-core/src/test/java/org/springframework/util/StringUtilsTests.java
  17. 4
      spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java
  18. 6
      spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java

1
spring-core/src/main/java/org/springframework/core/codec/ResourceEncoder.java

@ -18,7 +18,6 @@ package org.springframework.core.codec; @@ -18,7 +18,6 @@ package org.springframework.core.codec;
import java.io.IOException;
import java.util.Map;
import java.util.OptionalLong;
import reactor.core.publisher.Flux;

3
spring-core/src/main/java/org/springframework/core/codec/ResourceRegionEncoder.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -71,7 +71,6 @@ public class ResourceRegionEncoder extends AbstractEncoder<ResourceRegion> { @@ -71,7 +71,6 @@ public class ResourceRegionEncoder extends AbstractEncoder<ResourceRegion> {
}
@Override
@SuppressWarnings("unchecked")
public Flux<DataBuffer> encode(Publisher<? extends ResourceRegion> inputStream,
DataBufferFactory bufferFactory, ResolvableType elementType, @Nullable MimeType mimeType,
@Nullable Map<String, Object> hints) {

4
spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java

@ -1297,13 +1297,9 @@ public class BridgeMethodResolverTests { @@ -1297,13 +1297,9 @@ public class BridgeMethodResolverTests {
//-------------------
public static abstract class BaseEntity {
private String id;
}
public static class FooEntity extends BaseEntity {
private String name;
}
public static class BaseClass<T> {

78
spring-core/src/test/java/org/springframework/core/ConstantsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -82,23 +82,23 @@ public class ConstantsTests { @@ -82,23 +82,23 @@ public class ConstantsTests {
Set<?> values = c.getValues("");
assertEquals(7, values.size());
assertTrue(values.contains(new Integer(0)));
assertTrue(values.contains(new Integer(66)));
assertTrue(values.contains(Integer.valueOf(0)));
assertTrue(values.contains(Integer.valueOf(66)));
assertTrue(values.contains(""));
values = c.getValues("D");
assertEquals(1, values.size());
assertTrue(values.contains(new Integer(0)));
assertTrue(values.contains(Integer.valueOf(0)));
values = c.getValues("prefix");
assertEquals(2, values.size());
assertTrue(values.contains(new Integer(1)));
assertTrue(values.contains(new Integer(2)));
assertTrue(values.contains(Integer.valueOf(1)));
assertTrue(values.contains(Integer.valueOf(2)));
values = c.getValuesForProperty("myProperty");
assertEquals(2, values.size());
assertTrue(values.contains(new Integer(1)));
assertTrue(values.contains(new Integer(2)));
assertTrue(values.contains(Integer.valueOf(1)));
assertTrue(values.contains(Integer.valueOf(2)));
}
@Test
@ -110,23 +110,23 @@ public class ConstantsTests { @@ -110,23 +110,23 @@ public class ConstantsTests {
Set<?> values = c.getValues("");
assertEquals(7, values.size());
assertTrue(values.contains(new Integer(0)));
assertTrue(values.contains(new Integer(66)));
assertTrue(values.contains(Integer.valueOf(0)));
assertTrue(values.contains(Integer.valueOf(66)));
assertTrue(values.contains(""));
values = c.getValues("D");
assertEquals(1, values.size());
assertTrue(values.contains(new Integer(0)));
assertTrue(values.contains(Integer.valueOf(0)));
values = c.getValues("prefix");
assertEquals(2, values.size());
assertTrue(values.contains(new Integer(1)));
assertTrue(values.contains(new Integer(2)));
assertTrue(values.contains(Integer.valueOf(1)));
assertTrue(values.contains(Integer.valueOf(2)));
values = c.getValuesForProperty("myProperty");
assertEquals(2, values.size());
assertTrue(values.contains(new Integer(1)));
assertTrue(values.contains(new Integer(2)));
assertTrue(values.contains(Integer.valueOf(1)));
assertTrue(values.contains(Integer.valueOf(2)));
}
finally {
Locale.setDefault(oldLocale);
@ -144,24 +144,24 @@ public class ConstantsTests { @@ -144,24 +144,24 @@ public class ConstantsTests {
Set<?> values = c.getValuesForSuffix("_PROPERTY");
assertEquals(2, values.size());
assertTrue(values.contains(new Integer(3)));
assertTrue(values.contains(new Integer(4)));
assertTrue(values.contains(Integer.valueOf(3)));
assertTrue(values.contains(Integer.valueOf(4)));
}
@Test
public void toCode() {
Constants c = new Constants(A.class);
assertEquals("DOG", c.toCode(new Integer(0), ""));
assertEquals("DOG", c.toCode(new Integer(0), "D"));
assertEquals("DOG", c.toCode(new Integer(0), "DO"));
assertEquals("DOG", c.toCode(new Integer(0), "DoG"));
assertEquals("DOG", c.toCode(new Integer(0), null));
assertEquals("CAT", c.toCode(new Integer(66), ""));
assertEquals("CAT", c.toCode(new Integer(66), "C"));
assertEquals("CAT", c.toCode(new Integer(66), "ca"));
assertEquals("CAT", c.toCode(new Integer(66), "cAt"));
assertEquals("CAT", c.toCode(new Integer(66), null));
assertEquals("DOG", c.toCode(Integer.valueOf(0), ""));
assertEquals("DOG", c.toCode(Integer.valueOf(0), "D"));
assertEquals("DOG", c.toCode(Integer.valueOf(0), "DO"));
assertEquals("DOG", c.toCode(Integer.valueOf(0), "DoG"));
assertEquals("DOG", c.toCode(Integer.valueOf(0), null));
assertEquals("CAT", c.toCode(Integer.valueOf(66), ""));
assertEquals("CAT", c.toCode(Integer.valueOf(66), "C"));
assertEquals("CAT", c.toCode(Integer.valueOf(66), "ca"));
assertEquals("CAT", c.toCode(Integer.valueOf(66), "cAt"));
assertEquals("CAT", c.toCode(Integer.valueOf(66), null));
assertEquals("S1", c.toCode("", ""));
assertEquals("S1", c.toCode("", "s"));
assertEquals("S1", c.toCode("", "s1"));
@ -179,8 +179,8 @@ public class ConstantsTests { @@ -179,8 +179,8 @@ public class ConstantsTests {
catch (Constants.ConstantException expected) {
}
assertEquals("MY_PROPERTY_NO", c.toCodeForProperty(new Integer(1), "myProperty"));
assertEquals("MY_PROPERTY_YES", c.toCodeForProperty(new Integer(2), "myProperty"));
assertEquals("MY_PROPERTY_NO", c.toCodeForProperty(Integer.valueOf(1), "myProperty"));
assertEquals("MY_PROPERTY_YES", c.toCodeForProperty(Integer.valueOf(2), "myProperty"));
try {
c.toCodeForProperty("bogus", "bogus");
fail("Should have thrown ConstantException");
@ -188,16 +188,16 @@ public class ConstantsTests { @@ -188,16 +188,16 @@ public class ConstantsTests {
catch (Constants.ConstantException expected) {
}
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), ""));
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "G"));
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "OG"));
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), "DoG"));
assertEquals("DOG", c.toCodeForSuffix(new Integer(0), null));
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), ""));
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "T"));
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "at"));
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), "cAt"));
assertEquals("CAT", c.toCodeForSuffix(new Integer(66), null));
assertEquals("DOG", c.toCodeForSuffix(Integer.valueOf(0), ""));
assertEquals("DOG", c.toCodeForSuffix(Integer.valueOf(0), "G"));
assertEquals("DOG", c.toCodeForSuffix(Integer.valueOf(0), "OG"));
assertEquals("DOG", c.toCodeForSuffix(Integer.valueOf(0), "DoG"));
assertEquals("DOG", c.toCodeForSuffix(Integer.valueOf(0), null));
assertEquals("CAT", c.toCodeForSuffix(Integer.valueOf(66), ""));
assertEquals("CAT", c.toCodeForSuffix(Integer.valueOf(66), "T"));
assertEquals("CAT", c.toCodeForSuffix(Integer.valueOf(66), "at"));
assertEquals("CAT", c.toCodeForSuffix(Integer.valueOf(66), "cAt"));
assertEquals("CAT", c.toCodeForSuffix(Integer.valueOf(66), null));
assertEquals("S1", c.toCodeForSuffix("", ""));
assertEquals("S1", c.toCodeForSuffix("", "1"));
assertEquals("S1", c.toCodeForSuffix("", "s1"));

7
spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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,7 +16,6 @@ @@ -16,7 +16,6 @@
package org.springframework.core.codec;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Collections;
@ -78,4 +77,6 @@ public class DataBufferDecoderTests extends AbstractDataBufferAllocatingTestCase @@ -78,4 +77,6 @@ public class DataBufferDecoderTests extends AbstractDataBufferAllocatingTestCase
assertEquals("foobar", DataBufferTestUtils.dumpString(outputBuffer, StandardCharsets.UTF_8));
release(outputBuffer);
}}
}
}

10
spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@ -516,7 +516,7 @@ public class TypeDescriptorTests { @@ -516,7 +516,7 @@ public class TypeDescriptorTests {
@Test
public void narrow() {
TypeDescriptor desc = TypeDescriptor.valueOf(Number.class);
Integer value = new Integer(3);
Integer value = Integer.valueOf(3);
desc = desc.narrow(value);
assertEquals(Integer.class, desc.getType());
}
@ -524,7 +524,7 @@ public class TypeDescriptorTests { @@ -524,7 +524,7 @@ public class TypeDescriptorTests {
@Test
public void elementType() {
TypeDescriptor desc = TypeDescriptor.valueOf(List.class);
Integer value = new Integer(3);
Integer value = Integer.valueOf(3);
desc = desc.elementTypeDescriptor(value);
assertEquals(Integer.class, desc.getType());
}
@ -542,7 +542,7 @@ public class TypeDescriptorTests { @@ -542,7 +542,7 @@ public class TypeDescriptorTests {
@Test
public void mapKeyType() {
TypeDescriptor desc = TypeDescriptor.valueOf(Map.class);
Integer value = new Integer(3);
Integer value = Integer.valueOf(3);
desc = desc.getMapKeyTypeDescriptor(value);
assertEquals(Integer.class, desc.getType());
}
@ -560,7 +560,7 @@ public class TypeDescriptorTests { @@ -560,7 +560,7 @@ public class TypeDescriptorTests {
@Test
public void mapValueType() {
TypeDescriptor desc = TypeDescriptor.valueOf(Map.class);
Integer value = new Integer(3);
Integer value = Integer.valueOf(3);
desc = desc.getMapValueTypeDescriptor(value);
assertEquals(Integer.class, desc.getType());
}

4
spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@ -122,7 +122,7 @@ public class ConvertingComparatorTests { @@ -122,7 +122,7 @@ public class ConvertingComparatorTests {
@Override
public Integer convert(String source) {
return new Integer(source);
return Integer.valueOf(source);
}
}

72
spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java

@ -156,7 +156,7 @@ public class DefaultConversionServiceTests { @@ -156,7 +156,7 @@ public class DefaultConversionServiceTests {
@Test
public void testStringToInteger() {
assertEquals(Integer.valueOf("1"), conversionService.convert("1", Integer.class));
assertEquals(Integer.valueOf(1), conversionService.convert("1", Integer.class));
}
@Test
@ -166,7 +166,7 @@ public class DefaultConversionServiceTests { @@ -166,7 +166,7 @@ public class DefaultConversionServiceTests {
@Test
public void testStringToLong() {
assertEquals(Long.valueOf("1"), conversionService.convert("1", Long.class));
assertEquals(Long.valueOf(1), conversionService.convert("1", Long.class));
}
@Test
@ -181,7 +181,7 @@ public class DefaultConversionServiceTests { @@ -181,7 +181,7 @@ public class DefaultConversionServiceTests {
@Test
public void testFloatToString() {
assertEquals("1.0", conversionService.convert(new Float("1.0"), String.class));
assertEquals("1.0", conversionService.convert(Float.valueOf("1.0"), String.class));
}
@Test
@ -191,7 +191,7 @@ public class DefaultConversionServiceTests { @@ -191,7 +191,7 @@ public class DefaultConversionServiceTests {
@Test
public void testDoubleToString() {
assertEquals("1.0", conversionService.convert(new Double("1.0"), String.class));
assertEquals("1.0", conversionService.convert(Double.valueOf("1.0"), String.class));
}
@Test
@ -336,7 +336,7 @@ public class DefaultConversionServiceTests { @@ -336,7 +336,7 @@ public class DefaultConversionServiceTests {
@Test
public void testCharacterToNumber() {
assertEquals(new Integer(65), conversionService.convert('A', Integer.class));
assertEquals(Integer.valueOf(65), conversionService.convert('A', Integer.class));
}
// collection conversion
@ -354,9 +354,9 @@ public class DefaultConversionServiceTests { @@ -354,9 +354,9 @@ public class DefaultConversionServiceTests {
@SuppressWarnings("unchecked")
List<Integer> result = (List<Integer>) conversionService.convert(new String[] {"1", "2", "3"}, TypeDescriptor
.valueOf(String[].class), new TypeDescriptor(getClass().getDeclaredField("genericList")));
assertEquals(new Integer("1"), result.get(0));
assertEquals(new Integer("2"), result.get(1));
assertEquals(new Integer("3"), result.get(2));
assertEquals(Integer.valueOf(1), result.get(0));
assertEquals(Integer.valueOf(2), result.get(1));
assertEquals(Integer.valueOf(3), result.get(2));
}
@Test
@ -430,9 +430,9 @@ public class DefaultConversionServiceTests { @@ -430,9 +430,9 @@ public class DefaultConversionServiceTests {
public void convertStringToArrayWithElementConversion() {
Integer[] result = conversionService.convert("1,2,3", Integer[].class);
assertEquals(3, result.length);
assertEquals(new Integer(1), result[0]);
assertEquals(new Integer(2), result[1]);
assertEquals(new Integer(3), result[2]);
assertEquals(Integer.valueOf(1), result[0]);
assertEquals(Integer.valueOf(2), result[1]);
assertEquals(Integer.valueOf(3), result[2]);
}
@Test
@ -461,7 +461,7 @@ public class DefaultConversionServiceTests { @@ -461,7 +461,7 @@ public class DefaultConversionServiceTests {
public void convertArrayToObjectWithElementConversion() {
String[] array = new String[] {"3"};
Integer result = conversionService.convert(array, Integer.class);
assertEquals(new Integer(3), result);
assertEquals(Integer.valueOf(3), result);
}
@Test
@ -482,7 +482,7 @@ public class DefaultConversionServiceTests { @@ -482,7 +482,7 @@ public class DefaultConversionServiceTests {
public void convertObjectToArrayWithElementConversion() {
Integer[] result = conversionService.convert(3L, Integer[].class);
assertEquals(1, result.length);
assertEquals(new Integer(3), result[0]);
assertEquals(Integer.valueOf(3), result[0]);
}
@Test
@ -504,9 +504,9 @@ public class DefaultConversionServiceTests { @@ -504,9 +504,9 @@ public class DefaultConversionServiceTests {
list.add("2");
list.add("3");
Integer[] result = conversionService.convert(list, Integer[].class);
assertEquals(new Integer(1), result[0]);
assertEquals(new Integer(2), result[1]);
assertEquals(new Integer(3), result[2]);
assertEquals(Integer.valueOf(1), result[0]);
assertEquals(Integer.valueOf(2), result[1]);
assertEquals(Integer.valueOf(3), result[2]);
}
@Test
@ -556,14 +556,14 @@ public class DefaultConversionServiceTests { @@ -556,14 +556,14 @@ public class DefaultConversionServiceTests {
public void convertCollectionToObject() {
List<Long> list = Collections.singletonList(3L);
Long result = conversionService.convert(list, Long.class);
assertEquals(new Long(3), result);
assertEquals(Long.valueOf(3), result);
}
@Test
public void convertCollectionToObjectWithElementConversion() {
List<String> list = Collections.singletonList("3");
Integer result = conversionService.convert(list, Integer.class);
assertEquals(new Integer(3), result);
assertEquals(Integer.valueOf(3), result);
}
@Test
@ -604,15 +604,15 @@ public class DefaultConversionServiceTests { @@ -604,15 +604,15 @@ public class DefaultConversionServiceTests {
List<Integer> result = (List<Integer>) conversionService.convert(3L, TypeDescriptor.valueOf(Long.class),
new TypeDescriptor(getClass().getField("genericList")));
assertEquals(1, result.size());
assertEquals(new Integer(3), result.get(0));
assertEquals(Integer.valueOf(3), result.get(0));
}
@Test
public void convertArrayToArray() {
Integer[] result = conversionService.convert(new String[] {"1", "2", "3"}, Integer[].class);
assertEquals(new Integer(1), result[0]);
assertEquals(new Integer(2), result[1]);
assertEquals(new Integer(3), result[2]);
assertEquals(Integer.valueOf(1), result[0]);
assertEquals(Integer.valueOf(2), result[1]);
assertEquals(Integer.valueOf(3), result[2]);
}
@Test
@ -679,9 +679,9 @@ public class DefaultConversionServiceTests { @@ -679,9 +679,9 @@ public class DefaultConversionServiceTests {
@SuppressWarnings("unchecked")
List<Integer> bar = (List<Integer>) conversionService.convert(foo, TypeDescriptor.forObject(foo),
new TypeDescriptor(getClass().getField("genericList")));
assertEquals(new Integer(1), bar.get(0));
assertEquals(new Integer(2), bar.get(1));
assertEquals(new Integer(3), bar.get(2));
assertEquals(Integer.valueOf(1), bar.get(0));
assertEquals(Integer.valueOf(2), bar.get(1));
assertEquals(Integer.valueOf(3), bar.get(2));
}
@Test
@ -717,9 +717,9 @@ public class DefaultConversionServiceTests { @@ -717,9 +717,9 @@ public class DefaultConversionServiceTests {
List<Integer> bar = (List<Integer>) conversionService.convert(values,
TypeDescriptor.forObject(values), new TypeDescriptor(getClass().getField("genericList")));
assertEquals(3, bar.size());
assertEquals(new Integer(1), bar.get(0));
assertEquals(new Integer(2), bar.get(1));
assertEquals(new Integer(3), bar.get(2));
assertEquals(Integer.valueOf(1), bar.get(0));
assertEquals(Integer.valueOf(2), bar.get(1));
assertEquals(Integer.valueOf(3), bar.get(2));
}
@Test
@ -730,8 +730,8 @@ public class DefaultConversionServiceTests { @@ -730,8 +730,8 @@ public class DefaultConversionServiceTests {
@SuppressWarnings("unchecked")
List<Integer> integers = (List<Integer>) conversionService.convert(strings,
TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Integer.class)));
assertEquals(new Integer(3), integers.get(0));
assertEquals(new Integer(9), integers.get(1));
assertEquals(Integer.valueOf(3), integers.get(0));
assertEquals(Integer.valueOf(9), integers.get(1));
}
@Test
@ -764,8 +764,8 @@ public class DefaultConversionServiceTests { @@ -764,8 +764,8 @@ public class DefaultConversionServiceTests {
@SuppressWarnings("unchecked")
Map<Integer, Integer> integers = (Map<Integer, Integer>) conversionService.convert(strings,
TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(Integer.class)));
assertEquals(new Integer(9), integers.get(3));
assertEquals(new Integer(31), integers.get(6));
assertEquals(Integer.valueOf(9), integers.get(3));
assertEquals(Integer.valueOf(31), integers.get(6));
}
@Test
@ -858,13 +858,13 @@ public class DefaultConversionServiceTests { @@ -858,13 +858,13 @@ public class DefaultConversionServiceTests {
@Test(expected = ConverterNotFoundException.class)
public void convertObjectToObjectNoValueOfMethodOrConstructor() {
conversionService.convert(new Long(3), SSN.class);
conversionService.convert(Long.valueOf(3), SSN.class);
}
@Test
public void convertObjectToObjectFinderMethod() {
TestEntity e = conversionService.convert(1L, TestEntity.class);
assertEquals(new Long(1), e.getId());
assertEquals(Long.valueOf(1), e.getId());
}
@Test
@ -877,7 +877,7 @@ public class DefaultConversionServiceTests { @@ -877,7 +877,7 @@ public class DefaultConversionServiceTests {
@Test
public void convertObjectToObjectFinderMethodWithIdConversion() {
TestEntity entity = conversionService.convert("1", TestEntity.class);
assertEquals(new Long(1), entity.getId());
assertEquals(Long.valueOf(1), entity.getId());
}
@Test
@ -964,7 +964,7 @@ public class DefaultConversionServiceTests { @@ -964,7 +964,7 @@ public class DefaultConversionServiceTests {
watch.stop();
watch.start("convert 4,000,000 manually");
for (int i = 0; i < 4000000; i++) {
new Integer(3).toString();
Integer.valueOf(3).toString();
}
watch.stop();
// System.out.println(watch.prettyPrint());

6
spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -104,7 +104,7 @@ public class GenericConversionServiceTests { @@ -104,7 +104,7 @@ public class GenericConversionServiceTests {
@Test
public void convert() {
conversionService.addConverterFactory(new StringToNumberConverterFactory());
assertEquals(new Integer(3), conversionService.convert("3", Integer.class));
assertEquals(Integer.valueOf(3), conversionService.convert("3", Integer.class));
}
@Test
@ -188,7 +188,7 @@ public class GenericConversionServiceTests { @@ -188,7 +188,7 @@ public class GenericConversionServiceTests {
}
});
Integer result = conversionService.convert("3", Integer.class);
assertEquals(new Integer(3), result);
assertEquals(Integer.valueOf(3), result);
}
// SPR-8718

16
spring-core/src/test/java/org/springframework/core/convert/support/ReactiveAdapterRegistryTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -114,7 +114,7 @@ public class ReactiveAdapterRegistryTests { @@ -114,7 +114,7 @@ public class ReactiveAdapterRegistryTests {
Publisher<Integer> source = Flowable.fromArray(1, 2, 3);
Object target = getAdapter(Mono.class).fromPublisher(source);
assertTrue(target instanceof Mono);
assertEquals(new Integer(1), ((Mono<Integer>) target).block(Duration.ofMillis(1000)));
assertEquals(Integer.valueOf(1), ((Mono<Integer>) target).block(Duration.ofMillis(1000)));
}
@Test
@ -122,7 +122,7 @@ public class ReactiveAdapterRegistryTests { @@ -122,7 +122,7 @@ public class ReactiveAdapterRegistryTests {
Publisher<Integer> source = Flowable.fromArray(1, 2, 3);
Object target = getAdapter(CompletableFuture.class).fromPublisher(source);
assertTrue(target instanceof CompletableFuture);
assertEquals(new Integer(1), ((CompletableFuture<Integer>) target).get());
assertEquals(Integer.valueOf(1), ((CompletableFuture<Integer>) target).get());
}
@Test
@ -139,7 +139,7 @@ public class ReactiveAdapterRegistryTests { @@ -139,7 +139,7 @@ public class ReactiveAdapterRegistryTests {
Publisher<Integer> source = Flowable.fromArray(1);
Object target = getAdapter(rx.Single.class).fromPublisher(source);
assertTrue(target instanceof rx.Single);
assertEquals(new Integer(1), ((rx.Single<Integer>) target).toBlocking().value());
assertEquals(Integer.valueOf(1), ((rx.Single<Integer>) target).toBlocking().value());
}
@Test
@ -173,7 +173,7 @@ public class ReactiveAdapterRegistryTests { @@ -173,7 +173,7 @@ public class ReactiveAdapterRegistryTests {
Publisher<Integer> source = Flowable.fromArray(1);
Object target = getAdapter(io.reactivex.Single.class).fromPublisher(source);
assertTrue(target instanceof io.reactivex.Single);
assertEquals(new Integer(1), ((io.reactivex.Single<Integer>) target).blockingGet());
assertEquals(Integer.valueOf(1), ((io.reactivex.Single<Integer>) target).blockingGet());
}
@Test
@ -198,7 +198,7 @@ public class ReactiveAdapterRegistryTests { @@ -198,7 +198,7 @@ public class ReactiveAdapterRegistryTests {
Object source = rx.Single.just(1);
Object target = getAdapter(rx.Single.class).toPublisher(source);
assertTrue("Expected Mono Publisher: " + target.getClass().getName(), target instanceof Mono);
assertEquals(new Integer(1), ((Mono<Integer>) target).block(Duration.ofMillis(1000)));
assertEquals(Integer.valueOf(1), ((Mono<Integer>) target).block(Duration.ofMillis(1000)));
}
@Test
@ -232,7 +232,7 @@ public class ReactiveAdapterRegistryTests { @@ -232,7 +232,7 @@ public class ReactiveAdapterRegistryTests {
Object source = io.reactivex.Single.just(1);
Object target = getAdapter(io.reactivex.Single.class).toPublisher(source);
assertTrue("Expected Mono Publisher: " + target.getClass().getName(), target instanceof Mono);
assertEquals(new Integer(1), ((Mono<Integer>) target).block(Duration.ofMillis(1000)));
assertEquals(Integer.valueOf(1), ((Mono<Integer>) target).block(Duration.ofMillis(1000)));
}
@Test
@ -249,7 +249,7 @@ public class ReactiveAdapterRegistryTests { @@ -249,7 +249,7 @@ public class ReactiveAdapterRegistryTests {
future.complete(1);
Object target = getAdapter(CompletableFuture.class).toPublisher(future);
assertTrue("Expected Mono Publisher: " + target.getClass().getName(), target instanceof Mono);
assertEquals(new Integer(1), ((Mono<Integer>) target).block(Duration.ofMillis(1000)));
assertEquals(Integer.valueOf(1), ((Mono<Integer>) target).block(Duration.ofMillis(1000)));
}

2
spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java

@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
package org.springframework.core.io.buffer;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.ByteBuffer;
@ -100,7 +99,6 @@ public class DataBufferUtilsTests extends AbstractDataBufferAllocatingTestCase { @@ -100,7 +99,6 @@ public class DataBufferUtilsTests extends AbstractDataBufferAllocatingTestCase {
@Test
public void readInputStream() throws Exception {
InputStream is = DataBufferUtilsTests.class.getResourceAsStream("DataBufferUtilsTests.txt");
Flux<DataBuffer> flux = DataBufferUtils.readInputStream(
() -> DataBufferUtilsTests.class.getResourceAsStream("DataBufferUtilsTests.txt"),
this.bufferFactory, 3);

14
spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@ -71,12 +71,12 @@ public class CollectionUtilsTests { @@ -71,12 +71,12 @@ public class CollectionUtilsTests {
public void testMergePrimitiveArrayIntoCollection() {
int[] arr = new int[] {1, 2};
List<Comparable<?>> list = new LinkedList<>();
list.add(new Integer(3));
list.add(Integer.valueOf(3));
CollectionUtils.mergeArrayIntoCollection(arr, list);
assertEquals(new Integer(3), list.get(0));
assertEquals(new Integer(1), list.get(1));
assertEquals(new Integer(2), list.get(2));
assertEquals(Integer.valueOf(3), list.get(0));
assertEquals(Integer.valueOf(1), list.get(1));
assertEquals(Integer.valueOf(2), list.get(2));
}
@Test
@ -85,7 +85,7 @@ public class CollectionUtilsTests { @@ -85,7 +85,7 @@ public class CollectionUtilsTests {
defaults.setProperty("prop1", "value1");
Properties props = new Properties(defaults);
props.setProperty("prop2", "value2");
props.put("prop3", new Integer(3));
props.put("prop3", Integer.valueOf(3));
Map<String, String> map = new HashMap<>();
map.put("prop4", "value4");
@ -93,7 +93,7 @@ public class CollectionUtilsTests { @@ -93,7 +93,7 @@ public class CollectionUtilsTests {
CollectionUtils.mergePropertiesIntoMap(props, map);
assertEquals("value1", map.get("prop1"));
assertEquals("value2", map.get("prop2"));
assertEquals(new Integer(3), map.get("prop3"));
assertEquals(Integer.valueOf(3), map.get("prop3"));
assertEquals("value4", map.get("prop4"));
}

72
spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@ -40,12 +40,12 @@ public class NumberUtilsTests { @@ -40,12 +40,12 @@ public class NumberUtilsTests {
String aFloat = "" + Float.MAX_VALUE;
String aDouble = "" + Double.MAX_VALUE;
assertEquals("Byte did not parse", new Byte(Byte.MAX_VALUE), NumberUtils.parseNumber(aByte, Byte.class));
assertEquals("Short did not parse", new Short(Short.MAX_VALUE), NumberUtils.parseNumber(aShort, Short.class));
assertEquals("Integer did not parse", new Integer(Integer.MAX_VALUE), NumberUtils.parseNumber(anInteger, Integer.class));
assertEquals("Long did not parse", new Long(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class));
assertEquals("Float did not parse", new Float(Float.MAX_VALUE), NumberUtils.parseNumber(aFloat, Float.class));
assertEquals("Double did not parse", new Double(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class));
assertEquals("Byte did not parse", Byte.valueOf(Byte.MAX_VALUE), NumberUtils.parseNumber(aByte, Byte.class));
assertEquals("Short did not parse", Short.valueOf(Short.MAX_VALUE), NumberUtils.parseNumber(aShort, Short.class));
assertEquals("Integer did not parse", Integer.valueOf(Integer.MAX_VALUE), NumberUtils.parseNumber(anInteger, Integer.class));
assertEquals("Long did not parse", Long.valueOf(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class));
assertEquals("Float did not parse", Float.valueOf(Float.MAX_VALUE), NumberUtils.parseNumber(aFloat, Float.class));
assertEquals("Double did not parse", Double.valueOf(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class));
}
@Test
@ -58,12 +58,12 @@ public class NumberUtilsTests { @@ -58,12 +58,12 @@ public class NumberUtilsTests {
String aFloat = "" + Float.MAX_VALUE;
String aDouble = "" + Double.MAX_VALUE;
assertEquals("Byte did not parse", new Byte(Byte.MAX_VALUE), NumberUtils.parseNumber(aByte, Byte.class, nf));
assertEquals("Short did not parse", new Short(Short.MAX_VALUE), NumberUtils.parseNumber(aShort, Short.class, nf));
assertEquals("Integer did not parse", new Integer(Integer.MAX_VALUE), NumberUtils.parseNumber(anInteger, Integer.class, nf));
assertEquals("Long did not parse", new Long(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class, nf));
assertEquals("Float did not parse", new Float(Float.MAX_VALUE), NumberUtils.parseNumber(aFloat, Float.class, nf));
assertEquals("Double did not parse", new Double(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class, nf));
assertEquals("Byte did not parse", Byte.valueOf(Byte.MAX_VALUE), NumberUtils.parseNumber(aByte, Byte.class, nf));
assertEquals("Short did not parse", Short.valueOf(Short.MAX_VALUE), NumberUtils.parseNumber(aShort, Short.class, nf));
assertEquals("Integer did not parse", Integer.valueOf(Integer.MAX_VALUE), NumberUtils.parseNumber(anInteger, Integer.class, nf));
assertEquals("Long did not parse", Long.valueOf(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class, nf));
assertEquals("Float did not parse", Float.valueOf(Float.MAX_VALUE), NumberUtils.parseNumber(aFloat, Float.class, nf));
assertEquals("Double did not parse", Double.valueOf(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class, nf));
}
@Test
@ -75,12 +75,12 @@ public class NumberUtilsTests { @@ -75,12 +75,12 @@ public class NumberUtilsTests {
String aFloat = " " + Float.MAX_VALUE + " ";
String aDouble = " " + Double.MAX_VALUE + " ";
assertEquals("Byte did not parse", new Byte(Byte.MAX_VALUE), NumberUtils.parseNumber(aByte, Byte.class));
assertEquals("Short did not parse", new Short(Short.MAX_VALUE), NumberUtils.parseNumber(aShort, Short.class));
assertEquals("Integer did not parse", new Integer(Integer.MAX_VALUE), NumberUtils.parseNumber(anInteger, Integer.class));
assertEquals("Long did not parse", new Long(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class));
assertEquals("Float did not parse", new Float(Float.MAX_VALUE), NumberUtils.parseNumber(aFloat, Float.class));
assertEquals("Double did not parse", new Double(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class));
assertEquals("Byte did not parse", Byte.valueOf(Byte.MAX_VALUE), NumberUtils.parseNumber(aByte, Byte.class));
assertEquals("Short did not parse", Short.valueOf(Short.MAX_VALUE), NumberUtils.parseNumber(aShort, Short.class));
assertEquals("Integer did not parse", Integer.valueOf(Integer.MAX_VALUE), NumberUtils.parseNumber(anInteger, Integer.class));
assertEquals("Long did not parse", Long.valueOf(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class));
assertEquals("Float did not parse", Float.valueOf(Float.MAX_VALUE), NumberUtils.parseNumber(aFloat, Float.class));
assertEquals("Double did not parse", Double.valueOf(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class));
}
@Test
@ -93,18 +93,18 @@ public class NumberUtilsTests { @@ -93,18 +93,18 @@ public class NumberUtilsTests {
String aFloat = " " + Float.MAX_VALUE + " ";
String aDouble = " " + Double.MAX_VALUE + " ";
assertEquals("Byte did not parse", new Byte(Byte.MAX_VALUE), NumberUtils.parseNumber(aByte, Byte.class, nf));
assertEquals("Short did not parse", new Short(Short.MAX_VALUE), NumberUtils.parseNumber(aShort, Short.class, nf));
assertEquals("Integer did not parse", new Integer(Integer.MAX_VALUE), NumberUtils.parseNumber(anInteger, Integer.class, nf));
assertEquals("Long did not parse", new Long(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class, nf));
assertEquals("Float did not parse", new Float(Float.MAX_VALUE), NumberUtils.parseNumber(aFloat, Float.class, nf));
assertEquals("Double did not parse", new Double(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class, nf));
assertEquals("Byte did not parse", Byte.valueOf(Byte.MAX_VALUE), NumberUtils.parseNumber(aByte, Byte.class, nf));
assertEquals("Short did not parse", Short.valueOf(Short.MAX_VALUE), NumberUtils.parseNumber(aShort, Short.class, nf));
assertEquals("Integer did not parse", Integer.valueOf(Integer.MAX_VALUE), NumberUtils.parseNumber(anInteger, Integer.class, nf));
assertEquals("Long did not parse", Long.valueOf(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class, nf));
assertEquals("Float did not parse", Float.valueOf(Float.MAX_VALUE), NumberUtils.parseNumber(aFloat, Float.class, nf));
assertEquals("Double did not parse", Double.valueOf(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class, nf));
}
@Test
public void parseNumberAsHex() {
String aByte = "0x" + Integer.toHexString(new Byte(Byte.MAX_VALUE).intValue());
String aShort = "0x" + Integer.toHexString(new Short(Short.MAX_VALUE).intValue());
String aByte = "0x" + Integer.toHexString(Byte.valueOf(Byte.MAX_VALUE).intValue());
String aShort = "0x" + Integer.toHexString(Short.valueOf(Short.MAX_VALUE).intValue());
String anInteger = "0x" + Integer.toHexString(Integer.MAX_VALUE);
String aLong = "0x" + Long.toHexString(Long.MAX_VALUE);
String aReallyBigInt = "FEBD4E677898DFEBFFEE44";
@ -135,7 +135,7 @@ public class NumberUtilsTests { @@ -135,7 +135,7 @@ public class NumberUtilsTests {
@Test
public void convertDoubleToBigInteger() {
Double decimal = new Double(3.14d);
Double decimal = Double.valueOf(3.14d);
assertEquals(new BigInteger("3"), NumberUtils.convertNumberToTargetClass(decimal, BigInteger.class));
}
@ -223,8 +223,8 @@ public class NumberUtilsTests { @@ -223,8 +223,8 @@ public class NumberUtilsTests {
catch (IllegalArgumentException expected) {
}
assertEquals(new Long(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class));
assertEquals(new Double(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class));
assertEquals(Long.valueOf(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class));
assertEquals(Double.valueOf(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class));
}
@Test
@ -253,8 +253,8 @@ public class NumberUtilsTests { @@ -253,8 +253,8 @@ public class NumberUtilsTests {
catch (IllegalArgumentException expected) {
}
assertEquals(new Long(Long.MIN_VALUE), NumberUtils.parseNumber(aLong, Long.class));
assertEquals(new Double(Double.MIN_VALUE), NumberUtils.parseNumber(aDouble, Double.class));
assertEquals(Long.valueOf(Long.MIN_VALUE), NumberUtils.parseNumber(aLong, Long.class));
assertEquals(Double.valueOf(Double.MIN_VALUE), NumberUtils.parseNumber(aDouble, Double.class));
}
@Test
@ -284,8 +284,8 @@ public class NumberUtilsTests { @@ -284,8 +284,8 @@ public class NumberUtilsTests {
catch (IllegalArgumentException expected) {
}
assertEquals(new Long(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class, nf));
assertEquals(new Double(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class, nf));
assertEquals(Long.valueOf(Long.MAX_VALUE), NumberUtils.parseNumber(aLong, Long.class, nf));
assertEquals(Double.valueOf(Double.MAX_VALUE), NumberUtils.parseNumber(aDouble, Double.class, nf));
}
@Test
@ -315,8 +315,8 @@ public class NumberUtilsTests { @@ -315,8 +315,8 @@ public class NumberUtilsTests {
catch (IllegalArgumentException expected) {
}
assertEquals(new Long(Long.MIN_VALUE), NumberUtils.parseNumber(aLong, Long.class, nf));
assertEquals(new Double(Double.MIN_VALUE), NumberUtils.parseNumber(aDouble, Double.class, nf));
assertEquals(Long.valueOf(Long.MIN_VALUE), NumberUtils.parseNumber(aLong, Long.class, nf));
assertEquals(Double.valueOf(Double.MIN_VALUE), NumberUtils.parseNumber(aDouble, Double.class, nf));
}
@Test

4
spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java

@ -102,7 +102,7 @@ public class ObjectUtilsTests { @@ -102,7 +102,7 @@ public class ObjectUtilsTests {
assertTrue(isEmpty(new Integer[0]));
assertFalse(isEmpty(new int[] { 42 }));
assertFalse(isEmpty(new Integer[] { new Integer(42) }));
assertFalse(isEmpty(new Integer[] { 42 }));
}
@Test
@ -737,7 +737,7 @@ public class ObjectUtilsTests { @@ -737,7 +737,7 @@ public class ObjectUtilsTests {
@Test
public void nullSafeToStringWithObjectArray() {
Object[] array = {"Han", new Long(43)};
Object[] array = {"Han", Long.valueOf(43)};
assertEquals("{Han, 43}", ObjectUtils.nullSafeToString(array));
}

4
spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java

@ -302,13 +302,13 @@ public class ReflectionUtilsTests { @@ -302,13 +302,13 @@ public class ReflectionUtilsTests {
class Parent {
@SuppressWarnings("unused")
public Number m1() {
return new Integer(42);
return Integer.valueOf(42);
}
}
class Leaf extends Parent {
@Override
public Integer m1() {
return new Integer(42);
return Integer.valueOf(42);
}
}
int m1MethodCount = 0;

2
spring-core/src/test/java/org/springframework/util/StringUtilsTests.java

@ -305,7 +305,7 @@ public class StringUtilsTests { @@ -305,7 +305,7 @@ public class StringUtilsTests {
public void testQuoteIfString() {
assertEquals("'myString'", StringUtils.quoteIfString("myString"));
assertEquals("''", StringUtils.quoteIfString(""));
assertEquals(new Integer(5), StringUtils.quoteIfString(5));
assertEquals(Integer.valueOf(5), StringUtils.quoteIfString(5));
assertNull(StringUtils.quoteIfString(null));
}

4
spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java

@ -35,14 +35,14 @@ public class BooleanComparatorTests { @@ -35,14 +35,14 @@ public class BooleanComparatorTests {
@Test
public void shouldCompareWithTrueLow() {
Comparator<Boolean> c = new BooleanComparator(true);
assertThat(c.compare(new Boolean(true), new Boolean(false)), is(-1));
assertThat(c.compare(true, false), is(-1));
assertThat(c.compare(Boolean.TRUE, Boolean.TRUE), is(0));
}
@Test
public void shouldCompareWithTrueHigh() {
Comparator<Boolean> c = new BooleanComparator(false);
assertThat(c.compare(new Boolean(true), new Boolean(false)), is(1));
assertThat(c.compare(true, false), is(1));
assertThat(c.compare(Boolean.TRUE, Boolean.TRUE), is(0));
}

6
spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@ -37,7 +37,7 @@ import org.junit.Test; @@ -37,7 +37,7 @@ import org.junit.Test;
*/
public class ListBasedXMLEventReaderTests {
private final XMLInputFactory inputFactory = XMLInputFactory.newFactory();
private final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
private final XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
@ -65,4 +65,4 @@ public class ListBasedXMLEventReaderTests { @@ -65,4 +65,4 @@ public class ListBasedXMLEventReaderTests {
return events;
}
}
}

Loading…
Cancel
Save