You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/03/16 18:39:27 UTC
[GitHub] [flink] RyanSkraba commented on a change in pull request #18848: [FLINK-26251][akka] Migrate test to JUnit5
RyanSkraba commented on a change in pull request #18848:
URL: https://github.com/apache/flink/pull/18848#discussion_r828226789
##########
File path: flink-rpc/flink-rpc-akka/src/test/java/org/apache/flink/runtime/concurrent/akka/ClassLoadingUtilsTest.java
##########
@@ -48,14 +46,14 @@ public void testRunnableWithContextClassLoader() throws Exception {
ClassLoadingUtils.withContextClassLoader(runnable, TEST_CLASS_LOADER);
// the runnable should only be wrapped, not run immediately
- assertThat(contextClassLoader.isDone(), is(false));
+ assertThat(contextClassLoader.isDone()).isFalse();
Review comment:
```suggestion
assertThat(contextClassLoader).isNotDone();
```
There are some nice assertions for CompletableFuture.
##########
File path: flink-rpc/flink-rpc-akka/src/test/java/org/apache/flink/runtime/concurrent/akka/ClassLoadingUtilsTest.java
##########
@@ -48,14 +46,14 @@ public void testRunnableWithContextClassLoader() throws Exception {
ClassLoadingUtils.withContextClassLoader(runnable, TEST_CLASS_LOADER);
// the runnable should only be wrapped, not run immediately
- assertThat(contextClassLoader.isDone(), is(false));
+ assertThat(contextClassLoader.isDone()).isFalse();
wrappedRunnable.run();
- assertThat(contextClassLoader.get(), is(TEST_CLASS_LOADER));
+ assertThat(contextClassLoader.get()).isSameAs(TEST_CLASS_LOADER);
Review comment:
```suggestion
assertThat(contextClassLoader)
.succeedsWithin(Duration.ofSeconds(1))
.isSameAs(TEST_CLASS_LOADER);
```
Likewise, we could specify a timeout for the Future, which is a good practice (even if we want to specify "forever", which is what the original does).
##########
File path: flink-rpc/flink-rpc-akka/src/test/java/org/apache/flink/runtime/rpc/akka/AkkaRpcActorHandshakeTest.java
##########
@@ -23,36 +23,32 @@
import org.apache.flink.runtime.rpc.RpcUtils;
import org.apache.flink.runtime.rpc.exceptions.HandshakeException;
import org.apache.flink.util.ExceptionUtils;
-import org.apache.flink.util.TestLogger;
import org.apache.flink.util.concurrent.FutureUtils;
import akka.actor.ActorSystem;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.instanceOf;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
/** Tests for the handshake between rpc endpoints. */
-public class AkkaRpcActorHandshakeTest extends TestLogger {
+class AkkaRpcActorHandshakeTest {
private static final Time timeout = Time.seconds(10L);
private static AkkaRpcService akkaRpcService1;
private static AkkaRpcService akkaRpcService2;
private static WrongVersionAkkaRpcService wrongVersionAkkaRpcService;
- @BeforeClass
- public static void setupClass() {
+ @BeforeAll
+ private static void setupClass() {
Review comment:
?? This works, but the [JUnit5 docs](https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/BeforeAll.html) suggests that it shouldn't : `@BeforeAll methods must have a void return type, must not be private, and must be static by default. `
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org