WW-5334 Extract Portlet test case into own module

This commit is contained in:
Kusal Kithul-Godage
2023-08-18 22:07:03 +10:00
parent 110ef71eb7
commit d47538c7db
7 changed files with 121 additions and 35 deletions
-20
View File
@@ -65,26 +65,6 @@
<artifactId>struts2-convention-plugin</artifactId>
<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>
</dependency>
</dependencies>
<properties>
+1
View File
@@ -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>
+5
View File
@@ -0,0 +1,5 @@
# Struts 2 Portlet JUnit plugin
The Portlet JUnit Plugin supports testing applications that use the Portlet Plugin.
## Installation
Just drop this plugin JAR into `WEB-INF/lib` folder or add it as a Maven dependency.
+58
View File
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* 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.
*/
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-plugins</artifactId>
<version>6.3.0-SNAPSHOT</version>
</parent>
<artifactId>struts2-portlet-junit-plugin</artifactId>
<packaging>jar</packaging>
<name>DEPRECATED: Struts 2 Portlet JUnit Plugin - since 6.4.0</name>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-junit-plugin</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet-plugin</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet-mocks-plugin</artifactId>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
@@ -35,19 +35,6 @@ import javax.portlet.PortletMode;
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 @@ public abstract class StrutsPortletTestCase extends StrutsTestCase {
* @return Map with session parameters
*/
private Map<String, Object> createSession() {
return new HashMap<String, Object>(portletRequest.getPortletSession().getAttributeMap());
return new HashMap<>(portletRequest.getPortletSession().getAttributeMap());
}
}
+56
View File
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/*
* 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.
*/
-->
<project name="Apache Struts">
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>${fluido-skin.version}</version>
</skin>
<bannerLeft>
<name>Apache Software Foundation</name>
<src>http://www.apache.org/images/asf-logo.gif</src>
<href>http://www.apache.org/</href>
</bannerLeft>
<bannerRight>
<name>Apache Struts</name>
<src>http://struts.apache.org/img/struts-logo.svg</src>
<href>http://struts.apache.org/</href>
</bannerRight>
<publishDate position="left"/>
<version position="right"/>
<body>
<links>
<item name="Apache" href="http://www.apache.org/"/>
<item name="Struts" href="http://struts.apache.org/"/>
</links>
<menu ref="parent"/>
<menu ref="reports"/>
<footer>
<![CDATA[<div class="row span12">
Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project
logos are trademarks of The Apache Software Foundation.
</div>]]>
</footer>
</body>
</project>
-1
View File
@@ -66,7 +66,6 @@
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>