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) @RunWith(SpringRunner.class)
@SpringBootTest(classes = Spring5Application.class) @SpringBootTest(classes = Spring5Application.class)
public class BeanRegistrationTest { public class BeanRegistrationIntegrationTest {
@Autowired @Autowired
private GenericWebApplicationContext context; private GenericWebApplicationContext context;

View File

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

View File

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

View File

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

View File

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

View File

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