Skip to content

Commit

Permalink
PLUTO-686: TCK: Contesting tests that invoke portletConfig.getContain…
Browse files Browse the repository at this point in the history
…erRuntimeOptions (code review)
  • Loading branch information
ngriffin7a committed Jan 30, 2018
1 parent a7eeb6f commit c573052
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 60 deletions.
67 changes: 24 additions & 43 deletions portlet-tck_3.0/V2PortletTests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>prepare-package</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy file="${basedir}/${portlet.descriptor.dir}/portlet.xml"
tofile="${project.build.directory}/${project.build.finalName}/WEB-INF/portlet.xml" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -121,9 +139,10 @@
<profile>
<id>pluto</id>
<properties>
<expected.number>2</expected.number>
<expected.size>2</expected.size>
<expected.option>javax.portlet.servletDefaultSessionScope</expected.option>
<expected.portlet.value>PORTLET_SCOPE</expected.portlet.value>
<expected.value>PORTLET_SCOPE</expected.value>
<portlet.descriptor.dir>src/main/webapp/WEB-INF/pluto</portlet.descriptor.dir>
</properties>
<dependencies>
<dependency>
Expand All @@ -146,49 +165,11 @@
<profile>
<id>liferay</id>
<properties>
<expected.number>1</expected.number>
<expected.size>1</expected.size>
<expected.option>javax.portlet.escapeXml</expected.option>
<expected.portlet.value>true</expected.portlet.value>
<expected.value>true</expected.value>
<portlet.descriptor.dir>src/main/webapp/WEB-INF/liferay</portlet.descriptor.dir>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>prepare-package</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy file="${basedir}/src/main/webapp/WEB-INF/portlet.xml"
tofile="${basedir}/src/main/webapp/WEB-INF/portlet.tmp" />
<copy file="${basedir}/src/main/resources/xml-resources/liferay/portlet.xml"
tofile="${basedir}/src/main/webapp/WEB-INF/portlet.xml"
overwrite="true" />
</target>
</configuration>
</execution>
<execution>
<id>package</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<move file="${basedir}/src/main/webapp/WEB-INF/portlet.tmp"
tofile="${basedir}/src/main/webapp/WEB-INF/portlet.xml"
overwrite="true" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ public void render(RenderRequest portletReq, RenderResponse portletResp)
* different containers expect different options
*/
PortletContext portletContext = portletConfig.getPortletContext();
String expectedNumber = portletContext.getInitParameter("tck.EXPECTED_NUMBER");
String expectedOption = portletContext.getInitParameter("tck.EXPECTED_OPTION");
String expectedPortletValue = portletContext.getInitParameter("tck.EXPECTED_PORTLET_VALUE");
String expectedSize = portletContext.getInitParameter("javax.portlet.portletConfig.getContainerRuntimeOptions.EXPECTED_SIZE");
String expectedOption = portletContext.getInitParameter("javax.portlet.portletConfig.getContainerRuntimeOptions.EXPECTED_OPTION");
String expectedValue = portletContext.getInitParameter("javax.portlet.portletConfig.getContainerRuntimeOptions.EXPECTED_VALUE");

/*
* TestCase:
Expand All @@ -348,7 +348,7 @@ public void render(RenderRequest portletReq, RenderResponse portletResp)
Map<String, String[]> runoption1 = portletConfig
.getContainerRuntimeOptions();

if (runoption1.size() == Integer.parseInt(expectedNumber)) {
if (runoption1.size() == Integer.parseInt(expectedSize)) {
if (runoption1 != null && runoption1
.containsKey(expectedOption)) {
tr11.setTcSuccess(true);
Expand All @@ -375,10 +375,10 @@ public void render(RenderRequest portletReq, RenderResponse portletResp)
Map<String, String[]> runoption2 = portletConfig
.getContainerRuntimeOptions();
String[] val5 = runoption2.get(expectedOption);
if (runoption2.size() == Integer.parseInt(expectedNumber)) {
if (runoption2.size() == Integer.parseInt(expectedSize)) {
if (runoption2 != null
&& runoption2.containsKey(expectedOption)
&& val5[0].equals(expectedPortletValue)) {
&& val5[0].equals(expectedValue)) {
tr12.setTcSuccess(true);
} else {
tr12.appendTcDetail(
Expand All @@ -401,7 +401,7 @@ public void render(RenderRequest portletReq, RenderResponse portletResp)
V2PORTLETTESTS_PORTLETCONFIG_APIRENDER_GETCONTAINERRUNTIMEOPTIONS3);
Map<String, String[]> runoption3 = portletConfig
.getContainerRuntimeOptions();
if (runoption3.size() == Integer.parseInt(expectedNumber)) {
if (runoption3.size() == Integer.parseInt(expectedSize)) {
if (runoption3 != null && !runoption3.containsKey("newruntimeoption")) {
tr13.setTcSuccess(true);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,6 @@
</public-render-parameter>
<container-runtime-option>
<name>javax.portlet.escapeXml</name>
<value>APPLICATION</value>
<value>false</value>
</container-runtime-option>
</portlet-app>
10 changes: 5 additions & 5 deletions portlet-tck_3.0/V2PortletTests/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>javax.portlet-tck-PortletTests</display-name>
<context-param>
<param-name>tck.EXPECTED_NUMBER</param-name>
<param-value>${expected.number}</param-value>
<param-name>javax.portlet.portletConfig.getContainerRuntimeOptions.EXPECTED_SIZE</param-name>
<param-value>${expected.size}</param-value>
</context-param>
<context-param>
<param-name>tck.EXPECTED_OPTION</param-name>
<param-name>javax.portlet.portletConfig.getContainerRuntimeOptions.EXPECTED_OPTION</param-name>
<param-value>${expected.option}</param-value>
</context-param>
<context-param>
<param-name>tck.EXPECTED_PORTLET_VALUE</param-name>
<param-value>${expected.portlet.value}</param-value>
<param-name>javax.portlet.portletConfig.getContainerRuntimeOptions.EXPECTED_VALUE</param-name>
<param-value>${expected.value}</param-value>
</context-param>
</web-app>
9 changes: 5 additions & 4 deletions portlet-tck_3.0/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<!-- Set to true for modules that define all test pages in a file (page file is not generated from the portlet.xml) -->
<additional.pagefile.only>false</additional.pagefile.only>

<portlet.descriptor.dir>src/main/webapp/WEB-INF</portlet.descriptor.dir>
</properties>

<modules>
Expand Down Expand Up @@ -269,7 +270,7 @@

<!-- automatically generate test case list for module -->
<transformationSet>
<dir>src/main/webapp/WEB-INF</dir>
<dir>${portlet.descriptor.dir}</dir>
<includes>
<include>portlet.xml</include>
</includes>
Expand Down Expand Up @@ -309,7 +310,7 @@

<!-- Automatically generate page file for the module -->
<transformationSet>
<dir>src/main/webapp/WEB-INF</dir>
<dir>${portlet.descriptor.dir}</dir>
<includes>
<include>portlet.xml</include>
</includes>
Expand Down Expand Up @@ -517,8 +518,7 @@
<archiveClasses>false</archiveClasses>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>
WEB-INF/classes/xml-resources/liferay,
WEB-INF/classes/xml-resources/liferay/portlet.xml,
WEB-INF/liferay/portlet.xml
WEB-INF/liferay-portlet.xml,
WEB-INF/classes/log4j.properties
</packagingExcludes>
Expand Down Expand Up @@ -563,6 +563,7 @@
<archiveClasses>false</archiveClasses>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>
WEB-INF/pluto/portlet.xml,
WEB-INF/classes/logging.properties
</packagingExcludes>
<webResources>
Expand Down

0 comments on commit c573052

Please sign in to comment.