|
| 1 | +/* |
| 2 | + * Copyright 2025 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.data.mongodb.repository; |
| 17 | + |
| 18 | +import org.junit.jupiter.api.Disabled; |
| 19 | + |
| 20 | +import org.springframework.context.ApplicationContext; |
| 21 | +import org.springframework.context.annotation.Bean; |
| 22 | +import org.springframework.context.annotation.Configuration; |
| 23 | +import org.springframework.context.annotation.ImportResource; |
| 24 | +import org.springframework.data.mongodb.core.MongoOperations; |
| 25 | +import org.springframework.data.mongodb.core.TestMongoConfiguration; |
| 26 | +import org.springframework.data.mongodb.repository.aot.AotFragmentTestConfigurationSupport; |
| 27 | +import org.springframework.data.mongodb.repository.support.MongoRepositoryFactory; |
| 28 | +import org.springframework.data.repository.core.support.RepositoryComposition; |
| 29 | +import org.springframework.test.context.ContextConfiguration; |
| 30 | + |
| 31 | +/** |
| 32 | + * Integration tests for {@link PersonRepository} with mounted AOT-generated repository methods. |
| 33 | + * |
| 34 | + * @author Mark Paluch |
| 35 | + */ |
| 36 | +@ContextConfiguration(classes = AotPersonRepositoryIntegrationTests.Config.class) |
| 37 | +@Disabled("Several mismatches, some class-loader visibility issues and some behavioral differences remain to be fixed") |
| 38 | +class AotPersonRepositoryIntegrationTests extends AbstractPersonRepositoryIntegrationTests { |
| 39 | + |
| 40 | + @Configuration |
| 41 | + @ImportResource("classpath:/org/springframework/data/mongodb/repository/PersonRepositoryIntegrationTests-infrastructure.xml") |
| 42 | + static class Config extends TestMongoConfiguration { |
| 43 | + |
| 44 | + @Bean |
| 45 | + static AotFragmentTestConfigurationSupport aot() { |
| 46 | + return new AotFragmentTestConfigurationSupport(PersonRepository.class, false); |
| 47 | + } |
| 48 | + |
| 49 | + @Bean |
| 50 | + PersonRepository personRepository(MongoOperations mongoOperations, ApplicationContext context) { |
| 51 | + |
| 52 | + MongoRepositoryFactory factory = new MongoRepositoryFactory(mongoOperations); |
| 53 | + factory.setBeanFactory(context); |
| 54 | + factory.setBeanClassLoader(context.getClassLoader()); |
| 55 | + factory.setEnvironment(context.getEnvironment()); |
| 56 | + |
| 57 | + Object aotFragment = context.getBean("fragment"); |
| 58 | + |
| 59 | + return factory.getRepository(PersonRepository.class, RepositoryComposition.RepositoryFragments.just(aotFragment)); |
| 60 | + } |
| 61 | + |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments