Skip to content

Commit

Permalink
Re-enable BlockHound integration tests
Browse files Browse the repository at this point in the history
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 reactor/BlockHound#33 for details.
  • Loading branch information
sbrannen committed Jan 11, 2022
1 parent f2fe8a8 commit 5aefcd2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 6 additions & 0 deletions spring-core/spring-core.gradle
Expand Up @@ -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"
]
}
@@ -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.
Expand All @@ -22,7 +22,6 @@

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;
Expand All @@ -32,16 +31,23 @@

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
Expand All @@ -64,7 +70,7 @@ void localVariableTableParameterNameDiscoverer() {
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");
});
}

Expand Down

0 comments on commit 5aefcd2

Please sign in to comment.