1
+ package org.utbot.bytecode.versions
2
+
3
+ import org.junit.jupiter.api.Assertions.assertFalse
4
+ import org.junit.jupiter.api.Assertions.assertNotNull
5
+ import org.junit.jupiter.api.Assertions.assertNull
6
+ import org.junit.jupiter.api.Assertions.assertTrue
7
+ import org.junit.jupiter.api.Disabled
8
+ import org.junit.jupiter.api.Test
9
+ import org.utbot.examples.objects.SimpleDataClass
10
+ import org.utbot.framework.util.SootUtils.runSoot
11
+ import soot.Scene
12
+
13
+ @Suppress(" UNREACHABLE_CODE" )
14
+ @Disabled(" TODO: https://github.com/UnitTestBot/UTBotJava/issues/891" )
15
+ class SootTest {
16
+ @Test
17
+ fun `no method isBlank in JDK 8` () {
18
+ runSoot(
19
+ SimpleDataClass ::class .java,
20
+ forceReload = true ,
21
+ TODO (" Get JDK 8" )
22
+ )
23
+
24
+ val stringClass = Scene .v().getSootClass(" java.lang.String" )
25
+ assertFalse(stringClass.isPhantomClass)
26
+
27
+ val isBlankMethod = stringClass.getMethodByNameUnsafe(" isBlank" ) // no such method in JDK 8
28
+ assertNull(isBlankMethod)
29
+ }
30
+
31
+ @Test
32
+ fun `method isBlank exists in JDK 11` () {
33
+ runSoot(
34
+ SimpleDataClass ::class .java,
35
+ forceReload = true ,
36
+ TODO (" Get JDK 11" )
37
+ )
38
+
39
+ val stringClass = Scene .v().getSootClass(" java.lang.String" )
40
+ assertFalse(stringClass.isPhantomClass)
41
+
42
+ val isBlankMethod = stringClass.getMethodByNameUnsafe(" isBlank" ) // there is such method in JDK 11
43
+ assertNotNull(isBlankMethod)
44
+ }
45
+
46
+ @Test
47
+ fun `no records in JDK 11` () {
48
+ runSoot(
49
+ SimpleDataClass ::class .java,
50
+ forceReload = true ,
51
+ TODO (" Get JDK 11" )
52
+ )
53
+
54
+ val stringClass = Scene .v().getSootClass(" java.lang.Record" ) // must not exist in JDK 11
55
+ assertTrue(stringClass.isPhantomClass)
56
+ }
57
+
58
+ @Test
59
+ fun `records exists in JDK 17` () {
60
+ runSoot(
61
+ SimpleDataClass ::class .java,
62
+ forceReload = true ,
63
+ TODO (" Get JDK 17" )
64
+ )
65
+
66
+ val stringClass = Scene .v().getSootClass(" java.lang.Record" ) // must exist in JDK 17
67
+ assertFalse(stringClass.isPhantomClass)
68
+ }
69
+ }
0 commit comments