Validate our own tests work with JUnit5 and the vintage engine
Closes gh-14737 Co-authored-by: Stephane Nicoll <snicoll@pivotal.io>
This commit is contained in:
committed by
Stephane Nicoll
parent
d9f339a1b6
commit
1db1c8b03c
@@ -15,13 +15,11 @@
|
||||
*/
|
||||
package sample.data.jdbc;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -30,26 +28,25 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@AutoConfigureTestDatabase
|
||||
public class CustomerRepositoryIntegrationTests {
|
||||
class CustomerRepositoryIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
private CustomerRepository repository;
|
||||
|
||||
@Test
|
||||
public void findAllCustomers() {
|
||||
void findAllCustomers() {
|
||||
assertThat(this.repository.findAll()).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByNameWithMatch() {
|
||||
void findByNameWithMatch() {
|
||||
assertThat(this.repository.findByName("joan")).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findByNameWithNoMatch() {
|
||||
void findByNameWithNoMatch() {
|
||||
assertThat(this.repository.findByName("hugh")).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
package sample.data.jdbc;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
@@ -37,22 +35,21 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class SampleDataJdbcApplicationTests {
|
||||
class SampleDataJdbcApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
private MockMvc mvc;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomers() throws Exception {
|
||||
void testCustomers() throws Exception {
|
||||
this.mvc.perform(get("/").param("name", "merEDith")).andExpect(status().isOk())
|
||||
.andExpect(content().string(containsString("Meredith")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user