Skip to content

Commit ef9027e

Browse files
committed
Polishing
1 parent b8d2a16 commit ef9027e

File tree

8 files changed

+28
-47
lines changed

8 files changed

+28
-47
lines changed

spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ public MultiValueMap<String, String> getQueryParams() {
255255
// Encoding
256256

257257
HierarchicalUriComponents encodeTemplate(Charset charset) {
258-
259258
if (this.encodeState.isEncoded()) {
260259
return this;
261260
}

spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,25 +325,22 @@ public static UriComponentsBuilder fromOriginHeader(String origin) {
325325
}
326326

327327

328-
// encode methods
328+
// Encode methods
329329

330330
/**
331331
* Request to have the URI template encoded first at build time, and
332332
* URI variables encoded later when expanded.
333-
*
334333
* <p>In comparison to {@link UriComponents#encode()}, this method has the
335334
* same effect on the URI template, i.e. each URI component is encoded by
336335
* quoting <em>only</em> illegal characters within that URI component type.
337336
* However URI variables are encoded more strictly, by quoting both illegal
338337
* characters and characters with reserved meaning.
339-
*
340338
* <p>For most cases, prefer this method over {@link UriComponents#encode()}
341339
* which is useful only if intentionally expanding variables with reserved
342340
* characters. For example ';' is legal in a path, but also has reserved
343341
* meaning as a separator. When expanding a variable that contains ';' it
344342
* probably should be encoded, unless the intent is to insert path params
345343
* through the expanded variable.
346-
*
347344
* @since 5.0.8
348345
*/
349346
public final UriComponentsBuilder encode() {
@@ -362,7 +359,7 @@ public UriComponentsBuilder encode(Charset charset) {
362359
}
363360

364361

365-
// build methods
362+
// Build methods
366363

367364
/**
368365
* Build a {@code UriComponents} instance from the various components contained in this builder.
@@ -387,8 +384,7 @@ public UriComponents build(boolean encoded) {
387384
HierarchicalUriComponents uriComponents =
388385
new HierarchicalUriComponents(this.scheme, this.fragment, this.userInfo,
389386
this.host, this.port, this.pathBuilder.build(), this.queryParams, encoded);
390-
391-
return this.encodeTemplate ? uriComponents.encodeTemplate(this.charset) : uriComponents;
387+
return (this.encodeTemplate ? uriComponents.encodeTemplate(this.charset) : uriComponents);
392388
}
393389
}
394390

spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverterTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
6262

6363

6464
@Before
65-
public void setUp() {
65+
public void setup() {
6666
converter = new Jaxb2CollectionHttpMessageConverter<Collection<Object>>();
6767
rootElementListType = new ParameterizedTypeReference<List<RootElement>>() {}.getType();
6868
rootElementSetType = new ParameterizedTypeReference<Set<RootElement>>() {}.getType();
@@ -72,7 +72,7 @@ public void setUp() {
7272

7373

7474
@Test
75-
public void canRead() throws Exception {
75+
public void canRead() {
7676
assertTrue(converter.canRead(rootElementListType, null, null));
7777
assertTrue(converter.canRead(rootElementSetType, null, null));
7878
assertTrue(converter.canRead(typeSetType, null, null));

spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -16,13 +16,7 @@
1616

1717
package org.springframework.http.converter.xml;
1818

19-
import static org.junit.Assert.*;
20-
import static org.xmlunit.diff.ComparisonType.*;
21-
import static org.xmlunit.diff.DifferenceEvaluators.*;
22-
import static org.xmlunit.matchers.CompareMatcher.*;
23-
2419
import java.nio.charset.StandardCharsets;
25-
2620
import javax.xml.bind.Marshaller;
2721
import javax.xml.bind.Unmarshaller;
2822
import javax.xml.bind.annotation.XmlAttribute;
@@ -48,6 +42,11 @@
4842
import org.springframework.http.MockHttpOutputMessage;
4943
import org.springframework.http.converter.HttpMessageNotReadableException;
5044

45+
import static org.junit.Assert.*;
46+
import static org.xmlunit.diff.ComparisonType.*;
47+
import static org.xmlunit.diff.DifferenceEvaluators.*;
48+
import static org.xmlunit.matchers.CompareMatcher.*;
49+
5150
/**
5251
* Tests for {@link Jaxb2RootElementHttpMessageConverter}.
5352
*
@@ -68,7 +67,7 @@ public class Jaxb2RootElementHttpMessageConverterTests {
6867

6968

7069
@Before
71-
public void setUp() {
70+
public void setup() {
7271
converter = new Jaxb2RootElementHttpMessageConverter();
7372
rootElement = new RootElement();
7473
DefaultAopProxyFactory proxyFactory = new DefaultAopProxyFactory();
@@ -81,15 +80,15 @@ public void setUp() {
8180

8281

8382
@Test
84-
public void canRead() throws Exception {
83+
public void canRead() {
8584
assertTrue("Converter does not support reading @XmlRootElement",
8685
converter.canRead(RootElement.class, null));
8786
assertTrue("Converter does not support reading @XmlType",
8887
converter.canRead(Type.class, null));
8988
}
9089

9190
@Test
92-
public void canWrite() throws Exception {
91+
public void canWrite() {
9392
assertTrue("Converter does not support writing @XmlRootElement",
9493
converter.canWrite(RootElement.class, null));
9594
assertTrue("Converter does not support writing @XmlRootElement subclass",

spring-web/src/test/java/org/springframework/http/converter/xml/MarshallingHttpMessageConverterTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
public class MarshallingHttpMessageConverterTests {
4444

4545
@Test
46-
public void canRead() throws Exception {
46+
public void canRead() {
4747
Unmarshaller unmarshaller = mock(Unmarshaller.class);
4848

4949
given(unmarshaller.supports(Integer.class)).willReturn(false);
@@ -58,7 +58,7 @@ public void canRead() throws Exception {
5858
}
5959

6060
@Test
61-
public void canWrite() throws Exception {
61+
public void canWrite() {
6262
Marshaller marshaller = mock(Marshaller.class);
6363

6464
given(marshaller.supports(Integer.class)).willReturn(false);
@@ -136,8 +136,8 @@ public void write() throws Exception {
136136
MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter(marshaller);
137137
converter.write(body, null, outputMessage);
138138

139-
assertEquals("Invalid content-type", new MediaType("application", "xml"), outputMessage.getHeaders()
140-
.getContentType());
139+
assertEquals("Invalid content-type", new MediaType("application", "xml"),
140+
outputMessage.getHeaders().getContentType());
141141
}
142142

143143
@Test

spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -48,13 +48,8 @@
4848
import org.springframework.http.converter.HttpMessageNotReadableException;
4949
import org.springframework.util.FileCopyUtils;
5050

51-
import static org.junit.Assert.assertEquals;
52-
import static org.junit.Assert.assertNotEquals;
53-
import static org.junit.Assert.assertThat;
54-
import static org.junit.Assert.assertTrue;
55-
import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
56-
57-
// Do NOT statically import org.junit.Assert.*, since XMLAssert extends junit.framework.Assert
51+
import static org.junit.Assert.*;
52+
import static org.xmlunit.matchers.CompareMatcher.*;
5853

5954
/**
6055
* @author Arjen Poutsma
@@ -73,7 +68,7 @@ public class SourceHttpMessageConverterTests {
7368

7469

7570
@Before
76-
public void setUp() throws IOException {
71+
public void setup() throws IOException {
7772
converter = new SourceHttpMessageConverter<>();
7873
Resource external = new ClassPathResource("external.txt", getClass());
7974

@@ -163,7 +158,7 @@ public void readSAXSourceExternal() throws Exception {
163158
XMLReader reader = result.getXMLReader();
164159
reader.setContentHandler(new DefaultHandler() {
165160
@Override
166-
public void characters(char[] ch, int start, int length) throws SAXException {
161+
public void characters(char[] ch, int start, int length) {
167162
String s = new String(ch, start, length);
168163
assertNotEquals("Invalid result", "Foo Bar", s);
169164
}

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.List;
3030
import java.util.Map;
3131
import java.util.concurrent.TimeUnit;
32-
3332
import javax.servlet.http.Cookie;
3433
import javax.servlet.http.HttpServletRequest;
3534
import javax.servlet.http.HttpServletResponse;
@@ -86,13 +85,7 @@
8685
import org.springframework.web.servlet.ModelAndView;
8786
import org.springframework.web.util.UriComponentsBuilder;
8887

89-
import static org.junit.Assert.assertEquals;
90-
import static org.junit.Assert.assertFalse;
91-
import static org.junit.Assert.assertNotNull;
92-
import static org.junit.Assert.assertNull;
93-
import static org.junit.Assert.assertSame;
94-
import static org.junit.Assert.assertThat;
95-
import static org.junit.Assert.assertTrue;
88+
import static org.junit.Assert.*;
9689

9790
/**
9891
* A test fixture with a controller with all supported method signature styles
@@ -378,7 +371,7 @@ public String handle(
378371
User user,
379372
@ModelAttribute OtherUser otherUser,
380373
Model model,
381-
UriComponentsBuilder builder) throws Exception {
374+
UriComponentsBuilder builder) {
382375

383376
model.addAttribute("cookie", cookie).addAttribute("pathvar", pathvar).addAttribute("header", header)
384377
.addAttribute("systemHeader", systemHeader).addAttribute("headerMap", headerMap)
@@ -404,7 +397,7 @@ public String handleRequestBody(@RequestBody byte[] bytes) throws Exception {
404397

405398
@ResponseStatus(code = HttpStatus.ACCEPTED)
406399
@ResponseBody
407-
public String handleAndValidateRequestBody(@Valid TestBean modelAttr, Errors errors) throws Exception {
400+
public String handleAndValidateRequestBody(@Valid TestBean modelAttr, Errors errors) {
408401
return "Error count [" + errors.getErrorCount() + "]";
409402
}
410403

@@ -453,7 +446,7 @@ public void validate(@Nullable Object target, Errors errors) {
453446
private static class ColorArgumentResolver implements WebArgumentResolver {
454447

455448
@Override
456-
public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) throws Exception {
449+
public Object resolveArgument(MethodParameter methodParameter, NativeWebRequest webRequest) {
457450
return new Color(0);
458451
}
459452
}

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
import org.springframework.web.servlet.FlashMap;
5555
import org.springframework.web.servlet.ModelAndView;
5656

57-
import static org.junit.Assert.assertEquals;
58-
import static org.junit.Assert.assertTrue;
57+
import static org.junit.Assert.*;
5958

6059
/**
6160
* Unit tests for {@link RequestMappingHandlerAdapter}.

0 commit comments

Comments
 (0)