Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-06-12 Thread via GitHub


1996fanrui merged PR #24881:
URL: https://github.com/apache/flink/pull/24881


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-06-12 Thread via GitHub


1996fanrui commented on PR #24881:
URL: https://github.com/apache/flink/pull/24881#issuecomment-2164197766

   @flinkbot run azure


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-06-12 Thread via GitHub


1996fanrui commented on code in PR #24881:
URL: https://github.com/apache/flink/pull/24881#discussion_r1636152962


##
flink-core/src/test/java/org/apache/flink/core/fs/InitOutputPathTest.java:
##
@@ -23,59 +23,52 @@
 import org.apache.flink.core.fs.local.LocalFileSystem;
 import org.apache.flink.core.testutils.CheckedThread;
 import org.apache.flink.core.testutils.OneShotLatch;
+import org.apache.flink.testutils.junit.utils.TempDirUtils;
 
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
+import lombok.SneakyThrows;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.nio.file.FileAlreadyExistsException;
 import java.util.concurrent.locks.ReentrantLock;
 
-import static org.junit.Assert.fail;
-import static org.powermock.api.mockito.PowerMockito.whenNew;
+import static org.apache.flink.util.Preconditions.checkNotNull;
+import static org.junit.Assert.assertThrows;
 
 /** A test validating that the initialization of local output paths is 
properly synchronized. */
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(LocalFileSystem.class)
-public class InitOutputPathTest {
+class InitOutputPathTest {
 
-@Rule public final TemporaryFolder tempDir = new TemporaryFolder();
+@TempDir private static java.nio.file.Path tempFolder;
 
 /**
  * This test validates that this test case makes sense - that the error 
can be produced in the
  * absence of synchronization, if the threads make progress in a certain 
way, here enforced by
  * latches.
  */
 @Test
-public void testErrorOccursUnSynchronized() throws Exception {
+void testErrorOccursUnSynchronized() throws Exception {
 // deactivate the lock to produce the original un-synchronized state
 Field lock = 
FileSystem.class.getDeclaredField("OUTPUT_DIRECTORY_INIT_LOCK");
 lock.setAccessible(true);
-lock.set(null, new NoOpLock());
 
-try {
-// in the original un-synchronized state, we can force the race to 
occur by using
-// the proper latch order to control the process of the concurrent 
threads
-runTest(true);
-fail("should fail with an exception");
-} catch (FileNotFoundException e) {
-// expected
-} finally {
-// reset the proper value
-lock.set(null, new ReentrantLock(true));
-}
+Field modifiers = Field.class.getDeclaredField("modifiers");
+modifiers.setAccessible(true);
+modifiers.setInt(lock, lock.getModifiers() & ~Modifier.FINAL);
+
+lock.set(null, new NoOpLock());
+// in the original un-synchronized state, we can force the race to 
occur by using
+// the proper latch order to control the process of the concurrent 
threads
+assertThrows(FileNotFoundException.class, () -> runTest(true));

Review Comment:
   using assertThatThrownBy instead.



##
flink-core/src/test/java/org/apache/flink/core/fs/SafetyNetCloseableRegistryTest.java:
##
@@ -20,26 +20,27 @@
 
 import org.apache.flink.core.testutils.CheckedThread;
 import org.apache.flink.util.AbstractAutoCloseableRegistry;
-import org.apache.flink.util.ExceptionUtils;
 
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import java.io.Closeable;
+import java.io.File;
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
 /** Tests for the {@link SafetyNetCloseableRegistry}. */
 public class SafetyNetCloseableRegistryTest

Review Comment:
   ```suggestion
   class SafetyNetCloseableRegistryTest
   ```



##
flink-core/src/test/java/org/apache/flink/core/fs/local/LocalFileSystemRecoverableWriterTest.java:
##
@@ -21,18 +21,18 @@
 import org.apache.flink.core.fs.AbstractRecoverableWriterTest;
 import org.apache.flink.core.fs.FileSystem;
 import org.apache.flink.core.fs.Path;
+import org.apache.flink.testutils.junit.utils.TempDirUtils;
 
-import org.junit.ClassRule;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.io.TempDir;
 
 /** Tests for the {@link LocalRecoverableWriter}. */
 public class LocalFileSystemRecoverableWriterTest extends 
AbstractRecoverableWriterTest {

Review 

Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-06-11 Thread via GitHub


1996fanrui commented on PR #24881:
URL: https://github.com/apache/flink/pull/24881#issuecomment-2161888308

   > Thanks @GOODBOY008 for the quick update, LGTM now. Hi @1996fanrui, could 
you help double check this PR?
   
   Thank @Jiabao-Sun for the ping, I will check it these 2 days.


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-06-04 Thread via GitHub


Jiabao-Sun commented on code in PR #24881:
URL: https://github.com/apache/flink/pull/24881#discussion_r1626824660


##
flink-core/src/test/java/org/apache/flink/core/fs/AutoCloseableRegistryTest.java:
##
@@ -66,9 +64,9 @@ public void testSuppressedExceptions() throws Exception {
 
 fail("Close should throw exception");
 } catch (Exception ex) {
-assertEquals("1", ex.getMessage());
-assertEquals("2", ex.getSuppressed()[0].getMessage());
-assertEquals("java.lang.AssertionError: 3", 
ex.getSuppressed()[1].getMessage());
+assertThat(ex.getMessage()).isEqualTo("1");
+assertThat(ex.getSuppressed()[0].getMessage()).isEqualTo("2");
+
assertThat(ex.getSuppressed()[1].getMessage()).isEqualTo("java.lang.AssertionError:
 3");

Review Comment:
   ```java
   assertThatThrownBy(autoCloseableRegistry::close)
   .hasMessage("1")
   .satisfies(
   e -> 
assertThat(e.getSuppressed()[0]).hasMessage("2"),
   e -> 
assertThat(e.getSuppressed()[1]).hasMessage("java.lang.AssertionError: 3"));
   ```



##
flink-core/src/test/java/org/apache/flink/core/fs/local/LocalFileSystemTest.java:
##
@@ -156,37 +151,38 @@ public void testLocalFilesystem() throws Exception {
 
 testbytestest = new byte[5];
 final FSDataInputStream lfsinput2 = lfs.open(pathtotestfile2);
-assertEquals(lfsinput2.read(testbytestest), 5);
+assertThat(lfsinput2.read(testbytestest)).isEqualTo(5);
 lfsinput2.close();
-assertTrue(Arrays.equals(testbytes, testbytestest));
+assertThat(testbytestest).containsExactly(testbytes);
 
 // does lfs see two files?
-assertEquals(lfs.listStatus(pathtotmpdir).length, 2);
+assertThat(lfs.listStatus(pathtotmpdir)).hasSize(2);
 
 // do we get exactly one blocklocation per file? no matter what start 
and len we provide
-
assertEquals(lfs.getFileBlockLocations(lfs.getFileStatus(pathtotestfile1), 0, 
0).length, 1);
+
assertThat(lfs.getFileBlockLocations(lfs.getFileStatus(pathtotestfile1), 0, 
0).length)
+.isOne();
 
 /*
  * can lfs delete files / directories?
  */
-assertTrue(lfs.delete(pathtotestfile1, false));
+assertThat(lfs.delete(pathtotestfile1, false)).isTrue();
 
 // and can lfs also delete directories recursively?
-assertTrue(lfs.delete(pathtotmpdir, true));
+assertThat(lfs.delete(pathtotmpdir, true)).isTrue();
 
-assertTrue(!tempdir.exists());
+assertThat(tempdir.exists()).isFalse();

Review Comment:
   ```suggestion
   assertThat(tempdir).doesNotExist();
   ```



##
flink-filesystems/flink-azure-fs-hadoop/src/test/java/org/apache/flink/fs/azurefs/AzureBlobRecoverableWriterTest.java:
##
@@ -46,15 +43,11 @@ public class AzureBlobRecoverableWriterTest extends 
AbstractRecoverableWriterTes
 private static final String ACCESS_KEY = 
System.getenv("ARTIFACTS_AZURE_ACCESS_KEY");
 private static final String TEST_DATA_DIR = "tests-" + UUID.randomUUID();
 
-@BeforeClass
+@BeforeAll
 public static void checkCredentialsAndSetup() throws IOException {

Review Comment:
   ```suggestion
   static void checkCredentialsAndSetup() throws IOException {
   ```



##
flink-core/src/test/java/org/apache/flink/core/memory/ByteArrayOutputStreamWithPosTest.java:
##
@@ -20,90 +20,91 @@
 
 import org.apache.flink.configuration.ConfigConstants;
 
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 import java.io.IOException;
 import java.util.Arrays;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 /** Tests for {@link ByteArrayOutputStreamWithPos}. */
-public class ByteArrayOutputStreamWithPosTest {
+class ByteArrayOutputStreamWithPosTest {
 
 private static final int BUFFER_SIZE = 32;
 
-@Rule public ExpectedException thrown = ExpectedException.none();
-
 private ByteArrayOutputStreamWithPos stream;
 
-@Before
-public void setup() {
+@BeforeEach
+void setup() {
 stream = new ByteArrayOutputStreamWithPos(BUFFER_SIZE);
 }
 
 /** Test setting position which is exactly the same with the buffer size. 
*/
 @Test
-public void testSetPositionWhenBufferIsFull() throws Exception {
+void testSetPositionWhenBufferIsFull() throws Exception {
 stream.write(new byte[BUFFER_SIZE]);
 
 // check whether the buffer is filled fully
-Assert.assertEquals(BUFFER_SIZE, stream.getBuf().length);
+assertThat(stream.getBuf()).hasSize(BUFFER_SIZE);
 
 // check current position i

Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-06-03 Thread via GitHub


flinkbot commented on PR #24881:
URL: https://github.com/apache/flink/pull/24881#issuecomment-2145361395

   
   ## CI report:
   
   * c1b3b0623e1d0fd68ca0d10924cea9bfa693b368 UNKNOWN
   
   
   Bot commands
 The @flinkbot bot supports the following commands:
   
- `@flinkbot run azure` re-run the last Azure build
   


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-06-03 Thread via GitHub


GOODBOY008 opened a new pull request, #24881:
URL: https://github.com/apache/flink/pull/24881

   (no comment)


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-06-03 Thread via GitHub


GOODBOY008 closed pull request #24685: [FLINK-25537] [JUnit5 Migration] Module: 
flink-core with,Package: core
URL: https://github.com/apache/flink/pull/24685


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-06-02 Thread via GitHub


1996fanrui commented on PR #24685:
URL: https://github.com/apache/flink/pull/24685#issuecomment-2144183912

   > @flinkbot run azure
   
   Hi @GOODBOY008 , the CI cannot be triggered for this PR. Creating a new PR 
may be a workaround for it.


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-05-31 Thread via GitHub


GOODBOY008 commented on PR #24685:
URL: https://github.com/apache/flink/pull/24685#issuecomment-2143263153

   @flinkbot run azure


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-05-30 Thread via GitHub


GOODBOY008 commented on PR #24685:
URL: https://github.com/apache/flink/pull/24685#issuecomment-2141075315

   @flinkbot run azure


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-05-30 Thread via GitHub


GOODBOY008 commented on PR #24685:
URL: https://github.com/apache/flink/pull/24685#issuecomment-2140991378

   @flinkbot run azure


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-05-29 Thread via GitHub


1996fanrui commented on code in PR #24685:
URL: https://github.com/apache/flink/pull/24685#discussion_r1597784913


##
flink-core/src/test/java/org/apache/flink/core/memory/CrossSegmentTypeTest.java:
##
@@ -86,15 +84,15 @@ private void testCompare(MemorySegment seg1, MemorySegment 
seg2, Random random)
 int cmp = seg1.compare(seg2, pos1, pos2, len);
 
 if (pos1 < pos2 - shift) {
-assertTrue(cmp <= 0);
+assertThat(cmp).isLessThanOrEqualTo(0);
 } else {
-assertTrue(cmp >= 0);
+assertThat(cmp >= 0).isTrue();

Review Comment:
   ```suggestion
   assertThat(cmp).isGreaterThanOrEqualTo(0);
   ```



-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-05-11 Thread via GitHub


1996fanrui commented on PR #24685:
URL: https://github.com/apache/flink/pull/24685#issuecomment-2105650954

   > @1996fanrui PTAL
   
   Thanks @GOODBOY008 for the ping, this PR is huge, I try to review it next 
week.


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-05-11 Thread via GitHub


GOODBOY008 commented on PR #24685:
URL: https://github.com/apache/flink/pull/24685#issuecomment-2105650442

   @1996fanrui PTAL


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-04-19 Thread via GitHub


GOODBOY008 commented on PR #24685:
URL: https://github.com/apache/flink/pull/24685#issuecomment-2066192460

   @Jiabao-Sun @1996fanrui PTAL


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-04-19 Thread via GitHub


flinkbot commented on PR #24685:
URL: https://github.com/apache/flink/pull/24685#issuecomment-2066063146

   
   ## CI report:
   
   * 2b1bc24cbfb7a12d0741a34caae26bd52ad195f5 UNKNOWN
   
   
   Bot commands
 The @flinkbot bot supports the following commands:
   
- `@flinkbot run azure` re-run the last Azure build
   


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[PR] [FLINK-25537] [JUnit5 Migration] Module: flink-core with,Package: core [flink]

2024-04-19 Thread via GitHub


GOODBOY008 opened a new pull request, #24685:
URL: https://github.com/apache/flink/pull/24685

   changes:
   
   - Migrate module core to junit5 with core package.


-- 
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-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org