You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ma...@apache.org on 2022/12/07 16:20:52 UTC

[flink] branch master updated: [FLINK-30316][statebackend] Migrate tests to JUnit5

This is an automated email from the ASF dual-hosted git repository.

mapohl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new a0a5c71f785 [FLINK-30316][statebackend] Migrate tests to JUnit5
a0a5c71f785 is described below

commit a0a5c71f785dace33d05e9f96f122bd1d0425905
Author: Sergey Nuyanzin <sn...@gmail.com>
AuthorDate: Tue Dec 6 16:37:22 2022 +0100

    [FLINK-30316][statebackend] Migrate tests to JUnit5
---
 .../flink-statebackend-common/pom.xml              | 21 +++++++++++++++++
 .../common/PeriodicMaterializationManagerTest.java | 26 ++++++++++++----------
 .../org.junit.jupiter.api.extension.Extension      | 16 +++++++++++++
 3 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/flink-state-backends/flink-statebackend-common/pom.xml b/flink-state-backends/flink-statebackend-common/pom.xml
index d48313b6ff0..e890d679b7f 100644
--- a/flink-state-backends/flink-statebackend-common/pom.xml
+++ b/flink-state-backends/flink-statebackend-common/pom.xml
@@ -74,4 +74,25 @@ under the License.
 
     </dependencies>
 
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<executions>
+					<execution>
+						<goals>
+							<goal>test-jar</goal>
+						</goals>
+						<configuration>
+							<excludes>
+								<!-- test-jar is still used by JUnit4 modules -->
+								<exclude>META-INF/services/org.junit.jupiter.api.extension.Extension</exclude>
+							</excludes>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
 </project>
diff --git a/flink-state-backends/flink-statebackend-common/src/test/java/org/apache/flink/state/common/PeriodicMaterializationManagerTest.java b/flink-state-backends/flink-statebackend-common/src/test/java/org/apache/flink/state/common/PeriodicMaterializationManagerTest.java
index 089d37d459d..19c07801dca 100644
--- a/flink-state-backends/flink-statebackend-common/src/test/java/org/apache/flink/state/common/PeriodicMaterializationManagerTest.java
+++ b/flink-state-backends/flink-statebackend-common/src/test/java/org/apache/flink/state/common/PeriodicMaterializationManagerTest.java
@@ -21,21 +21,19 @@ import org.apache.flink.runtime.concurrent.ManuallyTriggeredScheduledExecutorSer
 import org.apache.flink.runtime.mailbox.SyncMailboxExecutor;
 import org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups;
 import org.apache.flink.state.common.PeriodicMaterializationManager.MaterializationTarget;
-import org.apache.flink.util.TestLogger;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import static org.apache.flink.shaded.guava30.com.google.common.collect.Iterators.getOnlyElement;
 import static org.apache.flink.util.concurrent.Executors.newDirectExecutorService;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.lessThanOrEqualTo;
+import static org.assertj.core.api.Assertions.assertThat;
 
 /** {@link PeriodicMaterializationManager} test. */
-public class PeriodicMaterializationManagerTest extends TestLogger {
+class PeriodicMaterializationManagerTest {
 
     @Test
-    public void testInitialDelay() {
+    void testInitialDelay() {
         ManuallyTriggeredScheduledExecutorService scheduledExecutorService =
                 new ManuallyTriggeredScheduledExecutorService();
         long periodicMaterializeDelay = 10_000L;
@@ -56,12 +54,16 @@ public class PeriodicMaterializationManagerTest extends TestLogger {
             test.start();
 
             assertThat(
-                    String.format(
-                            "task for initial materialization should be scheduled with a 0..%d delay",
-                            periodicMaterializeDelay),
-                    getOnlyElement(scheduledExecutorService.getAllScheduledTasks().iterator())
-                            .getDelay(MILLISECONDS),
-                    lessThanOrEqualTo(periodicMaterializeDelay));
+                            getOnlyElement(
+                                            scheduledExecutorService
+                                                    .getAllScheduledTasks()
+                                                    .iterator())
+                                    .getDelay(MILLISECONDS))
+                    .as(
+                            String.format(
+                                    "task for initial materialization should be scheduled with a 0..%d delay",
+                                    periodicMaterializeDelay))
+                    .isLessThanOrEqualTo(periodicMaterializeDelay);
         }
     }
 }
diff --git a/flink-state-backends/flink-statebackend-common/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension b/flink-state-backends/flink-statebackend-common/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
new file mode 100644
index 00000000000..28999133c2b
--- /dev/null
+++ b/flink-state-backends/flink-statebackend-common/src/test/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+org.apache.flink.util.TestLoggerExtension
\ No newline at end of file