I have a junit test like above but when i launch test, i get this error (JDK 13.0.1):
java.lang.UnsupportedOperationException: Reflective setAccessible(true) disabled
java.lang.IllegalAccessException: class io.netty.util.internal.PlatformDependent0$6 cannot access class jdk.internal.misc.Unsafe (in module java.base) because module java.base does not export jdk.internal.misc to unnamed module @4a94ee4
My tool is Intellij CE Edition 2019.3.1. This is my class and pom file:
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
class WebClientStockClientIntegrationTest {
private static final String SYMBOL = "EUR";
private WebClient webClient = WebClient.builder().build();
@Test
void shouldRetrieveStockPricesFromStockService() {
WebClientStockClient webClientStockClient = new WebClientStockClient(webClient);
Flux<StockPrice> prices = webClientStockClient.pricesFor(SYMBOL);
Assertions.assertNotNull(prices);
Assertions.assertTrue(prices.take(5).count().block() > 0);
}
}
My pom with spring-boot and dependencies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
..
<properties>
<java.version>11</java.version>
</properties>
I solved: I add :
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED -Dio.netty.tryReflectionSetAccessible=true
to my test configuration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With