mirror of
https://github.com/corda/corda.git
synced 2025-01-30 08:04:16 +00:00
ENT-11113 Updating test case for accessing modifier as per JDK17 compatibility
This commit is contained in:
parent
d9e0172bf7
commit
49f35aa5ea
@ -330,6 +330,7 @@ jar {
|
|||||||
tasks.named('test', Test) {
|
tasks.named('test', Test) {
|
||||||
maxHeapSize = "3g"
|
maxHeapSize = "3g"
|
||||||
maxParallelForks = (System.env.CORDA_NODE_TESTING_FORKS == null) ? 1 : "$System.env.CORDA_NODE_TESTING_FORKS".toInteger()
|
maxParallelForks = (System.env.CORDA_NODE_TESTING_FORKS == null) ? 1 : "$System.env.CORDA_NODE_TESTING_FORKS".toInteger()
|
||||||
|
jvmArgs(['--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED', '--add-opens', 'java.base/java.util=ALL-UNNAMED'])
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
@ -7,12 +7,12 @@ import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
|||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Ignore
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.ArgumentMatchers.contains
|
import org.mockito.ArgumentMatchers.contains
|
||||||
import org.mockito.kotlin.spy
|
import org.mockito.kotlin.spy
|
||||||
import org.mockito.kotlin.verify
|
import org.mockito.kotlin.verify
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
|
import java.lang.invoke.MethodHandles
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
import java.lang.reflect.Modifier
|
import java.lang.reflect.Modifier
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
@ -71,13 +71,12 @@ class ConfigHelperTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 300_000)
|
@Test(timeout = 300_000)
|
||||||
@Ignore("TODO JDK17: Modifiers no longer supported")
|
|
||||||
fun `bad keys are ignored and warned for`() {
|
fun `bad keys are ignored and warned for`() {
|
||||||
val loggerField = Node::class.java.getDeclaredField("staticLog")
|
val loggerField = Node::class.java.getDeclaredField("staticLog")
|
||||||
loggerField.isAccessible = true
|
loggerField.isAccessible = true
|
||||||
val modifiersField = Field::class.java.getDeclaredField("modifiers")
|
val fieldLookup = MethodHandles.privateLookupIn(Field::class.java, MethodHandles.lookup());
|
||||||
modifiersField.isAccessible = true
|
val modifiersField = fieldLookup.findVarHandle(Field::class.java, "modifiers", Int::class.javaPrimitiveType)
|
||||||
modifiersField.setInt(loggerField, loggerField.modifiers and Modifier.FINAL.inv())
|
modifiersField.set(loggerField, loggerField.modifiers and Modifier.FINAL.inv())
|
||||||
val originalLogger = loggerField.get(null) as Logger
|
val originalLogger = loggerField.get(null) as Logger
|
||||||
val spyLogger = spy(originalLogger)
|
val spyLogger = spy(originalLogger)
|
||||||
loggerField.set(null, spyLogger)
|
loggerField.set(null, spyLogger)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user