-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1813 from cherylking/updateCompileJsp
Handle Java source versions other than 8 for compile-jsp
- Loading branch information
Showing
9 changed files
with
343 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 185 additions & 0 deletions
185
liberty-maven-plugin/src/it/compile-jsp-source-17-it/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
82 changes: 82 additions & 0 deletions
82
.../compile-jsp-source-17-it/src/test/java/net/wasdev/wlp/maven/test/app/CompileJSPTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
liberty-maven-plugin/src/it/compile-jsp-source-17-it/src/test/resources/server.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
10 changes: 10 additions & 0 deletions
10
liberty-maven-plugin/src/it/compile-jsp-source-17-it/webapp/index.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.