Skip to content

Commit e0062c9

Browse files
authored
Merge pull request #27515 from gjwatts/add-java-22-specific-test
Add Java 22 specific test to FAT
2 parents 6bd1f33 + 4901bf1 commit e0062c9

File tree

10 files changed

+230
-2
lines changed

10 files changed

+230
-2
lines changed

dev/cnf/oss_ibm.maven

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ io.openliberty:java-apps:18.0.0
6262
io.openliberty:java-apps:19.0.0
6363
io.openliberty:java-apps:20.0.0
6464
io.openliberty:java-apps:21.0.0
65+
io.openliberty:java-apps:22.0.0
6566
net.sf.jtidy:jtidy:9.3.8
6667
org.apache.aries.blueprint:org.apache.aries.blueprint:1.3.0-ibm-s20170710-0926
6768
org.apache.geronimo.specs:geronimo-ejb_3.1_spec-alt:1.0.0

dev/io.openliberty.java.internal_fat/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017,2023 IBM Corporation and others.
2+
* Copyright (c) 2017,2024 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -17,6 +17,7 @@ configurations {
1717
app19
1818
app20
1919
app21
20+
app22
2021
}
2122

2223
dependencies {
@@ -25,6 +26,7 @@ configurations {
2526
app19 'io.openliberty:java-apps:19.0.0'
2627
app20 'io.openliberty:java-apps:20.0.0'
2728
app21 'io.openliberty:java-apps:21.0.0'
29+
app22 'io.openliberty:java-apps:22.0.0'
2830
}
2931

3032
task copyKernelService(type: Copy) {
@@ -75,6 +77,12 @@ task copyApp21(type: Copy) {
7577
rename 'java-apps-*.*.*.*', 'io.openliberty.java.internal_fat_21.war'
7678
}
7779

80+
task copyApp22(type: Copy) {
81+
from configurations.app22
82+
into new File(autoFvtDir, 'publish/servers/java22-server/apps/')
83+
rename 'java-apps-*.*.*.*', 'io.openliberty.java.internal_fat_22.war'
84+
}
85+
7886
addRequiredLibraries.dependsOn copyKernelService
7987
addRequiredLibraries.dependsOn copyApp17A
8088
addRequiredLibraries.dependsOn copyApp17B
@@ -83,3 +91,4 @@ addRequiredLibraries.dependsOn copyApp18B
8391
addRequiredLibraries.dependsOn copyApp19
8492
addRequiredLibraries.dependsOn copyApp20
8593
addRequiredLibraries.dependsOn copyApp21
94+
addRequiredLibraries.dependsOn copyApp22

dev/io.openliberty.java.internal_fat/fat/src/io/openliberty/java/internal/fat/FATSuite.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017, 2023 IBM Corporation and others.
2+
* Copyright (c) 2017, 2024 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -28,6 +28,7 @@
2828
Java19Test.class,
2929
Java20Test.class,
3030
Java21Test.class,
31+
Java22Test.class,
3132
JavaIllegalAccessTest.class,
3233
AlwaysPassesTest.class
3334
})
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* IBM Corporation - initial API and implementation
12+
*******************************************************************************/
13+
package io.openliberty.java.internal.fat;
14+
15+
import static org.junit.Assert.assertTrue;
16+
17+
import org.junit.AfterClass;
18+
import org.junit.BeforeClass;
19+
import org.junit.Test;
20+
import org.junit.runner.RunWith;
21+
22+
import componenttest.annotation.MaximumJavaLevel;
23+
import componenttest.annotation.MinimumJavaLevel;
24+
import componenttest.annotation.Server;
25+
import componenttest.custom.junit.runner.FATRunner;
26+
import componenttest.topology.impl.LibertyServer;
27+
import componenttest.topology.utils.FATServletClient;
28+
import componenttest.topology.utils.HttpUtils;
29+
30+
@RunWith(FATRunner.class)
31+
@MinimumJavaLevel(javaLevel = 22)
32+
@MaximumJavaLevel(javaLevel = 22)
33+
public class Java22Test extends FATServletClient {
34+
35+
public static final String APP_NAME = "io.openliberty.java.internal_fat_22";
36+
37+
@Server("java22-server")
38+
public static LibertyServer server;
39+
40+
@BeforeClass
41+
public static void setUp() throws Exception {
42+
// NOTE: This FAT uses a pre-compiled application which is compiled at the bytecode
43+
// level of JDK 22, which is higher than what our build systems normally use
44+
// Code source files for this WAR file this FAT uses can be found in the src-reference/java22 directory at the root of this FAT
45+
// The full project for building the required WAR file can be found here: https://github.com/OpenLiberty/open-liberty-misc/tree/main/io.openliberty.java.internal_fat_22
46+
server.addInstalledAppForValidation(APP_NAME);
47+
server.startServer();
48+
}
49+
50+
@AfterClass
51+
public static void tearDown() throws Exception {
52+
server.stopServer();
53+
}
54+
55+
@Test
56+
public void testJava22App() throws Exception {
57+
String appResponse = HttpUtils.getHttpResponseAsString(server, APP_NAME + '/');
58+
assertContains(appResponse, "<<< EXIT SUCCESSFUL");
59+
}
60+
61+
private static void assertContains(String str, String lookFor) {
62+
assertTrue("Expected to find string '" + lookFor + "' but it was not found in the string: " + str, str.contains(lookFor));
63+
}
64+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
###############################################################################
2+
# Copyright (c) 2024 IBM Corporation and others.
3+
# All rights reserved. This program and the accompanying materials
4+
# are made available under the terms of the Eclipse Public License 2.0
5+
# which accompanies this distribution, and is available at
6+
# http://www.eclipse.org/legal/epl-2.0/
7+
#
8+
# SPDX-License-Identifier: EPL-2.0
9+
#
10+
# Contributors:
11+
# IBM Corporation - initial API and implementation
12+
###############################################################################
13+
bootstrap.include=../testports.properties
14+
com.ibm.ws.logging.trace.specification=*=info
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--enable-preview
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
Copyright (c) 2024 IBM Corporation and others.
3+
All rights reserved. This program and the accompanying materials
4+
are made available under the terms of the Eclipse Public License 2.0
5+
which accompanies this distribution, and is available at
6+
http://www.eclipse.org/legal/epl-2.0/
7+
8+
SPDX-License-Identifier: EPL-2.0
9+
10+
Contributors:
11+
IBM Corporation - initial API and implementation
12+
-->
13+
<server>
14+
15+
<featureManager>
16+
<feature>servlet-4.0</feature>
17+
<feature>componenttest-1.0</feature>
18+
<feature>jaxrs-2.1</feature>
19+
</featureManager>
20+
21+
<include location="../fatTestPorts.xml"/>
22+
23+
<application location="io.openliberty.java.internal_fat_22.war" />
24+
25+
</server>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* IBM Corporation - initial API and implementation
12+
*******************************************************************************/
13+
package io.openliberty.java.internal;
14+
15+
import javax.ws.rs.ApplicationPath;
16+
import javax.ws.rs.core.Application;
17+
18+
@ApplicationPath("/")
19+
public class TestApp extends Application {
20+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* IBM Corporation - initial API and implementation
12+
*******************************************************************************/
13+
package io.openliberty.java.internal;
14+
15+
import java.io.PrintWriter;
16+
import java.io.StringWriter;
17+
import java.util.ArrayList;
18+
import java.util.Arrays;
19+
20+
import javax.enterprise.context.ApplicationScoped;
21+
import javax.ws.rs.GET;
22+
import javax.ws.rs.Path;
23+
24+
@Path("/")
25+
@ApplicationScoped
26+
public class TestService {
27+
28+
private StringWriter sw = new StringWriter();
29+
30+
@GET
31+
public String test() {
32+
try {
33+
log(">>> ENTER");
34+
doTest();
35+
log("<<< EXIT SUCCESSFUL");
36+
} catch (Exception e) {
37+
e.printStackTrace(System.out);
38+
e.printStackTrace(new PrintWriter(sw));
39+
log("<<< EXIT FAILED");
40+
}
41+
String result = sw.toString();
42+
sw = new StringWriter();
43+
return result;
44+
}
45+
46+
47+
private void doTest() throws Exception {
48+
log("Beginning Java 22 testing");
49+
ArrayList<String> favoriteShows = new ArrayList<String>(Arrays.asList("Outpost","Grimm","Community","Scrubs","Castle","Star Trek"));
50+
int count = countElements(favoriteShows);
51+
52+
if (count != favoriteShows.size()) {
53+
log("Failed testing");
54+
throw new Exception("Number of elements counted in ArrayList (" + count + ") is not equal to the size (" + favoriteShows.size() + ")!");
55+
}
56+
57+
log("Goodbye testing");
58+
}
59+
60+
/**
61+
* Demonstrate unnamed variables : JEP 456 -> https://openjdk.org/jeps/456
62+
*
63+
* @param shows
64+
* @return
65+
*/
66+
public int countElements(ArrayList<String> list) {
67+
int total = 0;
68+
for (var _ : list) { // Use _ for unnamed variable
69+
total++;
70+
}
71+
return total;
72+
}
73+
74+
75+
public void log(String msg) {
76+
System.out.println(msg);
77+
sw.append(msg);
78+
sw.append("<br/>");
79+
}
80+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 IBM Corporation and others.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* http://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* IBM Corporation - initial API and implementation
12+
*******************************************************************************/
13+
package io.openliberty.java.internal;

0 commit comments

Comments
 (0)