Browse Source
Add verification to ensure the same behavior of reflectively and AOT implemented query methods. See #4961pull/5026/head
3 changed files with 92 additions and 18 deletions
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
/* |
||||
* Copyright 2025 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.data.mongodb.repository; |
||||
|
||||
import org.junit.jupiter.api.Disabled; |
||||
|
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.context.annotation.ImportResource; |
||||
import org.springframework.data.mongodb.core.MongoOperations; |
||||
import org.springframework.data.mongodb.core.TestMongoConfiguration; |
||||
import org.springframework.data.mongodb.repository.aot.AotFragmentTestConfigurationSupport; |
||||
import org.springframework.data.mongodb.repository.support.MongoRepositoryFactory; |
||||
import org.springframework.data.repository.core.support.RepositoryComposition; |
||||
import org.springframework.test.context.ContextConfiguration; |
||||
|
||||
/** |
||||
* Integration tests for {@link PersonRepository} with mounted AOT-generated repository methods. |
||||
* |
||||
* @author Mark Paluch |
||||
*/ |
||||
@ContextConfiguration(classes = AotPersonRepositoryIntegrationTests.Config.class) |
||||
@Disabled("Several mismatches, some class-loader visibility issues and some behavioral differences remain to be fixed") |
||||
class AotPersonRepositoryIntegrationTests extends AbstractPersonRepositoryIntegrationTests { |
||||
|
||||
@Configuration |
||||
@ImportResource("classpath:/org/springframework/data/mongodb/repository/PersonRepositoryIntegrationTests-infrastructure.xml") |
||||
static class Config extends TestMongoConfiguration { |
||||
|
||||
@Bean |
||||
static AotFragmentTestConfigurationSupport aot() { |
||||
return new AotFragmentTestConfigurationSupport(PersonRepository.class, false); |
||||
} |
||||
|
||||
@Bean |
||||
PersonRepository personRepository(MongoOperations mongoOperations, ApplicationContext context) { |
||||
|
||||
MongoRepositoryFactory factory = new MongoRepositoryFactory(mongoOperations); |
||||
factory.setBeanFactory(context); |
||||
factory.setBeanClassLoader(context.getClassLoader()); |
||||
factory.setEnvironment(context.getEnvironment()); |
||||
|
||||
Object aotFragment = context.getBean("fragment"); |
||||
|
||||
return factory.getRepository(PersonRepository.class, RepositoryComposition.RepositoryFragments.just(aotFragment)); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:mongo="http://www.springframework.org/schema/data/mongo" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xmlns:util="http://www.springframework.org/schema/util" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/data/mongo https://www.springframework.org/schema/data/mongo/spring-mongo.xsd |
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd |
||||
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd"> |
||||
|
||||
<mongo:db-factory dbname="repositories"/> |
||||
|
||||
<mongo:mapping-converter auto-index-creation="true"/> |
||||
|
||||
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> |
||||
<constructor-arg ref="mongoDbFactory"/> |
||||
<constructor-arg ref="mappingConverter"/> |
||||
<property name="writeConcern"> |
||||
<util:constant static-field="com.mongodb.WriteConcern.JOURNALED"/> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean class="org.springframework.data.mongodb.repository.SampleEvaluationContextExtension"/> |
||||
|
||||
</beans> |
||||
Loading…
Reference in new issue