cleanup work

This commit is contained in:
eugenp 2016-12-18 22:13:53 +02:00
parent e84137bdfc
commit 51a96d14de
3 changed files with 80 additions and 76 deletions

View File

@ -20,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = ServerLocationApp.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = ServerLocationApp.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ServerLocationAppTests { public class ServerLocationAppIntegrationTest {
ConfigurableApplicationContext application2; ConfigurableApplicationContext application2;
ConfigurableApplicationContext application3; ConfigurableApplicationContext application3;

View File

@ -7,9 +7,9 @@ import org.baeldung.config.PersistenceConfig;
import org.baeldung.config.SecurityConfig; import org.baeldung.config.SecurityConfig;
import org.baeldung.persistence.dao.UserRepository; import org.baeldung.persistence.dao.UserRepository;
import org.baeldung.persistence.model.User; import org.baeldung.persistence.model.User;
import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.After;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.security.authentication.AuthenticationProvider; import org.springframework.security.authentication.AuthenticationProvider;
@ -23,7 +23,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = { MvcConfig.class, SecurityConfig.class, PersistenceConfig.class }) @SpringApplicationConfiguration(classes = { MvcConfig.class, SecurityConfig.class, PersistenceConfig.class })
@WebAppConfiguration @WebAppConfiguration
public class CustomUserDetailsServiceTest { public class CustomUserDetailsServiceIntegrationTest {
public static final String USERNAME = "user"; public static final String USERNAME = "user";
public static final String PASSWORD = "pass"; public static final String PASSWORD = "pass";
@ -38,6 +38,8 @@ public class CustomUserDetailsServiceTest {
@Autowired @Autowired
PasswordEncoder passwordEncoder; PasswordEncoder passwordEncoder;
//
@Test @Test
public void givenExistingUser_whenAuthenticate_thenRetrieveFromDb() { public void givenExistingUser_whenAuthenticate_thenRetrieveFromDb() {
User user = new User(); User user = new User();
@ -64,6 +66,8 @@ public class CustomUserDetailsServiceTest {
authenticationProvider.authenticate(auth); authenticationProvider.authenticate(auth);
} }
//
@After @After
public void tearDown() { public void tearDown() {
myUserRepository.removeUserByUsername(USERNAME); myUserRepository.removeUserByUsername(USERNAME);