diff --git a/apps/rest-showcase/pom.xml b/apps/rest-showcase/pom.xml index 17f9c4a195..6dcd20c3ea 100644 --- a/apps/rest-showcase/pom.xml +++ b/apps/rest-showcase/pom.xml @@ -56,12 +56,10 @@ org.apache.logging.log4j log4j-api - ${log4j2.version} org.apache.logging.log4j log4j-core - ${log4j2.version} diff --git a/apps/showcase/pom.xml b/apps/showcase/pom.xml index 1a04728ce1..0287d6cb5f 100644 --- a/apps/showcase/pom.xml +++ b/apps/showcase/pom.xml @@ -108,22 +108,18 @@ org.apache.logging.log4j log4j-api - ${log4j2.version} org.apache.logging.log4j log4j-core - ${log4j2.version} org.apache.logging.log4j log4j-jcl - ${log4j2.version} org.apache.logging.log4j log4j-slf4j-impl - ${log4j2.version} @@ -134,10 +130,6 @@ org.directwebremoting dwr - - commons-fileupload - commons-fileupload - junit diff --git a/core/pom.xml b/core/pom.xml index 59f0d43fdf..3a10ed47d0 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -260,7 +260,6 @@ org.apache.logging.log4j log4j-core - ${log4j2.version} test diff --git a/plugins/bean-validation/pom.xml b/plugins/bean-validation/pom.xml index cf6df5c6af..499b06c027 100644 --- a/plugins/bean-validation/pom.xml +++ b/plugins/bean-validation/pom.xml @@ -55,17 +55,6 @@ javax.el test - - org.mockito - mockito-core - test - - - - org.objenesis - objenesis - 3.2 - - - javax.portlet - portlet-api - compile - true - - - - org.apache.struts - struts2-portlet-plugin - true - - - org.apache.struts - struts2-portlet-mocks-plugin - true + org.apache.commons + commons-compress + 1.23.0 + test diff --git a/plugins/junit/src/test/java/org/apache/struts2/junit/StrutsTestCaseTest.java b/plugins/junit/src/test/java/org/apache/struts2/junit/StrutsTestCaseTest.java index d2b042e8af..1de57bb043 100644 --- a/plugins/junit/src/test/java/org/apache/struts2/junit/StrutsTestCaseTest.java +++ b/plugins/junit/src/test/java/org/apache/struts2/junit/StrutsTestCaseTest.java @@ -19,13 +19,9 @@ package org.apache.struts2.junit; import com.opensymphony.xwork2.Action; -import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionProxy; -import org.apache.struts2.StrutsStatics; import org.apache.struts2.dispatcher.mapper.ActionMapping; -import org.junit.Test; -import javax.portlet.PortletContext; import javax.servlet.ServletException; import java.io.UnsupportedEncodingException; @@ -64,38 +60,4 @@ public void testGetValueFromStack() throws ServletException, UnsupportedEncoding String name = (String) findValueAfterExecute("name"); assertEquals("FD", name); } - - @Test - public void shouldPortletContextBeAvailable() throws Exception { - // given - assertNull(ActionContext.getContext().get(StrutsStatics.STRUTS_PORTLET_CONTEXT)); - - // when - String output = executeAction("/test/testAction.action"); - assertEquals("Hello", output); - - // then - Object portletContext = ActionContext.getContext().get(StrutsStatics.STRUTS_PORTLET_CONTEXT); - assertNotNull(portletContext); - assertTrue(portletContext instanceof PortletContext); - } - - @Test - public void shouldAdditionalContextParamsBeAvailable() throws Exception { - // given - String key = "my-param"; - assertNull(ActionContext.getContext().get(key)); - - // when - String output = executeAction("/test/testAction.action"); - assertEquals("Hello", output); - - // then - assertNotNull(ActionContext.getContext().get(key)); - } - - @Override - protected void applyAdditionalParams(ActionContext context) { - context.put("my-param", new Object()); - } } diff --git a/plugins/osgi/pom.xml b/plugins/osgi/pom.xml index 67cff36449..37ac0bd3c3 100644 --- a/plugins/osgi/pom.xml +++ b/plugins/osgi/pom.xml @@ -84,11 +84,6 @@ struts2-velocity-plugin - - org.apache.commons - commons-lang3 - - commons-digester commons-digester @@ -105,14 +100,6 @@ spring-test test - - - org.apache.logging.log4j - log4j-core - ${log4j2.version} - test - - UTF-8 diff --git a/plugins/oval/pom.xml b/plugins/oval/pom.xml index 1993a5397b..d2044105d1 100644 --- a/plugins/oval/pom.xml +++ b/plugins/oval/pom.xml @@ -49,11 +49,6 @@ xstream - - org.apache.commons - commons-lang3 - - javax.persistence persistence-api diff --git a/plugins/pom.xml b/plugins/pom.xml index 6376d4a454..267985dbe6 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -50,6 +50,7 @@ pell-multipart plexus portlet + portlet-junit portlet-mocks portlet-tiles rest @@ -66,6 +67,7 @@ org.apache.struts struts2-core + provided @@ -74,7 +76,23 @@ junit test + + org.mockito + mockito-core + test + + + org.apache.logging.log4j + log4j-core + test + + + + javax.servlet.jsp + jsp-api + provided + javax.servlet javax.servlet-api diff --git a/plugins/portlet-junit/README.md b/plugins/portlet-junit/README.md new file mode 100644 index 0000000000..db36979ba0 --- /dev/null +++ b/plugins/portlet-junit/README.md @@ -0,0 +1,2 @@ +# Struts 2 Portlet JUnit plugin +The Portlet JUnit Plugin supports testing applications that use the Portlet Plugin. diff --git a/plugins/portlet-junit/pom.xml b/plugins/portlet-junit/pom.xml new file mode 100644 index 0000000000..639986ceeb --- /dev/null +++ b/plugins/portlet-junit/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.apache.struts + struts2-plugins + 6.3.0-SNAPSHOT + + + struts2-portlet-junit-plugin + jar + DEPRECATED: Struts 2 Portlet JUnit Plugin - since 6.3.0 + + + + org.apache.struts + struts2-junit-plugin + + + junit + junit + + + + org.apache.struts + struts2-portlet-plugin + provided + + + org.apache.struts + struts2-portlet-mocks-plugin + + + + + UTF-8 + + diff --git a/plugins/junit/src/main/java/org/apache/struts2/junit/StrutsPortletTestCase.java b/plugins/portlet-junit/src/main/java/org/apache/struts2/junit/StrutsPortletTestCase.java similarity index 82% rename from plugins/junit/src/main/java/org/apache/struts2/junit/StrutsPortletTestCase.java rename to plugins/portlet-junit/src/main/java/org/apache/struts2/junit/StrutsPortletTestCase.java index de7d8da917..ad6fbeefae 100644 --- a/plugins/junit/src/main/java/org/apache/struts2/junit/StrutsPortletTestCase.java +++ b/plugins/portlet-junit/src/main/java/org/apache/struts2/junit/StrutsPortletTestCase.java @@ -35,19 +35,6 @@ import java.util.HashMap; import java.util.Map; -/* - * Changes: This is a copy of org.apache.struts2.StrutsPortletTestCase from the Struts 2 portlet-plugin, moved - * into the junit-plugin (same package org.apache.struts2). - * The import order above was changed to alphabetical. - * - * Note: The assumption is that anyone utilizing StrutsPortletTestCase currently from the portlet-plugin will almost - * certainly be using the junit-plugin. Under that assumption, the refactored-move of StrutsPortletTestCase - * should not cause issues for pre-existing usage of StrutsPortletTestCase. - */ - -/** - * Base class used to test action in portlet environment - */ public abstract class StrutsPortletTestCase extends StrutsTestCase { private static final Logger LOG = LogManager.getLogger(StrutsPortletTestCase.class); @@ -95,7 +82,7 @@ protected int getMajorVersion() { * @return Map with session parameters */ private Map createSession() { - return new HashMap(portletRequest.getPortletSession().getAttributeMap()); + return new HashMap<>(portletRequest.getPortletSession().getAttributeMap()); } } diff --git a/plugins/portlet-junit/src/site/site.xml b/plugins/portlet-junit/src/site/site.xml new file mode 100644 index 0000000000..54fdcf4f47 --- /dev/null +++ b/plugins/portlet-junit/src/site/site.xml @@ -0,0 +1,56 @@ + + + + + org.apache.maven.skins + maven-fluido-skin + ${fluido-skin.version} + + + Apache Software Foundation + http://www.apache.org/images/asf-logo.gif + http://www.apache.org/ + + + Apache Struts + http://struts.apache.org/img/struts-logo.svg + http://struts.apache.org/ + + + + + + + + + + + + +
+ + Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project + logos are trademarks of The Apache Software Foundation. + ]]> +
+ + diff --git a/plugins/portlet-junit/src/test/java/org/apache/struts2/junit/StrutsPortletTestCaseTest.java b/plugins/portlet-junit/src/test/java/org/apache/struts2/junit/StrutsPortletTestCaseTest.java new file mode 100644 index 0000000000..22c92a0e0d --- /dev/null +++ b/plugins/portlet-junit/src/test/java/org/apache/struts2/junit/StrutsPortletTestCaseTest.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.junit; + +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionProxy; +import org.apache.struts2.StrutsStatics; + +import javax.portlet.PortletContext; + +public class StrutsPortletTestCaseTest extends StrutsPortletTestCase { + + String KEY = "my-param"; + + public void testShouldPortletContextBeAvailable() throws Exception { + // given + assertNull(ActionContext.getContext().get(StrutsStatics.STRUTS_PORTLET_CONTEXT)); + + // when + ActionProxy proxy = getActionProxy("/test/testAction.action"); + String result = proxy.execute(); + + // then + assertEquals(Action.SUCCESS, result); + Object portletContext = ActionContext.getContext().get(StrutsStatics.STRUTS_PORTLET_CONTEXT); + assertNotNull(portletContext); + assertTrue(portletContext instanceof PortletContext); + } + + public void testShouldAdditionalContextParamsBeAvailable() throws Exception { + // given + assertNull(ActionContext.getContext().get(KEY)); + + // when + ActionProxy proxy = getActionProxy("/test/testAction.action"); + String result = proxy.execute(); + + // then + assertEquals(Action.SUCCESS, result); + assertNotNull(ActionContext.getContext().get(KEY)); + } + + @Override + protected void applyAdditionalParams(ActionContext context) { + context.put(KEY, new Object()); + } +} diff --git a/plugins/portlet-junit/src/test/resources/struts.xml b/plugins/portlet-junit/src/test/resources/struts.xml new file mode 100644 index 0000000000..e8c59512c3 --- /dev/null +++ b/plugins/portlet-junit/src/test/resources/struts.xml @@ -0,0 +1,34 @@ + + + + + + + + + 200 + + + + diff --git a/plugins/portlet-tiles/pom.xml b/plugins/portlet-tiles/pom.xml index 7caba14429..3c266ea831 100644 --- a/plugins/portlet-tiles/pom.xml +++ b/plugins/portlet-tiles/pom.xml @@ -40,11 +40,6 @@ org.apache.struts struts2-portlet-plugin - - javax.servlet.jsp - jsp-api - provided - javax.portlet portlet-api diff --git a/plugins/portlet/pom.xml b/plugins/portlet/pom.xml index 3d15c4e698..bffaac236b 100644 --- a/plugins/portlet/pom.xml +++ b/plugins/portlet/pom.xml @@ -32,13 +32,10 @@ DEPRECATED: Struts 2 Portlet Plugin - since 6.0.0 - - org.apache.struts struts2-portlet-mocks-plugin test - true @@ -46,12 +43,6 @@ struts2-velocity-plugin - - junit - junit - true - - @@ -60,22 +51,10 @@ true - - javax.servlet.jsp - jsp-api - provided - - - - org.apache.commons - commons-lang3 - - javax.portlet portlet-api - provided @@ -116,29 +95,15 @@ test - - org.apache.logging.log4j - log4j-core - ${log4j2.version} - test - - org.springframework spring-test true - - - commons-fileupload - commons-fileupload - test - - 4.3.30.RELEASE UTF-8 diff --git a/plugins/spring/pom.xml b/plugins/spring/pom.xml index 6809e46186..021c9f8626 100644 --- a/plugins/spring/pom.xml +++ b/plugins/spring/pom.xml @@ -70,11 +70,6 @@ test - - org.apache.commons - commons-lang3 - - org.apache.commons commons-jci-fam diff --git a/plugins/testng/pom.xml b/plugins/testng/pom.xml index 7ca5b08466..79e7ed31fe 100644 --- a/plugins/testng/pom.xml +++ b/plugins/testng/pom.xml @@ -44,12 +44,6 @@ org.springframework spring-core - - - javax.servlet.jsp - jsp-api - provided - diff --git a/plugins/tiles/pom.xml b/plugins/tiles/pom.xml index 9716e71980..cbd9f27e79 100644 --- a/plugins/tiles/pom.xml +++ b/plugins/tiles/pom.xml @@ -75,11 +75,6 @@ javax.el true - - javax.servlet.jsp - jsp-api - provided - org.apache.velocity velocity-engine-core diff --git a/plugins/velocity/pom.xml b/plugins/velocity/pom.xml index 09fc32d3c1..a3ec0ac3ae 100644 --- a/plugins/velocity/pom.xml +++ b/plugins/velocity/pom.xml @@ -50,18 +50,14 @@ - javax.servlet - javax.servlet-api - - - - javax.servlet.jsp - jsp-api + mockobjects + mockobjects-core + test - mockobjects - mockobjects-core + org.apache.struts + struts2-junit-plugin test diff --git a/plugins/xslt/pom.xml b/plugins/xslt/pom.xml index 61771261bb..12f2177895 100644 --- a/plugins/xslt/pom.xml +++ b/plugins/xslt/pom.xml @@ -35,11 +35,7 @@ org.apache.struts struts2-junit-plugin - - - javax.servlet.jsp - jsp-api - provided + test org.springframework diff --git a/pom.xml b/pom.xml index fb2759965a..e650eb27f7 100644 --- a/pom.xml +++ b/pom.xml @@ -1000,15 +1000,6 @@ org.mockito mockito-core 4.3.1 - - - - org.objenesis - objenesis - - test @@ -1035,12 +1026,21 @@ log4j-api ${log4j2.version} - + + org.apache.logging.log4j + log4j-core + ${log4j2.version} + org.apache.logging.log4j log4j-jcl ${log4j2.version} + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j2.version} + org.testng