I am using the @DataJpaTest annotation feature to test my repositories, following this.
Test Configuration:
@RunWith(SpringRunner.class)
@DataJpaTest
public class UserRepositoryTest {
@Autowired
private TestEntityManager entityManager;
@Autowired
private UserRepository userRepository;
@Test
public void whenFindByName_thenReturnEmployee() {
...
}
}
I have an Oauth2 Security Config as I am developing a REST API.
When I try to run my test, the application context cannot be loaded because of No qualifying bean of type 'org.springframework.security.authentication.AuthenticationManager' available
.
That class is part of my @Configuration
@Configuration
@EnableAuthorizationServer
public class AuthorizationAdapter extends AuthorizationServerConfigurerAdapter {
@Autowired
private AuthenticationManager authenticationManager;
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.authenticationManager(authenticationManager);
}
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory().withClient(CLIENT_ID).secret(SECRET).authorizedGrantTypes("password", "refresh_token").scopes("global")
.accessTokenValiditySeconds(180);
}
}
I need not to load that kind of configuration, as I don't need it to test my repositories. How can I achieve this?
did you solved it ? I have the same error
RépondreSupprimer