1
1
/*
2
- * Copyright 2002-2021 the original author or authors.
2
+ * Copyright 2002-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
20
20
import java .io .InputStream ;
21
21
22
22
import org .junit .jupiter .api .Test ;
23
+ import org .junit .jupiter .api .condition .EnabledOnJre ;
24
+ import org .junit .jupiter .api .condition .JRE ;
23
25
24
26
import static org .assertj .core .api .Assertions .assertThat ;
25
27
@@ -31,20 +33,29 @@ public class JavaVersionTests {
31
33
32
34
private static final int JDK17_CLASS_VERSION = 61 ;
33
35
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
+
34
44
@ 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 );
37
48
}
38
49
39
- private void assertClassVersion (Class <?> clazz ) throws Exception {
50
+ private void assertClassVersion (Class <?> clazz , int classVersion ) throws Exception {
40
51
String classResourceName = clazz .getName ().replaceAll ("\\ ." , "/" ) + ".class" ;
41
52
try (InputStream input = Thread .currentThread ().getContextClassLoader ()
42
53
.getResourceAsStream (classResourceName )) {
43
54
DataInputStream data = new DataInputStream (input );
44
55
data .readInt ();
45
56
data .readShort (); // minor
46
57
int major = data .readShort ();
47
- assertThat (major ).isEqualTo (JDK17_CLASS_VERSION );
58
+ assertThat (major ).isEqualTo (classVersion );
48
59
}
49
60
}
50
61
0 commit comments