|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
|
* Copyright 2002-2022 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -17,19 +17,15 @@
@@ -17,19 +17,15 @@
|
|
|
|
|
package org.springframework.test.web.servlet.samples.spr; |
|
|
|
|
|
|
|
|
|
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.Configuration; |
|
|
|
|
import org.springframework.test.context.ContextConfiguration; |
|
|
|
|
import org.springframework.test.context.junit.jupiter.SpringExtension; |
|
|
|
|
import org.springframework.test.context.web.WebAppConfiguration; |
|
|
|
|
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig; |
|
|
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|
|
|
|
import org.springframework.web.context.WebApplicationContext; |
|
|
|
|
import org.springframework.web.filter.CharacterEncodingFilter; |
|
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc; |
|
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatNoException; |
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -37,26 +33,23 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
@@ -37,26 +33,23 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|
|
|
|
* |
|
|
|
|
* @author Wesley Hall |
|
|
|
|
*/ |
|
|
|
|
@ExtendWith(SpringExtension.class) |
|
|
|
|
@WebAppConfiguration |
|
|
|
|
@ContextConfiguration |
|
|
|
|
public class MockMvcBuilderMethodChainTests { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private WebApplicationContext wac; |
|
|
|
|
@SpringJUnitWebConfig |
|
|
|
|
class MockMvcBuilderMethodChainTests { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void chainMultiple() { |
|
|
|
|
MockMvcBuilders |
|
|
|
|
void chainMultiple(WebApplicationContext wac) { |
|
|
|
|
assertThatNoException().isThrownBy(() -> |
|
|
|
|
MockMvcBuilders |
|
|
|
|
.webAppContextSetup(wac) |
|
|
|
|
.addFilter(new CharacterEncodingFilter() ) |
|
|
|
|
.defaultRequest(get("/").contextPath("/mywebapp")) |
|
|
|
|
.build(); |
|
|
|
|
.build() |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
|
@EnableWebMvc |
|
|
|
|
static class WebConfig implements WebMvcConfigurer { |
|
|
|
|
static class WebConfig { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|