Re-enable BlockHound integration tests

Prior to this commit, our BlockHound integration tests were disabled
after the migration to a JDK 17 baseline since the build now always
runs on JDK 14 or higher.

To re-enable the tests we now supply the deprecated
-XX:+AllowRedefinitionToAddDeleteMethods command-line argument to the JVM
for tests in the Gradle build. Users can also configure this manually
within an IDE to run SpringCoreBlockHoundIntegrationTests.

If that command-line argument is removed from the JVM at some point in
the future, we will need to investigate an alternative solution.

See https://github.com/reactor/BlockHound/issues/33 for details.
This commit is contained in:
Sam Brannen
2022-01-11 14:54:59 +01:00
parent f2fe8a87fa
commit 5aefcd2fdb
2 changed files with 18 additions and 6 deletions

View File

@@ -92,4 +92,10 @@ test {
// Make sure the classes dir is used on the test classpath (required by ResourceTests).
// When test fixtures are involved, the JAR is used by default.
classpath = sourceSets.main.output.classesDirs + classpath - files(jar.archiveFile)
// Ensure that BlockHound tests run on JDK 13+. For details, see:
// https://github.com/reactor/BlockHound/issues/33
jvmArgs += [
"-XX:+AllowRedefinitionToAddDeleteMethods"
]
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@ import java.util.concurrent.CompletableFuture;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import reactor.blockhound.BlockHound;
import reactor.core.scheduler.ReactorBlockHoundIntegration;
import reactor.core.scheduler.Schedulers;
@@ -32,16 +31,23 @@ import org.springframework.util.ConcurrentReferenceHashMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.condition.JRE.JAVA_14;
/**
* Tests to verify the spring-core BlockHound integration rules.
*
* <p>NOTE: to run this test class in the IDE, you need to specify the following
* JVM argument. For details, see
* <a href="https://github.com/reactor/BlockHound/issues/33">BlockHound issue 33</a>.
*
* <pre style="code">
* -XX:+AllowRedefinitionToAddDeleteMethods
* </pre>
*
* @author Rossen Stoyanchev
* @author Sam Brannen
* @since 5.2.4
*/
@DisabledForJreRange(min = JAVA_14)
public class SpringCoreBlockHoundIntegrationTests {
class SpringCoreBlockHoundIntegrationTests {
@BeforeAll
@@ -64,7 +70,7 @@ public class SpringCoreBlockHoundIntegrationTests {
testNonBlockingTask(() -> {
Method setName = TestObject.class.getMethod("setName", String.class);
String[] names = new LocalVariableTableParameterNameDiscoverer().getParameterNames(setName);
assertThat(names).isEqualTo(new String[] {"name"});
assertThat(names).containsExactly("name");
});
}