Backport Java 17 test compatibility changes.
Avoid usage of encapsulated tests as dummies. Add dependency override for ASM dependencies. See #2423
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -240,7 +240,7 @@
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.2.3U1</version>
|
||||
<version>2.3.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ package org.springframework.data;
|
||||
import static de.schauderhaft.degraph.check.JCheck.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@Disabled("Requires newer version of ASM 5.1")
|
||||
public class DependencyTests {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -19,9 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.Format;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
@@ -33,6 +30,7 @@ import org.jmolecules.ddd.types.Association;
|
||||
import org.jmolecules.ddd.types.Identifier;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.ConverterFactory;
|
||||
@@ -48,6 +46,7 @@ import org.springframework.data.convert.Jsr310Converters.LocalDateTimeToDateConv
|
||||
import org.springframework.data.convert.ThreeTenBackPortConverters.LocalDateTimeToJavaTimeInstantConverter;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
|
||||
import org.threeten.bp.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -163,8 +162,8 @@ class CustomConversionsUnitTests {
|
||||
void shouldSelectPropertCustomReadTargetForCglibProxiedType() {
|
||||
|
||||
CustomConversions conversions = new CustomConversions(StoreConversions.NONE,
|
||||
Arrays.asList(CustomObjectToStringConverter.INSTANCE));
|
||||
assertThat(conversions.hasCustomReadTarget(createProxyTypeFor(Object.class), String.class)).isTrue();
|
||||
Arrays.asList(CustomTypeToStringConverter.INSTANCE));
|
||||
assertThat(conversions.hasCustomReadTarget(createProxyTypeFor(CustomType.class), String.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1131, DATACMNS-1035
|
||||
@@ -316,7 +315,7 @@ class CustomConversionsUnitTests {
|
||||
INSTANCE;
|
||||
|
||||
public Format convert(String source) {
|
||||
return DateFormat.getInstance();
|
||||
return new DateFormat();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,12 +366,13 @@ class CustomConversionsUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
enum CustomObjectToStringConverter implements Converter<Object, String> {
|
||||
@ReadingConverter
|
||||
enum CustomTypeToStringConverter implements Converter<CustomType, String> {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public String convert(Object source) {
|
||||
public String convert(CustomType source) {
|
||||
return source != null ? source.toString() : null;
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ class CustomConversionsUnitTests {
|
||||
}
|
||||
|
||||
try {
|
||||
return targetType.newInstance();
|
||||
return targetType.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(e.getMessage(), e);
|
||||
}
|
||||
@@ -423,4 +423,11 @@ class CustomConversionsUnitTests {
|
||||
}
|
||||
|
||||
static class CustomType {}
|
||||
|
||||
static class Format {}
|
||||
|
||||
static class DateFormat extends Format {}
|
||||
|
||||
static class SimpleDateFormat extends DateFormat {}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import lombok.With;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -130,7 +129,7 @@ public class PersistentPropertyAccessorTests {
|
||||
void kotlinCopyMethodShouldNotSetUnsettableProperty(
|
||||
Function<Object, PersistentPropertyAccessor<?>> propertyAccessorFunction) {
|
||||
|
||||
SingleSettableProperty bean = new SingleSettableProperty(UUID.randomUUID());
|
||||
SingleSettableProperty bean = new SingleSettableProperty(1.1);
|
||||
PersistentPropertyAccessor accessor = propertyAccessorFunction.apply(bean);
|
||||
SamplePersistentProperty property = getProperty(bean, "version");
|
||||
|
||||
@@ -224,4 +223,9 @@ public class PersistentPropertyAccessorTests {
|
||||
String immutable;
|
||||
}
|
||||
|
||||
static class UnsettableVersion {
|
||||
|
||||
private final int version = (int) Math.random();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.mapping.model
|
||||
|
||||
import org.springframework.data.annotation.Id
|
||||
import java.time.LocalDateTime
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
@@ -30,7 +29,7 @@ data class ExtendedDataClassKt(val id: Long, val name: String) {
|
||||
}
|
||||
}
|
||||
|
||||
data class SingleSettableProperty constructor(val id: UUID = UUID.randomUUID()) {
|
||||
data class SingleSettableProperty constructor(val id: Double = Math.random()) {
|
||||
val version: Int? = null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user