From 85e9b728fae0063e25999a740efebd2482b851c7 Mon Sep 17 00:00:00 2001 From: Fleur Kelpin Date: Fri, 2 Feb 2018 22:54:16 +0100 Subject: [PATCH] Add repro project for SPR-16461 --- SPR-16461/README.md | 37 +++ SPR-16461/pom.xml | 268 ++++++++++++++++++ .../issues/AnimalController.java | 26 ++ .../issues/config/WebConfig.java | 29 ++ .../springframework/issues/model/Animal.java | 16 ++ .../org/springframework/issues/model/Cat.java | 17 ++ SPR-16461/src/main/resources/log4j.properties | 7 + .../src/main/webapp/WEB-INF/views/home.jsp | 11 + SPR-16461/src/main/webapp/WEB-INF/web.xml | 41 +++ .../org/springframework/issues/.gitignore | 0 SPR-16461/src/test/resources/log4j.properties | 7 + 11 files changed, 459 insertions(+) create mode 100644 SPR-16461/README.md create mode 100644 SPR-16461/pom.xml create mode 100644 SPR-16461/src/main/java/org/springframework/issues/AnimalController.java create mode 100644 SPR-16461/src/main/java/org/springframework/issues/config/WebConfig.java create mode 100644 SPR-16461/src/main/java/org/springframework/issues/model/Animal.java create mode 100644 SPR-16461/src/main/java/org/springframework/issues/model/Cat.java create mode 100644 SPR-16461/src/main/resources/log4j.properties create mode 100644 SPR-16461/src/main/webapp/WEB-INF/views/home.jsp create mode 100644 SPR-16461/src/main/webapp/WEB-INF/web.xml create mode 100644 SPR-16461/src/test/java/org/springframework/issues/.gitignore create mode 100644 SPR-16461/src/test/resources/log4j.properties diff --git a/SPR-16461/README.md b/SPR-16461/README.md new file mode 100644 index 00000000..de678036 --- /dev/null +++ b/SPR-16461/README.md @@ -0,0 +1,37 @@ +## Spring MVC project with Java config + +This is a simple template for creating issue reproduction projects per +the [README in the root of this repository](https://github.com/spring-projects/spring-framework-issues#readme). +Please review that document before starting. + +As described at the link above, do not edit this project directly! Rather +use the `./create-repro-project.sh` script to create a fresh copy to +a new directory having the same name as the JIRA issue you're trying +to reproduce and edit from there. + +## Deploying + +It is possible to deploy your application directly from the command-line +using maven. See the next two sections on Cargo and Jetty. + +### Cargo + +You can deploy with the [Cargo Maven plugin](http://cargo.codehaus.org/) which +supports a wide [range of servers](http://cargo.codehaus.org/Containers). +The required command is `mvn package cargo:run`. + +By default Cargo is configured to start with `Tomcat 8` but you can easily +edit the plugin settings in `pom.xml` to switch to a different server +and version. The pom.xml or to switch to debug settings. + +### Jetty + +You can also deploy with the +[Jetty Maven plugin](http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html). +The required command is `mvn jetty:run` or `mvnDebug jetty:run`. + +## Logging + +This project contains a `log4j.properties` file in `src/main/resources` that you +may wish to configure to emit more detailed logging. The root logger is set to +`INFO` and a custom `org.springframework.web` logger is set to `DEBUG`. diff --git a/SPR-16461/pom.xml b/SPR-16461/pom.xml new file mode 100644 index 00000000..e1c38df4 --- /dev/null +++ b/SPR-16461/pom.xml @@ -0,0 +1,268 @@ + + 4.0.0 + org.springframework.issues + SPR-16461 + 1.0-SNAPSHOT + Spring MVC Issue Reproduction Project + war + + + UTF-8 + 1.6 + 4.3.5.RELEASE + 1.7.22 + 8.5.9 + + + + + + org.springframework + spring-context + ${spring.version} + + + + commons-logging + commons-logging + + + + + org.springframework + spring-webmvc + ${spring.version} + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + runtime + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + runtime + + + log4j + log4j + 1.2.17 + runtime + + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + + + + + + + + + + + + + + + com.google.code.gson + gson + 2.6 + + + + + + + junit + junit + 4.12 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + install + install + + sources + + + + + + org.apache.maven.plugins + maven-eclipse-plugin + 2.8 + + true + false + 2.0 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12.4 + + + **/*Tests.java + **/*Test.java + + + **/*Abstract*.java + + + + + org.eclipse.jetty + jetty-maven-plugin + 9.3.3.v20150827 + + + org.codehaus.cargo + cargo-maven2-plugin + 1.6.2 + + + + 8080 + medium + -Xms96m -Xmx512m -Djava.awt.headless=true + + + + + tomcat8x + + http://archive.apache.org/dist/tomcat/tomcat-8/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip + + + + + + + + + + spring-maven-snapshot + Springframework Maven Snapshot Repository + http://repo.spring.io/snapshot + + true + + + + + + diff --git a/SPR-16461/src/main/java/org/springframework/issues/AnimalController.java b/SPR-16461/src/main/java/org/springframework/issues/AnimalController.java new file mode 100644 index 00000000..ec2d9c85 --- /dev/null +++ b/SPR-16461/src/main/java/org/springframework/issues/AnimalController.java @@ -0,0 +1,26 @@ +package org.springframework.issues; + +import org.springframework.issues.model.Animal; +import org.springframework.issues.model.Cat; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.web.bind.annotation.RequestMethod.GET; + +@RestController +public class AnimalController +{ + private final Cat bizzy = new Cat("Bizzy", 10); + + @RequestMapping(method = GET, value = "/animal") + public Animal getAnimal() + { + return bizzy; + } + + @RequestMapping(method = GET, value = "/cat") + public Cat getCat() + { + return bizzy; + } +} diff --git a/SPR-16461/src/main/java/org/springframework/issues/config/WebConfig.java b/SPR-16461/src/main/java/org/springframework/issues/config/WebConfig.java new file mode 100644 index 00000000..26caad3b --- /dev/null +++ b/SPR-16461/src/main/java/org/springframework/issues/config/WebConfig.java @@ -0,0 +1,29 @@ +package org.springframework.issues.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.view.InternalResourceViewResolver; + +@EnableWebMvc +@ComponentScan(basePackages="org.springframework.issues") +@Configuration +public class WebConfig extends WebMvcConfigurerAdapter { + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/").setViewName("home"); + } + + @Bean + public InternalResourceViewResolver viewResolver() { + InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); + viewResolver.setPrefix("/WEB-INF/views/"); + viewResolver.setSuffix(".jsp"); + return viewResolver; + } + +} diff --git a/SPR-16461/src/main/java/org/springframework/issues/model/Animal.java b/SPR-16461/src/main/java/org/springframework/issues/model/Animal.java new file mode 100644 index 00000000..1d52368d --- /dev/null +++ b/SPR-16461/src/main/java/org/springframework/issues/model/Animal.java @@ -0,0 +1,16 @@ +package org.springframework.issues.model; + +public class Animal +{ + private final String name; + + public Animal(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } +} diff --git a/SPR-16461/src/main/java/org/springframework/issues/model/Cat.java b/SPR-16461/src/main/java/org/springframework/issues/model/Cat.java new file mode 100644 index 00000000..71399410 --- /dev/null +++ b/SPR-16461/src/main/java/org/springframework/issues/model/Cat.java @@ -0,0 +1,17 @@ +package org.springframework.issues.model; + +public class Cat extends Animal +{ + private final int whiskers; + + public Cat(String name, int whiskers) + { + super(name); + this.whiskers = whiskers; + } + + public int getWhiskers() + { + return whiskers; + } +} diff --git a/SPR-16461/src/main/resources/log4j.properties b/SPR-16461/src/main/resources/log4j.properties new file mode 100644 index 00000000..17a835fa --- /dev/null +++ b/SPR-16461/src/main/resources/log4j.properties @@ -0,0 +1,7 @@ +log4j.rootCategory=INFO, stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n + +log4j.category.org.springframework.web=DEBUG diff --git a/SPR-16461/src/main/webapp/WEB-INF/views/home.jsp b/SPR-16461/src/main/webapp/WEB-INF/views/home.jsp new file mode 100644 index 00000000..1696c2dd --- /dev/null +++ b/SPR-16461/src/main/webapp/WEB-INF/views/home.jsp @@ -0,0 +1,11 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> + + + + +Home + + +

Home

+ + diff --git a/SPR-16461/src/main/webapp/WEB-INF/web.xml b/SPR-16461/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..d612c693 --- /dev/null +++ b/SPR-16461/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.springframework.issues.config + + + + org.springframework.web.context.ContextLoaderListener + + + + appServlet + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + + + 1 + + + + appServlet + / + + + + + + + + diff --git a/SPR-16461/src/test/java/org/springframework/issues/.gitignore b/SPR-16461/src/test/java/org/springframework/issues/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/SPR-16461/src/test/resources/log4j.properties b/SPR-16461/src/test/resources/log4j.properties new file mode 100644 index 00000000..17a835fa --- /dev/null +++ b/SPR-16461/src/test/resources/log4j.properties @@ -0,0 +1,7 @@ +log4j.rootCategory=INFO, stdout + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n + +log4j.category.org.springframework.web=DEBUG