Skip to content

Commit 1094b07

Browse files
committed
Add AOT TCK.
1 parent 2363375 commit 1094b07

File tree

2 files changed

+82
-8
lines changed

2 files changed

+82
-8
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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.jdbc.repository;
17+
18+
import org.springframework.beans.factory.annotation.Autowired;
19+
import org.springframework.context.ApplicationContext;
20+
import org.springframework.context.annotation.Bean;
21+
import org.springframework.context.annotation.ComponentScan;
22+
import org.springframework.context.annotation.Configuration;
23+
import org.springframework.context.annotation.FilterType;
24+
import org.springframework.data.jdbc.core.dialect.JdbcH2Dialect;
25+
import org.springframework.data.jdbc.repository.aot.AotFragmentTestConfigurationSupport;
26+
import org.springframework.data.jdbc.repository.aot.UserRepository;
27+
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
28+
import org.springframework.data.jdbc.testing.DatabaseType;
29+
import org.springframework.data.jdbc.testing.EnabledOnDatabase;
30+
import org.springframework.data.jdbc.testing.IntegrationTest;
31+
import org.springframework.data.jdbc.testing.TestClass;
32+
import org.springframework.data.repository.core.support.RepositoryComposition;
33+
34+
/**
35+
* Integration test for {@link DummyEntityRepository} using JavaConfig with mounted AOT-generated repository methods.
36+
*
37+
* @author Mark Paluch
38+
*/
39+
@IntegrationTest
40+
@EnabledOnDatabase(DatabaseType.H2)
41+
class AotJdbcRepositoryIntegrationTests extends JdbcRepositoryIntegrationTests {
42+
43+
@Configuration
44+
@EnableJdbcRepositories(includeFilters = {
45+
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = AotJdbcRepositoryIntegrationTests.class) })
46+
static class AotConfig extends Config {
47+
48+
@Autowired ApplicationContext context;
49+
50+
@Bean
51+
TestClass testClass() {
52+
return TestClass.of(JdbcRepositoryIntegrationTests.class);
53+
}
54+
55+
@Bean
56+
static AotFragmentTestConfigurationSupport aot() {
57+
return new AotFragmentTestConfigurationSupport(UserRepository.class, JdbcH2Dialect.INSTANCE, AotConfig.class,
58+
false);
59+
}
60+
61+
@Bean
62+
@Override
63+
DummyEntityRepository dummyEntityRepository() {
64+
65+
RepositoryComposition.RepositoryFragments fragments = RepositoryComposition.RepositoryFragments
66+
.just(context.getBean("fragment"));
67+
68+
return factory.getRepository(DummyEntityRepository.class, fragments);
69+
}
70+
71+
}
72+
73+
}

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryIntegrationTests.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,11 +1515,12 @@ interface DummyProjectExample {
15151515
String getName();
15161516
}
15171517

1518-
interface ProvidedIdEntityRepository extends CrudRepository<ProvidedIdEntity, Long> {
1518+
public interface ProvidedIdEntityRepository extends CrudRepository<ProvidedIdEntity, Long> {
15191519

15201520
}
15211521

1522-
interface DummyEntityRepository extends CrudRepository<DummyEntity, Long>, QueryByExampleExecutor<DummyEntity> {
1522+
public interface DummyEntityRepository
1523+
extends CrudRepository<DummyEntity, Long>, QueryByExampleExecutor<DummyEntity> {
15231524

15241525
@Lock(LockMode.PESSIMISTIC_WRITE)
15251526
List<DummyEntity> findAllByName(String name);
@@ -1607,15 +1608,15 @@ interface DummyEntityRepository extends CrudRepository<DummyEntity, Long>, Query
16071608
List<DummyEntity> findByBytes(byte[] bytes);
16081609
}
16091610

1610-
interface RootRepository extends ListCrudRepository<Root, Long> {
1611+
public interface RootRepository extends ListCrudRepository<Root, Long> {
16111612
List<Root> findAllByOrderByIdAsc();
16121613
}
16131614

1614-
interface WithDelimitedColumnRepository extends CrudRepository<WithDelimitedColumn, Long> {}
1615+
public interface WithDelimitedColumnRepository extends CrudRepository<WithDelimitedColumn, Long> {}
16151616

1616-
interface EntityWithSequenceRepository extends CrudRepository<EntityWithSequence, Long> {}
1617+
public interface EntityWithSequenceRepository extends CrudRepository<EntityWithSequence, Long> {}
16171618

1618-
interface ExpressionSqlTypePropagationRepository extends CrudRepository<ExpressionSqlTypePropagation, Long> {
1619+
public interface ExpressionSqlTypePropagationRepository extends CrudRepository<ExpressionSqlTypePropagation, Long> {
16191620

16201621
// language=sql
16211622
@Modifying
@@ -1626,7 +1627,7 @@ INSERT INTO EXPRESSION_SQL_TYPE_PROPAGATION(identifier, enum_class)
16261627
void saveWithSpel(@Param("expressionSqlTypePropagation") ExpressionSqlTypePropagation expressionSqlTypePropagation);
16271628
}
16281629

1629-
interface DummyProjection {
1630+
public interface DummyProjection {
16301631
String getName();
16311632
}
16321633

@@ -2029,7 +2030,7 @@ public boolean isNew() {
20292030
}
20302031
}
20312032

2032-
static class DummyEntity {
2033+
public static class DummyEntity {
20332034

20342035
@Id Long idProp;
20352036
String name;

0 commit comments

Comments
 (0)