Browse Source

Isolate AOT Test to Security Components

PR gh-17724
pull/17765/head
Josh Cummings 7 months ago committed by Rob Winch
parent
commit
714781df78
  1. 13
      config/src/test/java/org/springframework/security/config/annotation/method/configuration/aot/EnableMethodSecurityAotTests.java

13
config/src/test/java/org/springframework/security/config/annotation/method/configuration/aot/EnableMethodSecurityAotTests.java

@ -18,6 +18,8 @@ package org.springframework.security.config.annotation.method.configuration.aot;
import javax.sql.DataSource; import javax.sql.DataSource;
import jakarta.persistence.EntityManager;
import org.jspecify.annotations.NonNull;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
@ -29,7 +31,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.aot.ApplicationContextAotGenerator; import org.springframework.context.aot.ApplicationContextAotGenerator;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
@ -72,7 +74,6 @@ public class EnableMethodSecurityAotTests {
@Configuration @Configuration
@EnableMethodSecurity @EnableMethodSecurity
@EnableJpaRepositories
static class AppConfig { static class AppConfig {
@Bean @Bean
@ -92,6 +93,14 @@ public class EnableMethodSecurityAotTests {
return factory; return factory;
} }
@Bean
JpaRepositoryFactoryBean<@NonNull MessageRepository, Message, Long> repo(EntityManager entityManager) {
JpaRepositoryFactoryBean<@NonNull MessageRepository, Message, Long> bean = new JpaRepositoryFactoryBean<>(
MessageRepository.class);
bean.setEntityManager(entityManager);
return bean;
}
} }
} }

Loading…
Cancel
Save