Skip to content

Commit 75f12da

Browse files
authored
Merge pull request #1961 from venmanyarun/toolchain_v2
adding jvm.options and server.env scanning for JAVA_HOME check for toolchain
2 parents 10f3143 + 3a3dffd commit 75f12da

54 files changed

Lines changed: 2892 additions & 150 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/maven.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
- name: Run tests that require a minimum of Java 17 or later
130130
if: ${{ matrix.java != '8' && matrix.java != '11'}}
131131
timeout-minutes: 20
132-
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 }}"
132+
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-*,*toolchain-java-warning-jvmoption*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}"
133133
# Run tests
134134
- name: Run tests
135135
timeout-minutes: 90
@@ -247,7 +247,7 @@ jobs:
247247
working-directory: ${{github.workspace}}
248248
if: ${{ matrix.java != '8' && matrix.java != '11'}}
249249
timeout-minutes: 45
250-
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 }}"
250+
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-*,*toolchain-java-warning-jvmoption*" -Druntime=${{ matrix.RUNTIME }} -DruntimeVersion="${{ matrix.RUNTIME_VERSION }}"
251251
# Run tests
252252
- name: Run tests
253253
working-directory: ${{github.workspace}}

liberty-maven-plugin/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
<groupId>org.apache.maven.plugins</groupId>
171171
<artifactId>maven-invoker-plugin</artifactId>
172172
<configuration>
173+
<preBuildHookScript>setup</preBuildHookScript>
173174
<debug>false</debug>
174175
<goals>
175176
<goal>install</goal>
@@ -230,6 +231,9 @@
230231
<pomExcludes>
231232
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
232233
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
234+
<pomExclude>toolchain-java-warning-jvmoption-custom-file-it/pom.xml</pomExclude>
235+
<pomExclude>toolchain-java-warning-jvmoption-file-it/pom.xml</pomExclude>
236+
<pomExclude>toolchain-java-warning-jvmoption-property-it/pom.xml</pomExclude>
233237
<pomExclude>dev-container-it/pom.xml</pomExclude>
234238
<pomExclude>compile-jsp-source-17-it/pom.xml</pomExclude>
235239
<pomExclude>compile-jsp-source-17-jakarta-it/pom.xml</pomExclude>
@@ -273,6 +277,9 @@
273277
<pomExclude>install-features-it/pom.xml</pomExclude>
274278
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
275279
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
280+
<pomExclude>toolchain-java-warning-jvmoption-custom-file-it/pom.xml</pomExclude>
281+
<pomExclude>toolchain-java-warning-jvmoption-file-it/pom.xml</pomExclude>
282+
<pomExclude>toolchain-java-warning-jvmoption-property-it/pom.xml</pomExclude>
276283
<pomExclude>dev-container-it/pom.xml</pomExclude>
277284
<pomExclude>compile-jsp-source-17-it/pom.xml</pomExclude>
278285
<pomExclude>compile-jsp-source-17-jakarta-it/pom.xml</pomExclude>
@@ -317,6 +324,9 @@
317324
<pomExclude>generate-features-it/pom.xml</pomExclude>
318325
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
319326
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
327+
<pomExclude>toolchain-java-warning-jvmoption-custom-file-it/pom.xml</pomExclude>
328+
<pomExclude>toolchain-java-warning-jvmoption-file-it/pom.xml</pomExclude>
329+
<pomExclude>toolchain-java-warning-jvmoption-property-it/pom.xml</pomExclude>
320330
<pomExclude>compile-jsp-source-17-it/pom.xml</pomExclude>
321331
<pomExclude>compile-jsp-source-17-jakarta-it/pom.xml</pomExclude>
322332
</pomExcludes>
@@ -365,6 +375,9 @@
365375
<pomExclude>generate-features-it/pom.xml</pomExclude>
366376
<pomExclude>binary-scanner-it/pom.xml</pomExclude>
367377
<pomExclude>springboot-3-tests/pom.xml</pomExclude>
378+
<pomExclude>toolchain-java-warning-jvmoption-custom-file-it/pom.xml</pomExclude>
379+
<pomExclude>toolchain-java-warning-jvmoption-file-it/pom.xml</pomExclude>
380+
<pomExclude>toolchain-java-warning-jvmoption-property-it/pom.xml</pomExclude>
368381
<pomExclude>compile-jsp-source-17-it/pom.xml</pomExclude>
369382
<pomExclude>compile-jsp-source-17-jakarta-it/pom.xml</pomExclude>
370383
</pomExcludes>
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>io.openliberty.tools.it</groupId>
8+
<artifactId>tests</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
</parent>
11+
<properties>
12+
<liberty.env.JAVA_HOME>${env.JAVA_HOME}</liberty.env.JAVA_HOME>
13+
</properties>
14+
<artifactId>toolchain-java-warning-env-property-it</artifactId>
15+
<packaging>war</packaging>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.apache.geronimo.specs</groupId>
20+
<artifactId>geronimo-servlet_3.0_spec</artifactId>
21+
<version>1.0</version>
22+
<scope>provided</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>commons-logging</groupId>
26+
<artifactId>commons-logging</artifactId>
27+
<version>1.0.4</version>
28+
<scope>test</scope>
29+
</dependency>
30+
<dependency>
31+
<groupId>junit</groupId>
32+
<artifactId>junit</artifactId>
33+
<version>4.13.1</version>
34+
<scope>test</scope>
35+
</dependency>
36+
</dependencies>
37+
38+
<build>
39+
<pluginManagement>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-war-plugin</artifactId>
44+
<version>3.4.0</version>
45+
</plugin>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-failsafe-plugin</artifactId>
49+
<version>3.1.2</version>
50+
</plugin>
51+
<plugin>
52+
<groupId>org.apache.maven.plugins</groupId>
53+
<artifactId>maven-surefire-plugin</artifactId>
54+
<version>3.1.2</version>
55+
</plugin>
56+
</plugins>
57+
</pluginManagement>
58+
<plugins>
59+
<plugin>
60+
<artifactId>maven-war-plugin</artifactId>
61+
<configuration>
62+
<failOnMissingWebXml>false</failOnMissingWebXml>
63+
</configuration>
64+
</plugin>
65+
<plugin>
66+
<groupId>io.openliberty.tools</groupId>
67+
<artifactId>liberty-maven-plugin</artifactId>
68+
<version>@pom.version@</version>
69+
<extensions>true</extensions>
70+
<configuration>
71+
<jdkToolchain>
72+
<version>11</version>
73+
</jdkToolchain>
74+
<stripVersion>true</stripVersion>
75+
<assemblyArtifact>
76+
<groupId>${project.groupId}</groupId>
77+
<artifactId>assembly-server</artifactId>
78+
<version>${project.version}</version>
79+
<type>zip</type>
80+
</assemblyArtifact>
81+
<serverName>test</serverName>
82+
<serverXmlFile>src/test/resources/server.xml</serverXmlFile>
83+
<deployPackages>project</deployPackages>
84+
<looseApplication>false</looseApplication>
85+
</configuration>
86+
<executions>
87+
<execution>
88+
<id>install-liberty</id>
89+
<phase>package</phase>
90+
<goals>
91+
<goal>install-server</goal>
92+
</goals>
93+
</execution>
94+
<execution>
95+
<id>create-liberty-server</id>
96+
<phase>package</phase>
97+
<goals>
98+
<goal>create</goal>
99+
</goals>
100+
</execution>
101+
<execution>
102+
<id>install-artifact</id>
103+
<phase>package</phase>
104+
<goals>
105+
<goal>deploy</goal>
106+
</goals>
107+
<configuration>
108+
<appsDirectory>apps</appsDirectory>
109+
<stripVersion>true</stripVersion>
110+
</configuration>
111+
</execution>
112+
<execution>
113+
<id>start-liberty-server</id>
114+
<phase>pre-integration-test</phase>
115+
<goals>
116+
<goal>start</goal>
117+
</goals>
118+
<configuration>
119+
<background>true</background>
120+
<verifyTimeout>40</verifyTimeout>
121+
</configuration>
122+
</execution>
123+
<execution>
124+
<id>check-liberty-server</id>
125+
<phase>pre-integration-test</phase>
126+
<goals>
127+
<goal>status</goal>
128+
</goals>
129+
</execution>
130+
<execution>
131+
<id>stop-liberty-server</id>
132+
<phase>post-integration-test</phase>
133+
<goals>
134+
<goal>stop</goal>
135+
</goals>
136+
</execution>
137+
<execution>
138+
<id>clean-server</id>
139+
<phase>post-integration-test</phase>
140+
<goals>
141+
<goal>clean</goal>
142+
</goals>
143+
<configuration>
144+
<cleanDropins>true</cleanDropins>
145+
<cleanApps>true</cleanApps>
146+
<cleanLogs>false</cleanLogs>
147+
<cleanWorkarea>false</cleanWorkarea>
148+
</configuration>
149+
</execution>
150+
</executions>
151+
</plugin>
152+
<plugin>
153+
<groupId>org.apache.maven.plugins</groupId>
154+
<artifactId>maven-failsafe-plugin</artifactId>
155+
<configuration>
156+
<redirectTestOutputToFile>true</redirectTestOutputToFile>
157+
<forkMode>once</forkMode>
158+
<forkedProcessTimeoutInSeconds>300</forkedProcessTimeoutInSeconds>
159+
<argLine>-enableassertions</argLine>
160+
<workingDirectory>${project.build.directory}</workingDirectory>
161+
<includes>
162+
<include>**/*Test.java</include>
163+
</includes>
164+
</configuration>
165+
<executions>
166+
<execution>
167+
<id>integration-test</id>
168+
<goals>
169+
<goal>integration-test</goal>
170+
</goals>
171+
</execution>
172+
<execution>
173+
<id>verify</id>
174+
<phase>verify</phase>
175+
<goals>
176+
<goal>verify</goal>
177+
</goals>
178+
</execution>
179+
</executions>
180+
</plugin>
181+
<plugin>
182+
<groupId>org.apache.maven.plugins</groupId>
183+
<artifactId>maven-surefire-plugin</artifactId>
184+
<configuration>
185+
<skip>true</skip>
186+
</configuration>
187+
</plugin>
188+
</plugins>
189+
</build>
190+
</project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
2+
<html>
3+
<head>
4+
<title>Maven test install artifact</title>
5+
</head>
6+
<body>
7+
<h2>Successful installation of war</h2>
8+
<p>Maven test war has been successfully installed into the server.</p>
9+
</body>
10+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package net.wasdev.wlp.maven.test.app;
2+
3+
import java.net.MalformedURLException;
4+
import java.net.URL;
5+
6+
import static org.junit.Assert.assertTrue;
7+
import static org.junit.Assert.fail;
8+
import org.junit.Test;
9+
10+
import net.wasdev.wlp.maven.test.support.HttpUtils;
11+
12+
/**
13+
*
14+
* Web application test case
15+
*
16+
*/
17+
18+
public class PluginWARTest {
19+
20+
private String baseURL = "http://localhost:9080/";
21+
22+
@Test
23+
public void testWAR() throws Exception {
24+
URL url = null;
25+
try {
26+
url = new URL(baseURL + "toolchain-java-warning-env-property-it/index.jsp");
27+
String textToFind = "Successful installation of war";
28+
assertTrue("Failed to find expected text:" + textToFind,
29+
HttpUtils.findStringInUrl(url, textToFind));
30+
} catch (MalformedURLException e) {
31+
fail("Fail to access " + url + " caused by " + e.getMessage());
32+
}
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package net.wasdev.wlp.maven.test.app;
2+
3+
4+
import java.io.File;
5+
import java.io.FileNotFoundException;
6+
import java.io.FileInputStream;
7+
8+
import javax.xml.parsers.DocumentBuilder;
9+
import javax.xml.parsers.DocumentBuilderFactory;
10+
import javax.xml.xpath.XPath;
11+
import javax.xml.xpath.XPathConstants;
12+
import javax.xml.xpath.XPathFactory;
13+
14+
import java.util.Scanner;
15+
16+
import org.junit.Test;
17+
18+
import org.junit.Assert;
19+
import org.w3c.dom.Document;
20+
import org.w3c.dom.NodeList;
21+
22+
/**
23+
*
24+
* Web application test case
25+
*
26+
*/
27+
28+
public class ToolchainTest {
29+
30+
public final String CONFIG_XML = "liberty-plugin-config.xml";
31+
public final String LOG_LOCATION = "liberty/usr/servers/test/logs/messages.log";
32+
static final String TOOLCHAIN_NOT_HONORED_WARNING = "CWWKM4101W: The toolchain JDK configuration for goal %s is not honored because the JAVA_HOME property is specified in project properties.";
33+
34+
35+
@Test
36+
public void testConfigPropFileExist() throws Exception {
37+
File f = new File(CONFIG_XML);
38+
Assert.assertTrue(f.getCanonicalFile() + " doesn't exist", f.exists());
39+
}
40+
41+
42+
@Test
43+
public void testApplicationFileExist() throws Exception {
44+
File f = new File("liberty/usr/servers/test/apps/toolchain-java-warning-env-property-it.war");
45+
Assert.assertTrue(f.getCanonicalFile() + " doesn't exist", f.exists());
46+
}
47+
48+
@Test
49+
public void testToolchainLogExists() throws Exception {
50+
File f = new File(LOG_LOCATION);
51+
Assert.assertTrue(f.getCanonicalFile() + " doesn't exist", f.exists());
52+
File buildLog = new File("../build.log");
53+
Assert.assertTrue(buildLog.exists());
54+
55+
Assert.assertTrue("Did not find project properties contain java.home message for create goal in build.log", logContainsMessage(buildLog, String.format(TOOLCHAIN_NOT_HONORED_WARNING, "create")));
56+
Assert.assertTrue("Did not find project properties contain java.home message for start goal in build.log", logContainsMessage(buildLog, String.format(TOOLCHAIN_NOT_HONORED_WARNING, "start")));
57+
Assert.assertTrue("Did not find project properties contain java.home message for status goal in build.log", logContainsMessage(buildLog, String.format(TOOLCHAIN_NOT_HONORED_WARNING, "status")));
58+
}
59+
60+
private boolean logContainsMessage( File logFile, String message) throws FileNotFoundException {
61+
62+
Assert.assertTrue("Log file not found at location: "+ LOG_LOCATION, logFile.exists());
63+
boolean found = false;
64+
65+
try (Scanner scanner = new Scanner(logFile);) {
66+
while (scanner.hasNextLine()) {
67+
if(scanner.nextLine().contains(message)) {
68+
found = true;
69+
}
70+
}
71+
}
72+
73+
return found;
74+
}
75+
}

0 commit comments

Comments
 (0)