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:
Madhura Bhave
2018-12-05 13:56:29 -08:00
committed by Stephane Nicoll
parent d9f339a1b6
commit 1db1c8b03c
821 changed files with 2279 additions and 2787 deletions

View File

@@ -16,13 +16,11 @@
package sample.jpa;
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.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -38,23 +36,22 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
* @author Oliver Gierke
* @author Dave Syer
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@WebAppConfiguration
public class SampleJpaApplicationTests {
class SampleJpaApplicationTests {
@Autowired
private WebApplicationContext context;
private MockMvc mvc;
@Before
@BeforeEach
public void setUp() {
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
}
@Test
public void testHome() throws Exception {
void testHome() throws Exception {
this.mvc.perform(get("/")).andExpect(status().isOk())
.andExpect(xpath("//tbody/tr").nodeCount(4));
}

View File

@@ -17,13 +17,11 @@ package sample.jpa.repository;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import sample.jpa.domain.Note;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,16 +31,15 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class JpaNoteRepositoryIntegrationTests {
class JpaNoteRepositoryIntegrationTests {
@Autowired
JpaNoteRepository repository;
@Test
public void findsAllNotes() {
void findsAllNotes() {
List<Note> notes = this.repository.findAll();
assertThat(notes).hasSize(4);
for (Note note : notes) {

View File

@@ -17,13 +17,11 @@ package sample.jpa.repository;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import sample.jpa.domain.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import static org.assertj.core.api.Assertions.assertThat;
@@ -33,16 +31,15 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class JpaTagRepositoryIntegrationTests {
class JpaTagRepositoryIntegrationTests {
@Autowired
JpaTagRepository repository;
@Test
public void findsAllTags() {
void findsAllTags() {
List<Tag> tags = this.repository.findAll();
assertThat(tags).hasSize(3);
for (Tag tag : tags) {