Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Java source versions other than 8 for compile-jsp #1813

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
matrix:
# test against latest update of each major Java version, as well as specific updates of LTS versions:
RUNTIME: [ol, wlp]
RUNTIME_VERSION: [23.0.0.12]
RUNTIME_VERSION: [24.0.0.3]
java: [21, 17, 11, 8]
exclude:
- java: 8
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
# Run tests that require a minimum of Java 17 or later
- name: Run tests that require a minimum of Java 17 or later
if: ${{ matrix.java == '17' || matrix.java == '21'}}
run: ./mvnw -V verify --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -Ponline-its -D"invoker.streamLogsOnFailures"=true -D"invoker.test"="*setup*,*springboot-3-*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}"
run: ./mvnw -V verify --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -Ponline-its -D"invoker.streamLogsOnFailures"=true -D"invoker.test"="*setup*,*springboot-3-*,*compile-jsp-source-17-*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}"
# Run tests
- name: Run tests
run: ./mvnw -V verify --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -Ponline-its -D"invoker.streamLogsOnFailures"=true -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}"
Expand All @@ -80,7 +80,7 @@ jobs:
matrix:
# test against latest update of each major Java version, as well as specific updates of LTS versions:
RUNTIME: [ol, wlp]
RUNTIME_VERSION: [23.0.0.12]
RUNTIME_VERSION: [24.0.0.3]
java: [21, 17, 11, 8]
exclude:
- java: 8
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
# Run tests that require a minimum of Java 17 or later
- name: Run tests that require a minimum of Java 17 or later
if: ${{ matrix.java == '17' || matrix.java == '21'}}
run: .\mvnw.cmd -V verify -Ponline-its --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -D"invoker.streamLogsOnFailures"=true -D"invoker.test"="*setup*,*springboot-3-*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}"
run: .\mvnw.cmd -V verify -Ponline-its --batch-mode --no-transfer-progress --errors -DtrimStackTrace=false -D"invoker.streamLogsOnFailures"=true -D"invoker.test"="*setup*,*springboot-3-*,*compile-jsp-source-17-*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}"
# Run tests
- name: Run tests
working-directory: C:/ci.maven
Expand Down
6 changes: 5 additions & 1 deletion liberty-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dependency>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-ant-tasks</artifactId>
<version>1.9.14</version>
<version>1.9.15-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down Expand Up @@ -225,6 +225,7 @@
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
<pomExclude>dev-container-it/pom.xml</pomExclude>
<pomExclude>compile-jsp-source-17-it/pom.xml</pomExclude>
</pomExcludes>
</configuration>
</plugin>
Expand Down Expand Up @@ -266,6 +267,7 @@
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
<pomExclude>dev-container-it/pom.xml</pomExclude>
<pomExclude>compile-jsp-source-17-it/pom.xml</pomExclude>
</pomExcludes>
</configuration>
</plugin>
Expand Down Expand Up @@ -306,6 +308,7 @@
<pomExclude>generate-features-it/pom.xml</pomExclude>
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
<pomExclude>compile-jsp-source-17-it/pom.xml</pomExclude>
</pomExcludes>
</configuration>
</plugin>
Expand Down Expand Up @@ -351,6 +354,7 @@
<pomExclude>generate-features-it/pom.xml</pomExclude>
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
<pomExclude>compile-jsp-source-17-it/pom.xml</pomExclude>
</pomExcludes>
</configuration>
</plugin>
Expand Down
4 changes: 4 additions & 0 deletions liberty-maven-plugin/src/it/compile-jsp-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
</dependency>
</dependencies>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>

<build>
<pluginManagement>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ public void testXmlElements() throws Exception {
Assert.assertTrue("ejbLite-3.2 <feature/> found ==>", features.contains("ejbLite-3.2"));
Assert.assertTrue("mongodb-2.0 <feature/> found ==>", features.contains("mongodb-2.0"));
Assert.assertTrue("jsp-2.3 <feature/> found ==>", features.contains("jsp-2.3"));

// parse input XML Document
String expression2 = "/server/jspEngine";
nodes = (NodeList) xPath.compile(expression2).evaluate(inputDoc, XPathConstants.NODESET);
Assert.assertEquals("Number of <jspEngine/> elements ==>", 1, nodes.getLength());

if (nodes.item(0) instanceof Element) {
Element child = (Element) nodes.item(0);
String nodeValue = child.getAttribute("javaSourceLevel");
Assert.assertTrue("Unexpected javaSourceLevel ==>"+nodeValue, nodeValue.equals("8"));
}
}
}
}
185 changes: 185 additions & 0 deletions liberty-maven-plugin/src/it/compile-jsp-source-17-it/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.openliberty.tools.it</groupId>
<artifactId>tests</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>compile-jsp-source-17-it</artifactId>
<packaging>war</packaging>

<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>@pom.version@</version>
<extensions>true</extensions>
<configuration>
<stripVersion>true</stripVersion>
<serverName>test</serverName>
<serverXmlFile>src/test/resources/server.xml</serverXmlFile>
<deployPackages>project</deployPackages>
<looseApplication>false</looseApplication>
</configuration>
<executions>
<execution>
<id>install-liberty</id>
<phase>package</phase>
<goals>
<goal>install-server</goal>
</goals>
</execution>
<execution>
<id>create-liberty-server</id>
<phase>package</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
<execution>
<id>install-artifact</id>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<stripVersion>true</stripVersion>
</configuration>
</execution>
<execution>
<id>start-liberty-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>install-feature</goal>
<goal>start</goal>
<goal>compile-jsp</goal>
</goals>
<configuration>
<features>
<acceptLicense>true</acceptLicense>
<feature>mongodb-2.0</feature>
<feature>ejbLite-3.2</feature>
</features>
<background>true</background>
<verifyTimeout>40</verifyTimeout>
</configuration>
</execution>
<execution>
<id>check-liberty-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>status</goal>
</goals>
</execution>
<execution>
<id>stop-liberty-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
<execution>
<id>clean-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<cleanDropins>false</cleanDropins>
<cleanApps>false</cleanApps>
<cleanLogs>false</cleanLogs>
<cleanWorkarea>false</cleanWorkarea>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<forkMode>once</forkMode>
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
<argLine>-enableassertions</argLine>
<workingDirectory>${project.build.directory}</workingDirectory>
<includes>
<include>**/*CompileJSPTest.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package net.wasdev.wlp.maven.test.app;

import java.awt.List;
import java.util.ArrayList;
import java.io.File;
import java.io.FileInputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;

import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;


/**
*
* Web application test case
*
*/

public class CompileJSPTest {

public final String COMPILE_JSP_SEVER_XML = "compileJsp/servers/defaultServer/server.xml";

@Test
public void testServerXMLPropFileExist() throws Exception {
File f = new File(COMPILE_JSP_SEVER_XML);
Assert.assertTrue(f.getCanonicalFile() + " doesn't exist", f.exists());
}

@Test
public void testXmlElements() throws Exception {
File in = new File(COMPILE_JSP_SEVER_XML);
try (FileInputStream input = new FileInputStream(in);) {

// get input XML Document
DocumentBuilderFactory inputBuilderFactory = DocumentBuilderFactory.newInstance();
inputBuilderFactory.setIgnoringComments(true);
inputBuilderFactory.setCoalescing(true);
inputBuilderFactory.setIgnoringElementContentWhitespace(true);
inputBuilderFactory.setValidating(false);
inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
inputBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
DocumentBuilder inputBuilder = inputBuilderFactory.newDocumentBuilder();
Document inputDoc=inputBuilder.parse(input);

// parse input XML Document
XPath xPath = XPathFactory.newInstance().newXPath();
String expression = "/server/featureManager/feature[text()]";
NodeList nodes = (NodeList) xPath.compile(expression).evaluate(inputDoc, XPathConstants.NODESET);
Assert.assertEquals("Number of <feature/> elements ==>", 3, nodes.getLength());

ArrayList<String> features = new ArrayList<String>();

for(int i = 0; i < nodes.getLength(); i++) {
features.add(nodes.item(i).getTextContent().trim());
}

Assert.assertTrue("ejbLite-3.2 <feature/> found ==>", features.contains("ejbLite-3.2"));
Assert.assertTrue("mongodb-2.0 <feature/> found ==>", features.contains("mongodb-2.0"));
Assert.assertTrue("jsp-2.3 <feature/> found ==>", features.contains("jsp-2.3"));

// parse input XML Document
String expression2 = "/server/jspEngine";
nodes = (NodeList) xPath.compile(expression2).evaluate(inputDoc, XPathConstants.NODESET);
Assert.assertEquals("Number of <jspEngine/> elements ==>", 1, nodes.getLength());

if (nodes.item(0) instanceof Element) {
Element child = (Element) nodes.item(0);
String nodeValue = child.getAttribute("javaSourceLevel");
Assert.assertTrue("Unexpected javaSourceLevel ==>"+nodeValue, nodeValue.equals("17"));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<server description="default server">
<featureManager>
<feature>jsp-2.3</feature>
</featureManager>
</server>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Maven test install artifact</title>
</head>
<body>
<h2>Successful installation of war</h2>
<p>Maven test war has been successfully installed into the server.</p>
</body>
</html>
Loading
Loading