11/*
2- * Copyright 2002-2021 the original author or authors.
2+ * Copyright 2002-2023 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2020import java .io .InputStream ;
2121
2222import org .junit .jupiter .api .Test ;
23+ import org .junit .jupiter .api .condition .EnabledOnJre ;
24+ import org .junit .jupiter .api .condition .JRE ;
2325
2426import static org .assertj .core .api .Assertions .assertThat ;
2527
@@ -31,20 +33,29 @@ public class JavaVersionTests {
3133
3234 private static final int JDK17_CLASS_VERSION = 61 ;
3335
36+ private static final int JDK21_CLASS_VERSION = 65 ;
37+
38+ @ Test
39+ @ EnabledOnJre (JRE .JAVA_17 )
40+ public void authenticationWhenJdk17ThenCorrectJdkCompatibility () throws Exception {
41+ assertClassVersion (Authentication .class , JDK17_CLASS_VERSION );
42+ }
43+
3444 @ Test
35- public void authenticationCorrectJdkCompatibility () throws Exception {
36- assertClassVersion (Authentication .class );
45+ @ EnabledOnJre (JRE .JAVA_21 )
46+ public void authenticationWhenJdk21ThenCorrectJdkCompatibility () throws Exception {
47+ assertClassVersion (Authentication .class , JDK21_CLASS_VERSION );
3748 }
3849
39- private void assertClassVersion (Class <?> clazz ) throws Exception {
50+ private void assertClassVersion (Class <?> clazz , int classVersion ) throws Exception {
4051 String classResourceName = clazz .getName ().replaceAll ("\\ ." , "/" ) + ".class" ;
4152 try (InputStream input = Thread .currentThread ().getContextClassLoader ()
4253 .getResourceAsStream (classResourceName )) {
4354 DataInputStream data = new DataInputStream (input );
4455 data .readInt ();
4556 data .readShort (); // minor
4657 int major = data .readShort ();
47- assertThat (major ).isEqualTo (JDK17_CLASS_VERSION );
58+ assertThat (major ).isEqualTo (classVersion );
4859 }
4960 }
5061
0 commit comments