cleanup work for tests

This commit is contained in:
Eugen Paraschiv 2018-03-04 17:52:56 +02:00
parent 4a489e4afc
commit 5fd8e4293e
8 changed files with 10 additions and 20 deletions

Binary file not shown.

View File

@ -13,7 +13,7 @@ import com.baeldung.Spring5Application;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Spring5Application.class)
public class BeanRegistrationTest {
public class BeanRegistrationIntegrationTest {
@Autowired
private GenericWebApplicationContext context;

View File

@ -13,7 +13,7 @@ import org.springframework.test.web.reactive.server.WebTestClient;
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = SpringSecurity5Application.class)
public class SecurityTest {
public class SecurityIntegrationTest {
@Autowired
ApplicationContext context;
@ -22,27 +22,17 @@ public class SecurityTest {
@Before
public void setup() {
this.rest = WebTestClient
.bindToApplicationContext(this.context)
.configureClient()
.build();
this.rest = WebTestClient.bindToApplicationContext(this.context).configureClient().build();
}
@Test
public void whenNoCredentials_thenRedirectToLogin() {
this.rest.get()
.uri("/")
.exchange()
.expectStatus().is3xxRedirection();
this.rest.get().uri("/").exchange().expectStatus().is3xxRedirection();
}
@Test
@WithMockUser
public void whenHasCredentials_thenSeesGreeting() {
this.rest.get()
.uri("/")
.exchange()
.expectStatus().isOk()
.expectBody(String.class).isEqualTo("Hello, user");
this.rest.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("Hello, user");
}
}

View File

@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SessionAttrsApplicationTests {
public class SessionAttrsApplicationIntegrationTest {
@Test
public void contextLoads() {

View File

@ -25,7 +25,7 @@ import org.springframework.web.context.WebApplicationContext;
@SpringBootTest
@AutoConfigureMockMvc
@Import(TestConfig.class)
public class TodoControllerWithScopedProxyTest {
public class TodoControllerWithScopedProxyIntegrationTest {
@Autowired
private MockMvc mockMvc;

View File

@ -24,7 +24,7 @@ import org.springframework.web.servlet.FlashMap;
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class TodoControllerWithSessionAttributesTest {
public class TodoControllerWithSessionAttributesIntegrationTest {
@Autowired
private MockMvc mockMvc;

View File

@ -16,7 +16,7 @@ import reactor.core.publisher.Mono;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Spring5Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class WebTestClientTest {
public class WebTestClientIntegrationTest {
@LocalServerPort
private int port;

View File

@ -23,7 +23,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
public class UserRepositoryTest {
public class UserRepositoryIntegrationTest {
private final String USER_NAME_ADAM = "Adam";
private final Integer ACTIVE_STATUS = 1;