Skip to content

Commit c20a43f

Browse files
committed
Polish WebRequestDataBinderIntegrationTests
1 parent e0fa58a commit c20a43f

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderIntegrationTests.java

Lines changed: 17 additions & 17 deletions
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-2021 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.
@@ -32,10 +32,11 @@
3232
import org.junit.jupiter.api.AfterAll;
3333
import org.junit.jupiter.api.BeforeAll;
3434
import org.junit.jupiter.api.Test;
35+
import org.junit.jupiter.api.TestInstance;
36+
import org.junit.jupiter.api.TestInstance.Lifecycle;
3537

3638
import org.springframework.core.io.ClassPathResource;
3739
import org.springframework.core.io.Resource;
38-
import org.springframework.http.MediaType;
3940
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
4041
import org.springframework.util.LinkedMultiValueMap;
4142
import org.springframework.util.MultiValueMap;
@@ -48,23 +49,22 @@
4849
* @author Brian Clozel
4950
* @author Sam Brannen
5051
*/
51-
public class WebRequestDataBinderIntegrationTests {
52+
@TestInstance(Lifecycle.PER_CLASS)
53+
class WebRequestDataBinderIntegrationTests {
5254

53-
private static Server jettyServer;
55+
private final PartsServlet partsServlet = new PartsServlet();
5456

55-
private static final PartsServlet partsServlet = new PartsServlet();
56-
57-
private static final PartListServlet partListServlet = new PartListServlet();
57+
private final PartListServlet partListServlet = new PartListServlet();
5858

5959
private final RestTemplate template = new RestTemplate(new HttpComponentsClientHttpRequestFactory());
6060

61-
protected static String baseUrl;
61+
private Server jettyServer;
6262

63-
protected static MediaType contentType;
63+
private String baseUrl;
6464

6565

6666
@BeforeAll
67-
public static void startJettyServer() throws Exception {
67+
void startJettyServer() throws Exception {
6868
// Let server pick its own random, available port.
6969
jettyServer = new Server(0);
7070

@@ -89,15 +89,15 @@ public static void startJettyServer() throws Exception {
8989
}
9090

9191
@AfterAll
92-
public static void stopJettyServer() throws Exception {
92+
void stopJettyServer() throws Exception {
9393
if (jettyServer != null) {
9494
jettyServer.stop();
9595
}
9696
}
9797

9898

9999
@Test
100-
public void partsBinding() {
100+
void partsBinding() {
101101
PartsBean bean = new PartsBean();
102102
partsServlet.setBean(bean);
103103

@@ -113,7 +113,7 @@ public void partsBinding() {
113113
}
114114

115115
@Test
116-
public void partListBinding() {
116+
void partListBinding() {
117117
PartListBean bean = new PartListBean();
118118
partListServlet.setBean(bean);
119119

@@ -143,17 +143,17 @@ public void service(HttpServletRequest request, HttpServletResponse response) {
143143
response.setStatus(HttpServletResponse.SC_OK);
144144
}
145145

146-
public void setBean(T bean) {
146+
void setBean(T bean) {
147147
this.bean = bean;
148148
}
149149
}
150150

151151

152152
private static class PartsBean {
153153

154-
public Part firstPart;
154+
private Part firstPart;
155155

156-
public Part secondPart;
156+
private Part secondPart;
157157

158158
public Part getFirstPart() {
159159
return firstPart;
@@ -182,7 +182,7 @@ private static class PartsServlet extends AbstractStandardMultipartServlet<Parts
182182

183183
private static class PartListBean {
184184

185-
public List<Part> partList;
185+
private List<Part> partList;
186186

187187
public List<Part> getPartList() {
188188
return partList;

0 commit comments

Comments
 (0)