@Test public void defaultConfiguration() throws Exception { registerAndRefresh(AuditAutoConfiguration.class); assertThat(this.context.getBean(AuditEventRepository.class)).isNotNull(); assertThat(this.context.getBean(AuthenticationAuditListener.class)).isNotNull(); assertThat(this.context.getBean(AuthorizationAuditListener.class)).isNotNull(); }
@Test public void testTraceConfiguration() throws Exception { this.context = new AnnotationConfigApplicationContext(); this.context.register(AuditAutoConfiguration.class); this.context.refresh(); assertNotNull(this.context.getBean(AuditEventRepository.class)); assertNotNull(this.context.getBean(AuthenticationAuditListener.class)); assertNotNull(this.context.getBean(AuthorizationAuditListener.class)); }
@Bean @ConditionalOnClass(name = "org.springframework.security.access.event.AbstractAuthorizationEvent") @ConditionalOnMissingBean(AbstractAuthorizationAuditListener.class) public AuthorizationAuditListener authorizationAuditListener() throws Exception { return new AuthorizationAuditListener(); }
@Bean @ConditionalOnClass(name = "org.springframework.security.access.event.AbstractAuthorizationEvent") public AuthorizationAuditListener authorizationAuditListener() throws Exception { return new AuthorizationAuditListener(); }