Switch to JUnit 5.

Issue #2075.
This commit is contained in:
Oliver Drotbohm
2021-10-12 22:14:05 +02:00
parent 3d03b0cbe6
commit 5f4e24b912
125 changed files with 1607 additions and 1554 deletions

View File

@@ -19,9 +19,9 @@ import static org.hamcrest.CoreMatchers.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
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.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -32,7 +32,7 @@ import org.springframework.hateoas.MediaTypes;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -45,10 +45,10 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
* @author Oliver Gierke
* @soundtrack Miles Davis - Blue in green (Kind of blue)
*/
@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@WebAppConfiguration
@ContextConfiguration
public class HalExplorerIntegrationTests {
class HalExplorerIntegrationTests {
static final String BASE_PATH = "/api";
static final String EXPLORER_INDEX = "/explorer/index.html";
@@ -69,14 +69,14 @@ public class HalExplorerIntegrationTests {
MockMvc mvc;
@Before
public void setUp() {
@BeforeEach
void setUp() {
this.mvc = MockMvcBuilders.webAppContextSetup(context).//
defaultRequest(get(BASE_PATH).accept(MediaType.TEXT_HTML)).build();
}
@Test // DATAREST-293
public void exposesJsonUnderApiRootByDefault() throws Exception {
void exposesJsonUnderApiRootByDefault() throws Exception {
mvc.perform(get(BASE_PATH).accept(MediaType.ALL)).//
andExpect(status().isOk()).//
@@ -84,7 +84,7 @@ public class HalExplorerIntegrationTests {
}
@Test // DATAREST-293
public void redirectsToBrowserForApiRootAndHtml() throws Exception {
void redirectsToBrowserForApiRootAndHtml() throws Exception {
mvc.perform(get(BASE_PATH).accept(MediaType.TEXT_HTML)).//
andExpect(status().isFound()).//
@@ -92,7 +92,7 @@ public class HalExplorerIntegrationTests {
}
@Test // DATAREST-293
public void forwardsBrowserToIndexHtml() throws Exception {
void forwardsBrowserToIndexHtml() throws Exception {
mvc.perform(get(BASE_PATH.concat("/explorer"))).//
andExpect(status().isFound()).//
@@ -100,7 +100,7 @@ public class HalExplorerIntegrationTests {
}
@Test // DATAREST-293
public void exposesHalBrowser() throws Exception {
void exposesHalBrowser() throws Exception {
mvc.perform(get(BASE_PATH.concat("/explorer/index.html"))).//
andExpect(status().isOk()).//
@@ -108,7 +108,7 @@ public class HalExplorerIntegrationTests {
}
@Test // DATAREST-293
public void retrunsApiIfHtmlIsNotExplicitlyListed() throws Exception {
void retrunsApiIfHtmlIsNotExplicitlyListed() throws Exception {
mvc.perform(get(BASE_PATH).accept(MediaType.APPLICATION_JSON, MediaType.ALL)).//
andExpect(status().isOk()).//

View File

@@ -23,8 +23,7 @@ import java.util.Collections;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -41,10 +40,10 @@ import org.springframework.web.util.UriComponentsBuilder;
* @author Mark Paluch
* @soundtrack Nils Wülker - Homeless Diamond (feat. Lauren Flynn)
*/
public class HalExplorerUnitTests {
class HalExplorerUnitTests {
@Test // DATAREST-565, DATAREST-720
public void createsContextRelativeRedirectForBrowser() throws Exception {
void createsContextRelativeRedirectForBrowser() throws Exception {
MockHttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest();
@@ -64,7 +63,7 @@ public class HalExplorerUnitTests {
}
@Test // DATAREST-1264
public void producesProxyRelativeRedirectIfNecessary() throws ServletException, IOException {
void producesProxyRelativeRedirectIfNecessary() throws ServletException, IOException {
MockHttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/explorer");