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