Skip to content

Commit 9334740

Browse files
committed
Polishing
1 parent 4e8aebc commit 9334740

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,46 +17,39 @@
1717
package org.springframework.test.web.servlet.samples.spr;
1818

1919
import org.junit.jupiter.api.Test;
20-
import org.junit.jupiter.api.extension.ExtendWith;
2120

22-
import org.springframework.beans.factory.annotation.Autowired;
2321
import org.springframework.context.annotation.Configuration;
24-
import org.springframework.test.context.ContextConfiguration;
25-
import org.springframework.test.context.junit.jupiter.SpringExtension;
26-
import org.springframework.test.context.web.WebAppConfiguration;
22+
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
2723
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
2824
import org.springframework.web.context.WebApplicationContext;
2925
import org.springframework.web.filter.CharacterEncodingFilter;
3026
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
31-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
3227

28+
import static org.assertj.core.api.Assertions.assertThatNoException;
3329
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
3430

3531
/**
3632
* Test for SPR-10277 (multiple method chaining when building MockMvc).
3733
*
3834
* @author Wesley Hall
3935
*/
40-
@ExtendWith(SpringExtension.class)
41-
@WebAppConfiguration
42-
@ContextConfiguration
43-
public class MockMvcBuilderMethodChainTests {
44-
45-
@Autowired
46-
private WebApplicationContext wac;
36+
@SpringJUnitWebConfig
37+
class MockMvcBuilderMethodChainTests {
4738

4839
@Test
49-
public void chainMultiple() {
50-
MockMvcBuilders
40+
void chainMultiple(WebApplicationContext wac) {
41+
assertThatNoException().isThrownBy(() ->
42+
MockMvcBuilders
5143
.webAppContextSetup(wac)
5244
.addFilter(new CharacterEncodingFilter() )
5345
.defaultRequest(get("/").contextPath("/mywebapp"))
54-
.build();
46+
.build()
47+
);
5548
}
5649

5750
@Configuration
5851
@EnableWebMvc
59-
static class WebConfig implements WebMvcConfigurer {
52+
static class WebConfig {
6053
}
6154

6255
}

0 commit comments

Comments
 (0)