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.data.rest;
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;
@@ -41,29 +39,28 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
* @author Oliver Gierke
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@SpringBootTest
// Separate profile for web tests to avoid clashing databases
public class SampleDataRestApplicationTests {
class SampleDataRestApplicationTests {
@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("/api")).andExpect(status().isOk())
.andExpect(content().string(containsString("hotels")));
}
@Test
public void findByNameAndCountry() throws Exception {
void findByNameAndCountry() throws Exception {
this.mvc.perform(get(
"/api/cities/search/findByNameAndCountryAllIgnoringCase?name=Melbourne&country=Australia"))
.andExpect(status().isOk())
@@ -72,7 +69,7 @@ public class SampleDataRestApplicationTests {
}
@Test
public void findByContaining() throws Exception {
void findByContaining() throws Exception {
this.mvc.perform(get(
"/api/cities/search/findByNameContainingAndCountryContainingAllIgnoringCase?name=&country=UK"))
.andExpect(status().isOk())

View File

@@ -16,15 +16,13 @@
package sample.data.rest.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import sample.data.rest.domain.City;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@@ -34,21 +32,20 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oliver Gierke
* @author Andy Wilkinson
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class CityRepositoryIntegrationTests {
class CityRepositoryIntegrationTests {
@Autowired
CityRepository repository;
@Test
public void findsFirstPageOfCities() {
void findsFirstPageOfCities() {
Page<City> cities = this.repository.findAll(PageRequest.of(0, 10));
assertThat(cities.getTotalElements()).isGreaterThan(20L);
}
@Test
public void findByNameAndCountry() {
void findByNameAndCountry() {
City city = this.repository.findByNameAndCountryAllIgnoringCase("Melbourne",
"Australia");
assertThat(city).isNotNull();
@@ -56,7 +53,7 @@ public class CityRepositoryIntegrationTests {
}
@Test
public void findContaining() {
void findContaining() {
Page<City> cities = this.repository
.findByNameContainingAndCountryContainingAllIgnoringCase("", "UK",
PageRequest.of(0, 10));