Skip to content

Commit e9d24d5

Browse files
committed
Polishing
(cherry picked from commit 86b8112)
1 parent 4a27a98 commit e9d24d5

File tree

4 files changed

+28
-25
lines changed

4 files changed

+28
-25
lines changed

spring-web/src/main/java/org/springframework/http/client/ClientHttpRequest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -23,10 +23,11 @@
2323
import org.springframework.http.HttpRequest;
2424

2525
/**
26-
* Represents a client-side HTTP request. Created via an implementation of the {@link ClientHttpRequestFactory}.
26+
* Represents a client-side HTTP request.
27+
* Created via an implementation of the {@link ClientHttpRequestFactory}.
2728
*
28-
* <p>A {@code ClientHttpRequest} can be {@linkplain #execute() executed}, getting a
29-
* {@link ClientHttpResponse} which can be read from.
29+
* <p>A {@code ClientHttpRequest} can be {@linkplain #execute() executed},
30+
* receiving a {@link ClientHttpResponse} which can be read from.
3031
*
3132
* @author Arjen Poutsma
3233
* @since 3.0

spring-web/src/main/java/org/springframework/http/client/ClientHttpResponse.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -23,10 +23,11 @@
2323
import org.springframework.http.HttpStatus;
2424

2525
/**
26-
* Represents a client-side HTTP response. Obtained via an calling of the {@link ClientHttpRequest#execute()}.
26+
* Represents a client-side HTTP response.
27+
* Obtained via an calling of the {@link ClientHttpRequest#execute()}.
2728
*
28-
* <p>A {@code ClientHttpResponse} must be {@linkplain #close() closed}, typically in a
29-
* {@code finally} block.
29+
* <p>A {@code ClientHttpResponse} must be {@linkplain #close() closed},
30+
* typically in a {@code finally} block.
3031
*
3132
* @author Arjen Poutsma
3233
* @since 3.0
@@ -55,7 +56,7 @@ public interface ClientHttpResponse extends HttpInputMessage, Closeable {
5556
String getStatusText() throws IOException;
5657

5758
/**
58-
* Closes this response, freeing any resources created.
59+
* Close this response, freeing any resources created.
5960
*/
6061
@Override
6162
void close();

spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void setUp() throws Exception {
7373

7474
// final Template expectedTemplate = new Template();
7575
fc = new FreeMarkerConfigurer();
76-
fc.setTemplateLoaderPaths(new String[] { "classpath:/", "file://" + System.getProperty("java.io.tmpdir") });
76+
fc.setTemplateLoaderPaths("classpath:/", "file://" + System.getProperty("java.io.tmpdir"));
7777
fc.afterPropertiesSet();
7878

7979
wac.getDefaultListableBeanFactory().registerSingleton("freeMarkerConfigurer", fc);
@@ -86,6 +86,7 @@ public void setUp() throws Exception {
8686
response = new MockHttpServletResponse();
8787
}
8888

89+
8990
@Test
9091
public void testExposeSpringMacroHelpers() throws Exception {
9192
FreeMarkerView fv = new FreeMarkerView() {
@@ -128,7 +129,8 @@ protected void processTemplate(Template template, SimpleHash model, HttpServletR
128129

129130
try {
130131
fv.render(model, request, response);
131-
} catch (Exception ex) {
132+
}
133+
catch (Exception ex) {
132134
assertTrue(ex instanceof ServletException);
133135
assertTrue(ex.getMessage().contains(FreeMarkerView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE));
134136
}

spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerViewTests.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -23,10 +23,14 @@
2323
import java.util.HashMap;
2424
import java.util.Locale;
2525
import java.util.Map;
26-
2726
import javax.servlet.http.HttpServletResponse;
2827

28+
import freemarker.ext.servlet.AllHttpScopesHashModel;
29+
import freemarker.template.Configuration;
30+
import freemarker.template.Template;
31+
import freemarker.template.TemplateException;
2932
import org.junit.Test;
33+
3034
import org.springframework.context.ApplicationContextException;
3135
import org.springframework.mock.web.test.MockHttpServletRequest;
3236
import org.springframework.mock.web.test.MockHttpServletResponse;
@@ -40,11 +44,6 @@
4044
import org.springframework.web.servlet.view.InternalResourceView;
4145
import org.springframework.web.servlet.view.RedirectView;
4246

43-
import freemarker.ext.servlet.AllHttpScopesHashModel;
44-
import freemarker.template.Configuration;
45-
import freemarker.template.Template;
46-
import freemarker.template.TemplateException;
47-
4847
import static org.junit.Assert.*;
4948
import static org.mockito.BDDMockito.*;
5049

@@ -70,7 +69,7 @@ public void testNoFreeMarkerConfig() throws Exception {
7069
}
7170
catch (ApplicationContextException ex) {
7271
// Check there's a helpful error message
73-
assertTrue(ex.getMessage().indexOf("FreeMarkerConfig") != -1);
72+
assertTrue(ex.getMessage().contains("FreeMarkerConfig"));
7473
}
7574
}
7675

@@ -83,7 +82,7 @@ public void testNoTemplateName() throws Exception {
8382
}
8483
catch (IllegalArgumentException ex) {
8584
// Check there's a helpful error message
86-
assertTrue(ex.getMessage().indexOf("url") != -1);
85+
assertTrue(ex.getMessage().contains("url"));
8786
}
8887
}
8988

@@ -94,7 +93,7 @@ public void testValidTemplateName() throws Exception {
9493
WebApplicationContext wac = mock(WebApplicationContext.class);
9594
MockServletContext sc = new MockServletContext();
9695

97-
Map configs = new HashMap();
96+
Map<String, FreeMarkerConfig> configs = new HashMap<String, FreeMarkerConfig>();
9897
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
9998
configurer.setConfiguration(new TestConfiguration());
10099
configs.put("configurer", configurer);
@@ -110,7 +109,7 @@ public void testValidTemplateName() throws Exception {
110109
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
111110
HttpServletResponse response = new MockHttpServletResponse();
112111

113-
Map model = new HashMap();
112+
Map<String, Object> model = new HashMap<String, Object>();
114113
model.put("myattr", "myvalue");
115114
fv.render(model, request, response);
116115

@@ -124,7 +123,7 @@ public void testKeepExistingContentType() throws Exception {
124123
WebApplicationContext wac = mock(WebApplicationContext.class);
125124
MockServletContext sc = new MockServletContext();
126125

127-
Map configs = new HashMap();
126+
Map<String, FreeMarkerConfig> configs = new HashMap<String, FreeMarkerConfig>();
128127
FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
129128
configurer.setConfiguration(new TestConfiguration());
130129
configs.put("configurer", configurer);
@@ -141,7 +140,7 @@ public void testKeepExistingContentType() throws Exception {
141140
HttpServletResponse response = new MockHttpServletResponse();
142141
response.setContentType("myContentType");
143142

144-
Map model = new HashMap();
143+
Map<String, Object> model = new HashMap<String, Object>();
145144
model.put("myattr", "myvalue");
146145
fv.render(model, request, response);
147146

@@ -185,7 +184,7 @@ private class TestConfiguration extends Configuration {
185184
@Override
186185
public Template getTemplate(String name, final Locale locale) throws IOException {
187186
if (name.equals("templateName") || name.equals("prefix_test_suffix")) {
188-
return new Template(name, new StringReader("test")) {
187+
return new Template(name, new StringReader("test"), this) {
189188
@Override
190189
public void process(Object model, Writer writer) throws TemplateException, IOException {
191190
assertEquals(Locale.US, locale);

0 commit comments

Comments
 (0)