1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
32
32
import org .junit .jupiter .api .AfterAll ;
33
33
import org .junit .jupiter .api .BeforeAll ;
34
34
import org .junit .jupiter .api .Test ;
35
+ import org .junit .jupiter .api .TestInstance ;
36
+ import org .junit .jupiter .api .TestInstance .Lifecycle ;
35
37
36
38
import org .springframework .core .io .ClassPathResource ;
37
39
import org .springframework .core .io .Resource ;
38
- import org .springframework .http .MediaType ;
39
40
import org .springframework .http .client .HttpComponentsClientHttpRequestFactory ;
40
41
import org .springframework .util .LinkedMultiValueMap ;
41
42
import org .springframework .util .MultiValueMap ;
48
49
* @author Brian Clozel
49
50
* @author Sam Brannen
50
51
*/
51
- public class WebRequestDataBinderIntegrationTests {
52
+ @ TestInstance (Lifecycle .PER_CLASS )
53
+ class WebRequestDataBinderIntegrationTests {
52
54
53
- private static Server jettyServer ;
55
+ private final PartsServlet partsServlet = new PartsServlet () ;
54
56
55
- private static final PartsServlet partsServlet = new PartsServlet ();
56
-
57
- private static final PartListServlet partListServlet = new PartListServlet ();
57
+ private final PartListServlet partListServlet = new PartListServlet ();
58
58
59
59
private final RestTemplate template = new RestTemplate (new HttpComponentsClientHttpRequestFactory ());
60
60
61
- protected static String baseUrl ;
61
+ private Server jettyServer ;
62
62
63
- protected static MediaType contentType ;
63
+ private String baseUrl ;
64
64
65
65
66
66
@ BeforeAll
67
- public static void startJettyServer () throws Exception {
67
+ void startJettyServer () throws Exception {
68
68
// Let server pick its own random, available port.
69
69
jettyServer = new Server (0 );
70
70
@@ -89,15 +89,15 @@ public static void startJettyServer() throws Exception {
89
89
}
90
90
91
91
@ AfterAll
92
- public static void stopJettyServer () throws Exception {
92
+ void stopJettyServer () throws Exception {
93
93
if (jettyServer != null ) {
94
94
jettyServer .stop ();
95
95
}
96
96
}
97
97
98
98
99
99
@ Test
100
- public void partsBinding () {
100
+ void partsBinding () {
101
101
PartsBean bean = new PartsBean ();
102
102
partsServlet .setBean (bean );
103
103
@@ -113,7 +113,7 @@ public void partsBinding() {
113
113
}
114
114
115
115
@ Test
116
- public void partListBinding () {
116
+ void partListBinding () {
117
117
PartListBean bean = new PartListBean ();
118
118
partListServlet .setBean (bean );
119
119
@@ -143,17 +143,17 @@ public void service(HttpServletRequest request, HttpServletResponse response) {
143
143
response .setStatus (HttpServletResponse .SC_OK );
144
144
}
145
145
146
- public void setBean (T bean ) {
146
+ void setBean (T bean ) {
147
147
this .bean = bean ;
148
148
}
149
149
}
150
150
151
151
152
152
private static class PartsBean {
153
153
154
- public Part firstPart ;
154
+ private Part firstPart ;
155
155
156
- public Part secondPart ;
156
+ private Part secondPart ;
157
157
158
158
public Part getFirstPart () {
159
159
return firstPart ;
@@ -182,7 +182,7 @@ private static class PartsServlet extends AbstractStandardMultipartServlet<Parts
182
182
183
183
private static class PartListBean {
184
184
185
- public List <Part > partList ;
185
+ private List <Part > partList ;
186
186
187
187
public List <Part > getPartList () {
188
188
return partList ;
0 commit comments