Skip to content

Commit c7faedf

Browse files
christophstroblmp911de
authored andcommitted
Disable tests on Java 16 that require class-based proxies.
Original pull request: #3687. Resolves #3656
1 parent bf3375d commit c7faedf

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/MongoMappingContext.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.data.mapping.model.Property;
2727
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
2828
import org.springframework.data.mapping.model.SimpleTypeHolder;
29+
import org.springframework.data.util.NullableWrapperConverters;
2930
import org.springframework.data.util.TypeInformation;
3031
import org.springframework.lang.Nullable;
3132

@@ -69,6 +70,11 @@ public void setFieldNamingStrategy(@Nullable FieldNamingStrategy fieldNamingStra
6970
*/
7071
@Override
7172
protected boolean shouldCreatePersistentEntityFor(TypeInformation<?> type) {
73+
74+
if (NullableWrapperConverters.supports(type.getType())) {
75+
return false;
76+
}
77+
7278
return !MongoSimpleTypes.HOLDER.isSimpleType(type.getType()) && !AbstractMap.class.isAssignableFrom(type.getType());
7379
}
7480

@@ -133,7 +139,7 @@ public MongoPersistentEntity<?> getPersistentEntity(MongoPersistentProperty pers
133139

134140
MongoPersistentEntity<?> entity = super.getPersistentEntity(persistentProperty);
135141

136-
if(entity == null || !persistentProperty.isUnwrapped()) {
142+
if (entity == null || !persistentProperty.isUnwrapped()) {
137143
return entity;
138144
}
139145

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DbRefMappingMongoConverterUnitTests.java

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import org.bson.types.ObjectId;
3737
import org.junit.jupiter.api.BeforeEach;
3838
import org.junit.jupiter.api.Test;
39+
import org.junit.jupiter.api.condition.DisabledForJreRange;
40+
import org.junit.jupiter.api.condition.JRE;
3941
import org.junit.jupiter.api.extension.ExtendWith;
4042
import org.mockito.Mock;
4143
import org.mockito.Mockito;
@@ -179,6 +181,7 @@ public void lazyLoadingProxyForLazyDbRefOnInterface() {
179181
}
180182

181183
@Test // DATAMONGO-348
184+
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
182185
public void lazyLoadingProxyForLazyDbRefOnConcreteCollection() {
183186

184187
String id = "42";
@@ -506,6 +509,7 @@ public void shouldNotEagerlyResolveIdPropertyWithPropertyAccess() {
506509
}
507510

508511
@Test // DATAMONGO-1076
512+
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
509513
public void shouldNotTriggerResolvingOfLazyLoadedProxyWhenFinalizeMethodIsInvoked() throws Exception {
510514

511515
MongoPersistentEntity<?> entity = mappingContext
@@ -524,6 +528,7 @@ public void shouldNotTriggerResolvingOfLazyLoadedProxyWhenFinalizeMethodIsInvoke
524528
}
525529

526530
@Test // DATAMONGO-1194
531+
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
527532
public void shouldBulkFetchListOfReferences() {
528533

529534
String id1 = "1";
@@ -574,6 +579,7 @@ public void shouldBulkFetchSetOfReferencesForConstructorCreation() {
574579
}
575580

576581
@Test // DATAMONGO-1194
582+
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
577583
public void shouldFallbackToOneByOneFetchingWhenElementsInListOfReferencesPointToDifferentCollections() {
578584

579585
String id1 = "1";

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/PersonRepositoryLazyLoadingIntegrationTests.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
import java.util.Arrays;
2323
import java.util.List;
2424

25-
import org.junit.Before;
26-
import org.junit.Test;
27-
import org.junit.runner.RunWith;
28-
25+
import org.junit.jupiter.api.BeforeEach;
26+
import org.junit.jupiter.api.Test;
27+
import org.junit.jupiter.api.condition.DisabledForJreRange;
28+
import org.junit.jupiter.api.condition.JRE;
29+
import org.junit.jupiter.api.extension.ExtendWith;
2930
import org.springframework.beans.factory.annotation.Autowired;
3031
import org.springframework.data.mongodb.core.MongoOperations;
3132
import org.springframework.test.context.ContextConfiguration;
32-
import org.springframework.test.context.junit4.SpringRunner;
33+
import org.springframework.test.context.junit.jupiter.SpringExtension;
3334

3435
/**
3536
* Integration test for {@link PersonRepository} for lazy loading support.
@@ -38,13 +39,13 @@
3839
* @author Oliver Gierke
3940
*/
4041
@ContextConfiguration(locations = "PersonRepositoryIntegrationTests-context.xml")
41-
@RunWith(SpringRunner.class)
42+
@ExtendWith(SpringExtension.class)
4243
public class PersonRepositoryLazyLoadingIntegrationTests {
4344

4445
@Autowired PersonRepository repository;
4546
@Autowired MongoOperations operations;
4647

47-
@Before
48+
@BeforeEach
4849
public void setUp() throws InterruptedException {
4950

5051
repository.deleteAll();
@@ -61,7 +62,6 @@ public void shouldLoadAssociationWithDbRefOnInterfaceAndLazyLoadingEnabled() thr
6162
Person person = new Person();
6263
person.setFirstname("Oliver");
6364
person.setFans(Arrays.asList(thomas));
64-
person.setRealFans(new ArrayList<User>(Arrays.asList(thomas)));
6565
repository.save(person);
6666

6767
Person oliver = repository.findById(person.id).get();
@@ -75,15 +75,15 @@ public void shouldLoadAssociationWithDbRefOnInterfaceAndLazyLoadingEnabled() thr
7575
}
7676

7777
@Test // DATAMONGO-348
78-
public void shouldLoadAssociationWithDbRefOnConcreteCollectionAndLazyLoadingEnabled() throws Exception {
78+
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
79+
public void shouldLoadAssociationWithDbRefOnConcreteCollectionAndLazyLoadingEnabled() {
7980

8081
User thomas = new User();
8182
thomas.username = "Thomas";
8283
operations.save(thomas);
8384

8485
Person person = new Person();
8586
person.setFirstname("Oliver");
86-
person.setFans(Arrays.asList(thomas));
8787
person.setRealFans(new ArrayList<User>(Arrays.asList(thomas)));
8888
repository.save(person);
8989

0 commit comments

Comments
 (0)