This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch struts-2-4 in repository https://gitbox.apache.org/repos/asf/struts.git
commit 061337f253e8558238757352ad001c4099191fcc Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Sun Apr 15 21:08:45 2018 +0200 Fixes tests --- apps/blank/pom.xml | 9 +++ apps/jboss-blank/pom.xml | 9 +++ core/pom.xml | 75 +++++++++++++--------- .../apache/struts2/dispatcher/PostbackResult.java | 1 + .../dispatcher/ServletActionRedirectResult.java | 1 + .../struts2/dispatcher/StrutsResultSupport.java | 8 ++- core/src/site/resources/tags/ajax/a.html | 8 +++ .../site/resources/tags/ajax/autocompleter.html | 8 +++ .../site/resources/tags/ajax/datetimepicker.html | 8 +++ core/src/site/resources/tags/ajax/div.html | 8 +++ core/src/site/resources/tags/ajax/submit.html | 8 +++ core/src/site/resources/tags/ajax/tabbedpanel.html | 8 +++ core/src/site/resources/tags/ajax/textarea.html | 8 +++ core/src/site/resources/tags/ajax/tree.html | 8 +++ core/src/site/resources/tags/ajax/treenode.html | 8 +++ .../interceptor/FileUploadInterceptorTest.java | 5 +- plugins/dojo/pom.xml | 43 ++++--------- plugins/embeddedjsp/pom.xml | 21 ++++-- plugins/json/pom.xml | 5 ++ plugins/junit/pom.xml | 9 +++ plugins/pom.xml | 8 +++ .../result/PortletActionRedirectResult.java | 1 + plugins/rest/pom.xml | 6 ++ .../apache/struts2/rest/DefaultHttpHeaders.java | 3 + .../struts2/rest/DefaultHttpHeadersTest.java | 16 +++-- plugins/spring/pom.xml | 10 ++- .../apache/struts2/views/tiles/TilesResult.java | 1 + pom.xml | 4 +- 28 files changed, 234 insertions(+), 73 deletions(-) diff --git a/apps/blank/pom.xml b/apps/blank/pom.xml index f955a89..44453e7 100644 --- a/apps/blank/pom.xml +++ b/apps/blank/pom.xml @@ -57,6 +57,15 @@ <version>${log4j2.version}</version> </dependency> + <!-- The Servlet API mocks in Spring Framework 4.x only supports Servlet 3.0 and higher. + This is only necessary in tests--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>${project.groupId}</groupId> <artifactId>struts2-junit-plugin</artifactId> diff --git a/apps/jboss-blank/pom.xml b/apps/jboss-blank/pom.xml index 5568bc3..899730d 100644 --- a/apps/jboss-blank/pom.xml +++ b/apps/jboss-blank/pom.xml @@ -48,6 +48,15 @@ <version>2.0</version> <scope>provided</scope> </dependency> + <!-- The Servlet API mocks in Spring Framework 4.x only supports Servlet 3.0 and higher. + This is only necessary in tests--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>test</scope> + <optional>true</optional> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>struts2-junit-plugin</artifactId> diff --git a/core/pom.xml b/core/pom.xml index 68341f1..cbfa816 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -33,45 +33,62 @@ <name>Struts 2 Core</name> <properties> - <tlib.version>2.3</tlib.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> - <groupId>org.apache.myfaces.tobago</groupId> - <artifactId>maven-apt-plugin</artifactId> - <version>1.0.15</version> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> <configuration> - <A>uri=/struts-tags,tlibVersion=${tlib.version},jspVersion=2.0,shortName=s,displayName=Struts Tags, - outFile=${basedir}/target/classes/META-INF/struts-tags.tld, - description="To make it easier to access dynamic data; - the Apache Struts framework includes a library of custom tags. - The tags interact with the framework's validation and internationalization features; - to ensure that input is correct and output is localized. - The Struts Tags can be used with JSP FreeMarker or Velocity.", - outTemplatesDir=${basedir}/src/site/resources/tags - </A> - <resourceTargetPath>target</resourceTargetPath> - <fork>false</fork> - <force>true</force> - <nocompile>true</nocompile> - <showWarnings>true</showWarnings> - <factory>org.apache.struts.annotations.taglib.apt.TLDAnnotationProcessorFactory</factory> - <target>1.5</target> + <compilerArgs> + <arg>-Auri=/struts-tags</arg> + <arg>-AtlibVersion=${tlib.version}</arg> + <arg>-AjspVersion=2.0</arg> + <arg>-AshortName=s</arg> + <arg>-AdisplayName=Struts Tags</arg> + <arg>-AoutFile=${basedir}/target/classes/META-INF/struts-tags.tld</arg> + <arg>-Adescription="To make it easier to access dynamic data; + the Apache Struts framework includes a library of custom tags. + The tags interact with the framework's validation and + internationalization features; + to ensure that input is correct and output is localized. + The Struts Tags can be used with JSP FreeMarker or Velocity."</arg> + <arg>-AoutTemplatesDir=${basedir}/src/site/resources/tags</arg> + </compilerArgs> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <argLine>-Duser.language=en -Duser.region=US</argLine> + <properties> + <property> + <name>maven.testng.output.dir</name> + <value>${project.basedir}/target/surefire-reports</value> + </property> + </properties> + <useSystemClassLoader>false</useSystemClassLoader> + <additionalClasspathElements> + <element>${project.build.testOutputDirectory}/xwork-jar.jar</element> + <element>${project.build.testOutputDirectory}/xwork-zip.zip</element> + <element>${project.build.testOutputDirectory}/xwork - jar.jar</element> + <element>${project.build.testOutputDirectory}/xwork - zip.zip</element> + </additionalClasspathElements> <includes> - <include>**/*.java</include> + <include>**/*Test.java</include> </includes> + <excludes> + <exclude>**/XWorkTestCase.java</exclude> + <exclude>**/TestBean.java</exclude> + <exclude>**/TestBean2.java</exclude> + <exclude>**/TestInterceptor.java</exclude> + <exclude>**/AnnotatedTestBean.java</exclude> + <exclude>**/DefaultFileManagerTest.java</exclude> + </excludes> </configuration> - <executions> - <execution> - <phase>compile</phase> - <goals> - <goal>execute</goal> - </goals> - </execution> - </executions> </plugin> </plugins> </build> diff --git a/core/src/main/java/org/apache/struts2/dispatcher/PostbackResult.java b/core/src/main/java/org/apache/struts2/dispatcher/PostbackResult.java index 89e3400..fa65b01 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/PostbackResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/PostbackResult.java @@ -129,6 +129,7 @@ public class PostbackResult extends StrutsResultSupport { actionName = conditionalParse(actionName, invocation); if (namespace == null) { namespace = invocation.getProxy().getNamespace(); + parseLocation = false; } else { namespace = conditionalParse(namespace, invocation); } diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java b/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java index 5e0f835..ff8fbbf 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java @@ -166,6 +166,7 @@ public class ServletActionRedirectResult extends ServletRedirectResult implement actionName = conditionalParse(actionName, invocation); if (namespace == null) { namespace = invocation.getProxy().getNamespace(); + parseLocation = false; } else { namespace = conditionalParse(namespace, invocation); } diff --git a/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java b/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java index bbcffa3..362d69d 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java @@ -118,6 +118,8 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics { private String location; private String lastFinalLocation; + protected boolean parseLocation = true; + public StrutsResultSupport() { this(null, true, false); } @@ -187,7 +189,11 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics { * @throws Exception if an error occurs while executing the result. */ public void execute(ActionInvocation invocation) throws Exception { - lastFinalLocation = conditionalParse(location, invocation); + if (parseLocation) { + lastFinalLocation = conditionalParse(location, invocation); + } else { + lastFinalLocation = location; + } doExecute(lastFinalLocation, invocation); } diff --git a/core/src/site/resources/tags/ajax/a.html b/core/src/site/resources/tags/ajax/a.html index 6b1293d..6f4af2d 100644 --- a/core/src/site/resources/tags/ajax/a.html +++ b/core/src/site/resources/tags/ajax/a.html @@ -66,6 +66,14 @@ Please do not edit it directly. <td align="left" valign="top">Comma delimmited list of topics that will published before the request</td> </tr> <tr> + <td align="left" valign="top">class</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top"></td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td> + </tr> + <tr> <td align="left" valign="top">cssClass</td> <td align="left" valign="top">false</td> <td align="left" valign="top"></td> diff --git a/core/src/site/resources/tags/ajax/autocompleter.html b/core/src/site/resources/tags/ajax/autocompleter.html index 7f9c2a5..f63ee49 100644 --- a/core/src/site/resources/tags/ajax/autocompleter.html +++ b/core/src/site/resources/tags/ajax/autocompleter.html @@ -66,6 +66,14 @@ Please do not edit it directly. <td align="left" valign="top">Comma delimmited list of topics that will published before the request</td> </tr> <tr> + <td align="left" valign="top">class</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top"></td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td> + </tr> + <tr> <td align="left" valign="top">cssClass</td> <td align="left" valign="top">false</td> <td align="left" valign="top"></td> diff --git a/core/src/site/resources/tags/ajax/datetimepicker.html b/core/src/site/resources/tags/ajax/datetimepicker.html index 30c0817..6ff1b92 100644 --- a/core/src/site/resources/tags/ajax/datetimepicker.html +++ b/core/src/site/resources/tags/ajax/datetimepicker.html @@ -50,6 +50,14 @@ Please do not edit it directly. <td align="left" valign="top">If true, weekly size of calendar changes to acomodate the month if false, 42 day format is used</td> </tr> <tr> + <td align="left" valign="top">class</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top"></td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td> + </tr> + <tr> <td align="left" valign="top">cssClass</td> <td align="left" valign="top">false</td> <td align="left" valign="top"></td> diff --git a/core/src/site/resources/tags/ajax/div.html b/core/src/site/resources/tags/ajax/div.html index caa2a52..2936d34 100644 --- a/core/src/site/resources/tags/ajax/div.html +++ b/core/src/site/resources/tags/ajax/div.html @@ -66,6 +66,14 @@ Please do not edit it directly. <td align="left" valign="top">Comma delimmited list of topics that will published before the request</td> </tr> <tr> + <td align="left" valign="top">class</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top"></td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td> + </tr> + <tr> <td align="left" valign="top">closable</td> <td align="left" valign="top">false</td> <td align="left" valign="top">false</td> diff --git a/core/src/site/resources/tags/ajax/submit.html b/core/src/site/resources/tags/ajax/submit.html index 8f3f3d0..fab7f05 100644 --- a/core/src/site/resources/tags/ajax/submit.html +++ b/core/src/site/resources/tags/ajax/submit.html @@ -74,6 +74,14 @@ Please do not edit it directly. <td align="left" valign="top">Comma delimmited list of topics that will published before the request</td> </tr> <tr> + <td align="left" valign="top">class</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top"></td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td> + </tr> + <tr> <td align="left" valign="top">cssClass</td> <td align="left" valign="top">false</td> <td align="left" valign="top"></td> diff --git a/core/src/site/resources/tags/ajax/tabbedpanel.html b/core/src/site/resources/tags/ajax/tabbedpanel.html index 00817df..47ed9fd 100644 --- a/core/src/site/resources/tags/ajax/tabbedpanel.html +++ b/core/src/site/resources/tags/ajax/tabbedpanel.html @@ -58,6 +58,14 @@ Please do not edit it directly. <td align="left" valign="top">Comma separated list of topics to be published when a tab is clicked on (before it is selected)The tab container widget will be passed as the first argument to the topic. The second parameter is the tab widget.The event can be cancelled setting to 'true' the 'cancel' property of the third parameter passed to the topics.</td> </tr> <tr> + <td align="left" valign="top">class</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top"></td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td> + </tr> + <tr> <td align="left" valign="top">closeButton</td> <td align="left" valign="top">false</td> <td align="left" valign="top"></td> diff --git a/core/src/site/resources/tags/ajax/textarea.html b/core/src/site/resources/tags/ajax/textarea.html index edf8578..778165b 100644 --- a/core/src/site/resources/tags/ajax/textarea.html +++ b/core/src/site/resources/tags/ajax/textarea.html @@ -42,6 +42,14 @@ Please do not edit it directly. <td align="left" valign="top">Set the html accesskey attribute on rendered html element</td> </tr> <tr> + <td align="left" valign="top">class</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top"></td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td> + </tr> + <tr> <td align="left" valign="top">cols</td> <td align="left" valign="top">false</td> <td align="left" valign="top"></td> diff --git a/core/src/site/resources/tags/ajax/tree.html b/core/src/site/resources/tags/ajax/tree.html index c2d5ddc..ac86c26 100644 --- a/core/src/site/resources/tags/ajax/tree.html +++ b/core/src/site/resources/tags/ajax/tree.html @@ -58,6 +58,14 @@ Please do not edit it directly. <td align="left" valign="top">The childCollectionProperty property.</td> </tr> <tr> + <td align="left" valign="top">class</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top"></td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td> + </tr> + <tr> <td align="left" valign="top">collapsedNotifyTopics</td> <td align="left" valign="top">false</td> <td align="left" valign="top"></td> diff --git a/core/src/site/resources/tags/ajax/treenode.html b/core/src/site/resources/tags/ajax/treenode.html index 0daad28..b03346a 100644 --- a/core/src/site/resources/tags/ajax/treenode.html +++ b/core/src/site/resources/tags/ajax/treenode.html @@ -42,6 +42,14 @@ Please do not edit it directly. <td align="left" valign="top">Set the html accesskey attribute on rendered html element</td> </tr> <tr> + <td align="left" valign="top">class</td> + <td align="left" valign="top">false</td> + <td align="left" valign="top"></td> + <td align="left" valign="top">false</td> + <td align="left" valign="top">String</td> + <td align="left" valign="top">The css class to use for element - it's an alias of cssClass attribute.</td> + </tr> + <tr> <td align="left" valign="top">cssClass</td> <td align="left" valign="top">false</td> <td align="left" valign="top"></td> diff --git a/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java index 47ec711..4fe49db 100644 --- a/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java +++ b/core/src/test/java/org/apache/struts2/interceptor/FileUploadInterceptorTest.java @@ -40,6 +40,7 @@ import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URL; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -217,13 +218,13 @@ public class FileUploadInterceptorTest extends StrutsInternalTestCase { req.addHeader("Content-type", "multipart/form-data"); req.setContent(null); // there is no content - MyFileupAction action = container.inject(MyFileupAction.class); + MyFileupAction action = new MyFileupAction(); MockActionInvocation mai = new MockActionInvocation(); mai.setAction(action); mai.setResultCode("success"); mai.setInvocationContext(ActionContext.getContext()); - ActionContext.getContext().setParameters(HttpParameters.create().build()); + ActionContext.getContext().setParameters(Collections.<String, Object>emptyMap()); ActionContext.getContext().put(ServletActionContext.HTTP_REQUEST, createMultipartRequest(req, 2000)); interceptor.intercept(mai); diff --git a/plugins/dojo/pom.xml b/plugins/dojo/pom.xml index 0daaacf..41960b0 100644 --- a/plugins/dojo/pom.xml +++ b/plugins/dojo/pom.xml @@ -79,45 +79,26 @@ </profiles> <properties> - <tlib.version>2.2</tlib.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <build> <plugins> <plugin> - <groupId>org.apache.myfaces.tobago</groupId> - <artifactId>maven-apt-plugin</artifactId> - <version>1.0.15</version> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> <configuration> - <A> - uri=/struts-dojo-tags,tlibVersion=${tlib.version},jspVersion=2.0,shortName=sx, - displayName="Struts Dojo Tags", - outFile=${basedir}/target/classes/META-INF/struts-dojo-tags.tld, - description="Struts AJAX tags based on Dojo.", - outTemplatesDir=${basedir}/../../core/src/site/resources/tags/ajax - </A> - <resourceTargetPath>target</resourceTargetPath> - <fork>false</fork> - <force>true</force> - <nocompile>true</nocompile> - <showWarnings>true</showWarnings> - <factory> - org.apache.struts.annotations.taglib.apt.TLDAnnotationProcessorFactory - </factory> - <target>1.5</target> - <includes> - <include>**/*.java</include> - </includes> + <compilerArgs> + <arg>-Auri=/struts-tags</arg> + <arg>-AtlibVersion=${tlib.version}</arg> + <arg>-AjspVersion=2.0</arg> + <arg>-AshortName=sx</arg> + <arg>-AdisplayName=Struts Dojo Tags</arg> + <arg>-AoutFile=${basedir}/target/classes/META-INF/struts-dojo-tags.tld</arg> + <arg>-Adescription="Struts AJAX tags based on Dojo."</arg> + <arg>-AoutTemplatesDir=${basedir}/../../core/src/site/resources/tags/ajax</arg> + </compilerArgs> </configuration> - <executions> - <execution> - <phase>compile</phase> - <goals> - <goal>execute</goal> - </goals> - </execution> - </executions> </plugin> </plugins> </build> diff --git a/plugins/embeddedjsp/pom.xml b/plugins/embeddedjsp/pom.xml index c139966..769d01a 100644 --- a/plugins/embeddedjsp/pom.xml +++ b/plugins/embeddedjsp/pom.xml @@ -49,6 +49,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> <scope>test</scope> @@ -82,6 +87,15 @@ <artifactId>jasper</artifactId> <scope>provided</scope> </dependency> + + <!-- The Servlet API mocks in Spring Framework 4.x only supports Servlet 3.0 and higher. + This is only necessary in tests--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>test</scope> + </dependency> </dependencies> <build> @@ -89,17 +103,16 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.4.2</version> + <version>2.19.1</version> <configuration> <additionalClasspathElements> - <element>target/test-classes/jsps.jar</element> + <element>${project.build.testOutputDirectory}/jsps.jar</element> </additionalClasspathElements> - <forkMode>never</forkMode> </configuration> </plugin> </plugins> </build> <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> </project> diff --git a/plugins/json/pom.xml b/plugins/json/pom.xml index 21c2a6e..16c8957 100644 --- a/plugins/json/pom.xml +++ b/plugins/json/pom.xml @@ -90,6 +90,11 @@ <artifactId>spring-test</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <scope>test</scope> + </dependency> <dependency> <groupId>org.easytesting</groupId> diff --git a/plugins/junit/pom.xml b/plugins/junit/pom.xml index bc3ce93..1fce4f7 100644 --- a/plugins/junit/pom.xml +++ b/plugins/junit/pom.xml @@ -68,6 +68,15 @@ <scope>test</scope> </dependency> + <!-- The Servlet API mocks in Spring Framework 4.x only supports Servlet 3.0 and higher. + This is only necessary in tests--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>test</scope> + </dependency> + <!-- Portlet --> <dependency> <groupId>javax.portlet</groupId> diff --git a/plugins/pom.xml b/plugins/pom.xml index eb4c5ae..ecabe57 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -84,6 +84,14 @@ <scope>provided</scope> </dependency> + <!-- This is only necessary in tests--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>test</scope> + </dependency> + </dependencies> <properties> diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java index 04729c1..7fdb2c9 100644 --- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java +++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java @@ -181,6 +181,7 @@ public class PortletActionRedirectResult extends PortletResult { } if (namespace == null) { namespace = invocation.getProxy().getNamespace(); + parseLocation = false; } else { namespace = conditionalParse(namespace, invocation); } diff --git a/plugins/rest/pom.xml b/plugins/rest/pom.xml index 62caf8f..72e9e5c 100644 --- a/plugins/rest/pom.xml +++ b/plugins/rest/pom.xml @@ -77,6 +77,12 @@ <optional>true</optional> </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <scope>test</scope> + </dependency> + </dependencies> </project> diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/DefaultHttpHeaders.java b/plugins/rest/src/main/java/org/apache/struts2/rest/DefaultHttpHeaders.java index 506814e..59a6989 100644 --- a/plugins/rest/src/main/java/org/apache/struts2/rest/DefaultHttpHeaders.java +++ b/plugins/rest/src/main/java/org/apache/struts2/rest/DefaultHttpHeaders.java @@ -22,9 +22,12 @@ package org.apache.struts2.rest; import org.apache.struts2.RequestUtils; +import org.apache.struts2.util.DateFormatter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Date; import static javax.servlet.http.HttpServletResponse.*; diff --git a/plugins/rest/src/test/java/org/apache/struts2/rest/DefaultHttpHeadersTest.java b/plugins/rest/src/test/java/org/apache/struts2/rest/DefaultHttpHeadersTest.java index d80c33b..be7023e 100644 --- a/plugins/rest/src/test/java/org/apache/struts2/rest/DefaultHttpHeadersTest.java +++ b/plugins/rest/src/test/java/org/apache/struts2/rest/DefaultHttpHeadersTest.java @@ -18,7 +18,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.struts2.rest; import junit.framework.TestCase; @@ -36,19 +35,28 @@ import static javax.servlet.http.HttpServletResponse.SC_NOT_MODIFIED; import static javax.servlet.http.HttpServletResponse.SC_OK; public class DefaultHttpHeadersTest extends TestCase { + + private static final String DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz"; + private static final TimeZone GMT = TimeZone.getTimeZone("GMT"); + private MockHttpServletResponse mockResponse; private MockHttpServletRequest mockRequest; + private SimpleDateFormat dateFormat; @Override public void setUp() { mockResponse = new MockHttpServletResponse(); mockRequest = new MockHttpServletRequest(); + + dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.US); + dateFormat.setTimeZone(GMT); } @Override public void tearDown() { mockRequest = null; mockRequest = null; + dateFormat = null; } public void testApply() { @@ -63,9 +71,9 @@ public class DefaultHttpHeadersTest extends TestCase { headers.apply(mockRequest, mockResponse, new Object()); assertEquals(SC_CREATED, mockResponse.getStatus()); - assertEquals("http://localhost:80/foo/bar/44.xhtml", mockResponse.getHeader("Location")); + assertEquals("http://localhost/foo/bar/44.xhtml", mockResponse.getHeader("Location")); assertEquals("asdf", mockResponse.getHeader("ETag")); - assertEquals(now.getTime(), mockResponse.getHeader("Last-Modified")); + assertEquals(dateFormat.format(now), mockResponse.getHeader("Last-Modified")); } @@ -75,7 +83,7 @@ public class DefaultHttpHeadersTest extends TestCase { mockRequest.setRequestURI("/foo/bar"); headers.apply(mockRequest, mockResponse, new Object()); - assertEquals("http://localhost:80/foo/bar/44", mockResponse.getHeader("Location")); + assertEquals("http://localhost/foo/bar/44", mockResponse.getHeader("Location")); assertEquals(SC_CREATED, mockResponse.getStatus()); } diff --git a/plugins/spring/pom.xml b/plugins/spring/pom.xml index 50730a0..b175db0 100644 --- a/plugins/spring/pom.xml +++ b/plugins/spring/pom.xml @@ -71,7 +71,15 @@ <optional>true</optional> </dependency> - <dependency> + <!-- The Servlet API mocks in Spring Framework 4.x only supports Servlet 3.0 and higher. + This is only necessary in tests--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.easymock</groupId> <artifactId>easymock</artifactId> <scope>test</scope> diff --git a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java index e2a7dc7..5dcbf9c 100644 --- a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java +++ b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java @@ -119,6 +119,7 @@ public class TilesResult extends ServletDispatcherResult { LOG.debug("using new location name '{}' and @TilesDefinition '{}'", location, tilesDefinition); } setLocation(location); + setParse(false); ServletContext servletContext = ServletActionContext.getServletContext(); diff --git a/pom.xml b/pom.xml index a4254bf..5c0715a 100644 --- a/pom.xml +++ b/pom.xml @@ -81,6 +81,7 @@ <asm.version>5.2</asm.version> <tiles.version>2.2.2</tiles.version> <log4j2.version>2.11.0</log4j2.version> + <tlib.version>2.3</tlib.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> @@ -141,6 +142,7 @@ </includes> <excludes> <exclude>**/TestBean.java</exclude> + <exclude>**/Struts2PortletTest.java</exclude> </excludes> </configuration> </plugin> @@ -332,7 +334,7 @@ <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts-annotations</artifactId> - <version>1.0.5</version> + <version>1.0.6</version> </dependency> <dependency> -- To stop receiving notification emails like this one, please contact lukaszlen...@apache.org.