You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by dw...@apache.org on 2022/02/28 08:03:32 UTC
[flink] 03/03: [hotfix][runtime] CodeStyle correction for NetworkBufferPoolTest
This is an automated email from the ASF dual-hosted git repository.
dwysakowicz pushed a commit to branch release-1.14
in repository https://gitbox.apache.org/repos/asf/flink.git
commit e4c99b19e9fa876157a98d23b5b5bc498da7fac9
Author: Anton Kalashnikov <ka...@yandex.ru>
AuthorDate: Mon Feb 21 16:37:58 2022 +0100
[hotfix][runtime] CodeStyle correction for NetworkBufferPoolTest
---
.../io/network/buffer/NetworkBufferPoolTest.java | 23 ++++++----------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPoolTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPoolTest.java
index 13faa93..e5f878e 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPoolTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/io/network/buffer/NetworkBufferPoolTest.java
@@ -23,10 +23,7 @@ import org.apache.flink.core.testutils.CheckedThread;
import org.apache.flink.core.testutils.OneShotLatch;
import org.apache.flink.util.TestLogger;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.Timeout;
import java.io.IOException;
import java.time.Duration;
@@ -40,13 +37,13 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import static org.apache.flink.util.Preconditions.checkNotNull;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.core.IsCollectionContaining.hasItem;
import static org.hamcrest.core.IsNot.not;
@@ -55,7 +52,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -63,10 +59,6 @@ import static org.junit.Assert.fail;
/** Tests for {@link NetworkBufferPool}. */
public class NetworkBufferPoolTest extends TestLogger {
- @Rule public ExpectedException expectedException = ExpectedException.none();
-
- @Rule public Timeout timeout = new Timeout(10, TimeUnit.SECONDS);
-
@Test
public void testCreatePoolAfterDestroy() {
try {
@@ -434,10 +426,9 @@ public class NetworkBufferPoolTest extends TestLogger {
segment.free();
- expectedException.expect(IllegalStateException.class);
- expectedException.expectMessage("destroyed");
try {
- asyncRequest.sync();
+ Exception ex = assertThrows(IllegalStateException.class, asyncRequest::sync);
+ assertTrue(ex.getMessage().contains("destroyed"));
} finally {
globalPool.destroy();
}
@@ -518,11 +509,9 @@ public class NetworkBufferPoolTest extends TestLogger {
asyncRequest.start();
- expectedException.expect(IOException.class);
- expectedException.expectMessage("Timeout");
-
try {
- asyncRequest.sync();
+ Exception ex = assertThrows(IOException.class, asyncRequest::sync);
+ assertTrue(ex.getMessage().contains("Timeout"));
} finally {
globalPool.destroy();
}
@@ -683,7 +672,7 @@ public class NetworkBufferPoolTest extends TestLogger {
// wait until all available buffers are requested
while (segmentsRequested.size() + segments.size() + exclusiveSegments.size()
< numBuffers) {
- Thread.sleep(100);
+ Thread.sleep(10);
assertNull(cause.get());
}