Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit 53afb4e

Browse files
committed
Add SPR-9329
1 parent e9d063f commit 53afb4e

File tree

9 files changed

+394
-0
lines changed

9 files changed

+394
-0
lines changed

SPR-9329/pom.xml

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.springframework.issues</groupId>
5+
<artifactId>SPR-9329</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>Spring MVC Issue Reproduction Project</name>
8+
<packaging>war</packaging>
9+
10+
<properties>
11+
<java-version>1.6</java-version>
12+
<org.springframework-version>3.2.0.BUILD-SNAPSHOT</org.springframework-version>
13+
<org.slf4j-version>1.6.1</org.slf4j-version>
14+
</properties>
15+
16+
<dependencies>
17+
<!-- Spring Framework -->
18+
<dependency>
19+
<groupId>org.springframework</groupId>
20+
<artifactId>spring-context</artifactId>
21+
<version>${org.springframework-version}</version>
22+
<exclusions>
23+
<!-- Exclude Commons Logging in favor of SLF4j -->
24+
<exclusion>
25+
<groupId>commons-logging</groupId>
26+
<artifactId>commons-logging</artifactId>
27+
</exclusion>
28+
</exclusions>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.springframework</groupId>
32+
<artifactId>spring-webmvc</artifactId>
33+
<version>${org.springframework-version}</version>
34+
</dependency>
35+
36+
<!-- CGLIB, required for @Configuration usage -->
37+
<dependency>
38+
<groupId>cglib</groupId>
39+
<artifactId>cglib-nodep</artifactId>
40+
<version>2.2</version>
41+
</dependency>
42+
43+
<!-- Logging -->
44+
<dependency>
45+
<groupId>org.slf4j</groupId>
46+
<artifactId>slf4j-api</artifactId>
47+
<version>${org.slf4j-version}</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.slf4j</groupId>
51+
<artifactId>jcl-over-slf4j</artifactId>
52+
<version>${org.slf4j-version}</version>
53+
<scope>runtime</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.slf4j</groupId>
57+
<artifactId>slf4j-log4j12</artifactId>
58+
<version>${org.slf4j-version}</version>
59+
<scope>runtime</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>log4j</groupId>
63+
<artifactId>log4j</artifactId>
64+
<version>1.2.16</version>
65+
<scope>runtime</scope>
66+
</dependency>
67+
68+
<!-- Servlet API -->
69+
<dependency>
70+
<groupId>javax.servlet</groupId>
71+
<artifactId>servlet-api</artifactId>
72+
<version>2.5</version>
73+
<scope>provided</scope>
74+
</dependency>
75+
76+
<!-- JSP API and JSTL
77+
<dependency>
78+
<groupId>javax.servlet.jsp</groupId>
79+
<artifactId>jsp-api</artifactId>
80+
<version>2.1</version>
81+
<scope>provided</scope>
82+
</dependency>
83+
<dependency>
84+
<groupId>javax.servlet</groupId>
85+
<artifactId>jstl</artifactId>
86+
<version>1.2</version>
87+
</dependency>
88+
-->
89+
90+
<!-- Apache Tiles
91+
<dependency>
92+
<groupId>org.apache.tiles</groupId>
93+
<artifactId>tiles-jsp</artifactId>
94+
<version>2.1.3</version>
95+
<exclusions>
96+
<exclusion>
97+
<groupId>commons-logging</groupId>
98+
<artifactId>commons-logging-api</artifactId>
99+
</exclusion>
100+
</exclusions>
101+
</dependency>
102+
-->
103+
104+
<!-- JSR 303 with Hibernate Validator
105+
<dependency>
106+
<groupId>javax.validation</groupId>
107+
<artifactId>validation-api</artifactId>
108+
<version>1.0.0.GA</version>
109+
</dependency>
110+
<dependency>
111+
<groupId>org.hibernate</groupId>
112+
<artifactId>hibernate-validator</artifactId>
113+
<version>4.1.0.Final</version>
114+
</dependency>
115+
-->
116+
117+
<!-- Joda Time Library
118+
<dependency>
119+
<groupId>joda-time</groupId>
120+
<artifactId>joda-time</artifactId>
121+
<version>1.6.2</version>
122+
</dependency>
123+
<dependency>
124+
<groupId>joda-time</groupId>
125+
<artifactId>joda-time-jsptags</artifactId>
126+
<version>1.0.2</version>
127+
<scope>runtime</scope>
128+
</dependency>
129+
-->
130+
131+
<!-- Apache Commons File Upload
132+
<dependency>
133+
<groupId>commons-fileupload</groupId>
134+
<artifactId>commons-fileupload</artifactId>
135+
<version>1.2.2</version>
136+
</dependency>
137+
<dependency>
138+
<groupId>commons-io</groupId>
139+
<artifactId>commons-io</artifactId>
140+
<version>2.0.1</version>
141+
</dependency>
142+
-->
143+
144+
<!-- Jackson JSON Processor
145+
<dependency>
146+
<groupId>org.codehaus.jackson</groupId>
147+
<artifactId>jackson-mapper-asl</artifactId>
148+
<version>1.8.1</version>
149+
</dependency>
150+
-->
151+
152+
<!-- Rome Atom+RSS
153+
<dependency>
154+
<groupId>rome</groupId>
155+
<artifactId>rome</artifactId>
156+
<version>1.0</version>
157+
</dependency>
158+
-->
159+
160+
<!-- Test -->
161+
<dependency>
162+
<groupId>junit</groupId>
163+
<artifactId>junit</artifactId>
164+
<version>4.8</version>
165+
<scope>test</scope>
166+
</dependency>
167+
168+
<dependency>
169+
<groupId>org.springframework</groupId>
170+
<artifactId>spring-test</artifactId>
171+
<version>${org.springframework-version}</version>
172+
</dependency>
173+
174+
</dependencies>
175+
176+
<repositories>
177+
<repository>
178+
<id>spring-maven-snapshot</id>
179+
<name>Springframework Maven Snapshot Repository</name>
180+
<url>http://repo.springsource.org/snapshot</url>
181+
<snapshots>
182+
<enabled>true</enabled>
183+
</snapshots>
184+
</repository>
185+
</repositories>
186+
187+
<build>
188+
<plugins>
189+
<plugin>
190+
<artifactId>maven-compiler-plugin</artifactId>
191+
<configuration>
192+
<source>${java-version}</source>
193+
<target>${java-version}</target>
194+
</configuration>
195+
</plugin>
196+
<plugin>
197+
<groupId>org.apache.maven.plugins</groupId>
198+
<artifactId>maven-dependency-plugin</artifactId>
199+
<executions>
200+
<execution>
201+
<id>install</id>
202+
<phase>install</phase>
203+
<goals>
204+
<goal>sources</goal>
205+
</goals>
206+
</execution>
207+
</executions>
208+
</plugin>
209+
<plugin>
210+
<groupId>org.apache.maven.plugins</groupId>
211+
<artifactId>maven-eclipse-plugin</artifactId>
212+
<version>2.8</version>
213+
<configuration>
214+
<downloadSources>true</downloadSources>
215+
<downloadJavadocs>false</downloadJavadocs>
216+
<wtpversion>2.0</wtpversion>
217+
</configuration>
218+
</plugin>
219+
<plugin>
220+
<artifactId>maven-surefire-plugin</artifactId>
221+
<configuration>
222+
<includes>
223+
<include>**/*Tests.java</include>
224+
</includes>
225+
<excludes>
226+
<exclude>**/*Abstract*.java</exclude>
227+
</excludes>
228+
</configuration>
229+
</plugin>
230+
</plugins>
231+
</build>
232+
233+
</project>
234+

SPR-9329/src/main/java/org/springframework/issues/.gitignore

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.springframework.issues.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.ComponentScan;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
7+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
8+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
9+
import org.springframework.web.servlet.view.InternalResourceViewResolver;
10+
11+
@EnableWebMvc
12+
@ComponentScan(basePackages="org.springframework.issues")
13+
@Configuration
14+
public class WebConfig extends WebMvcConfigurerAdapter {
15+
16+
@Override
17+
public void addViewControllers(ViewControllerRegistry registry) {
18+
registry.addViewController("/").setViewName("home");
19+
}
20+
21+
@Bean
22+
public InternalResourceViewResolver viewResolver() {
23+
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
24+
viewResolver.setPrefix("/WEB-INF/views/");
25+
viewResolver.setSuffix(".jsp");
26+
return viewResolver;
27+
}
28+
29+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
log4j.rootCategory=INFO, stdout
2+
3+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5+
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
6+
7+
log4j.category.org.springframework.web=DEBUG
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
2+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3+
<html>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6+
<title>Home</title>
7+
</head>
8+
<body>
9+
<h1>Home</h1>
10+
</body>
11+
</html>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
5+
6+
<context-param>
7+
<param-name>contextClass</param-name>
8+
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
9+
</context-param>
10+
11+
<context-param>
12+
<param-name>contextConfigLocation</param-name>
13+
<param-value>org.springframework.issues.config</param-value>
14+
</context-param>
15+
16+
<listener>
17+
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
18+
</listener>
19+
20+
<servlet>
21+
<servlet-name>appServlet</servlet-name>
22+
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
23+
<init-param>
24+
<param-name>contextConfigLocation</param-name>
25+
<param-value></param-value>
26+
</init-param>
27+
<load-on-startup>1</load-on-startup>
28+
</servlet>
29+
30+
<servlet-mapping>
31+
<servlet-name>appServlet</servlet-name>
32+
<url-pattern>/</url-pattern>
33+
</servlet-mapping>
34+
35+
<!-- Disables Servlet Container welcome file handling. Needed for compatibility
36+
with Servlet 3.0 and Tomcat 7.0 -->
37+
<welcome-file-list>
38+
<welcome-file></welcome-file>
39+
</welcome-file-list>
40+
41+
</web-app>

SPR-9329/src/test/java/org/springframework/issues/.gitignore

Whitespace-only changes.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2002-2012 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.issues;
18+
19+
import static org.junit.Assert.assertEquals;
20+
21+
import java.util.Arrays;
22+
import java.util.List;
23+
24+
import org.junit.Test;
25+
import org.springframework.core.MethodParameter;
26+
import org.springframework.http.HttpHeaders;
27+
import org.springframework.http.HttpStatus;
28+
import org.springframework.http.ResponseEntity;
29+
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
30+
import org.springframework.http.converter.HttpMessageConverter;
31+
import org.springframework.mock.web.MockHttpServletRequest;
32+
import org.springframework.mock.web.MockHttpServletResponse;
33+
import org.springframework.web.context.request.ServletWebRequest;
34+
import org.springframework.web.method.support.ModelAndViewContainer;
35+
import org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor;
36+
37+
public class ResponseEntityTests {
38+
39+
@Test
40+
public void addCacheControl() throws Exception {
41+
42+
HttpHeaders headers = new HttpHeaders();
43+
headers.setCacheControl("no-cache");
44+
ResponseEntity<Object> responseEntity = new ResponseEntity<Object>(headers, HttpStatus.OK);
45+
46+
MockHttpServletRequest request = new MockHttpServletRequest();
47+
request.addHeader("Cache-Control", "no-cache");
48+
49+
MockHttpServletResponse response = new MockHttpServletResponse();
50+
ServletWebRequest webRequest = new ServletWebRequest(request, response);
51+
52+
MethodParameter returnType = new MethodParameter(this.getClass().getMethod("handle"), -1);
53+
54+
List<HttpMessageConverter<?>> converters = Arrays.<HttpMessageConverter<?>>asList(new ByteArrayHttpMessageConverter());
55+
HttpEntityMethodProcessor processor = new HttpEntityMethodProcessor(converters);
56+
processor.handleReturnValue(responseEntity, returnType, new ModelAndViewContainer(), webRequest);
57+
58+
assertEquals("no-cache", response.getHeader("Cache-Control"));
59+
}
60+
61+
public ResponseEntity<Object> handle() {
62+
return null;
63+
}
64+
65+
}

0 commit comments

Comments
 (0)