Skip to content

Commit

Permalink
Merge pull request apache#732 from apache/WW-5334-fix-cyclic
Browse files Browse the repository at this point in the history
WW-5334 Enable usage of junit-plugin inside velocity-plugin
  • Loading branch information
lukaszlenart authored Aug 19, 2023
2 parents 44f0a1b + 8248017 commit ea124a4
Show file tree
Hide file tree
Showing 31 changed files with 254 additions and 261 deletions.
2 changes: 0 additions & 2 deletions apps/rest-showcase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>

<dependency>
Expand Down
8 changes: 0 additions & 8 deletions apps/showcase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,18 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j2.version}</version>
</dependency>

<dependency>
Expand All @@ -134,10 +130,6 @@
<groupId>org.directwebremoting</groupId>
<artifactId>dwr</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down
1 change: 0 additions & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
<scope>test</scope>
</dependency>

Expand Down
11 changes: 0 additions & 11 deletions plugins/bean-validation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@
<artifactId>javax.el</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<!-- this library is excluded in the parent pom as it clashes with Easymock dependencies -->
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>3.2</version>
</dependency>

<!--
The Java EE API modules listed below are all marked @Deprecated(forRemoval=true), because they are scheduled
Expand Down
7 changes: 0 additions & 7 deletions plugins/cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
Expand Down
9 changes: 0 additions & 9 deletions plugins/convention/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
</build>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
Expand All @@ -68,11 +64,6 @@
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<properties>
Expand Down
9 changes: 0 additions & 9 deletions plugins/embeddedjsp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
<name>DEPRECATED: Struts 2 Embedded JSP Plugin, since 6.0.0</name>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-velocity-plugin</artifactId>
Expand Down Expand Up @@ -65,11 +61,6 @@
<artifactId>request</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-juli</artifactId>
Expand Down
9 changes: 0 additions & 9 deletions plugins/jasperreports/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
<name>Struts 2 Jasper Reports Plugin</name>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
Expand All @@ -62,11 +58,6 @@
<artifactId>struts2-junit-plugin</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
Expand Down
8 changes: 0 additions & 8 deletions plugins/javatemplates/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@
<name>Struts 2 Java Templates Plugin</name>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Expand Down
5 changes: 0 additions & 5 deletions plugins/jfreechart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@
<artifactId>struts2-junit-plugin</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Expand Down
16 changes: 0 additions & 16 deletions plugins/json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>

<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Expand Down
5 changes: 1 addition & 4 deletions plugins/junit/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Struts 2 JFreeChart plugin
# Struts 2 JUnit plugin
The JUnit Plugin supports testing actions within a Struts invocation, meaning that a full request is simulated,
and the output of the action can be tested.
You will find more details in [documentation](https://struts.apache.org/plugins/junit/).

## Installation
Just drop this plugin JAR into `WEB-INF/lib` folder or add it as a Maven dependency.
26 changes: 4 additions & 22 deletions plugins/junit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
<artifactId>struts2-spring-plugin</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -66,24 +61,11 @@
<scope>test</scope>
</dependency>

<!-- Portlet -->
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet-plugin</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet-mocks-plugin</artifactId>
<optional>true</optional>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.23.0</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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());
}
}
13 changes: 0 additions & 13 deletions plugins/osgi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@
<artifactId>struts2-velocity-plugin</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
Expand All @@ -105,14 +100,6 @@
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
<scope>test</scope>
</dependency>

</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
5 changes: 0 additions & 5 deletions plugins/oval/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
<artifactId>xstream</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
Expand Down
18 changes: 18 additions & 0 deletions plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<module>pell-multipart</module>
<module>plexus</module>
<module>portlet</module>
<module>portlet-junit</module>
<module>portlet-mocks</module>
<module>portlet-tiles</module>
<module>rest</module>
Expand All @@ -66,6 +67,7 @@
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test dependencies -->
Expand All @@ -74,7 +76,23 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions plugins/portlet-junit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Struts 2 Portlet JUnit plugin
The Portlet JUnit Plugin supports testing applications that use the Portlet Plugin.
Loading

0 comments on commit ea124a4

Please sign in to comment.