Skip to content

Commit 7f4e834

Browse files
frediareswqa
authored andcommitted
[FLINK-31876][QS] Migrate flink-queryable-state-runtime tests to JUnit5
1 parent 2d87362 commit 7f4e834

15 files changed

+690
-583
lines changed

flink-queryable-state/flink-queryable-state-runtime/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ under the License.
124124
<goals>
125125
<goal>test-jar</goal>
126126
</goals>
127+
<configuration>
128+
<excludes>
129+
<!-- test-jar is still used by JUnit4 modules -->
130+
<exclude>META-INF/services/org.junit.jupiter.api.extension.Extension</exclude>
131+
</excludes>
132+
</configuration>
127133
</execution>
128134
</executions>
129135
</plugin>

flink-queryable-state/flink-queryable-state-runtime/src/test/java/org/apache/flink/queryablestate/client/proxy/KvStateClientProxyImplTest.java

+19-24
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,24 @@
2323
import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
2424
import org.apache.flink.runtime.jobmaster.KvStateLocationOracle;
2525
import org.apache.flink.runtime.query.KvStateLocation;
26-
import org.apache.flink.util.TestLogger;
2726

28-
import org.junit.After;
29-
import org.junit.Before;
30-
import org.junit.Test;
27+
import org.junit.jupiter.api.AfterEach;
28+
import org.junit.jupiter.api.BeforeEach;
29+
import org.junit.jupiter.api.Test;
3130

3231
import java.net.InetAddress;
3332
import java.util.Collections;
3433
import java.util.concurrent.CompletableFuture;
3534

36-
import static org.hamcrest.Matchers.equalTo;
37-
import static org.hamcrest.Matchers.nullValue;
38-
import static org.junit.Assert.assertThat;
35+
import static org.assertj.core.api.Assertions.assertThat;
3936

4037
/** Tests for the {@link KvStateClientProxyImpl}. */
41-
public class KvStateClientProxyImplTest extends TestLogger {
38+
class KvStateClientProxyImplTest {
4239

4340
private KvStateClientProxyImpl kvStateClientProxy;
4441

45-
@Before
46-
public void setup() {
42+
@BeforeEach
43+
void setup() {
4744
kvStateClientProxy =
4845
new KvStateClientProxyImpl(
4946
InetAddress.getLoopbackAddress().getHostName(),
@@ -53,14 +50,14 @@ public void setup() {
5350
new DisabledKvStateRequestStats());
5451
}
5552

56-
@After
57-
public void shutdown() {
53+
@AfterEach
54+
void shutdown() {
5855
kvStateClientProxy.shutdown();
5956
}
6057

6158
/** Tests that we can set and retrieve the {@link KvStateLocationOracle}. */
6259
@Test
63-
public void testKvStateLocationOracle() {
60+
void testKvStateLocationOracle() {
6461
final JobID jobId1 = new JobID();
6562
final TestingKvStateLocationOracle kvStateLocationOracle1 =
6663
new TestingKvStateLocationOracle();
@@ -70,34 +67,32 @@ public void testKvStateLocationOracle() {
7067
new TestingKvStateLocationOracle();
7168
kvStateClientProxy.updateKvStateLocationOracle(jobId2, kvStateLocationOracle2);
7269

73-
assertThat(kvStateClientProxy.getKvStateLocationOracle(new JobID()), nullValue());
70+
assertThat(kvStateClientProxy.getKvStateLocationOracle(new JobID())).isNull();
7471

75-
assertThat(
76-
kvStateClientProxy.getKvStateLocationOracle(jobId1),
77-
equalTo(kvStateLocationOracle1));
78-
assertThat(
79-
kvStateClientProxy.getKvStateLocationOracle(jobId2),
80-
equalTo(kvStateLocationOracle2));
72+
assertThat(kvStateClientProxy.getKvStateLocationOracle(jobId1))
73+
.isEqualTo(kvStateLocationOracle1);
74+
assertThat(kvStateClientProxy.getKvStateLocationOracle(jobId2))
75+
.isEqualTo(kvStateLocationOracle2);
8176

8277
kvStateClientProxy.updateKvStateLocationOracle(jobId1, null);
83-
assertThat(kvStateClientProxy.getKvStateLocationOracle(jobId1), nullValue());
78+
assertThat(kvStateClientProxy.getKvStateLocationOracle(jobId1)).isNull();
8479
}
8580

8681
/**
8782
* Tests that {@link KvStateLocationOracle} registered under {@link
8883
* HighAvailabilityServices#DEFAULT_JOB_ID} will be used for all requests.
8984
*/
9085
@Test
91-
public void testLegacyCodePathPreference() {
86+
void testLegacyCodePathPreference() {
9287
final TestingKvStateLocationOracle kvStateLocationOracle =
9388
new TestingKvStateLocationOracle();
9489
kvStateClientProxy.updateKvStateLocationOracle(
9590
HighAvailabilityServices.DEFAULT_JOB_ID, kvStateLocationOracle);
9691
final JobID jobId = new JobID();
9792
kvStateClientProxy.updateKvStateLocationOracle(jobId, new TestingKvStateLocationOracle());
9893

99-
assertThat(
100-
kvStateClientProxy.getKvStateLocationOracle(jobId), equalTo(kvStateLocationOracle));
94+
assertThat(kvStateClientProxy.getKvStateLocationOracle(jobId))
95+
.isEqualTo(kvStateLocationOracle);
10196
}
10297

10398
/** Testing implementation of {@link KvStateLocationOracle}. */

0 commit comments

Comments
 (0)