Skip to content

Commit a3bed49

Browse files
committed
Update to use server Java when making Java level decisions for FATs
- Switch from using the JUnit side Java to determine the Java version used for a test since you can use Java 21 to run the test case, and a different Java level to run the Liberty server or client - Remove some Java 7 code that isn't valid any longer
1 parent adc1052 commit a3bed49

9 files changed

Lines changed: 69 additions & 76 deletions

File tree

dev/com.ibm.ws.security.oauth.oidc_fat.common/src/com/ibm/ws/security/oauth_oidc/fat/commonTest/CommonTest.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/*******************************************************************************
2-
* Copyright (c) 2020, 2025 IBM Corporation and others.
2+
* Copyright (c) 2020, 2026 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
66
* http://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
10-
* Contributors:
11-
* IBM Corporation - initial API and implementation
129
*******************************************************************************/
1310
package com.ibm.ws.security.oauth_oidc.fat.commonTest;
1411

@@ -373,12 +370,7 @@ public static TestServer commonSetUp(String requestedServer, String serverXML, S
373370
}
374371
}
375372

376-
boolean overrideForConsul = false;
377-
if (!useDerby && useMongo && JavaInfo.JAVA_VERSION == 7) { // Added Java 7 back in, need to do this to connect to Consul for MongoDB
378-
overrideForConsul = true;
379-
}
380-
381-
setupSSLClient(overrideForConsul);
373+
setupSSLClient();
382374

383375
/*
384376
* reconfigExpectations = new FATDataHelpers().addExpectation(null,
@@ -528,7 +520,7 @@ private static void addToServerRefList(TestServer server) throws Exception {
528520
* Perform setup for testing with SSL connections: TrustManager, hostname
529521
* verifier, ...
530522
*/
531-
private static void setupSSLClient(boolean overrideForConsul) {
523+
private static void setupSSLClient() {
532524

533525
String thisMethod = "setupSSLCLient";
534526

dev/fattest.simplicity/src/componenttest/annotation/processor/TestServletProcessor.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017, 2025 IBM Corporation and others.
2+
* Copyright (c) 2017, 2026 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
66
* http://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
10-
* Contributors:
11-
* IBM Corporation - initial API and implementation
129
*******************************************************************************/
1310
package componenttest.annotation.processor;
1411

@@ -71,9 +68,9 @@ public static List<FrameworkMethod> getServletTests(TestClass testClass) {
7168

7269
// For each @TestServlet for this server, add all @Test methods
7370
for (TestServlet anno : testServlets) {
74-
if (JavaInfo.JAVA_VERSION < anno.minJavaLevel()) {
71+
if (JavaInfo.BOOTSTRAP_JAVA_VERSION < anno.minJavaLevel()) {
7572
Log.info(c, m, "Skipping scan of TestServlet " + anno.servlet()
76-
+ " because the current java level " + JavaInfo.JAVA_VERSION
73+
+ " because the current java level " + JavaInfo.BOOTSTRAP_JAVA_VERSION
7774
+ " did not meet the configured minimum " + anno.minJavaLevel());
7875
continue;
7976
}

dev/fattest.simplicity/src/componenttest/custom/junit/runner/JavaLevelFilter.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017, 2025 IBM Corporation and others.
2+
* Copyright (c) 2017, 2026 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
66
* http://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
10-
* Contributors:
11-
* IBM Corporation - initial API and implementation
129
*******************************************************************************/
1310
package componenttest.custom.junit.runner;
1411

@@ -50,10 +47,10 @@ public boolean shouldRun(Description desc) {
5047
maximumJavaLevelAnnotation = FilterUtils.getTestClass(desc, getMyClass()).getAnnotation(MaximumJavaLevel.class);
5148
}
5249
if (maximumJavaLevelAnnotation != null) {
53-
if (JavaInfo.JAVA_VERSION > maximumJavaLevelAnnotation.javaLevel()) {
50+
if (JavaInfo.BOOTSTRAP_JAVA_VERSION > maximumJavaLevelAnnotation.javaLevel()) {
5451
Log.debug(getMyClass(), "Removing test " + desc.getMethodName()
5552
+ " from list to run, because its maximum java level is " + maximumJavaLevelAnnotation.javaLevel()
56-
+ " and we are running with " + JavaInfo.JAVA_VERSION);
53+
+ " and we are running with " + JavaInfo.BOOTSTRAP_JAVA_VERSION);
5754
return false;
5855
}
5956
}
@@ -69,11 +66,11 @@ public boolean shouldRun(Description desc) {
6966
}
7067

7168
// If there's a minimum java level annotaton, that sets a global minimum level, so if we don't meet that, don't run tests
72-
boolean javaLevelTooLowForAllFeatures = minimumJavaLevelAnnotation != null && JavaInfo.JAVA_VERSION < minimumJavaLevelAnnotation.javaLevel();
69+
boolean javaLevelTooLowForAllFeatures = minimumJavaLevelAnnotation != null && JavaInfo.BOOTSTRAP_JAVA_VERSION < minimumJavaLevelAnnotation.javaLevel();
7370
if (javaLevelTooLowForAllFeatures) {
7471
Log.debug(getMyClass(), "Removing test " + desc.getMethodName() + " with minimum java level " + minimumJavaLevelAnnotation.javaLevel()
7572
+ " from list to run, because it is too high for current java level "
76-
+ JavaInfo.JAVA_VERSION);
73+
+ JavaInfo.BOOTSTRAP_JAVA_VERSION);
7774
return false;
7875
}
7976

dev/fattest.simplicity/src/componenttest/rules/repeater/EmptyAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public class EmptyAction implements RepeatTestAction {
2828
private TestMode testRunMode = TestMode.LITE;
2929
private boolean liteFATOnly = false;
3030

31-
public static final Predicate<EmptyAction> GREATER_THAN_OR_EQUAL_JAVA_11 = (action) -> JavaInfo.JAVA_VERSION >= 11;
32-
public static final Predicate<EmptyAction> GREATER_THAN_OR_EQUAL_JAVA_17 = (action) -> JavaInfo.JAVA_VERSION >= 17;
33-
public static final Predicate<EmptyAction> GREATER_THAN_OR_EQUAL_JAVA_21 = (action) -> JavaInfo.JAVA_VERSION >= 21;
31+
public static final Predicate<EmptyAction> GREATER_THAN_OR_EQUAL_JAVA_11 = (action) -> JavaInfo.BOOTSTRAP_JAVA_VERSION >= 11;
32+
public static final Predicate<EmptyAction> GREATER_THAN_OR_EQUAL_JAVA_17 = (action) -> JavaInfo.BOOTSTRAP_JAVA_VERSION >= 17;
33+
public static final Predicate<EmptyAction> GREATER_THAN_OR_EQUAL_JAVA_21 = (action) -> JavaInfo.BOOTSTRAP_JAVA_VERSION >= 21;
3434

3535
@Override
3636
public void setup() {}

dev/fattest.simplicity/src/componenttest/rules/repeater/FeatureReplacementAction.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017, 2025 IBM Corporation and others.
2+
* Copyright (c) 2017, 2026 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
66
* http://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
10-
* Contributors:
11-
* IBM Corporation - initial API and implementation
129
*******************************************************************************/
1310
package componenttest.rules.repeater;
1411

@@ -106,9 +103,9 @@ public class FeatureReplacementAction implements RepeatTestAction {
106103
featuresWithNameChangeOnEE9 = Collections.unmodifiableMap(featureNameMapping);
107104
}
108105

109-
public static final Predicate<FeatureReplacementAction> GREATER_THAN_OR_EQUAL_JAVA_11 = (action) -> JavaInfo.JAVA_VERSION >= 11;
110-
public static final Predicate<FeatureReplacementAction> GREATER_THAN_OR_EQUAL_JAVA_17 = (action) -> JavaInfo.JAVA_VERSION >= 17;
111-
public static final Predicate<FeatureReplacementAction> GREATER_THAN_OR_EQUAL_JAVA_21 = (action) -> JavaInfo.JAVA_VERSION >= 21;
106+
public static final Predicate<FeatureReplacementAction> GREATER_THAN_OR_EQUAL_JAVA_11 = (action) -> JavaInfo.BOOTSTRAP_JAVA_VERSION >= 11;
107+
public static final Predicate<FeatureReplacementAction> GREATER_THAN_OR_EQUAL_JAVA_17 = (action) -> JavaInfo.BOOTSTRAP_JAVA_VERSION >= 17;
108+
public static final Predicate<FeatureReplacementAction> GREATER_THAN_OR_EQUAL_JAVA_21 = (action) -> JavaInfo.BOOTSTRAP_JAVA_VERSION >= 21;
112109

113110
public static EmptyAction NO_REPLACEMENT() {
114111
return new EmptyAction();
@@ -514,11 +511,11 @@ public boolean isEnabled() {
514511
}
515512

516513
public boolean checkEnabled() {
517-
if (JavaInfo.forCurrentVM().majorVersion() < minJavaLevel.majorVersion()) {
514+
if (JavaInfo.BOOTSTRAP_JAVA_VERSION < minJavaLevel.majorVersion()) {
518515
Log.info(c, "isEnabled", "Skipping action '" + toString() + "' because the java level is too low.");
519516
return false;
520517
}
521-
if (maxJavaLevel != null && JavaInfo.forCurrentVM().majorVersion() > maxJavaLevel.majorVersion()) {
518+
if (maxJavaLevel != null && JavaInfo.BOOTSTRAP_JAVA_VERSION > maxJavaLevel.majorVersion()) {
522519
Log.info(c, "isEnabled", "Skipping action '" + toString() + "' because the java level is too high.");
523520
return false;
524521
}

dev/fattest.simplicity/src/componenttest/rules/repeater/RepeatActions.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/*******************************************************************************
2-
* Copyright (c) 2020, 2024 IBM Corporation and others.
2+
* Copyright (c) 2020, 2026 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
66
* http://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
10-
* Contributors:
11-
* IBM Corporation - initial API and implementation
129
*******************************************************************************/
1310
package componenttest.rules.repeater;
1411

@@ -165,7 +162,7 @@ public static RepeatTests repeat(String[] servers,
165162
List<FeatureSet> actualOtherFeatureSets = new ArrayList<>(otherFeatureSets);
166163

167164
// If the firstFeatureSet requires a Java level higher than the one we're running, try to find a suitable replacement so we don't end up not running the test at all in LITE mode
168-
int currentJavaLevel = JavaInfo.forCurrentVM().majorVersion();
165+
int currentJavaLevel = JavaInfo.BOOTSTRAP_JAVA_VERSION;
169166
if (currentJavaLevel < firstFeatureSet.getMinJavaLevel().majorVersion()) {
170167

171168
// Find the newest feature set that's in otherFeatureSets and is compatible with the current java version

dev/fattest.simplicity/src/componenttest/topology/impl/JavaInfo.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/*******************************************************************************
2-
* Copyright (c) 2017, 2025 IBM Corporation and others.
2+
* Copyright (c) 2017, 2026 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
66
* http://www.eclipse.org/legal/epl-2.0/
77
*
88
* SPDX-License-Identifier: EPL-2.0
9-
*
10-
* Contributors:
11-
* IBM Corporation - initial API and implementation
129
*******************************************************************************/
1310
package componenttest.topology.impl;
1411

@@ -29,6 +26,8 @@
2926
import com.ibm.websphere.simplicity.log.Log;
3027
import com.ibm.ws.ffdc.annotation.FFDCIgnore;
3128

29+
import componenttest.common.apiservices.Bootstrap;
30+
3231
/**
3332
* A class used for identifying properties of a JDK other
3433
* than the one that is currently being run.
@@ -37,7 +36,19 @@ public class JavaInfo {
3736
private static Class<?> c = JavaInfo.class;
3837
private static Map<String, JavaInfo> cache = new HashMap<String, JavaInfo>();
3938

40-
public static int JAVA_VERSION = JavaInfo.forCurrentVM().majorVersion();
39+
public final static int JAVA_VERSION = JavaInfo.forCurrentVM().majorVersion();
40+
41+
public final static int BOOTSTRAP_JAVA_VERSION;
42+
static {
43+
try {
44+
BOOTSTRAP_JAVA_VERSION = JavaInfo.forBootstrap(Bootstrap.getInstance()).majorVersion();
45+
} catch (Exception ex) {
46+
if (ex instanceof RuntimeException) {
47+
throw (RuntimeException) ex;
48+
}
49+
throw new RuntimeException(ex);
50+
}
51+
}
4152

4253
public static JavaInfo forCurrentVM() {
4354
String javaHome = System.getProperty("java.home");
@@ -69,6 +80,19 @@ private static void cacheJavaInfo(String jdkPath, JavaInfo info) {
6980
cache.put(jdkPath.replace("\\", "/"), info);
7081
}
7182

83+
/**
84+
* Get the JavaInfo for the JDK that will be used for LibertyServer and LibertyClient
85+
* from the Bootstrap that is fed to those classes. The Java used to run the tests
86+
* can be different than the one to run the client and server when using the
87+
* supports.framework.java variable.
88+
* </ol>
89+
*/
90+
public static JavaInfo forBootstrap(Bootstrap bootstrap) throws IOException {
91+
String bootstrapHostName = bootstrap.getValue("hostName");
92+
String bootstrapJava = bootstrap.getValue(bootstrapHostName + ".JavaHome");
93+
return fromPath(bootstrapJava);
94+
}
95+
7296
/**
7397
* Get the JavaInfo for the JDK that will be used for a given LibertyServer.
7498
* The priority is determined in the following way:

0 commit comments

Comments
 (0)