You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2022/10/09 01:44:36 UTC
[incubator-streampark] branch dev updated: [Improve] Upgrade junit to 5.+ (#1778)
This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new af39f869d [Improve] Upgrade junit to 5.+ (#1778)
af39f869d is described below
commit af39f869d5be1b14614e5d22ab69d15fa43e1403
Author: ChunFu Wu <31...@qq.com>
AuthorDate: Sun Oct 9 09:44:30 2022 +0800
[Improve] Upgrade junit to 5.+ (#1778)
---
pom.xml | 17 ++-
streampark-common/pom.xml | 9 +-
.../streampark-console-service/pom.xml | 5 +-
.../benmanes/caffeine/cache/RefreshCacheTest.java | 2 +-
.../util/concurrent/CompletableFutureTest.java | 32 +++--
.../src/test/java/java/util/regex/RegexTest.java | 2 +-
.../org/apache/commons/mail/SendEmailTest.java | 10 +-
.../console/base/util/FileUtilsTest.java | 49 +++----
.../console/base/util/ShaHashUtilsTest.java | 11 +-
.../console/core/entity/DependencyTest.java | 2 +-
.../streampark/console/core/entity/GitTest.java | 10 +-
.../core/service/ApplicationServiceTest.java | 8 +-
.../core/service/alert/AlertServiceTest.java | 6 +-
.../console/system/authentication/JWTTest.java | 6 +-
streampark-flink/pom.xml | 8 --
.../streampark-flink-shims-base/pom.xml | 8 --
.../java/org/apache/streampark/RegExpTest.java | 22 +--
.../flink/submit/test/ParameterTestCase.scala | 8 +-
streampark-plugin/streampark-jvm-profiler/pom.xml | 8 +-
.../streampark/plugin/profiling/AgentITCase.java | 101 +++++++-------
.../plugin/profiling/AgentThreadFactoryTest.java | 7 +-
.../streampark/plugin/profiling/ArgumentsTest.java | 132 +++++++++---------
.../plugin/profiling/ProfilerRunnableTest.java | 7 +-
.../plugin/profiling/YamlConfigProviderTest.java | 49 +++----
.../profiler/CpuAndMemoryProfilerTest.java | 25 ++--
.../profiler/MethodArgumentProfilerTest.java | 21 +--
.../profiler/MethodDurationProfilerTest.java | 29 ++--
.../profiler/ProcessInfoProfilerTest.java | 43 +++---
.../profiler/StacktraceCollectorProfilerTest.java | 57 ++++----
.../profiler/StacktraceReporterProfilerTest.java | 51 +++----
.../profiling/profiler/ThreadInfoProfilerTest.java | 21 +--
.../reporter/ConsoleOutputReporterTest.java | 3 +-
.../transformer/MethodProfilerStaticProxyTest.java | 34 ++---
.../profiling/util/ClassAndMethodFilterTest.java | 49 +++----
.../util/ClassAndMethodMetricBufferTest.java | 67 ++++-----
.../util/ClassMethodArgmentMetricBufferTest.java | 37 ++---
.../util/ClassMethodArgumentFilterTest.java | 63 ++++-----
.../plugin/profiling/util/IOUtilsTest.java | 13 +-
.../plugin/profiling/util/ProcFileUtilsTest.java | 135 ++++++++++---------
.../plugin/profiling/util/ReflectionUtilsTest.java | 6 +-
.../plugin/profiling/util/SparkUtilsTest.java | 17 +--
.../profiling/util/StacktraceMetricBufferTest.java | 69 +++++-----
.../plugin/profiling/util/StringUtilsTest.java | 149 +++++++++++----------
streampark-storage/pom.xml | 6 +-
.../storage/oss/OssStorageServiceTest.java | 8 +-
45 files changed, 716 insertions(+), 706 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9fefc9ff2..c46fabbd5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -98,7 +98,6 @@
<hive.version>2.3.4</hive.version>
<hadoop.version>2.10.2</hadoop.version>
<hbase.version>2.1.10</hbase.version>
- <jupiter.version>5.6.3</jupiter.version>
<zkclient.version>0.11</zkclient.version>
<curator.version>4.2.0</curator.version>
<redis.version>3.3.0</redis.version>
@@ -136,7 +135,7 @@
<flink.table.uber.artifact.id>flink-table-uber_${scala.binary.version}</flink.table.uber.artifact.id>
<httpclient.version>4.5.13</httpclient.version>
<lombok.version>1.18.24</lombok.version>
- <junit.version>4.13.2</junit.version>
+ <jupiter.version>5.9.1</jupiter.version>
<PermGen>64m</PermGen>
<MaxPermGen>512m</MaxPermGen>
@@ -559,10 +558,18 @@
<version>${lombok.version}</version>
</dependency>
+ <!-- test -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>${jupiter.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <version>${jupiter.version}</version>
+ <scope>test</scope>
</dependency>
</dependencies>
diff --git a/streampark-common/pom.xml b/streampark-common/pom.xml
index 6e79956c7..2b4163d36 100644
--- a/streampark-common/pom.xml
+++ b/streampark-common/pom.xml
@@ -31,7 +31,7 @@
<dependencies>
- <!-- junit -->
+ <!-- test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
@@ -46,13 +46,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <version>${jupiter.version}</version>
- <scope>test</scope>
- </dependency>
-
<!-- enumeratum -->
<dependency>
<groupId>com.beachape</groupId>
diff --git a/streampark-console/streampark-console-service/pom.xml b/streampark-console/streampark-console-service/pom.xml
index 748209f8d..d997084b3 100644
--- a/streampark-console/streampark-console-service/pom.xml
+++ b/streampark-console/streampark-console-service/pom.xml
@@ -99,9 +99,10 @@
<artifactId>guava</artifactId>
</dependency>
+ <!--test-->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
diff --git a/streampark-console/streampark-console-service/src/test/java/com/github/benmanes/caffeine/cache/RefreshCacheTest.java b/streampark-console/streampark-console-service/src/test/java/com/github/benmanes/caffeine/cache/RefreshCacheTest.java
index 31386b927..4b88c8ce6 100644
--- a/streampark-console/streampark-console-service/src/test/java/com/github/benmanes/caffeine/cache/RefreshCacheTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/com/github/benmanes/caffeine/cache/RefreshCacheTest.java
@@ -17,7 +17,7 @@
package com.github.benmanes.caffeine.cache;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
diff --git a/streampark-console/streampark-console-service/src/test/java/java/util/concurrent/CompletableFutureTest.java b/streampark-console/streampark-console-service/src/test/java/java/util/concurrent/CompletableFutureTest.java
index 61dca2cb3..849fc855d 100644
--- a/streampark-console/streampark-console-service/src/test/java/java/util/concurrent/CompletableFutureTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/java/util/concurrent/CompletableFutureTest.java
@@ -17,12 +17,10 @@
package java.util.concurrent;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import org.apache.streampark.common.util.CompletableFutureUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -48,9 +46,9 @@ public class CompletableFutureTest {
e -> isStartException.set(true)
).get();
- assertTrue(future.isDone());
- assertTrue(isStartNormal.get());
- assertFalse(isStartException.get());
+ Assertions.assertTrue(future.isDone());
+ Assertions.assertTrue(isStartNormal.get());
+ Assertions.assertFalse(isStartException.get());
}
@Test
@@ -75,14 +73,14 @@ public class CompletableFutureTest {
},
e -> {
isStartException.set(true);
- assertTrue(future.isCancelled());
- assertTrue(e.getCause() instanceof CancellationException);
+ Assertions.assertTrue(future.isCancelled());
+ Assertions.assertTrue(e.getCause() instanceof CancellationException);
System.out.println("The future is cancelled.");
}
).get();
- assertTrue(future.isCancelled());
- assertFalse(isStartNormal.get());
- assertTrue(isStartException.get());
+ Assertions.assertTrue(future.isCancelled());
+ Assertions.assertFalse(isStartNormal.get());
+ Assertions.assertTrue(isStartException.get());
}
@Test
@@ -108,15 +106,15 @@ public class CompletableFutureTest {
},
e -> {
isStartException.set(true);
- assertFalse(future.isDone());
- assertTrue(e.getCause() instanceof TimeoutException);
+ Assertions.assertFalse(future.isDone());
+ Assertions.assertTrue(e.getCause() instanceof TimeoutException);
future.cancel(true);
System.out.println("Future is timed out.");
}
).get();
- assertTrue(future.isCancelled());
- assertFalse(isStartNormal.get());
- assertTrue(isStartException.get());
+ Assertions.assertTrue(future.isCancelled());
+ Assertions.assertFalse(isStartNormal.get());
+ Assertions.assertTrue(isStartException.get());
}
/**
diff --git a/streampark-console/streampark-console-service/src/test/java/java/util/regex/RegexTest.java b/streampark-console/streampark-console-service/src/test/java/java/util/regex/RegexTest.java
index 74e3bb20f..22846f614 100644
--- a/streampark-console/streampark-console-service/src/test/java/java/util/regex/RegexTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/java/util/regex/RegexTest.java
@@ -19,7 +19,7 @@ package java.util.regex;
import org.apache.streampark.common.util.CommandUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.net.MalformedURLException;
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/commons/mail/SendEmailTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/commons/mail/SendEmailTest.java
index 1b9799725..5b16a62d9 100644
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/commons/mail/SendEmailTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/commons/mail/SendEmailTest.java
@@ -26,8 +26,8 @@ import org.apache.streampark.console.core.entity.Application;
import org.apache.streampark.console.core.enums.FlinkAppState;
import freemarker.template.Template;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.StringWriter;
import java.util.Date;
@@ -41,7 +41,7 @@ public class SendEmailTest {
private SenderEmail senderEmail;
- @Before
+ @BeforeEach
public void initConfig() throws Exception {
this.template = FreemarkerUtils.loadTemplateFile("alert-email.ftl");
senderEmail = new SenderEmail();
@@ -108,7 +108,9 @@ public class SendEmailTest {
template.setStartTime(DateUtils.format(application.getStartTime(), DateUtils.fullFormat(), TimeZone.getDefault()));
template.setDuration(DateUtils.toRichTimeDuration(duration));
template.setLink(url);
- template.setEndTime(DateUtils.format(application.getEndTime() == null ? new Date() : application.getEndTime(), DateUtils.fullFormat(), TimeZone.getDefault()));
+ template.setEndTime(
+ DateUtils.format(application.getEndTime() == null ? new Date() : application.getEndTime(), DateUtils.fullFormat(),
+ TimeZone.getDefault()));
template.setRestart(application.isNeedRestartOnFailed());
template.setRestartIndex(application.getRestartCount());
template.setTotalRestart(application.getRestartSize());
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/util/FileUtilsTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/util/FileUtilsTest.java
index 68846b46f..60aa2f516 100644
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/util/FileUtilsTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/util/FileUtilsTest.java
@@ -17,18 +17,15 @@
package org.apache.streampark.console.base.util;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.nio.file.Path;
import java.util.Random;
/**
@@ -36,13 +33,10 @@ import java.util.Random;
*/
public class FileUtilsTest {
- @ClassRule
- public static final TemporaryFolder TEMP_FOLDER = new TemporaryFolder();
-
@Test
- public void testReadEndOfFile() throws IOException {
- final File outDir = TEMP_FOLDER.newFolder();
- File file = new File(outDir, "tmp_file");
+ public void testReadEndOfFile(@TempDir Path tempDir) throws IOException {
+ Path filePath = tempDir.resolve("tmp_file");
+ File file = filePath.toFile();
FileOutputStream outputStream = new FileOutputStream(file);
Random random = new Random();
int fileSize = 1000000;
@@ -54,25 +48,24 @@ public class FileUtilsTest {
// The read size is larger than the file size
byte[] readBytes = FileUtils.readEndOfFile(file, fileSize + 1);
- assertArrayEquals(fileBytes, readBytes);
+ Assertions.assertArrayEquals(fileBytes, readBytes);
// The read size is equals the file size
readBytes = FileUtils.readEndOfFile(file, fileSize);
- assertArrayEquals(fileBytes, readBytes);
+ Assertions.assertArrayEquals(fileBytes, readBytes);
// The read size is less than the file size
int readSize = 50000;
readBytes = FileUtils.readEndOfFile(file, readSize);
byte[] expectedBytes = new byte[readSize];
System.arraycopy(fileBytes, fileSize - readSize, expectedBytes, 0, expectedBytes.length);
- assertArrayEquals(expectedBytes, readBytes);
+ Assertions.assertArrayEquals(expectedBytes, readBytes);
}
@Test
- public void testReadEndOfFileWithChinese() throws IOException {
- final File outDir = TEMP_FOLDER.newFolder();
-
- File file = new File(outDir, "tmp_file");
+ public void testReadEndOfFileWithChinese(@TempDir Path tempDir) throws IOException {
+ Path filePath = tempDir.resolve("tmp_file");
+ File file = filePath.toFile();
PrintWriter writer = new PrintWriter(file);
String logWithChinese = "Hello world! 你好啊,hello xxxx";
writer.write(logWithChinese);
@@ -80,13 +73,13 @@ public class FileUtilsTest {
byte[] bytes = FileUtils.readEndOfFile(file, 1000000);
String readString = new String(bytes);
- assertEquals(logWithChinese, readString);
+ Assertions.assertEquals(logWithChinese, readString);
}
@Test
- public void testReadFileFromOffset() throws IOException {
- final File outDir = TEMP_FOLDER.newFolder();
- File file = new File(outDir, "tmp_file");
+ public void testReadFileFromOffset(@TempDir Path tempDir) throws IOException {
+ Path filePath = tempDir.resolve("tmp_file");
+ File file = filePath.toFile();
FileOutputStream outputStream = new FileOutputStream(file);
Random random = new Random();
int fileSize = 1000000;
@@ -98,11 +91,11 @@ public class FileUtilsTest {
// The read size is larger than the file size
byte[] readBytes = FileUtils.readFileFromOffset(file, 0, fileSize + 1);
- assertArrayEquals(fileBytes, readBytes);
+ Assertions.assertArrayEquals(fileBytes, readBytes);
// The read size is equals the file size
readBytes = FileUtils.readFileFromOffset(file, 0, fileSize);
- assertArrayEquals(fileBytes, readBytes);
+ Assertions.assertArrayEquals(fileBytes, readBytes);
// The read size is less than the file size
int readSize = 3456;
@@ -110,10 +103,10 @@ public class FileUtilsTest {
byte[] tmpReadBytes;
for (int i = 0; i < fileSize; i += tmpReadBytes.length) {
tmpReadBytes = FileUtils.readFileFromOffset(file, i, readSize);
- assertTrue(tmpReadBytes.length <= readSize);
+ Assertions.assertTrue(tmpReadBytes.length <= readSize);
System.arraycopy(tmpReadBytes, 0, readBytes, i, tmpReadBytes.length);
}
- assertArrayEquals(fileBytes, readBytes);
+ Assertions.assertArrayEquals(fileBytes, readBytes);
}
}
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/util/ShaHashUtilsTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/util/ShaHashUtilsTest.java
index fca2f46c4..9e28dea8a 100644
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/util/ShaHashUtilsTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/base/util/ShaHashUtilsTest.java
@@ -17,17 +17,18 @@
package org.apache.streampark.console.base.util;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
-import org.junit.Test;
-
-/** Test for {@link ShaHashUtils} */
+/**
+ * Test for {@link ShaHashUtils}
+ */
public class ShaHashUtilsTest {
@Test
public void testEncrypt() {
String randomSalt = "rh8b1ojwog777yrg0daesf04gk";
String encryptPassword = ShaHashUtils.encrypt(randomSalt, "streampark");
- assertEquals("2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f", encryptPassword);
+ Assertions.assertEquals("2513f3748847298ea324dffbf67fe68681dd92315bda830065facd8efe08f54f", encryptPassword);
}
}
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/DependencyTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/DependencyTest.java
index 524b72373..4576c05ce 100644
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/DependencyTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/DependencyTest.java
@@ -20,7 +20,7 @@ package org.apache.streampark.console.core.entity;
import org.apache.streampark.common.util.DependencyUtils;
import lombok.extern.slf4j.Slf4j;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/GitTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/GitTest.java
index faf1508c8..c90c1977f 100644
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/GitTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/entity/GitTest.java
@@ -19,8 +19,8 @@ package org.apache.streampark.console.core.entity;
import org.apache.streampark.console.core.enums.GitAuthorizedError;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.List;
@@ -28,20 +28,20 @@ public class GitTest {
private final Project project = new Project();
- @Before
+ @BeforeEach
public void before() {
project.setUrl("https://github.com/streamxhub/streampark-quickstart");
}
@Test
public void getBranchs() {
- List<String> branches = project.getAllBranches();
+ List<String> branches = project.getAllBranches();
branches.forEach(System.out::println);
}
@Test
public void auth() {
- GitAuthorizedError error = project.gitCheck();
+ GitAuthorizedError error = project.gitCheck();
System.out.println(error);
}
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/ApplicationServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/ApplicationServiceTest.java
index 379e31810..b8906ce5c 100644
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/ApplicationServiceTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/ApplicationServiceTest.java
@@ -20,19 +20,19 @@ package org.apache.streampark.console.core.service;
import org.apache.streampark.console.StreamParkConsoleBootstrap;
import org.apache.streampark.console.core.entity.Application;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.Date;
/**
* org.apache.streampark.console.core.service.ApplicationServiceTest
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = StreamParkConsoleBootstrap.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ApplicationServiceTest {
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/alert/AlertServiceTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/alert/AlertServiceTest.java
index 6c4896894..e64a9dbbd 100644
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/alert/AlertServiceTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/core/service/alert/AlertServiceTest.java
@@ -28,8 +28,8 @@ import org.apache.streampark.console.core.service.alert.impl.LarkAlertNotifyServ
import org.apache.streampark.console.core.service.alert.impl.WeComAlertNotifyServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.web.client.RestTemplate;
import java.util.Date;
@@ -41,7 +41,7 @@ public class AlertServiceTest {
ObjectMapper mapper = new ObjectMapper();
RestTemplate restTemplate = new RestTemplate();
- @Before
+ @BeforeEach
public void before1() {
alertTemplate = new AlertTemplate();
alertTemplate.setTitle("Notify: StreamPark alert job for test");
diff --git a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/authentication/JWTTest.java b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/authentication/JWTTest.java
index 8ac7d28f6..5beaa5da1 100644
--- a/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/authentication/JWTTest.java
+++ b/streampark-console/streampark-console-service/src/test/java/org/apache/streampark/console/system/authentication/JWTTest.java
@@ -21,8 +21,8 @@ import org.apache.streampark.common.util.DateUtils;
import org.apache.streampark.console.system.entity.AccessToken;
import com.auth0.jwt.JWT;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Date;
import java.util.TimeZone;
@@ -40,6 +40,6 @@ public class JWTTest {
assert token != null;
Date expiresAt = JWT.decode(token).getExpiresAt();
String decodeExpireTime = DateUtils.format(expiresAt, DateUtils.fullFormat(), TimeZone.getDefault());
- Assert.assertEquals(expireTime, decodeExpireTime);
+ Assertions.assertEquals(expireTime, decodeExpireTime);
}
}
diff --git a/streampark-flink/pom.xml b/streampark-flink/pom.xml
index 9cda2d986..1a6452fdf 100644
--- a/streampark-flink/pom.xml
+++ b/streampark-flink/pom.xml
@@ -65,14 +65,6 @@
<version>${jupiter.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <version>${jupiter.version}</version>
- <scope>test</scope>
- </dependency>
-
</dependencies>
<build>
diff --git a/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/pom.xml b/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/pom.xml
index 83ad311db..47560b545 100644
--- a/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/pom.xml
+++ b/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/pom.xml
@@ -89,14 +89,6 @@
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.2</version>
- <scope>test</scope>
- </dependency>
-
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-api</artifactId>
diff --git a/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/src/test/java/org/apache/streampark/RegExpTest.java b/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/src/test/java/org/apache/streampark/RegExpTest.java
index 3fa2dbd87..8c1e15661 100644
--- a/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/src/test/java/org/apache/streampark/RegExpTest.java
+++ b/streampark-flink/streampark-flink-shims/streampark-flink-shims-base/src/test/java/org/apache/streampark/RegExpTest.java
@@ -17,43 +17,45 @@
package org.apache.streampark;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
- * 一些简单的测试
+ * some simple tests
*/
public class RegExpTest {
/**
- * 不区分大小写,将所有内容作为一行进行匹配,.会匹配换行符,注意:\s可以匹配任何空白字符,包括换行符
+ * Case insensitive, matches everything as one line, . matches newlines, note: \s matches any whitespace character, including newlines
*/
public static final int DEFAULT_PATTERN_FLAGS = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
/**
* CREATE CATALOG catalog_name WITH (key1=val1, key2=val2, ...)<br>
- * 示例:create catalog hive_catalog with('name' = 'my_hive', 'conf' = '/home/hive/conf')
+ * Example:create catalog hive_catalog with('name' = 'my_hive', 'conf' = '/home/hive/conf')
*/
private static final Pattern CREATE_HIVE_CATALOG = Pattern.compile("CREATE\\s+CATALOG\\s+.+", DEFAULT_PATTERN_FLAGS);
@Test
public void testCreateHiveCatalog() {
String str = "create catalog hive with (\n" +
- " 'type' = 'hive',\n" +
- " 'hadoop-conf-dir' = 'D:\\IDEAWorkspace\\work\\baishan\\log\\data-max\\src\\main\\resources',\n" +
- " 'hive-conf-dir' = 'D:\\IDEAWorkspace\\work\\baishan\\log\\data-max\\src\\main\\resources'\n" +
- ")";
+ " 'type' = 'hive',\n" +
+ " 'hadoop-conf-dir' = 'D:\\IDEAWorkspace\\work\\baishan\\log\\data-max\\src\\main\\resources',\n" +
+ " 'hive-conf-dir' = 'D:\\IDEAWorkspace\\work\\baishan\\log\\data-max\\src\\main\\resources'\n" +
+ ")";
Matcher matcher = CREATE_HIVE_CATALOG.matcher(str);
System.out.println(matcher.matches());
}
/**
* CREATE [TEMPORARY|TEMPORARY SYSTEM] FUNCTION [IF NOT EXISTS] [catalog_name.][db_name.]function_name AS identifier [LANGUAGE JAVA|SCALA|PYTHON]<br>
- * 示例:create function test_fun as com.flink.testFun
+ * Example:create function test_fun as com.flink.testFun
*/
- private static final Pattern CREATE_FUNCTION = Pattern.compile("(CREATE\\s+(TEMPORARY\\s+|TEMPORARY\\s+SYSTEM\\s+|)FUNCTION\\s+(IF NOT EXISTS\\s+|)([A-Za-z]+[A-Za-z\\d.\\-_]+)\\s+AS\\s+'([A-Za-z].+)'\\s+LANGUAGE\\s+(JAVA|SCALA|PYTHON)\\s*)", DEFAULT_PATTERN_FLAGS);
+ private static final Pattern CREATE_FUNCTION = Pattern.compile(
+ "(CREATE\\s+(TEMPORARY\\s+|TEMPORARY\\s+SYSTEM\\s+|)FUNCTION\\s+(IF NOT EXISTS\\s+|)([A-Za-z]+[A-Za-z\\d.\\-_]+)\\s+AS\\s+'([A-Za-z].+)'\\s+LANGUAGE\\s+(JAVA|SCALA|PYTHON)\\s*)",
+ DEFAULT_PATTERN_FLAGS);
@Test
public void testCreateFunction() {
diff --git a/streampark-flink/streampark-flink-submit/streampark-flink-submit-core/src/test/scala/org/apache/streampark/flink/submit/test/ParameterTestCase.scala b/streampark-flink/streampark-flink-submit/streampark-flink-submit-core/src/test/scala/org/apache/streampark/flink/submit/test/ParameterTestCase.scala
index e54448381..4b97ef9b9 100644
--- a/streampark-flink/streampark-flink-submit/streampark-flink-submit-core/src/test/scala/org/apache/streampark/flink/submit/test/ParameterTestCase.scala
+++ b/streampark-flink/streampark-flink-submit/streampark-flink-submit-core/src/test/scala/org/apache/streampark/flink/submit/test/ParameterTestCase.scala
@@ -19,10 +19,7 @@ package org.apache.streampark.flink.submit.test
import org.apache.flink.api.java.utils.ParameterTool
import org.junit.jupiter.api.{Assertions, Test}
-import java.util.regex.Pattern
-import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
-import scala.util.Try
class ParameterTestCase {
@@ -50,7 +47,7 @@ class ParameterTestCase {
val argsStr = "--url localhost:8123 \n" +
"--insertSql1 'insert \'\'into default.test values (?,?,?,?,?)' \n" +
- "--insertSql2 'insert into default.test values (1,2,3,4,\"111\")'\n "+
+ "--insertSql2 'insert into default.test values (1,2,3,4,\"111\")'\n " +
"--insertSql2 \"insert into default.test values (1,2,3,4,\'111\')\" \n" +
"--insertSql2 'insert into default.test values (1,2,3,4,\"111\", \'22\', \'\')'"
@@ -99,9 +96,10 @@ class ParameterTestCase {
processElement(next, 0)
}
}
+
processElement(0, 0)
- val programArgs = argsArray.map(_.trim.replaceAll("^[\"|']|[\"|']$","")).toList
+ val programArgs = argsArray.map(_.trim.replaceAll("^[\"|']|[\"|']$", "")).toList
Assertions.assertEquals("localhost:8123", programArgs(1))
Assertions.assertEquals("insert \'\'into default.test values (?,?,?,?,?)", programArgs(3))
diff --git a/streampark-plugin/streampark-jvm-profiler/pom.xml b/streampark-plugin/streampark-jvm-profiler/pom.xml
index e28929647..b9a3be532 100644
--- a/streampark-plugin/streampark-jvm-profiler/pom.xml
+++ b/streampark-plugin/streampark-jvm-profiler/pom.xml
@@ -61,14 +61,12 @@
<artifactId>snakeyaml</artifactId>
</dependency>
- <!--Test-->
+ <!--test-->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.1</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
-
</dependencies>
<build>
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/AgentITCase.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/AgentITCase.java
index 9989d9c45..9b23ed15b 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/AgentITCase.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/AgentITCase.java
@@ -17,12 +17,13 @@
package org.apache.streampark.plugin.profiling;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Comparator;
@@ -30,6 +31,7 @@ import java.util.List;
import java.util.stream.Collectors;
public class AgentITCase {
+
@Test
public void runAgent() throws InterruptedException, IOException {
String javaHome = System.getProperty("java.home");
@@ -47,9 +49,11 @@ public class AgentITCase {
agentJar,
"-javaagent:"
+ agentJar
- + "=configProvider=org.apache.streampark.plugin.profiling.util.DummyConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ +
+ "=configProvider=org.apache.streampark.plugin.profiling.util.DummyConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ outputDir
- + ",tag=mytag,metricInterval=200,durationProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod,argumentProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod.1,ioProfiling=true",
+ +
+ ",tag=mytag,metricInterval=200,durationProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod,argumentProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod.1,ioProfiling=true",
"org.apache.streampark.plugin.profiling.example.HelloWorldApplication",
"2000");
@@ -60,46 +64,46 @@ public class AgentITCase {
process.waitFor();
File[] files = new File(outputDir).listFiles();
- Assert.assertEquals(5, files.length);
+ Assertions.assertEquals(5, files.length);
List<String> fileNames =
- Arrays.asList(files).stream().map(t -> t.getName()).sorted().collect(Collectors.toList());
+ Arrays.stream(files).map(File::getName).sorted().collect(Collectors.toList());
- Assert.assertEquals("CpuAndMemory.json", fileNames.get(0));
+ Assertions.assertEquals("CpuAndMemory.json", fileNames.get(0));
String jsonCpuAndMemory =
new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(0))));
System.out.println("-----CpuAndMemory-----");
System.out.println(jsonCpuAndMemory);
- Assert.assertTrue(jsonCpuAndMemory.contains("bufferPool"));
+ Assertions.assertTrue(jsonCpuAndMemory.contains("bufferPool"));
- Assert.assertEquals("IO.json", fileNames.get(1));
+ Assertions.assertEquals("IO.json", fileNames.get(1));
String jsonProcFileSystem =
new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(1))));
System.out.println("-----IO-----");
System.out.println(jsonProcFileSystem);
- Assert.assertTrue(jsonProcFileSystem.contains("read_bytes"));
- Assert.assertTrue(jsonProcFileSystem.contains("write_bytes"));
+ Assertions.assertTrue(jsonProcFileSystem.contains("read_bytes"));
+ Assertions.assertTrue(jsonProcFileSystem.contains("write_bytes"));
- Assert.assertEquals("MethodArgument.json", fileNames.get(2));
+ Assertions.assertEquals("MethodArgument.json", fileNames.get(2));
String jsonMethodArgument =
new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(2))));
System.out.println("-----MethodArgument-----");
System.out.println(jsonMethodArgument);
- Assert.assertTrue(jsonMethodArgument.contains("arg.1"));
+ Assertions.assertTrue(jsonMethodArgument.contains("arg.1"));
- Assert.assertEquals("MethodDuration.json", fileNames.get(3));
+ Assertions.assertEquals("MethodDuration.json", fileNames.get(3));
String jsonMethodDuration =
new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(3))));
System.out.println("-----MethodDuration-----");
System.out.println(jsonMethodDuration);
- Assert.assertTrue(jsonMethodDuration.contains("duration.sum"));
+ Assertions.assertTrue(jsonMethodDuration.contains("duration.sum"));
- Assert.assertEquals("ProcessInfo.json", fileNames.get(4));
+ Assertions.assertEquals("ProcessInfo.json", fileNames.get(4));
String jsonProcessInfo = new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(4))));
System.out.println("-----ProcessInfo-----");
System.out.println(jsonProcessInfo);
- Assert.assertTrue(jsonProcessInfo.contains("jvmClassPath"));
- Assert.assertTrue(jsonProcessInfo.contains(agentJar));
+ Assertions.assertTrue(jsonProcessInfo.contains("jvmClassPath"));
+ Assertions.assertTrue(jsonProcessInfo.contains(agentJar));
}
@Test
@@ -119,9 +123,11 @@ public class AgentITCase {
agentJar,
"-javaagent:"
+ agentJar
- + "=noop=true,configProvider=org.apache.streampark.plugin.profiling.util.DummyConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ +
+ "=noop=true,configProvider=org.apache.streampark.plugin.profiling.util.DummyConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ outputDir
- + ",tag=mytag,metricInterval=200,durationProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod,argumentProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod.1,ioProfiling=true",
+ +
+ ",tag=mytag,metricInterval=200,durationProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod,argumentProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod.1,ioProfiling=true",
"org.apache.streampark.plugin.profiling.example.HelloWorldApplication",
"2000");
@@ -132,7 +138,7 @@ public class AgentITCase {
process.waitFor();
File[] files = new File(outputDir).listFiles();
- Assert.assertEquals(0, files.length);
+ Assertions.assertEquals(0, files.length);
}
@Test
@@ -152,9 +158,11 @@ public class AgentITCase {
agentJar,
"-javaagent:"
+ agentJar
- + "=configProvider=org.apache.streampark.plugin.profiling.util.NoopConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ +
+ "=configProvider=org.apache.streampark.plugin.profiling.util.NoopConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ outputDir
- + ",tag=mytag,metricInterval=200,durationProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod,argumentProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod.1,ioProfiling=true",
+ +
+ ",tag=mytag,metricInterval=200,durationProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod,argumentProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod.1,ioProfiling=true",
"org.apache.streampark.plugin.profiling.example.HelloWorldApplication",
"2000");
@@ -165,7 +173,7 @@ public class AgentITCase {
process.waitFor();
File[] files = new File(outputDir).listFiles();
- Assert.assertEquals(0, files.length);
+ Assertions.assertEquals(0, files.length);
}
@Test
@@ -185,9 +193,11 @@ public class AgentITCase {
agentJar,
"-javaagent:"
+ agentJar
- + "=configProvider=org.apache.streampark.plugin.profiling.util.DummyConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ +
+ "=configProvider=org.apache.streampark.plugin.profiling.util.DummyConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ outputDir
- + ",tag=mytag,metricInterval=200,durationProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod,argumentProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod.0",
+ +
+ ",tag=mytag,metricInterval=200,durationProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod,argumentProfiling=org.apache.streampark.plugin.profiling.example.HelloWorldApplication.publicSleepMethod.0",
"org.apache.streampark.plugin.profiling.example.HelloWorldApplication",
"2000");
@@ -198,38 +208,38 @@ public class AgentITCase {
process.waitFor();
File[] files = new File(outputDir).listFiles();
- Assert.assertEquals(4, files.length);
+ Assertions.assertEquals(4, files.length);
List<String> fileNames =
- Arrays.asList(files).stream().map(t -> t.getName()).sorted().collect(Collectors.toList());
+ Arrays.stream(files).map(File::getName).sorted().collect(Collectors.toList());
- Assert.assertEquals("CpuAndMemory.json", fileNames.get(0));
+ Assertions.assertEquals("CpuAndMemory.json", fileNames.get(0));
String jsonCpuAndMemory =
new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(0))));
System.out.println("-----CpuAndMemory-----");
System.out.println(jsonCpuAndMemory);
- Assert.assertTrue(jsonCpuAndMemory.contains("bufferPool"));
+ Assertions.assertTrue(jsonCpuAndMemory.contains("bufferPool"));
- Assert.assertEquals("MethodArgument.json", fileNames.get(1));
+ Assertions.assertEquals("MethodArgument.json", fileNames.get(1));
String jsonMethodArgument =
new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(1))));
System.out.println("-----MethodArgument-----");
System.out.println(jsonMethodArgument);
- Assert.assertTrue(jsonMethodArgument.contains("arg.0"));
+ Assertions.assertTrue(jsonMethodArgument.contains("arg.0"));
- Assert.assertEquals("MethodDuration.json", fileNames.get(2));
+ Assertions.assertEquals("MethodDuration.json", fileNames.get(2));
String jsonMethodDuration =
new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(2))));
System.out.println("-----MethodDuration-----");
System.out.println(jsonMethodDuration);
- Assert.assertTrue(jsonMethodDuration.contains("duration.sum"));
+ Assertions.assertTrue(jsonMethodDuration.contains("duration.sum"));
- Assert.assertEquals("ProcessInfo.json", fileNames.get(3));
+ Assertions.assertEquals("ProcessInfo.json", fileNames.get(3));
String jsonProcessInfo = new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(3))));
System.out.println("-----ProcessInfo-----");
System.out.println(jsonProcessInfo);
- Assert.assertTrue(jsonProcessInfo.contains("jvmClassPath"));
- Assert.assertTrue(jsonProcessInfo.contains(agentJar));
+ Assertions.assertTrue(jsonProcessInfo.contains("jvmClassPath"));
+ Assertions.assertTrue(jsonProcessInfo.contains(agentJar));
}
@Test
@@ -249,7 +259,8 @@ public class AgentITCase {
agentJar,
"-javaagent:"
+ agentJar
- + "=configProvider=org.apache.streampark.plugin.profiling.util.DummyConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ +
+ "=configProvider=org.apache.streampark.plugin.profiling.util.DummyConfigProvider,reporter=org.apache.streampark.plugin.profiling.reporter.FileOutputReporter,outputDir="
+ outputDir
+ ",tag=mytag,appIdVariable=APP_ID",
"org.apache.streampark.plugin.profiling.example.HelloWorldApplication",
@@ -264,23 +275,23 @@ public class AgentITCase {
process.waitFor();
File[] files = new File(outputDir).listFiles();
- Assert.assertEquals(2, files.length);
+ Assertions.assertEquals(2, files.length);
List<String> fileNames =
- Arrays.asList(files).stream().map(t -> t.getName()).sorted().collect(Collectors.toList());
+ Arrays.stream(files).map(File::getName).sorted().collect(Collectors.toList());
- Assert.assertEquals("CpuAndMemory.json", fileNames.get(0));
+ Assertions.assertEquals("CpuAndMemory.json", fileNames.get(0));
String jsonCpuAndMemory =
new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(0))));
System.out.println("-----CpuAndMemory-----");
System.out.println(jsonCpuAndMemory);
- Assert.assertTrue(jsonCpuAndMemory.contains("TEST_APP_ID_123_ABC"));
+ Assertions.assertTrue(jsonCpuAndMemory.contains("TEST_APP_ID_123_ABC"));
- Assert.assertEquals("ProcessInfo.json", fileNames.get(1));
+ Assertions.assertEquals("ProcessInfo.json", fileNames.get(1));
String jsonProcessInfo = new String(Files.readAllBytes(Paths.get(outputDir, fileNames.get(1))));
System.out.println("-----ProcessInfo-----");
System.out.println(jsonProcessInfo);
- Assert.assertTrue(jsonProcessInfo.contains("TEST_APP_ID_123_ABC"));
+ Assertions.assertTrue(jsonProcessInfo.contains("TEST_APP_ID_123_ABC"));
}
private String getAgentJarPath() throws IOException {
@@ -297,7 +308,7 @@ public class AgentITCase {
throw new RuntimeException(e);
}
}))
- .map(t -> t.toString())
+ .map(Path::toString)
.filter(t -> t.endsWith(".jar"))
.get();
System.out.println("agentJar: " + agentJar);
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/AgentThreadFactoryTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/AgentThreadFactoryTest.java
index 82fdc7183..f074b18f0 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/AgentThreadFactoryTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/AgentThreadFactoryTest.java
@@ -17,12 +17,13 @@
package org.apache.streampark.plugin.profiling;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.atomic.AtomicInteger;
public class AgentThreadFactoryTest {
+
@Test
public void newThread() throws InterruptedException {
final AtomicInteger i = new AtomicInteger(10);
@@ -40,6 +41,6 @@ public class AgentThreadFactoryTest {
thread.start();
thread.join();
- Assert.assertEquals(11, i.get());
+ Assertions.assertEquals(11, i.get());
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/ArgumentsTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/ArgumentsTest.java
index 0907e9c27..3d9ae8687 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/ArgumentsTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/ArgumentsTest.java
@@ -21,8 +21,8 @@ import org.apache.streampark.plugin.profiling.reporter.ConsoleOutputReporter;
import org.apache.streampark.plugin.profiling.util.ClassAndMethod;
import org.apache.streampark.plugin.profiling.util.ClassMethodArgument;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
@@ -31,22 +31,23 @@ import java.util.List;
import java.util.Map;
public class ArgumentsTest {
+
@Test
public void allArguments() {
Arguments arguments =
Arguments.parseArgs(
"reporter=org.apache.streampark.plugin.profiling.ArgumentsTest$DummyReporter,durationProfiling=a.bc.foo,metricInterval=123,appIdVariable=APP_ID1,appIdRegex=app123,argumentProfiling=package1.class1.method1.1");
- Assert.assertEquals(6, arguments.getRawArgValues().size());
- Assert.assertFalse(arguments.isNoop());
- Assert.assertEquals(DummyReporter.class, arguments.getReporter().getClass());
- Assert.assertEquals(1, arguments.getDurationProfiling().size());
- Assert.assertEquals(new ClassAndMethod("a.bc", "foo"), arguments.getDurationProfiling().get(0));
- Assert.assertEquals(123, arguments.getMetricInterval());
- Assert.assertEquals("APP_ID1", arguments.getAppIdVariable());
- Assert.assertEquals("app123", arguments.getAppIdRegex());
-
- Assert.assertEquals(1, arguments.getArgumentProfiling().size());
- Assert.assertEquals(
+ Assertions.assertEquals(6, arguments.getRawArgValues().size());
+ Assertions.assertFalse(arguments.isNoop());
+ Assertions.assertEquals(DummyReporter.class, arguments.getReporter().getClass());
+ Assertions.assertEquals(1, arguments.getDurationProfiling().size());
+ Assertions.assertEquals(new ClassAndMethod("a.bc", "foo"), arguments.getDurationProfiling().get(0));
+ Assertions.assertEquals(123, arguments.getMetricInterval());
+ Assertions.assertEquals("APP_ID1", arguments.getAppIdVariable());
+ Assertions.assertEquals("app123", arguments.getAppIdRegex());
+
+ Assertions.assertEquals(1, arguments.getArgumentProfiling().size());
+ Assertions.assertEquals(
new ClassMethodArgument("package1.class1", "method1", 1),
arguments.getArgumentProfiling().get(0));
}
@@ -54,53 +55,54 @@ public class ArgumentsTest {
@Test
public void emptyArguments() {
Arguments arguments = Arguments.parseArgs("");
- Assert.assertEquals(0, arguments.getRawArgValues().size());
- Assert.assertFalse(arguments.isNoop());
- Assert.assertEquals(ConsoleOutputReporter.class, arguments.getReporter().getClass());
- Assert.assertEquals(0, arguments.getDurationProfiling().size());
- Assert.assertEquals(60000, arguments.getMetricInterval());
- Assert.assertEquals(0, arguments.getArgumentProfiling().size());
- Assert.assertNull(arguments.getTag());
- Assert.assertNull(arguments.getCluster());
- Assert.assertNull(arguments.getAppIdVariable());
+ Assertions.assertEquals(0, arguments.getRawArgValues().size());
+ Assertions.assertFalse(arguments.isNoop());
+ Assertions.assertEquals(ConsoleOutputReporter.class, arguments.getReporter().getClass());
+ Assertions.assertEquals(0, arguments.getDurationProfiling().size());
+ Assertions.assertEquals(60000, arguments.getMetricInterval());
+ Assertions.assertEquals(0, arguments.getArgumentProfiling().size());
+ Assertions.assertNull(arguments.getTag());
+ Assertions.assertNull(arguments.getCluster());
+ Assertions.assertNull(arguments.getAppIdVariable());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test()
public void emptyArgumentValue() {
- Arguments.parseArgs("reporter=,durationProfiling=,metricInterval=,appIdRegex=,");
+ Assertions.assertThrows(IllegalArgumentException.class,
+ () -> Arguments.parseArgs("reporter=,durationProfiling=,metricInterval=,appIdRegex=,"));
}
@Test
public void noop() {
Arguments arguments =
Arguments.parseArgs("durationProfiling=a.bc.foo,noop=true,durationProfiling=ab.c.d.test");
- Assert.assertEquals(2, arguments.getRawArgValues().size());
- Assert.assertTrue(arguments.isNoop());
- Assert.assertEquals(2, arguments.getDurationProfiling().size());
+ Assertions.assertEquals(2, arguments.getRawArgValues().size());
+ Assertions.assertTrue(arguments.isNoop());
+ Assertions.assertEquals(2, arguments.getDurationProfiling().size());
}
@Test
public void durationProfiling() {
Arguments arguments =
Arguments.parseArgs("durationProfiling=a.bc.foo,durationProfiling=ab.c.d.test");
- Assert.assertEquals(2, arguments.getDurationProfiling().size());
- Assert.assertEquals(new ClassAndMethod("a.bc", "foo"), arguments.getDurationProfiling().get(0));
- Assert.assertEquals(
+ Assertions.assertEquals(2, arguments.getDurationProfiling().size());
+ Assertions.assertEquals(new ClassAndMethod("a.bc", "foo"), arguments.getDurationProfiling().get(0));
+ Assertions.assertEquals(
new ClassAndMethod("ab.c.d", "test"), arguments.getDurationProfiling().get(1));
- Assert.assertEquals(Arguments.DEFAULT_METRIC_INTERVAL, arguments.getMetricInterval());
- Assert.assertEquals(Arguments.DEFAULT_APP_ID_REGEX, arguments.getAppIdRegex());
+ Assertions.assertEquals(Arguments.DEFAULT_METRIC_INTERVAL, arguments.getMetricInterval());
+ Assertions.assertEquals(Arguments.DEFAULT_APP_ID_REGEX, arguments.getAppIdRegex());
}
@Test
public void argumentProfiling() {
Arguments arguments =
Arguments.parseArgs("durationProfiling=a.bc.foo,durationProfiling=ab.c.d.test");
- Assert.assertEquals(2, arguments.getDurationProfiling().size());
- Assert.assertEquals(new ClassAndMethod("a.bc", "foo"), arguments.getDurationProfiling().get(0));
- Assert.assertEquals(
+ Assertions.assertEquals(2, arguments.getDurationProfiling().size());
+ Assertions.assertEquals(new ClassAndMethod("a.bc", "foo"), arguments.getDurationProfiling().get(0));
+ Assertions.assertEquals(
new ClassAndMethod("ab.c.d", "test"), arguments.getDurationProfiling().get(1));
- Assert.assertEquals(Arguments.DEFAULT_METRIC_INTERVAL, arguments.getMetricInterval());
- Assert.assertEquals(Arguments.DEFAULT_APP_ID_REGEX, arguments.getAppIdRegex());
+ Assertions.assertEquals(Arguments.DEFAULT_METRIC_INTERVAL, arguments.getMetricInterval());
+ Assertions.assertEquals(Arguments.DEFAULT_APP_ID_REGEX, arguments.getAppIdRegex());
}
@Test
@@ -109,7 +111,7 @@ public class ArgumentsTest {
arguments.setReporter("org.apache.streampark.plugin.profiling.ArgumentsTest$DummyReporter");
Reporter reporter = arguments.getReporter();
- Assert.assertTrue(reporter instanceof DummyReporter);
+ Assertions.assertTrue(reporter instanceof DummyReporter);
}
@Test
@@ -119,7 +121,7 @@ public class ArgumentsTest {
arguments.setConfigProvider(
"org.apache.streampark.plugin.profiling.ArgumentsTest$DummyConfigProvider");
ConfigProvider configProvider = arguments.getConfigProvider();
- Assert.assertTrue(configProvider instanceof DummyConfigProvider);
+ Assertions.assertTrue(configProvider instanceof DummyConfigProvider);
}
@Test
@@ -130,12 +132,12 @@ public class ArgumentsTest {
arguments.runConfigProvider();
- Assert.assertEquals("tag1", arguments.getTag());
- Assert.assertEquals("cluster1", arguments.getCluster());
- Assert.assertEquals(1000L, arguments.getMetricInterval());
- Assert.assertTrue(arguments.isIoProfiling());
- Assert.assertArrayEquals(
- new ClassAndMethod[]{
+ Assertions.assertEquals("tag1", arguments.getTag());
+ Assertions.assertEquals("cluster1", arguments.getCluster());
+ Assertions.assertEquals(1000L, arguments.getMetricInterval());
+ Assertions.assertTrue(arguments.isIoProfiling());
+ Assertions.assertArrayEquals(
+ new ClassAndMethod[] {
new ClassAndMethod("a.bc", "foo"), new ClassAndMethod("ab.c.d", "test")
},
arguments.getDurationProfiling().toArray(new ClassAndMethod[2]));
@@ -149,11 +151,11 @@ public class ArgumentsTest {
arguments.runConfigProvider();
- Assert.assertEquals("tag1", arguments.getTag());
- Assert.assertEquals(9000L, arguments.getMetricInterval());
- Assert.assertFalse(arguments.isIoProfiling());
- Assert.assertArrayEquals(
- new ClassAndMethod[]{
+ Assertions.assertEquals("tag1", arguments.getTag());
+ Assertions.assertEquals(9000L, arguments.getMetricInterval());
+ Assertions.assertFalse(arguments.isIoProfiling());
+ Assertions.assertArrayEquals(
+ new ClassAndMethod[] {
new ClassAndMethod("package.c900", "m900"), new ClassAndMethod("package.c901", "m901")
},
arguments.getDurationProfiling().toArray(new ClassAndMethod[2]));
@@ -167,11 +169,11 @@ public class ArgumentsTest {
arguments.runConfigProvider();
- Assert.assertEquals("tag1", arguments.getTag());
- Assert.assertEquals(9001L, arguments.getMetricInterval());
- Assert.assertFalse(arguments.isIoProfiling());
- Assert.assertArrayEquals(
- new ClassAndMethod[]{
+ Assertions.assertEquals("tag1", arguments.getTag());
+ Assertions.assertEquals(9001L, arguments.getMetricInterval());
+ Assertions.assertFalse(arguments.isIoProfiling());
+ Assertions.assertArrayEquals(
+ new ClassAndMethod[] {
new ClassAndMethod("package.c900", "m910"), new ClassAndMethod("package.c901", "m911")
},
arguments.getDurationProfiling().toArray(new ClassAndMethod[2]));
@@ -182,11 +184,11 @@ public class ArgumentsTest {
arguments.runConfigProvider();
- Assert.assertEquals("tag2", arguments.getTag());
- Assert.assertEquals(9002L, arguments.getMetricInterval());
- Assert.assertTrue(arguments.isIoProfiling());
- Assert.assertArrayEquals(
- new ClassAndMethod[]{
+ Assertions.assertEquals("tag2", arguments.getTag());
+ Assertions.assertEquals(9002L, arguments.getMetricInterval());
+ Assertions.assertTrue(arguments.isIoProfiling());
+ Assertions.assertArrayEquals(
+ new ClassAndMethod[] {
new ClassAndMethod("package.c900", "m920"), new ClassAndMethod("package.c901", "m921")
},
arguments.getDurationProfiling().toArray(new ClassAndMethod[2]));
@@ -197,11 +199,11 @@ public class ArgumentsTest {
arguments.runConfigProvider();
- Assert.assertEquals("tag3", arguments.getTag());
- Assert.assertEquals(9000L, arguments.getMetricInterval());
- Assert.assertTrue(arguments.isIoProfiling());
- Assert.assertArrayEquals(
- new ClassAndMethod[]{
+ Assertions.assertEquals("tag3", arguments.getTag());
+ Assertions.assertEquals(9000L, arguments.getMetricInterval());
+ Assertions.assertTrue(arguments.isIoProfiling());
+ Assertions.assertArrayEquals(
+ new ClassAndMethod[] {
new ClassAndMethod("package.c900", "m900"), new ClassAndMethod("package.c901", "m901")
},
arguments.getDurationProfiling().toArray(new ClassAndMethod[2]));
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/ProfilerRunnableTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/ProfilerRunnableTest.java
index 234629fc1..4ba4aefcf 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/ProfilerRunnableTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/ProfilerRunnableTest.java
@@ -17,12 +17,13 @@
package org.apache.streampark.plugin.profiling;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.concurrent.atomic.AtomicInteger;
public class ProfilerRunnableTest {
+
@Test
public void invokeRunnable() {
final AtomicInteger i = new AtomicInteger(10);
@@ -47,6 +48,6 @@ public class ProfilerRunnableTest {
profilerRunnable.run();
- Assert.assertEquals(11, i.get());
+ Assertions.assertEquals(11, i.get());
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/YamlConfigProviderTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/YamlConfigProviderTest.java
index dee5c1f51..adfebd80e 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/YamlConfigProviderTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/YamlConfigProviderTest.java
@@ -17,8 +17,8 @@
package org.apache.streampark.plugin.profiling;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
@@ -31,11 +31,12 @@ import java.util.List;
import java.util.Map;
public class YamlConfigProviderTest {
+
@Test
public void getConfig() throws IOException {
{
YamlConfigProvider provider = new YamlConfigProvider("not_exiting_file");
- Assert.assertEquals(0, provider.getConfig().size());
+ Assertions.assertEquals(0, provider.getConfig().size());
}
{
@@ -46,7 +47,7 @@ public class YamlConfigProviderTest {
Files.write(file.toPath(), content.getBytes(), StandardOpenOption.CREATE);
YamlConfigProvider provider = new YamlConfigProvider(file.getAbsolutePath());
- Assert.assertEquals(0, provider.getConfig().size());
+ Assertions.assertEquals(0, provider.getConfig().size());
}
{
@@ -76,20 +77,20 @@ public class YamlConfigProviderTest {
YamlConfigProvider provider = new YamlConfigProvider(file.getAbsolutePath());
Map<String, Map<String, List<String>>> config = provider.getConfig();
- Assert.assertEquals(2, config.size());
+ Assertions.assertEquals(2, config.size());
Map<String, List<String>> rootConfig = config.get("");
- Assert.assertEquals(4, rootConfig.size());
- Assert.assertEquals(Collections.singletonList("value1"), rootConfig.get("key1"));
- Assert.assertEquals(Arrays.asList("value2a", "value2b"), rootConfig.get("key2"));
- Assert.assertEquals(Collections.singletonList("value3a"), rootConfig.get("key3.key3a"));
- Assert.assertEquals(Arrays.asList("value3b", "value3c"), rootConfig.get("key3.key3b"));
+ Assertions.assertEquals(4, rootConfig.size());
+ Assertions.assertEquals(Collections.singletonList("value1"), rootConfig.get("key1"));
+ Assertions.assertEquals(Arrays.asList("value2a", "value2b"), rootConfig.get("key2"));
+ Assertions.assertEquals(Collections.singletonList("value3a"), rootConfig.get("key3.key3a"));
+ Assertions.assertEquals(Arrays.asList("value3b", "value3c"), rootConfig.get("key3.key3b"));
Map<String, List<String>> override1Config = config.get("override1");
- Assert.assertEquals(3, override1Config.size());
- Assert.assertEquals(Collections.singletonList("value11"), override1Config.get("key1"));
- Assert.assertEquals(Arrays.asList("value22a", "value22b"), override1Config.get("key2"));
- Assert.assertEquals(Collections.singletonList("value33a"), override1Config.get("key3.key3a"));
+ Assertions.assertEquals(3, override1Config.size());
+ Assertions.assertEquals(Collections.singletonList("value11"), override1Config.get("key1"));
+ Assertions.assertEquals(Arrays.asList("value22a", "value22b"), override1Config.get("key2"));
+ Assertions.assertEquals(Collections.singletonList("value33a"), override1Config.get("key3.key3a"));
}
}
@@ -97,7 +98,7 @@ public class YamlConfigProviderTest {
public void getConfigFromBadHttpUrl() throws IOException {
YamlConfigProvider provider = new YamlConfigProvider("http://localhost/bad_url");
Map<String, Map<String, List<String>>> config = provider.getConfig();
- Assert.assertEquals(0, config.size());
+ Assertions.assertEquals(0, config.size());
}
@Test
@@ -128,18 +129,18 @@ public class YamlConfigProviderTest {
YamlConfigProvider provider = new YamlConfigProvider(path.toString());
Map<String, Map<String, List<String>>> config = provider.getConfig();
- Assert.assertEquals(2, config.size());
+ Assertions.assertEquals(2, config.size());
Map<String, List<String>> rootConfig = config.get("");
- Assert.assertEquals(4, rootConfig.size());
- Assert.assertEquals(Collections.singletonList("value1"), rootConfig.get("key1"));
- Assert.assertEquals(Arrays.asList("value2a", "value2b"), rootConfig.get("key2"));
- Assert.assertEquals(Arrays.asList("value3b", "value3c"), rootConfig.get("key3.key3b"));
+ Assertions.assertEquals(4, rootConfig.size());
+ Assertions.assertEquals(Collections.singletonList("value1"), rootConfig.get("key1"));
+ Assertions.assertEquals(Arrays.asList("value2a", "value2b"), rootConfig.get("key2"));
+ Assertions.assertEquals(Arrays.asList("value3b", "value3c"), rootConfig.get("key3.key3b"));
Map<String, List<String>> override1Config = config.get("override1");
- Assert.assertEquals(3, override1Config.size());
- Assert.assertEquals(Collections.singletonList("value11"), override1Config.get("key1"));
- Assert.assertEquals(Arrays.asList("value22a", "value22b"), override1Config.get("key2"));
- Assert.assertEquals(Collections.singletonList("value33a"), override1Config.get("key3.key3a"));
+ Assertions.assertEquals(3, override1Config.size());
+ Assertions.assertEquals(Collections.singletonList("value11"), override1Config.get("key1"));
+ Assertions.assertEquals(Arrays.asList("value22a", "value22b"), override1Config.get("key2"));
+ Assertions.assertEquals(Collections.singletonList("value33a"), override1Config.get("key3.key3a"));
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/CpuAndMemoryProfilerTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/CpuAndMemoryProfilerTest.java
index f71fcb358..a060ffffd 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/CpuAndMemoryProfilerTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/CpuAndMemoryProfilerTest.java
@@ -19,14 +19,15 @@ package org.apache.streampark.plugin.profiling.profiler;
import org.apache.streampark.plugin.profiling.Reporter;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class CpuAndMemoryProfilerTest {
+
@Test
public void profile() {
final List<String> nameList = new ArrayList<>();
@@ -47,24 +48,24 @@ public class CpuAndMemoryProfilerTest {
});
profiler.setInterval(123);
- Assert.assertEquals(123L, profiler.getInterval());
+ Assertions.assertEquals(123L, profiler.getInterval());
profiler.profile();
profiler.profile();
- Assert.assertEquals(2, nameList.size());
- Assert.assertEquals(CpuAndMemoryProfiler.PROFILER_NAME, nameList.get(0));
+ Assertions.assertEquals(2, nameList.size());
+ Assertions.assertEquals(CpuAndMemoryProfiler.PROFILER_NAME, nameList.get(0));
- Assert.assertEquals(2, metricList.size());
- Assert.assertTrue(metricList.get(0).containsKey("processUuid"));
- Assert.assertTrue(metricList.get(0).containsKey("processCpuLoad"));
- Assert.assertTrue(metricList.get(0).containsKey("heapMemoryTotalUsed"));
- Assert.assertTrue(metricList.get(0).containsKey("gc"));
+ Assertions.assertEquals(2, metricList.size());
+ Assertions.assertTrue(metricList.get(0).containsKey("processUuid"));
+ Assertions.assertTrue(metricList.get(0).containsKey("processCpuLoad"));
+ Assertions.assertTrue(metricList.get(0).containsKey("heapMemoryTotalUsed"));
+ Assertions.assertTrue(metricList.get(0).containsKey("gc"));
Object obj = metricList.get(0).get("gc");
- Assert.assertTrue(obj instanceof List);
+ Assertions.assertTrue(obj instanceof List);
List<Map<String, Object>> gcMetrics = (List<Map<String, Object>>) obj;
- Assert.assertTrue(gcMetrics.size() >= 1);
+ Assertions.assertTrue(gcMetrics.size() >= 1);
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/MethodArgumentProfilerTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/MethodArgumentProfilerTest.java
index 28afb8e09..fc24d7c36 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/MethodArgumentProfilerTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/MethodArgumentProfilerTest.java
@@ -20,8 +20,8 @@ package org.apache.streampark.plugin.profiling.profiler;
import org.apache.streampark.plugin.profiling.Reporter;
import org.apache.streampark.plugin.profiling.util.ClassMethodArgumentMetricBuffer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.stream.Collectors;
public class MethodArgumentProfilerTest {
+
@Test
public void profile() {
final List<String> nameList = new ArrayList<>();
@@ -54,7 +55,7 @@ public class MethodArgumentProfilerTest {
MethodArgumentProfiler profiler = new MethodArgumentProfiler(buffer, reporter);
profiler.setInterval(123);
- Assert.assertEquals(123L, profiler.getInterval());
+ Assertions.assertEquals(123L, profiler.getInterval());
collector.collectMetric("class1", "method1", "arg1");
collector.collectMetric("class1", "method1", "arg1");
@@ -62,10 +63,10 @@ public class MethodArgumentProfilerTest {
profiler.profile();
- Assert.assertEquals(2, nameList.size());
- Assert.assertEquals(MethodArgumentProfiler.PROFILER_NAME, nameList.get(0));
+ Assertions.assertEquals(2, nameList.size());
+ Assertions.assertEquals(MethodArgumentProfiler.PROFILER_NAME, nameList.get(0));
- Assert.assertEquals(2, metricList.size());
+ Assertions.assertEquals(2, metricList.size());
List<Map<String, Object>> metricsToCheck =
metricList.stream()
@@ -75,8 +76,8 @@ public class MethodArgumentProfilerTest {
&& t.get("methodName").equals("method1")
&& t.get("metricName").equals("arg1"))
.collect(Collectors.toList());
- Assert.assertEquals(1, metricsToCheck.size());
- Assert.assertEquals(2.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
+ Assertions.assertEquals(1, metricsToCheck.size());
+ Assertions.assertEquals(2.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
metricsToCheck =
metricList.stream()
@@ -86,7 +87,7 @@ public class MethodArgumentProfilerTest {
&& t.get("methodName").equals("method2")
&& t.get("metricName").equals("arg2"))
.collect(Collectors.toList());
- Assert.assertEquals(1, metricsToCheck.size());
- Assert.assertEquals(1.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
+ Assertions.assertEquals(1, metricsToCheck.size());
+ Assertions.assertEquals(1.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/MethodDurationProfilerTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/MethodDurationProfilerTest.java
index d15d8065e..7fb673eeb 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/MethodDurationProfilerTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/MethodDurationProfilerTest.java
@@ -20,8 +20,8 @@ package org.apache.streampark.plugin.profiling.profiler;
import org.apache.streampark.plugin.profiling.Reporter;
import org.apache.streampark.plugin.profiling.util.ClassAndMethodLongMetricBuffer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.stream.Collectors;
public class MethodDurationProfilerTest {
+
@Test
public void profile() {
final List<String> nameList = new ArrayList<>();
@@ -54,7 +55,7 @@ public class MethodDurationProfilerTest {
MethodDurationProfiler profiler = new MethodDurationProfiler(buffer, reporter);
profiler.setInterval(123);
- Assert.assertEquals(123L, profiler.getInterval());
+ Assertions.assertEquals(123L, profiler.getInterval());
collector.collectLongMetric("class1", "method1", "metric1", 111);
collector.collectLongMetric("class1", "method1", "metric1", 333);
@@ -63,10 +64,10 @@ public class MethodDurationProfilerTest {
profiler.profile();
int metricCountForHistogram = 4;
- Assert.assertEquals(2 * metricCountForHistogram, nameList.size());
- Assert.assertEquals(MethodDurationProfiler.PROFILER_NAME, nameList.get(0));
+ Assertions.assertEquals(2 * metricCountForHistogram, nameList.size());
+ Assertions.assertEquals(MethodDurationProfiler.PROFILER_NAME, nameList.get(0));
- Assert.assertEquals(2 * metricCountForHistogram, metricList.size());
+ Assertions.assertEquals(2 * metricCountForHistogram, metricList.size());
List<Map<String, Object>> metricsToCheck =
metricList.stream()
@@ -76,8 +77,8 @@ public class MethodDurationProfilerTest {
&& t.get("methodName").equals("method1")
&& t.get("metricName").equals("metric1.count"))
.collect(Collectors.toList());
- Assert.assertEquals(1, metricsToCheck.size());
- Assert.assertEquals(2.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
+ Assertions.assertEquals(1, metricsToCheck.size());
+ Assertions.assertEquals(2.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
metricsToCheck =
metricList.stream()
@@ -87,8 +88,8 @@ public class MethodDurationProfilerTest {
&& t.get("methodName").equals("method1")
&& t.get("metricName").equals("metric1.sum"))
.collect(Collectors.toList());
- Assert.assertEquals(1, metricsToCheck.size());
- Assert.assertEquals(444.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
+ Assertions.assertEquals(1, metricsToCheck.size());
+ Assertions.assertEquals(444.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
metricsToCheck =
metricList.stream()
@@ -98,8 +99,8 @@ public class MethodDurationProfilerTest {
&& t.get("methodName").equals("method2")
&& t.get("metricName").equals("metric2.count"))
.collect(Collectors.toList());
- Assert.assertEquals(1, metricsToCheck.size());
- Assert.assertEquals(1.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
+ Assertions.assertEquals(1, metricsToCheck.size());
+ Assertions.assertEquals(1.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
metricsToCheck =
metricList.stream()
@@ -109,7 +110,7 @@ public class MethodDurationProfilerTest {
&& t.get("methodName").equals("method2")
&& t.get("metricName").equals("metric2.sum"))
.collect(Collectors.toList());
- Assert.assertEquals(1, metricsToCheck.size());
- Assert.assertEquals(222.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
+ Assertions.assertEquals(1, metricsToCheck.size());
+ Assertions.assertEquals(222.0, (Double) metricsToCheck.get(0).get("metricValue"), 0.01);
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/ProcessInfoProfilerTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/ProcessInfoProfilerTest.java
index c2ff126ba..cebf1db37 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/ProcessInfoProfilerTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/ProcessInfoProfilerTest.java
@@ -21,14 +21,15 @@ import org.apache.streampark.plugin.profiling.Reporter;
import org.apache.streampark.plugin.profiling.util.ProcFileUtils;
import org.apache.streampark.plugin.profiling.util.ProcessUtils;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ProcessInfoProfilerTest {
+
@Test
public void profile() {
final List<String> nameList = new ArrayList<>();
@@ -48,7 +49,7 @@ public class ProcessInfoProfilerTest {
}
});
- Assert.assertEquals(0L, profiler.getInterval());
+ Assertions.assertEquals(0L, profiler.getInterval());
profiler.profile();
profiler.profile();
@@ -56,40 +57,40 @@ public class ProcessInfoProfilerTest {
System.out.println("Metric list:");
System.out.println(metricList);
- Assert.assertTrue(nameList.size() >= 2);
- Assert.assertEquals(ProcessInfoProfiler.PROFILER_NAME, nameList.get(0));
+ Assertions.assertTrue(nameList.size() >= 2);
+ Assertions.assertEquals(ProcessInfoProfiler.PROFILER_NAME, nameList.get(0));
- Assert.assertTrue(metricList.size() >= 2);
+ Assertions.assertTrue(metricList.size() >= 2);
- Assert.assertTrue(metricList.get(0).containsKey("processUuid"));
- Assert.assertTrue(metricList.get(0).containsKey("jvmInputArguments"));
- Assert.assertTrue(metricList.get(0).containsKey("jvmClassPath"));
- Assert.assertTrue(metricList.get(0).containsKey("cmdline"));
+ Assertions.assertTrue(metricList.get(0).containsKey("processUuid"));
+ Assertions.assertTrue(metricList.get(0).containsKey("jvmInputArguments"));
+ Assertions.assertTrue(metricList.get(0).containsKey("jvmClassPath"));
+ Assertions.assertTrue(metricList.get(0).containsKey("cmdline"));
- Assert.assertTrue(metricList.get(metricList.size() - 1).containsKey("processUuid"));
- Assert.assertTrue(metricList.get(metricList.size() - 1).containsKey("jvmInputArguments"));
- Assert.assertTrue(metricList.get(metricList.size() - 1).containsKey("jvmClassPath"));
- Assert.assertTrue(metricList.get(metricList.size() - 1).containsKey("cmdline"));
+ Assertions.assertTrue(metricList.get(metricList.size() - 1).containsKey("processUuid"));
+ Assertions.assertTrue(metricList.get(metricList.size() - 1).containsKey("jvmInputArguments"));
+ Assertions.assertTrue(metricList.get(metricList.size() - 1).containsKey("jvmClassPath"));
+ Assertions.assertTrue(metricList.get(metricList.size() - 1).containsKey("cmdline"));
// Verify: if cmdline is empty, there should be jvmClassPath/jvmInputArguments,
// otherwise there should be no jvmClassPath/jvmInputArguments
if (ProcFileUtils.getCmdline() == null || ProcFileUtils.getCmdline().isEmpty()) {
- Assert.assertEquals(0, metricList.stream().filter(map -> !map.get("cmdline").equals("")).count());
+ Assertions.assertEquals(0, metricList.stream().filter(map -> !map.get("cmdline").equals("")).count());
- Assert.assertTrue(
+ Assertions.assertTrue(
metricList.stream().filter(map -> !map.get("jvmClassPath").equals("")).count() > 0);
if (ProcessUtils.getJvmInputArguments().isEmpty()) {
- Assert.assertEquals(0, metricList.stream().filter(map -> !map.get("jvmInputArguments").equals("")).count());
+ Assertions.assertEquals(0, metricList.stream().filter(map -> !map.get("jvmInputArguments").equals("")).count());
} else {
- Assert.assertTrue(
+ Assertions.assertTrue(
metricList.stream().filter(map -> !map.get("jvmInputArguments").equals("")).count() > 0);
}
} else {
- Assert.assertTrue(
+ Assertions.assertTrue(
metricList.stream().filter(map -> !map.get("cmdline").equals("")).count() > 0);
- Assert.assertEquals(0, metricList.stream().filter(map -> !map.get("jvmClassPath").equals("")).count());
- Assert.assertEquals(0, metricList.stream().filter(map -> !map.get("jvmInputArguments").equals("")).count());
+ Assertions.assertEquals(0, metricList.stream().filter(map -> !map.get("jvmClassPath").equals("")).count());
+ Assertions.assertEquals(0, metricList.stream().filter(map -> !map.get("jvmInputArguments").equals("")).count());
}
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/StacktraceCollectorProfilerTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/StacktraceCollectorProfilerTest.java
index 4892f5cd4..a5e3c3963 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/StacktraceCollectorProfilerTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/StacktraceCollectorProfilerTest.java
@@ -21,8 +21,8 @@ import org.apache.streampark.plugin.profiling.util.ClassAndMethod;
import org.apache.streampark.plugin.profiling.util.Stacktrace;
import org.apache.streampark.plugin.profiling.util.StacktraceMetricBuffer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
@@ -31,13 +31,14 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicLong;
public class StacktraceCollectorProfilerTest {
+
@Test
public void profile() throws InterruptedException {
StacktraceMetricBuffer buffer = new StacktraceMetricBuffer();
StacktraceCollectorProfiler profiler = new StacktraceCollectorProfiler(buffer, null);
profiler.setInterval(123);
- Assert.assertEquals(123L, profiler.getInterval());
+ Assertions.assertEquals(123L, profiler.getInterval());
// Use a semaphore to make sure the test thread runs before profile method
final Semaphore semaphore = new Semaphore(1);
@@ -68,7 +69,7 @@ public class StacktraceCollectorProfilerTest {
profiler.profile();
Map<Stacktrace, AtomicLong> map = buffer.reset();
- Assert.assertTrue(map.size() > 0);
+ Assertions.assertTrue(map.size() > 0);
int mainThreadCount = 0;
@@ -97,22 +98,22 @@ public class StacktraceCollectorProfilerTest {
}
}
- Assert.assertTrue(mainThreadCount >= 3);
+ Assertions.assertTrue(mainThreadCount >= 3);
- Assert.assertEquals(1, testThreadStacktrace.size());
- Assert.assertEquals("testDummySleepThread", testThreadStacktrace.get(0).getThreadName());
- Assert.assertEquals("TIMED_WAITING", testThreadStacktrace.get(0).getThreadState());
+ Assertions.assertEquals(1, testThreadStacktrace.size());
+ Assertions.assertEquals("testDummySleepThread", testThreadStacktrace.get(0).getThreadName());
+ Assertions.assertEquals("TIMED_WAITING", testThreadStacktrace.get(0).getThreadState());
ClassAndMethod[] stack = testThreadStacktrace.get(0).getStack();
- Assert.assertEquals(4, stack.length);
- Assert.assertEquals(new ClassAndMethod("java.lang.Thread", "sleep"), stack[0]);
- Assert.assertEquals(new ClassAndMethod("java.lang.Thread", "run"), stack[stack.length - 1]);
+ Assertions.assertEquals(4, stack.length);
+ Assertions.assertEquals(new ClassAndMethod("java.lang.Thread", "sleep"), stack[0]);
+ Assertions.assertEquals(new ClassAndMethod("java.lang.Thread", "run"), stack[stack.length - 1]);
- Assert.assertEquals(1, testThreadStacktraceCount.size());
- Assert.assertEquals(3L, testThreadStacktraceCount.get(0).longValue());
+ Assertions.assertEquals(1, testThreadStacktraceCount.size());
+ Assertions.assertEquals(3L, testThreadStacktraceCount.get(0).longValue());
- Assert.assertTrue(runnableThreadCount >= 3);
- Assert.assertTrue(waitingThreadCount >= 3);
+ Assertions.assertTrue(runnableThreadCount >= 3);
+ Assertions.assertTrue(waitingThreadCount >= 3);
try {
thread.interrupt();
@@ -128,7 +129,7 @@ public class StacktraceCollectorProfilerTest {
StacktraceCollectorProfiler profiler = new StacktraceCollectorProfiler(buffer, "testDummy");
profiler.setInterval(123);
- Assert.assertEquals(123L, profiler.getInterval());
+ Assertions.assertEquals(123L, profiler.getInterval());
// Use a semaphore to make sure the test thread runs before profile method
final Semaphore semaphore = new Semaphore(1);
@@ -159,7 +160,7 @@ public class StacktraceCollectorProfilerTest {
profiler.profile();
Map<Stacktrace, AtomicLong> map = buffer.reset();
- Assert.assertTrue(map.size() > 0);
+ Assertions.assertTrue(map.size() > 0);
int mainThreadCount = 0;
@@ -188,12 +189,12 @@ public class StacktraceCollectorProfilerTest {
}
}
- Assert.assertTrue(mainThreadCount >= 3);
+ Assertions.assertTrue(mainThreadCount >= 3);
- Assert.assertEquals(0, testThreadStacktrace.size());
+ Assertions.assertEquals(0, testThreadStacktrace.size());
- Assert.assertTrue(runnableThreadCount >= 3);
- Assert.assertTrue(waitingThreadCount >= 3);
+ Assertions.assertTrue(runnableThreadCount >= 3);
+ Assertions.assertTrue(waitingThreadCount >= 3);
try {
thread.interrupt();
@@ -209,7 +210,7 @@ public class StacktraceCollectorProfilerTest {
StacktraceCollectorProfiler profiler = new StacktraceCollectorProfiler(buffer, null, 20000);
profiler.setInterval(123);
- Assert.assertEquals(123L, profiler.getInterval());
+ Assertions.assertEquals(123L, profiler.getInterval());
// Use a semaphore to make sure the test thread runs before profile method
final Semaphore semaphore = new Semaphore(1);
@@ -233,7 +234,7 @@ public class StacktraceCollectorProfilerTest {
profiler.profile();
Map<Stacktrace, AtomicLong> map = buffer.reset();
- Assert.assertTrue(map.size() > 0);
+ Assertions.assertTrue(map.size() > 0);
List<Stacktrace> testThreadStacktrace = new ArrayList<>();
List<Long> testThreadStacktraceCount = new ArrayList<>();
@@ -245,14 +246,14 @@ public class StacktraceCollectorProfilerTest {
}
}
- Assert.assertEquals(1, testThreadStacktrace.size());
+ Assertions.assertEquals(1, testThreadStacktrace.size());
ClassAndMethod[] stack = testThreadStacktrace.get(0).getStack();
- Assert.assertTrue(stack.length > 1);
- Assert.assertEquals(new ClassAndMethod("_stack_", "_trimmed_"), stack[0]);
+ Assertions.assertTrue(stack.length > 1);
+ Assertions.assertEquals(new ClassAndMethod("_stack_", "_trimmed_"), stack[0]);
- Assert.assertEquals(1, testThreadStacktraceCount.size());
- Assert.assertEquals(1L, testThreadStacktraceCount.get(0).longValue());
+ Assertions.assertEquals(1, testThreadStacktraceCount.size());
+ Assertions.assertEquals(1L, testThreadStacktraceCount.get(0).longValue());
try {
thread.interrupt();
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/StacktraceReporterProfilerTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/StacktraceReporterProfilerTest.java
index b69e1ffb3..369aebdc2 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/StacktraceReporterProfilerTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/StacktraceReporterProfilerTest.java
@@ -22,14 +22,15 @@ import org.apache.streampark.plugin.profiling.util.ClassAndMethod;
import org.apache.streampark.plugin.profiling.util.Stacktrace;
import org.apache.streampark.plugin.profiling.util.StacktraceMetricBuffer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class StacktraceReporterProfilerTest {
+
@Test
public void profile() {
final List<String> nameList = new ArrayList<>();
@@ -54,11 +55,11 @@ public class StacktraceReporterProfilerTest {
StacktraceReporterProfiler profiler = new StacktraceReporterProfiler(buffer, reporter);
profiler.setInterval(123);
- Assert.assertEquals(123L, profiler.getInterval());
+ Assertions.assertEquals(123L, profiler.getInterval());
profiler.profile();
- Assert.assertEquals(0, nameList.size());
- Assert.assertEquals(0, metricList.size());
+ Assertions.assertEquals(0, nameList.size());
+ Assertions.assertEquals(0, metricList.size());
Stacktrace stacktrace = new Stacktrace();
buffer.appendValue(stacktrace);
@@ -67,22 +68,22 @@ public class StacktraceReporterProfilerTest {
long epochMillis2 = System.currentTimeMillis();
- Assert.assertEquals(1, nameList.size());
- Assert.assertEquals("Stacktrace", nameList.get(0));
+ Assertions.assertEquals(1, nameList.size());
+ Assertions.assertEquals("Stacktrace", nameList.get(0));
- Assert.assertEquals(1, metricList.size());
+ Assertions.assertEquals(1, metricList.size());
Map<String, Object> map = metricList.get(0);
- Assert.assertTrue((long) map.get("startEpoch") >= epochMillis1);
- Assert.assertTrue((long) map.get("startEpoch") <= epochMillis2);
- Assert.assertTrue((long) map.get("endEpoch") >= epochMillis1);
- Assert.assertTrue((long) map.get("endEpoch") <= epochMillis2);
- Assert.assertTrue((long) map.get("endEpoch") >= (long) map.get("startEpoch"));
- Assert.assertEquals(1L, (long) map.get("count"));
- Assert.assertNull(map.get("threadName"));
- Assert.assertNull(map.get("threadState"));
- Assert.assertArrayEquals(
+ Assertions.assertTrue((long) map.get("startEpoch") >= epochMillis1);
+ Assertions.assertTrue((long) map.get("startEpoch") <= epochMillis2);
+ Assertions.assertTrue((long) map.get("endEpoch") >= epochMillis1);
+ Assertions.assertTrue((long) map.get("endEpoch") <= epochMillis2);
+ Assertions.assertTrue((long) map.get("endEpoch") >= (long) map.get("startEpoch"));
+ Assertions.assertEquals(1L, (long) map.get("count"));
+ Assertions.assertNull(map.get("threadName"));
+ Assertions.assertNull(map.get("threadState"));
+ Assertions.assertArrayEquals(
new String[0], ((ArrayList<String>) map.get("stacktrace")).toArray(new String[0]));
stacktrace = new Stacktrace();
@@ -98,18 +99,18 @@ public class StacktraceReporterProfilerTest {
profiler.profile();
- Assert.assertEquals(2, nameList.size());
- Assert.assertEquals("Stacktrace", nameList.get(0));
- Assert.assertEquals("Stacktrace", nameList.get(1));
+ Assertions.assertEquals(2, nameList.size());
+ Assertions.assertEquals("Stacktrace", nameList.get(0));
+ Assertions.assertEquals("Stacktrace", nameList.get(1));
- Assert.assertEquals(2, metricList.size());
+ Assertions.assertEquals(2, metricList.size());
map = metricList.get(1);
- Assert.assertEquals(2L, (long) map.get("count"));
- Assert.assertEquals("thread1", map.get("threadName"));
- Assert.assertEquals("RUNNING", map.get("threadState"));
- Assert.assertArrayEquals(
+ Assertions.assertEquals(2L, (long) map.get("count"));
+ Assertions.assertEquals("thread1", map.get("threadName"));
+ Assertions.assertEquals("RUNNING", map.get("threadState"));
+ Assertions.assertArrayEquals(
new String[]{"class1.method1", "class2.method2"},
((ArrayList<String>) map.get("stacktrace")).toArray(new String[0]));
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/ThreadInfoProfilerTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/ThreadInfoProfilerTest.java
index 83820d0c4..87445d471 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/ThreadInfoProfilerTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/profiler/ThreadInfoProfilerTest.java
@@ -19,14 +19,15 @@ package org.apache.streampark.plugin.profiling.profiler;
import org.apache.streampark.plugin.profiling.Reporter;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ThreadInfoProfilerTest {
+
@Test
public void profile() {
final List<String> nameList = new ArrayList<>();
@@ -48,20 +49,20 @@ public class ThreadInfoProfilerTest {
});
// Set interval
profiler.setInterval(150);
- Assert.assertEquals(150L, profiler.getInterval());
+ Assertions.assertEquals(150L, profiler.getInterval());
// run 2 cycles on the profile.
profiler.profile();
profiler.profile();
// start assertion.
- Assert.assertEquals(2, nameList.size());
- Assert.assertEquals(ThreadInfoProfiler.PROFILER_NAME, nameList.get(0));
+ Assertions.assertEquals(2, nameList.size());
+ Assertions.assertEquals(ThreadInfoProfiler.PROFILER_NAME, nameList.get(0));
- Assert.assertEquals(2, metricList.size());
- Assert.assertTrue(metricList.get(0).containsKey("totalStartedThreadCount"));
- Assert.assertTrue(metricList.get(0).containsKey("newThreadCount"));
- Assert.assertTrue(metricList.get(0).containsKey("liveThreadCount"));
- Assert.assertTrue(metricList.get(0).containsKey("peakThreadCount"));
+ Assertions.assertEquals(2, metricList.size());
+ Assertions.assertTrue(metricList.get(0).containsKey("totalStartedThreadCount"));
+ Assertions.assertTrue(metricList.get(0).containsKey("newThreadCount"));
+ Assertions.assertTrue(metricList.get(0).containsKey("liveThreadCount"));
+ Assertions.assertTrue(metricList.get(0).containsKey("peakThreadCount"));
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/reporter/ConsoleOutputReporterTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/reporter/ConsoleOutputReporterTest.java
index d8d80b5fe..ad0250941 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/reporter/ConsoleOutputReporterTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/reporter/ConsoleOutputReporterTest.java
@@ -17,11 +17,12 @@
package org.apache.streampark.plugin.profiling.reporter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
public class ConsoleOutputReporterTest {
+
@Test
public void report() {
ConsoleOutputReporter reporter = new ConsoleOutputReporter();
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/transformer/MethodProfilerStaticProxyTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/transformer/MethodProfilerStaticProxyTest.java
index 8f6000ee5..264133569 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/transformer/MethodProfilerStaticProxyTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/transformer/MethodProfilerStaticProxyTest.java
@@ -22,10 +22,10 @@ import org.apache.streampark.plugin.profiling.profiler.MethodArgumentCollector;
import org.apache.streampark.plugin.profiling.util.ClassAndMethodMetricKey;
import org.apache.streampark.plugin.profiling.util.ClassMethodArgumentMetricBuffer;
-import junit.framework.Assert;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
@@ -33,14 +33,14 @@ import java.util.concurrent.atomic.AtomicLong;
public class MethodProfilerStaticProxyTest {
private ClassMethodArgumentMetricBuffer buffer;
- @Before
+ @BeforeEach
public void before() {
buffer = new ClassMethodArgumentMetricBuffer();
MethodArgumentCollector collector = new MethodArgumentCollector(buffer);
MethodProfilerStaticProxy.setArgumentCollector(collector);
}
- @After
+ @AfterEach
public void after() {
MethodProfilerStaticProxy.setCollector(null);
}
@@ -51,12 +51,12 @@ public class MethodProfilerStaticProxyTest {
MethodProfilerStaticProxy.collectMethodArgument("class1", "method1", 1, null);
Map<ClassAndMethodMetricKey, AtomicLong> metrics = buffer.reset();
- Assert.assertEquals(1, metrics.size());
+ Assertions.assertEquals(1, metrics.size());
ClassAndMethodMetricKey key = metrics.keySet().iterator().next();
- Assert.assertEquals("class1", key.getClassName());
- Assert.assertEquals("method1", key.getMethodName());
- Assert.assertEquals("arg.1.null", key.getMetricName());
- Assert.assertEquals(2, metrics.get(key).intValue());
+ Assertions.assertEquals("class1", key.getClassName());
+ Assertions.assertEquals("method1", key.getMethodName());
+ Assertions.assertEquals("arg.1.null", key.getMetricName());
+ Assertions.assertEquals(2, metrics.get(key).intValue());
}
@Test
@@ -72,12 +72,12 @@ public class MethodProfilerStaticProxyTest {
MethodProfilerStaticProxy.collectMethodArgument("class1", "method1", 1, veryLongValue);
Map<ClassAndMethodMetricKey, AtomicLong> metrics = buffer.reset();
- Assert.assertEquals(1, metrics.size());
+ Assertions.assertEquals(1, metrics.size());
ClassAndMethodMetricKey key = metrics.keySet().iterator().next();
- Assert.assertEquals("class1", key.getClassName());
- Assert.assertEquals("method1", key.getMethodName());
- Assert.assertEquals(Constants.MAX_STRING_LENGTH, key.getMetricName().length());
- Assert.assertTrue(key.getMetricName().startsWith("arg.1."));
- Assert.assertEquals(2, metrics.get(key).intValue());
+ Assertions.assertEquals("class1", key.getClassName());
+ Assertions.assertEquals("method1", key.getMethodName());
+ Assertions.assertEquals(Constants.MAX_STRING_LENGTH, key.getMetricName().length());
+ Assertions.assertTrue(key.getMetricName().startsWith("arg.1."));
+ Assertions.assertEquals(2, metrics.get(key).intValue());
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassAndMethodFilterTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassAndMethodFilterTest.java
index dedd9e1b2..ea7646053 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassAndMethodFilterTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassAndMethodFilterTest.java
@@ -17,34 +17,35 @@
package org.apache.streampark.plugin.profiling.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
public class ClassAndMethodFilterTest {
+
@Test
public void matchClass() {
ClassAndMethodFilter filter = new ClassAndMethodFilter(null);
- Assert.assertFalse(filter.matchMethod("class1", "method1"));
+ Assertions.assertFalse(filter.matchMethod("class1", "method1"));
filter = new ClassAndMethodFilter(Collections.singletonList(new ClassAndMethod("class1", "")));
- Assert.assertTrue(filter.matchClass("class1"));
+ Assertions.assertTrue(filter.matchClass("class1"));
filter = new ClassAndMethodFilter(Collections.singletonList(new ClassAndMethod("", "method1")));
- Assert.assertTrue(filter.matchClass("class1"));
+ Assertions.assertTrue(filter.matchClass("class1"));
filter = new ClassAndMethodFilter(Collections.singletonList(new ClassAndMethod("class2", "method1")));
- Assert.assertFalse(filter.matchClass("class1"));
- Assert.assertTrue(filter.matchClass("class2"));
+ Assertions.assertFalse(filter.matchClass("class1"));
+ Assertions.assertTrue(filter.matchClass("class2"));
filter =
new ClassAndMethodFilter(
Arrays.asList(
new ClassAndMethod("class2", "method1"), new ClassAndMethod("class1", "method1")));
- Assert.assertTrue(filter.matchClass("class1"));
- Assert.assertTrue(filter.matchClass("class2"));
+ Assertions.assertTrue(filter.matchClass("class1"));
+ Assertions.assertTrue(filter.matchClass("class2"));
filter =
new ClassAndMethodFilter(
@@ -52,42 +53,42 @@ public class ClassAndMethodFilterTest {
new ClassAndMethod("class2", "method1"),
new ClassAndMethod("class1", "method1"),
new ClassAndMethod("class3", "*")));
- Assert.assertTrue(filter.matchClass("class1xx"));
- Assert.assertTrue(filter.matchClass("class2xx"));
- Assert.assertTrue(filter.matchClass("class3xx"));
+ Assertions.assertTrue(filter.matchClass("class1xx"));
+ Assertions.assertTrue(filter.matchClass("class2xx"));
+ Assertions.assertTrue(filter.matchClass("class3xx"));
}
@Test
public void matchMethod() {
ClassAndMethodFilter filter = new ClassAndMethodFilter(null);
- Assert.assertFalse(filter.matchMethod("class1", "method1"));
+ Assertions.assertFalse(filter.matchMethod("class1", "method1"));
filter = new ClassAndMethodFilter(Collections.singletonList(new ClassAndMethod("class1", "")));
- Assert.assertFalse(filter.matchMethod("class1", "method1"));
+ Assertions.assertFalse(filter.matchMethod("class1", "method1"));
filter = new ClassAndMethodFilter(Collections.singletonList(new ClassAndMethod("", "method1")));
- Assert.assertTrue(filter.matchMethod("class1", "method1"));
+ Assertions.assertTrue(filter.matchMethod("class1", "method1"));
filter = new ClassAndMethodFilter(Collections.singletonList(new ClassAndMethod("class2", "method1")));
- Assert.assertFalse(filter.matchMethod("class1", "method1"));
+ Assertions.assertFalse(filter.matchMethod("class1", "method1"));
filter =
new ClassAndMethodFilter(
Arrays.asList(
new ClassAndMethod("", "method1"), new ClassAndMethod("class1", "method1")));
- Assert.assertTrue(filter.matchMethod("class1", "method1"));
+ Assertions.assertTrue(filter.matchMethod("class1", "method1"));
}
@Test
public void matchMethod_wildcard() {
ClassAndMethodFilter filter =
new ClassAndMethodFilter(Collections.singletonList(new ClassAndMethod("class1", "")));
- Assert.assertFalse(filter.matchMethod("class1", "method1"));
+ Assertions.assertFalse(filter.matchMethod("class1", "method1"));
filter =
new ClassAndMethodFilter(
Arrays.asList(new ClassAndMethod("class1", ""), new ClassAndMethod("class1", "*")));
- Assert.assertTrue(filter.matchMethod("class1", "method1"));
+ Assertions.assertTrue(filter.matchMethod("class1", "method1"));
}
@Test
@@ -97,8 +98,8 @@ public class ClassAndMethodFilterTest {
Arrays.asList(
new ClassAndMethod("package11.class1", "method1"),
new ClassAndMethod("package22", "method2")));
- Assert.assertTrue(filter.matchMethod("package22.class2", "method2"));
- Assert.assertFalse(filter.matchMethod("package2", "method2"));
+ Assertions.assertTrue(filter.matchMethod("package22.class2", "method2"));
+ Assertions.assertFalse(filter.matchMethod("package2", "method2"));
filter =
new ClassAndMethodFilter(
@@ -106,8 +107,8 @@ public class ClassAndMethodFilterTest {
new ClassAndMethod("package11.class1", "method1"),
new ClassAndMethod("package22", "method2"),
new ClassAndMethod("package33", "*")));
- Assert.assertTrue(filter.matchMethod("package22.class2", "method2"));
- Assert.assertFalse(filter.matchMethod("package2", "method2"));
- Assert.assertTrue(filter.matchMethod("package33.xx.yy", "method3"));
+ Assertions.assertTrue(filter.matchMethod("package22.class2", "method2"));
+ Assertions.assertFalse(filter.matchMethod("package2", "method2"));
+ Assertions.assertTrue(filter.matchMethod("package33.xx.yy", "method3"));
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassAndMethodMetricBufferTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassAndMethodMetricBufferTest.java
index 07095a266..f05078295 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassAndMethodMetricBufferTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassAndMethodMetricBufferTest.java
@@ -17,12 +17,13 @@
package org.apache.streampark.plugin.profiling.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Map;
public class ClassAndMethodMetricBufferTest {
+
@Test
public void appendValue() {
ClassAndMethodLongMetricBuffer buffer = new ClassAndMethodLongMetricBuffer();
@@ -32,40 +33,40 @@ public class ClassAndMethodMetricBufferTest {
buffer.appendValue("class2", "method2", "metric1", 1001);
Map<ClassAndMethodMetricKey, Histogram> map = buffer.reset();
- Assert.assertEquals(3, map.size());
+ Assertions.assertEquals(3, map.size());
Histogram histogram = map.get(new ClassAndMethodMetricKey("class1", "method1", "metric1"));
- Assert.assertEquals(1, histogram.getCount());
- Assert.assertEquals(11, histogram.getSum());
- Assert.assertEquals(11, histogram.getMin());
- Assert.assertEquals(11, histogram.getMax());
+ Assertions.assertEquals(1, histogram.getCount());
+ Assertions.assertEquals(11, histogram.getSum());
+ Assertions.assertEquals(11, histogram.getMin());
+ Assertions.assertEquals(11, histogram.getMax());
histogram = map.get(new ClassAndMethodMetricKey("class1", "method2", "metric1"));
- Assert.assertEquals(2, histogram.getCount());
- Assert.assertEquals(77, histogram.getSum());
- Assert.assertEquals(22, histogram.getMin());
- Assert.assertEquals(55, histogram.getMax());
+ Assertions.assertEquals(2, histogram.getCount());
+ Assertions.assertEquals(77, histogram.getSum());
+ Assertions.assertEquals(22, histogram.getMin());
+ Assertions.assertEquals(55, histogram.getMax());
histogram = map.get(new ClassAndMethodMetricKey("class2", "method2", "metric1"));
- Assert.assertEquals(1, histogram.getCount());
- Assert.assertEquals(1001, histogram.getSum());
- Assert.assertEquals(1001, histogram.getMin());
- Assert.assertEquals(1001, histogram.getMax());
+ Assertions.assertEquals(1, histogram.getCount());
+ Assertions.assertEquals(1001, histogram.getSum());
+ Assertions.assertEquals(1001, histogram.getMin());
+ Assertions.assertEquals(1001, histogram.getMax());
map = buffer.reset();
- Assert.assertEquals(0, map.size());
+ Assertions.assertEquals(0, map.size());
map = buffer.reset();
- Assert.assertEquals(0, map.size());
+ Assertions.assertEquals(0, map.size());
}
@Test
public void appendValue_concurrent() throws InterruptedException {
ClassAndMethodLongMetricBuffer buffer = new ClassAndMethodLongMetricBuffer();
- String[] classNames = new String[]{"class1", "class2", "class1", "class2", "class101"};
- String[] methodNames = new String[]{"method1", "method2", "method1", "method3", "method101"};
- int[] values = new int[]{1, 2, 10, 20, 101};
+ String[] classNames = new String[] {"class1", "class2", "class1", "class2", "class101"};
+ String[] methodNames = new String[] {"method1", "method2", "method1", "method3", "method101"};
+ int[] values = new int[] {1, 2, 10, 20, 101};
Thread[] threads = new Thread[classNames.length];
@@ -93,39 +94,39 @@ public class ClassAndMethodMetricBufferTest {
}
Map<ClassAndMethodMetricKey, Histogram> result = buffer.reset();
- Assert.assertEquals(4, result.size());
+ Assertions.assertEquals(4, result.size());
- Assert.assertEquals(
+ Assertions.assertEquals(
2 * repeatTimes,
result.get(new ClassAndMethodMetricKey("class1", "method1", "duration")).getCount());
- Assert.assertEquals(
+ Assertions.assertEquals(
11 * repeatTimes,
result.get(new ClassAndMethodMetricKey("class1", "method1", "duration")).getSum());
- Assert.assertEquals(
+ Assertions.assertEquals(
1, result.get(new ClassAndMethodMetricKey("class1", "method1", "duration")).getMin());
- Assert.assertEquals(
+ Assertions.assertEquals(
10, result.get(new ClassAndMethodMetricKey("class1", "method1", "duration")).getMax());
- Assert.assertEquals(
+ Assertions.assertEquals(
repeatTimes,
result.get(new ClassAndMethodMetricKey("class2", "method2", "duration")).getCount());
- Assert.assertEquals(
+ Assertions.assertEquals(
2 * repeatTimes,
result.get(new ClassAndMethodMetricKey("class2", "method2", "duration")).getSum());
- Assert.assertEquals(
+ Assertions.assertEquals(
2, result.get(new ClassAndMethodMetricKey("class2", "method2", "duration")).getMin());
- Assert.assertEquals(
+ Assertions.assertEquals(
2, result.get(new ClassAndMethodMetricKey("class2", "method2", "duration")).getMax());
- Assert.assertEquals(
+ Assertions.assertEquals(
repeatTimes,
result.get(new ClassAndMethodMetricKey("class2", "method3", "duration")).getCount());
- Assert.assertEquals(
+ Assertions.assertEquals(
20 * repeatTimes,
result.get(new ClassAndMethodMetricKey("class2", "method3", "duration")).getSum());
- Assert.assertEquals(
+ Assertions.assertEquals(
20, result.get(new ClassAndMethodMetricKey("class2", "method3", "duration")).getMin());
- Assert.assertEquals(
+ Assertions.assertEquals(
20, result.get(new ClassAndMethodMetricKey("class2", "method3", "duration")).getMax());
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassMethodArgmentMetricBufferTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassMethodArgmentMetricBufferTest.java
index 0b032deb9..73534bc1b 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassMethodArgmentMetricBufferTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassMethodArgmentMetricBufferTest.java
@@ -17,13 +17,14 @@
package org.apache.streampark.plugin.profiling.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
public class ClassMethodArgmentMetricBufferTest {
+
@Test
public void appendValue() {
ClassMethodArgumentMetricBuffer buffer = new ClassMethodArgumentMetricBuffer();
@@ -33,30 +34,30 @@ public class ClassMethodArgmentMetricBufferTest {
buffer.appendValue("class2", "method2", "arg1");
Map<ClassAndMethodMetricKey, AtomicLong> map = buffer.reset();
- Assert.assertEquals(3, map.size());
+ Assertions.assertEquals(3, map.size());
AtomicLong count = map.get(new ClassAndMethodMetricKey("class1", "method1", "arg1"));
- Assert.assertEquals(1, count.get());
+ Assertions.assertEquals(1, count.get());
count = map.get(new ClassAndMethodMetricKey("class1", "method2", "arg1"));
- Assert.assertEquals(2, count.get());
+ Assertions.assertEquals(2, count.get());
count = map.get(new ClassAndMethodMetricKey("class2", "method2", "arg1"));
- Assert.assertEquals(1, count.get());
+ Assertions.assertEquals(1, count.get());
map = buffer.reset();
- Assert.assertEquals(0, map.size());
+ Assertions.assertEquals(0, map.size());
map = buffer.reset();
- Assert.assertEquals(0, map.size());
+ Assertions.assertEquals(0, map.size());
}
@Test
public void appendValue_concurrent() throws InterruptedException {
ClassMethodArgumentMetricBuffer buffer = new ClassMethodArgumentMetricBuffer();
- String[] classNames = new String[]{"class1", "class2", "class1", "class2", "class101"};
- String[] methodNames = new String[]{"method1", "method2", "method1", "method3", "method101"};
+ String[] classNames = new String[] {"class1", "class2", "class1", "class2", "class101"};
+ String[] methodNames = new String[] {"method1", "method2", "method1", "method3", "method101"};
Thread[] threads = new Thread[classNames.length];
@@ -74,25 +75,25 @@ public class ClassMethodArgmentMetricBufferTest {
threads[i] = thread;
}
- for (int i = 0; i < threads.length; i++) {
- threads[i].start();
+ for (Thread thread : threads) {
+ thread.start();
}
- for (int i = 0; i < threads.length; i++) {
- threads[i].join();
+ for (Thread thread : threads) {
+ thread.join();
}
Map<ClassAndMethodMetricKey, AtomicLong> result = buffer.reset();
- Assert.assertEquals(4, result.size());
+ Assertions.assertEquals(4, result.size());
- Assert.assertEquals(
+ Assertions.assertEquals(
2 * repeatTimes,
result.get(new ClassAndMethodMetricKey("class1", "method1", "arg1")).get());
- Assert.assertEquals(
+ Assertions.assertEquals(
repeatTimes, result.get(new ClassAndMethodMetricKey("class2", "method2", "arg1")).get());
- Assert.assertEquals(
+ Assertions.assertEquals(
repeatTimes, result.get(new ClassAndMethodMetricKey("class2", "method3", "arg1")).get());
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassMethodArgumentFilterTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassMethodArgumentFilterTest.java
index 91520db2c..dbec99dad 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassMethodArgumentFilterTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ClassMethodArgumentFilterTest.java
@@ -17,38 +17,39 @@
package org.apache.streampark.plugin.profiling.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collections;
public class ClassMethodArgumentFilterTest {
+
@Test
public void matchClass() {
ClassMethodArgumentFilter filter = new ClassMethodArgumentFilter(null);
- Assert.assertEquals(0, filter.matchMethod("class1", "method1").size());
+ Assertions.assertEquals(0, filter.matchMethod("class1", "method1").size());
filter = new ClassMethodArgumentFilter(Collections.singletonList(new ClassMethodArgument("class1", "", 1)));
- Assert.assertTrue(filter.matchClass("class1"));
+ Assertions.assertTrue(filter.matchClass("class1"));
filter =
new ClassMethodArgumentFilter(Collections.singletonList(new ClassMethodArgument("", "method1", 1)));
- Assert.assertTrue(filter.matchClass("class1"));
+ Assertions.assertTrue(filter.matchClass("class1"));
filter =
new ClassMethodArgumentFilter(
Collections.singletonList(new ClassMethodArgument("class2", "method1", 1)));
- Assert.assertFalse(filter.matchClass("class1"));
- Assert.assertTrue(filter.matchClass("class2"));
+ Assertions.assertFalse(filter.matchClass("class1"));
+ Assertions.assertTrue(filter.matchClass("class2"));
filter =
new ClassMethodArgumentFilter(
Arrays.asList(
new ClassMethodArgument("class2", "method1", 1),
new ClassMethodArgument("class1", "method1", 1)));
- Assert.assertTrue(filter.matchClass("class1"));
- Assert.assertTrue(filter.matchClass("class2"));
+ Assertions.assertTrue(filter.matchClass("class1"));
+ Assertions.assertTrue(filter.matchClass("class2"));
filter =
new ClassMethodArgumentFilter(
@@ -56,52 +57,52 @@ public class ClassMethodArgumentFilterTest {
new ClassMethodArgument("class2", "method1", 1),
new ClassMethodArgument("class1", "method1", 1),
new ClassMethodArgument("class3", "*", 1)));
- Assert.assertTrue(filter.matchClass("class1xx"));
- Assert.assertTrue(filter.matchClass("class2xx"));
- Assert.assertTrue(filter.matchClass("class3xx"));
+ Assertions.assertTrue(filter.matchClass("class1xx"));
+ Assertions.assertTrue(filter.matchClass("class2xx"));
+ Assertions.assertTrue(filter.matchClass("class3xx"));
}
@Test
public void matchMethod() {
ClassMethodArgumentFilter filter = new ClassMethodArgumentFilter(null);
- Assert.assertEquals(0, filter.matchMethod("class1", "method1").size());
+ Assertions.assertEquals(0, filter.matchMethod("class1", "method1").size());
filter = new ClassMethodArgumentFilter(Collections.singletonList(new ClassMethodArgument("class1", "", 1)));
- Assert.assertEquals(0, filter.matchMethod("class1", "method1").size());
+ Assertions.assertEquals(0, filter.matchMethod("class1", "method1").size());
filter =
new ClassMethodArgumentFilter(Collections.singletonList(new ClassMethodArgument("", "method1", 10)));
- Assert.assertEquals(1, filter.matchMethod("class1", "method1").size());
- Assert.assertEquals(10, filter.matchMethod("class1", "method1").get(0).intValue());
+ Assertions.assertEquals(1, filter.matchMethod("class1", "method1").size());
+ Assertions.assertEquals(10, filter.matchMethod("class1", "method1").get(0).intValue());
filter =
new ClassMethodArgumentFilter(
- Collections.singletonList(new ClassMethodArgument("class2", "method1", 1)));
- Assert.assertEquals(0, filter.matchMethod("class1", "method1").size());
+ Collections.singletonList(new ClassMethodArgument("class2", "method1", 1)));
+ Assertions.assertEquals(0, filter.matchMethod("class1", "method1").size());
filter =
new ClassMethodArgumentFilter(
Arrays.asList(
new ClassMethodArgument("", "method1", 10),
new ClassMethodArgument("class1", "method1", 2)));
- Assert.assertEquals(2, filter.matchMethod("class1", "method1").size());
- Assert.assertEquals(10, filter.matchMethod("class1", "method1").get(0).intValue());
- Assert.assertEquals(2, filter.matchMethod("class1", "method1").get(1).intValue());
+ Assertions.assertEquals(2, filter.matchMethod("class1", "method1").size());
+ Assertions.assertEquals(10, filter.matchMethod("class1", "method1").get(0).intValue());
+ Assertions.assertEquals(2, filter.matchMethod("class1", "method1").get(1).intValue());
}
@Test
public void matchMethod_wildcard() {
ClassMethodArgumentFilter filter =
new ClassMethodArgumentFilter(Collections.singletonList(new ClassMethodArgument("class1", "", 10)));
- Assert.assertEquals(0, filter.matchMethod("class1", "method1").size());
+ Assertions.assertEquals(0, filter.matchMethod("class1", "method1").size());
filter =
new ClassMethodArgumentFilter(
Arrays.asList(
new ClassMethodArgument("class1", "", 10),
new ClassMethodArgument("class1", "*", 20)));
- Assert.assertEquals(1, filter.matchMethod("class1", "method1").size());
- Assert.assertEquals(20, filter.matchMethod("class1", "method1").get(0).intValue());
+ Assertions.assertEquals(1, filter.matchMethod("class1", "method1").size());
+ Assertions.assertEquals(20, filter.matchMethod("class1", "method1").get(0).intValue());
}
@Test
@@ -111,8 +112,8 @@ public class ClassMethodArgumentFilterTest {
Arrays.asList(
new ClassMethodArgument("package11.class1", "method1", 10),
new ClassMethodArgument("package22", "method2", 20)));
- Assert.assertEquals(1, filter.matchMethod("package22.class2", "method2").size());
- Assert.assertEquals(0, filter.matchMethod("package2", "method2").size());
+ Assertions.assertEquals(1, filter.matchMethod("package22.class2", "method2").size());
+ Assertions.assertEquals(0, filter.matchMethod("package2", "method2").size());
filter =
new ClassMethodArgumentFilter(
@@ -120,10 +121,10 @@ public class ClassMethodArgumentFilterTest {
new ClassMethodArgument("package11.class1", "method1", 10),
new ClassMethodArgument("package22", "method2", 20),
new ClassMethodArgument("package33", "*", 30)));
- Assert.assertEquals(1, filter.matchMethod("package22.class2", "method2").size());
- Assert.assertEquals(20, filter.matchMethod("package22.class2", "method2").get(0).intValue());
- Assert.assertEquals(0, filter.matchMethod("package2", "method2").size());
- Assert.assertEquals(1, filter.matchMethod("package33.xx.yy", "method3").size());
- Assert.assertEquals(30, filter.matchMethod("package33.xx.yy", "method3").get(0).intValue());
+ Assertions.assertEquals(1, filter.matchMethod("package22.class2", "method2").size());
+ Assertions.assertEquals(20, filter.matchMethod("package22.class2", "method2").get(0).intValue());
+ Assertions.assertEquals(0, filter.matchMethod("package2", "method2").size());
+ Assertions.assertEquals(1, filter.matchMethod("package33.xx.yy", "method3").size());
+ Assertions.assertEquals(30, filter.matchMethod("package33.xx.yy", "method3").get(0).intValue());
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/IOUtilsTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/IOUtilsTest.java
index 81007d7fc..9734ab5af 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/IOUtilsTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/IOUtilsTest.java
@@ -17,19 +17,20 @@
package org.apache.streampark.plugin.profiling.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
public class IOUtilsTest {
+
@Test
public void toByteArray() {
- byte[] bytes = new byte[]{1, 2, 3};
+ byte[] bytes = new byte[] {1, 2, 3};
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
byte[] result = Utils.toByteArray(byteArrayInputStream);
- Assert.assertEquals(3, result.length);
- Assert.assertEquals(1, result[0]);
- Assert.assertEquals(3, result[result.length - 1]);
+ Assertions.assertEquals(3, result.length);
+ Assertions.assertEquals(1, result[0]);
+ Assertions.assertEquals(3, result[result.length - 1]);
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ProcFileUtilsTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ProcFileUtilsTest.java
index 3f3d56a3b..a8b88844d 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ProcFileUtilsTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ProcFileUtilsTest.java
@@ -17,8 +17,8 @@
package org.apache.streampark.plugin.profiling.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.IOException;
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Map;
public class ProcFileUtilsTest {
+
@Test
public void getProcFileAsMap() throws IOException {
File file = File.createTempFile("test", "test");
@@ -46,36 +47,36 @@ public class ProcFileUtilsTest {
Files.write(file.toPath(), content.getBytes(), StandardOpenOption.CREATE);
Map<String, String> result = ProcFileUtils.getProcFileAsMap(file.getPath());
- Assert.assertEquals(6, result.size());
+ Assertions.assertEquals(6, result.size());
- Assert.assertEquals("cat", result.get("Name"));
- Assert.assertEquals("676 kB", result.get("VmRSS"));
- Assert.assertEquals("66646", result.get("Pid"));
- Assert.assertEquals("1", result.get("Threads"));
+ Assertions.assertEquals("cat", result.get("Name"));
+ Assertions.assertEquals("676 kB", result.get("VmRSS"));
+ Assertions.assertEquals("66646", result.get("Pid"));
+ Assertions.assertEquals("1", result.get("Threads"));
}
@Test
public void getProcFileAsMap_NotExistingFile() {
Map<String, String> result = ProcFileUtils.getProcFileAsMap("/not/existing/file");
- Assert.assertEquals(0, result.size());
+ Assertions.assertEquals(0, result.size());
}
@Test
public void getProcFileAsMap_Directory() {
Map<String, String> result = ProcFileUtils.getProcFileAsMap("/");
- Assert.assertEquals(0, result.size());
+ Assertions.assertEquals(0, result.size());
}
@Test
public void getProcFileAsRowColumn_NotExistingFile() {
List<String[]> result = ProcFileUtils.getProcFileAsRowColumn("/not/existing/file");
- Assert.assertEquals(0, result.size());
+ Assertions.assertEquals(0, result.size());
}
@Test
public void getProcFileAsRowColumn_Directory() {
List<String[]> result = ProcFileUtils.getProcFileAsRowColumn("/");
- Assert.assertEquals(0, result.size());
+ Assertions.assertEquals(0, result.size());
}
@Test
@@ -85,10 +86,10 @@ public class ProcFileUtilsTest {
// Mac has no proc file so result will be empty.
// Linux has proc file and result should contain some keys;
if (result.size() >= 1) {
- Assert.assertTrue(result.containsKey("Pid"));
- Assert.assertTrue(result.containsKey("VmRSS"));
- Assert.assertTrue(result.containsKey("VmSize"));
- Assert.assertTrue(result.containsKey("VmPeak"));
+ Assertions.assertTrue(result.containsKey("Pid"));
+ Assertions.assertTrue(result.containsKey("VmRSS"));
+ Assertions.assertTrue(result.containsKey("VmSize"));
+ Assertions.assertTrue(result.containsKey("VmPeak"));
}
}
@@ -99,10 +100,10 @@ public class ProcFileUtilsTest {
// Mac has no proc file so result will be empty.
// Linux has proc file and result should contain some keys;
if (result.size() >= 1) {
- Assert.assertTrue(result.containsKey("rchar"));
- Assert.assertTrue(result.containsKey("wchar"));
- Assert.assertTrue(result.containsKey("read_bytes"));
- Assert.assertTrue(result.containsKey("write_bytes"));
+ Assertions.assertTrue(result.containsKey("rchar"));
+ Assertions.assertTrue(result.containsKey("wchar"));
+ Assertions.assertTrue(result.containsKey("read_bytes"));
+ Assertions.assertTrue(result.containsKey("write_bytes"));
}
}
@@ -111,7 +112,7 @@ public class ProcFileUtilsTest {
{
Map<String, String> map = Collections.emptyMap();
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertNull(bytesValue);
+ Assertions.assertNull(bytesValue);
}
{
File file = File.createTempFile("test", "test");
@@ -122,7 +123,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertNull(bytesValue);
+ Assertions.assertNull(bytesValue);
}
{
File file = File.createTempFile("test", "test");
@@ -138,7 +139,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertNull(bytesValue);
+ Assertions.assertNull(bytesValue);
}
{
File file = File.createTempFile("test", "test");
@@ -154,7 +155,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676L, bytesValue.longValue());
+ Assertions.assertEquals(676L, bytesValue.longValue());
}
{
File file = File.createTempFile("test", "test");
@@ -170,7 +171,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676 * 1024L, bytesValue.longValue());
+ Assertions.assertEquals(676 * 1024L, bytesValue.longValue());
}
{
File file = File.createTempFile("test", "test");
@@ -186,7 +187,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676 * 1024L, bytesValue.longValue());
+ Assertions.assertEquals(676 * 1024L, bytesValue.longValue());
}
{
File file = File.createTempFile("test", "test");
@@ -202,7 +203,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676 * 1024L, bytesValue.longValue());
+ Assertions.assertEquals(676 * 1024L, bytesValue.longValue());
}
{
File file = File.createTempFile("test", "test");
@@ -218,7 +219,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676 * 1024L, bytesValue.longValue());
+ Assertions.assertEquals(676 * 1024L, bytesValue.longValue());
}
{
File file = File.createTempFile("test", "test");
@@ -234,7 +235,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676 * 1024L, bytesValue.longValue());
+ Assertions.assertEquals(676 * 1024L, bytesValue.longValue());
}
{
File file = File.createTempFile("test", "test");
@@ -250,7 +251,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676 * 1024 * 1024L, bytesValue.longValue());
+ Assertions.assertEquals(676 * 1024 * 1024L, bytesValue.longValue());
}
{
File file = File.createTempFile("test", "test");
@@ -266,7 +267,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676 * 1024 * 1024L, bytesValue.longValue());
+ Assertions.assertEquals(676 * 1024 * 1024L, bytesValue.longValue());
}
{
File file = File.createTempFile("test", "test");
@@ -282,7 +283,7 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676 * 1024 * 1024 * 1024L, bytesValue.longValue());
+ Assertions.assertEquals(676 * 1024 * 1024 * 1024L, bytesValue.longValue());
}
{
File file = File.createTempFile("test", "test");
@@ -298,15 +299,15 @@ public class ProcFileUtilsTest {
Map<String, String> map = ProcFileUtils.getProcFileAsMap(file.getPath());
Long bytesValue = ProcFileUtils.getBytesValue(map, "VmRSS");
- Assert.assertEquals(676 * 1024 * 1024 * 1024L, bytesValue.longValue());
+ Assertions.assertEquals(676 * 1024 * 1024 * 1024L, bytesValue.longValue());
}
}
@Test
public void getProcStatCpuTime() throws IOException {
{
- Assert.assertEquals(0, ProcFileUtils.getProcStatCpuTime(null).size());
- Assert.assertEquals(0, ProcFileUtils.getProcStatCpuTime(new ArrayList<>()).size());
+ Assertions.assertEquals(0, ProcFileUtils.getProcStatCpuTime(null).size());
+ Assertions.assertEquals(0, ProcFileUtils.getProcStatCpuTime(new ArrayList<>()).size());
}
{
File file = File.createTempFile("test", "test");
@@ -322,38 +323,38 @@ public class ProcFileUtilsTest {
Files.write(file.toPath(), content.getBytes(), StandardOpenOption.CREATE);
List<String[]> rows = ProcFileUtils.getProcFileAsRowColumn(file.getPath());
- Assert.assertEquals(7, rows.size());
+ Assertions.assertEquals(7, rows.size());
List<Map<String, Object>> cpuTimes = ProcFileUtils.getProcStatCpuTime(rows);
- Assert.assertEquals(4, cpuTimes.size());
-
- Assert.assertEquals("cpu", cpuTimes.get(0).get("cpu"));
- Assert.assertEquals(1172937054L, cpuTimes.get(0).get("user"));
- Assert.assertEquals(824289701L, cpuTimes.get(0).get("nice"));
- Assert.assertEquals(468234436L, cpuTimes.get(0).get("system"));
- Assert.assertEquals(75675853861L, cpuTimes.get(0).get("idle"));
- Assert.assertEquals(1569550L, cpuTimes.get(0).get("iowait"));
-
- Assert.assertEquals("cpuXYZ", cpuTimes.get(1).get("cpu"));
- Assert.assertEquals(1172937055L, cpuTimes.get(1).get("user"));
- Assert.assertEquals(824289702L, cpuTimes.get(1).get("nice"));
- Assert.assertEquals(468234436L, cpuTimes.get(1).get("system"));
- Assert.assertEquals(75675853861L, cpuTimes.get(1).get("idle"));
- Assert.assertEquals(1569550L, cpuTimes.get(1).get("iowait"));
-
- Assert.assertEquals("cpu0", cpuTimes.get(2).get("cpu"));
- Assert.assertEquals(62086703L, cpuTimes.get(2).get("user"));
- Assert.assertEquals(131209370L, cpuTimes.get(2).get("nice"));
- Assert.assertEquals(38265368L, cpuTimes.get(2).get("system"));
- Assert.assertEquals(3012668347L, cpuTimes.get(2).get("idle"));
- Assert.assertEquals(284193L, cpuTimes.get(2).get("iowait"));
-
- Assert.assertEquals("cpu1", cpuTimes.get(3).get("cpu"));
- Assert.assertEquals(67845808L, cpuTimes.get(3).get("user"));
- Assert.assertEquals(163124717L, cpuTimes.get(3).get("nice"));
- Assert.assertEquals(46602120L, cpuTimes.get(3).get("system"));
- Assert.assertEquals(2966238934L, cpuTimes.get(3).get("idle"));
- Assert.assertEquals(85123L, cpuTimes.get(3).get("iowait"));
+ Assertions.assertEquals(4, cpuTimes.size());
+
+ Assertions.assertEquals("cpu", cpuTimes.get(0).get("cpu"));
+ Assertions.assertEquals(1172937054L, cpuTimes.get(0).get("user"));
+ Assertions.assertEquals(824289701L, cpuTimes.get(0).get("nice"));
+ Assertions.assertEquals(468234436L, cpuTimes.get(0).get("system"));
+ Assertions.assertEquals(75675853861L, cpuTimes.get(0).get("idle"));
+ Assertions.assertEquals(1569550L, cpuTimes.get(0).get("iowait"));
+
+ Assertions.assertEquals("cpuXYZ", cpuTimes.get(1).get("cpu"));
+ Assertions.assertEquals(1172937055L, cpuTimes.get(1).get("user"));
+ Assertions.assertEquals(824289702L, cpuTimes.get(1).get("nice"));
+ Assertions.assertEquals(468234436L, cpuTimes.get(1).get("system"));
+ Assertions.assertEquals(75675853861L, cpuTimes.get(1).get("idle"));
+ Assertions.assertEquals(1569550L, cpuTimes.get(1).get("iowait"));
+
+ Assertions.assertEquals("cpu0", cpuTimes.get(2).get("cpu"));
+ Assertions.assertEquals(62086703L, cpuTimes.get(2).get("user"));
+ Assertions.assertEquals(131209370L, cpuTimes.get(2).get("nice"));
+ Assertions.assertEquals(38265368L, cpuTimes.get(2).get("system"));
+ Assertions.assertEquals(3012668347L, cpuTimes.get(2).get("idle"));
+ Assertions.assertEquals(284193L, cpuTimes.get(2).get("iowait"));
+
+ Assertions.assertEquals("cpu1", cpuTimes.get(3).get("cpu"));
+ Assertions.assertEquals(67845808L, cpuTimes.get(3).get("user"));
+ Assertions.assertEquals(163124717L, cpuTimes.get(3).get("nice"));
+ Assertions.assertEquals(46602120L, cpuTimes.get(3).get("system"));
+ Assertions.assertEquals(2966238934L, cpuTimes.get(3).get("idle"));
+ Assertions.assertEquals(85123L, cpuTimes.get(3).get("iowait"));
}
}
@@ -366,7 +367,7 @@ public class ProcFileUtilsTest {
Files.write(file.toPath(), content.getBytes(), StandardOpenOption.CREATE);
String result = ProcFileUtils.getPid(file.getPath());
- Assert.assertNull(result);
+ Assertions.assertNull(result);
}
@Test
@@ -379,12 +380,12 @@ public class ProcFileUtilsTest {
Files.write(file.toPath(), content.getBytes(), StandardOpenOption.CREATE);
String result = ProcFileUtils.getPid(file.getPath());
- Assert.assertEquals("66646", result);
+ Assertions.assertEquals("66646", result);
}
@Test
public void getCmdline() throws IOException {
String result = ProcFileUtils.getCmdline();
- Assert.assertTrue(result == null || !result.isEmpty());
+ Assertions.assertTrue(result == null || !result.isEmpty());
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ReflectionUtilsTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ReflectionUtilsTest.java
index d1248dcd9..6fb131205 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ReflectionUtilsTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/ReflectionUtilsTest.java
@@ -17,8 +17,8 @@
package org.apache.streampark.plugin.profiling.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.lang.reflect.InvocationTargetException;
@@ -31,7 +31,7 @@ public class ReflectionUtilsTest {
Object result =
ReflectionUtils.executeStaticMethods(
"org.apache.streampark.plugin.profiling.util.ReflectionUtilsTest$ClassB", "getClassA.method1");
- Assert.assertEquals("hello", result);
+ Assertions.assertEquals("hello", result);
}
static class ClassA {
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/SparkUtilsTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/SparkUtilsTest.java
index 6f0c09d4a..fd53b9287 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/SparkUtilsTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/SparkUtilsTest.java
@@ -19,31 +19,32 @@ package org.apache.streampark.plugin.profiling.util;
import org.apache.streampark.plugin.profiling.Arguments;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.lang.reflect.InvocationTargetException;
public class SparkUtilsTest {
+
@Test
public void probeAppId() {
- Assert.assertNull(SparkUtils.probeAppId(Arguments.ARG_APP_ID_REGEX));
- Assert.assertEquals("jar", SparkUtils.probeAppId("jar"));
+ Assertions.assertNull(SparkUtils.probeAppId(Arguments.ARG_APP_ID_REGEX));
+ Assertions.assertEquals("jar", SparkUtils.probeAppId("jar"));
}
@Test
public void getAppId()
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
- Assert.assertNull(SparkUtils.getSparkEnvAppId());
+ Assertions.assertNull(SparkUtils.getSparkEnvAppId());
}
@Test
public void probeRole() {
- Assert.assertEquals(
+ Assertions.assertEquals(
"executor",
SparkUtils.probeRole("java org.apache.spark.executor.CoarseGrainedExecutorBackend"));
- Assert.assertEquals("driver", SparkUtils.probeRole("java org.apache.spark.MockDriver"));
- Assert.assertNull(SparkUtils.probeRole("java foo"));
+ Assertions.assertEquals("driver", SparkUtils.probeRole("java org.apache.spark.MockDriver"));
+ Assertions.assertNull(SparkUtils.probeRole("java foo"));
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/StacktraceMetricBufferTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/StacktraceMetricBufferTest.java
index 4ca788ae3..63f2696d8 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/StacktraceMetricBufferTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/StacktraceMetricBufferTest.java
@@ -17,8 +17,8 @@
package org.apache.streampark.plugin.profiling.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.HashSet;
import java.util.Map;
@@ -26,6 +26,7 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
public class StacktraceMetricBufferTest {
+
@Test
public void appendValue() {
StacktraceMetricBuffer buffer = new StacktraceMetricBuffer();
@@ -54,7 +55,7 @@ public class StacktraceMetricBufferTest {
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread1");
stacktrace.setThreadState("RUNNING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method1")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method1")});
buffer.appendValue(stacktrace);
@@ -64,7 +65,7 @@ public class StacktraceMetricBufferTest {
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread1");
stacktrace.setThreadState("RUNNING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method1")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method1")});
buffer.appendValue(stacktrace);
}
@@ -72,7 +73,7 @@ public class StacktraceMetricBufferTest {
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread1");
stacktrace.setThreadState("WAITING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method1")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method1")});
buffer.appendValue(stacktrace);
@@ -82,7 +83,7 @@ public class StacktraceMetricBufferTest {
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread2");
stacktrace.setThreadState("RUNNING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method1")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method1")});
buffer.appendValue(stacktrace);
@@ -92,7 +93,7 @@ public class StacktraceMetricBufferTest {
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread2");
stacktrace.setThreadState("RUNNING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method1")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method1")});
buffer.appendValue(stacktrace);
@@ -102,7 +103,7 @@ public class StacktraceMetricBufferTest {
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread2");
stacktrace.setThreadState("RUNNING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method2")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method2")});
buffer.appendValue(stacktrace);
@@ -112,7 +113,7 @@ public class StacktraceMetricBufferTest {
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread3");
stacktrace.setThreadState("WAIRTING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class2", "method2")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class2", "method2")});
buffer.appendValue(stacktrace);
@@ -123,7 +124,7 @@ public class StacktraceMetricBufferTest {
stacktrace.setThreadName("thread3");
stacktrace.setThreadState("RUNNING");
stacktrace.setStack(
- new ClassAndMethod[]{
+ new ClassAndMethod[] {
new ClassAndMethod("class11", "method11"), new ClassAndMethod("class11", "method12")
});
@@ -136,7 +137,7 @@ public class StacktraceMetricBufferTest {
stacktrace.setThreadName("thread3");
stacktrace.setThreadState("RUNNING");
stacktrace.setStack(
- new ClassAndMethod[]{
+ new ClassAndMethod[] {
new ClassAndMethod("class11", "method11"), new ClassAndMethod("class11", "method12")
});
@@ -146,8 +147,8 @@ public class StacktraceMetricBufferTest {
}
long lastResetMillis = buffer.getLastResetMillis();
- Assert.assertTrue(System.currentTimeMillis() - lastResetMillis >= 0);
- Assert.assertTrue(System.currentTimeMillis() - lastResetMillis <= 1000);
+ Assertions.assertTrue(System.currentTimeMillis() - lastResetMillis >= 0);
+ Assertions.assertTrue(System.currentTimeMillis() - lastResetMillis <= 1000);
try {
Thread.sleep(10);
@@ -158,17 +159,17 @@ public class StacktraceMetricBufferTest {
Map<Stacktrace, AtomicLong> map = buffer.reset();
long lastResetMillis2 = buffer.getLastResetMillis();
- Assert.assertTrue(lastResetMillis2 - lastResetMillis >= 10);
- Assert.assertTrue(lastResetMillis2 - lastResetMillis <= 1000);
+ Assertions.assertTrue(lastResetMillis2 - lastResetMillis >= 10);
+ Assertions.assertTrue(lastResetMillis2 - lastResetMillis <= 1000);
- Assert.assertEquals(7, map.size());
- Assert.assertEquals(7, distinctStacktraces.size());
+ Assertions.assertEquals(7, map.size());
+ Assertions.assertEquals(7, distinctStacktraces.size());
{
Stacktrace stacktrace = new Stacktrace();
long count = map.get(stacktrace).longValue();
- Assert.assertEquals(3, count);
+ Assertions.assertEquals(3, count);
}
{
Stacktrace stacktrace = new Stacktrace();
@@ -177,75 +178,75 @@ public class StacktraceMetricBufferTest {
stacktrace.setStack(null);
long count = map.get(stacktrace).longValue();
- Assert.assertEquals(3, count);
+ Assertions.assertEquals(3, count);
}
{
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread1");
stacktrace.setThreadState("RUNNING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method1")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method1")});
long count = map.get(stacktrace).longValue();
- Assert.assertEquals(2, count);
+ Assertions.assertEquals(2, count);
}
{
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread1");
stacktrace.setThreadState("WAITING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method1")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method1")});
long count = map.get(stacktrace).longValue();
- Assert.assertEquals(1, count);
+ Assertions.assertEquals(1, count);
}
{
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread2");
stacktrace.setThreadState("RUNNING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method1")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method1")});
long count = map.get(stacktrace).longValue();
- Assert.assertEquals(2, count);
+ Assertions.assertEquals(2, count);
}
{
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread2");
stacktrace.setThreadState("RUNNING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class1", "method2")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class1", "method2")});
long count = map.get(stacktrace).longValue();
- Assert.assertEquals(1, count);
+ Assertions.assertEquals(1, count);
}
{
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread3");
stacktrace.setThreadState("WAIRTING");
- stacktrace.setStack(new ClassAndMethod[]{new ClassAndMethod("class2", "method2")});
+ stacktrace.setStack(new ClassAndMethod[] {new ClassAndMethod("class2", "method2")});
long count = map.get(stacktrace).longValue();
- Assert.assertEquals(1, count);
+ Assertions.assertEquals(1, count);
}
{
Stacktrace stacktrace = new Stacktrace();
stacktrace.setThreadName("thread3");
stacktrace.setThreadState("RUNNING");
stacktrace.setStack(
- new ClassAndMethod[]{
+ new ClassAndMethod[] {
new ClassAndMethod("class11", "method11"), new ClassAndMethod("class11", "method12")
});
long count = map.get(stacktrace).longValue();
- Assert.assertEquals(2, count);
+ Assertions.assertEquals(2, count);
}
for (Stacktrace stacktrace : distinctStacktraces) {
map.remove(stacktrace);
}
- Assert.assertEquals(0, map.size());
+ Assertions.assertEquals(0, map.size());
map = buffer.reset();
- Assert.assertEquals(0, map.size());
+ Assertions.assertEquals(0, map.size());
map = buffer.reset();
- Assert.assertEquals(0, map.size());
+ Assertions.assertEquals(0, map.size());
}
}
diff --git a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/StringUtilsTest.java b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/StringUtilsTest.java
index 08188738a..69eb24402 100644
--- a/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/StringUtilsTest.java
+++ b/streampark-plugin/streampark-jvm-profiler/src/test/java/org/apache/streampark/plugin/profiling/util/StringUtilsTest.java
@@ -17,120 +17,121 @@
package org.apache.streampark.plugin.profiling.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import java.util.List;
public class StringUtilsTest {
+
@Test
public void splitByLength() {
List<String> list = StringUtils.splitByLength("a", 1);
- Assert.assertEquals(1, list.size());
- Assert.assertEquals("a", list.get(0));
+ Assertions.assertEquals(1, list.size());
+ Assertions.assertEquals("a", list.get(0));
list = StringUtils.splitByLength("abc", 1);
- Assert.assertEquals(3, list.size());
- Assert.assertEquals("a", list.get(0));
- Assert.assertEquals("c", list.get(2));
+ Assertions.assertEquals(3, list.size());
+ Assertions.assertEquals("a", list.get(0));
+ Assertions.assertEquals("c", list.get(2));
list = StringUtils.splitByLength("abcd", 2);
- Assert.assertEquals(2, list.size());
- Assert.assertEquals("ab", list.get(0));
- Assert.assertEquals("cd", list.get(1));
+ Assertions.assertEquals(2, list.size());
+ Assertions.assertEquals("ab", list.get(0));
+ Assertions.assertEquals("cd", list.get(1));
list = StringUtils.splitByLength("abcde", 2);
- Assert.assertEquals(3, list.size());
- Assert.assertEquals("ab", list.get(0));
- Assert.assertEquals("cd", list.get(1));
- Assert.assertEquals("e", list.get(2));
+ Assertions.assertEquals(3, list.size());
+ Assertions.assertEquals("ab", list.get(0));
+ Assertions.assertEquals("cd", list.get(1));
+ Assertions.assertEquals("e", list.get(2));
}
@Test
public void extractByRegex() {
- Assert.assertEquals(0, StringUtils.extractByRegex(null, null).size());
- Assert.assertEquals(1, StringUtils.extractByRegex("", "").size());
- Assert.assertEquals("", StringUtils.extractByRegex("", "").get(0));
+ Assertions.assertEquals(0, StringUtils.extractByRegex(null, null).size());
+ Assertions.assertEquals(1, StringUtils.extractByRegex("", "").size());
+ Assertions.assertEquals("", StringUtils.extractByRegex("", "").get(0));
List<String> list =
StringUtils.extractByRegex(
"appcache/application_1498604172385_2751189/container_e241_1498604172385_2751189_01_000267",
"application_[\\w_]+");
- Assert.assertEquals(1, list.size());
- Assert.assertEquals("application_1498604172385_2751189", list.get(0));
+ Assertions.assertEquals(1, list.size());
+ Assertions.assertEquals("application_1498604172385_2751189", list.get(0));
list =
StringUtils.extractByRegex(
"appcache/application_1498604172385_2751189/container_e241_1498604172385_2751189_01_000267,appcache/application_1498604172385_2751190/container_e241_1498604172385_2751189_01_000267",
"application_[\\w_]+");
- Assert.assertEquals(2, list.size());
- Assert.assertEquals("application_1498604172385_2751189", list.get(0));
- Assert.assertEquals("application_1498604172385_2751190", list.get(1));
+ Assertions.assertEquals(2, list.size());
+ Assertions.assertEquals("application_1498604172385_2751189", list.get(0));
+ Assertions.assertEquals("application_1498604172385_2751190", list.get(1));
}
@Test
public void getValueAsBytes() {
- Assert.assertNull(StringUtils.getBytesValueOrNull(null));
- Assert.assertNull(StringUtils.getBytesValueOrNull(""));
- Assert.assertNull(StringUtils.getBytesValueOrNull("xxx"));
-
- Assert.assertEquals(0L, StringUtils.getBytesValueOrNull("0").longValue());
- Assert.assertEquals(123L, StringUtils.getBytesValueOrNull("123").longValue());
- Assert.assertEquals(123L, StringUtils.getBytesValueOrNull("123.").longValue());
- Assert.assertEquals(123L, StringUtils.getBytesValueOrNull("123.123").longValue());
-
- Assert.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123k").longValue());
- Assert.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123kb").longValue());
- Assert.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123 kb").longValue());
- Assert.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123K").longValue());
- Assert.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123KB").longValue());
- Assert.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123 KB").longValue());
-
- Assert.assertEquals(123 * 1024L * 1024L, StringUtils.getBytesValueOrNull("123m").longValue());
- Assert.assertEquals(123 * 1024L * 1024L, StringUtils.getBytesValueOrNull("123mb").longValue());
- Assert.assertEquals(123 * 1024L * 1024L, StringUtils.getBytesValueOrNull("123 mb").longValue());
- Assert.assertEquals(123 * 1024L * 1024L, StringUtils.getBytesValueOrNull("123M").longValue());
-
- Assert.assertEquals(
+ Assertions.assertNull(StringUtils.getBytesValueOrNull(null));
+ Assertions.assertNull(StringUtils.getBytesValueOrNull(""));
+ Assertions.assertNull(StringUtils.getBytesValueOrNull("xxx"));
+
+ Assertions.assertEquals(0L, StringUtils.getBytesValueOrNull("0").longValue());
+ Assertions.assertEquals(123L, StringUtils.getBytesValueOrNull("123").longValue());
+ Assertions.assertEquals(123L, StringUtils.getBytesValueOrNull("123.").longValue());
+ Assertions.assertEquals(123L, StringUtils.getBytesValueOrNull("123.123").longValue());
+
+ Assertions.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123k").longValue());
+ Assertions.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123kb").longValue());
+ Assertions.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123 kb").longValue());
+ Assertions.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123K").longValue());
+ Assertions.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123KB").longValue());
+ Assertions.assertEquals(123 * 1024L, StringUtils.getBytesValueOrNull("123 KB").longValue());
+
+ Assertions.assertEquals(123 * 1024L * 1024L, StringUtils.getBytesValueOrNull("123m").longValue());
+ Assertions.assertEquals(123 * 1024L * 1024L, StringUtils.getBytesValueOrNull("123mb").longValue());
+ Assertions.assertEquals(123 * 1024L * 1024L, StringUtils.getBytesValueOrNull("123 mb").longValue());
+ Assertions.assertEquals(123 * 1024L * 1024L, StringUtils.getBytesValueOrNull("123M").longValue());
+
+ Assertions.assertEquals(
123 * 1024L * 1024L * 1024L, StringUtils.getBytesValueOrNull("123g").longValue());
- Assert.assertEquals(
+ Assertions.assertEquals(
123 * 1024L * 1024L * 1024L, StringUtils.getBytesValueOrNull("123gb").longValue());
- Assert.assertEquals(
+ Assertions.assertEquals(
123 * 1024L * 1024L * 1024L, StringUtils.getBytesValueOrNull("123 gb").longValue());
- Assert.assertEquals(
+ Assertions.assertEquals(
123 * 1024L * 1024L * 1024L, StringUtils.getBytesValueOrNull("123G").longValue());
- Assert.assertEquals(123L, StringUtils.getBytesValueOrNull("123bytes").longValue());
- Assert.assertEquals(123L, StringUtils.getBytesValueOrNull("123 Bytes").longValue());
+ Assertions.assertEquals(123L, StringUtils.getBytesValueOrNull("123bytes").longValue());
+ Assertions.assertEquals(123L, StringUtils.getBytesValueOrNull("123 Bytes").longValue());
}
@Test
public void getArgumentValue() {
- Assert.assertNull(StringUtils.getArgumentValue(null, null));
- Assert.assertNull(StringUtils.getArgumentValue(null, ""));
- Assert.assertNull(StringUtils.getArgumentValue("", null));
+ Assertions.assertNull(StringUtils.getArgumentValue(null, null));
+ Assertions.assertNull(StringUtils.getArgumentValue(null, ""));
+ Assertions.assertNull(StringUtils.getArgumentValue("", null));
- Assert.assertNull(StringUtils.getArgumentValue("", ""));
- Assert.assertNull(StringUtils.getArgumentValue("test", ""));
- Assert.assertNull(StringUtils.getArgumentValue("", "test"));
+ Assertions.assertNull(StringUtils.getArgumentValue("", ""));
+ Assertions.assertNull(StringUtils.getArgumentValue("test", ""));
+ Assertions.assertNull(StringUtils.getArgumentValue("", "test"));
- Assert.assertEquals(
+ Assertions.assertEquals(
"com.foo.jobs.Abc", StringUtils.getArgumentValue("--class com.foo.jobs.Abc", "--class"));
- Assert.assertEquals(
+ Assertions.assertEquals(
"com.foo.jobs.Abc", StringUtils.getArgumentValue(" --class com.foo.jobs.Abc ", "--class"));
- Assert.assertEquals(
+ Assertions.assertEquals(
"com.foo.jobs.Abc", StringUtils.getArgumentValue(" --class com.foo.jobs.Abc ", "--class"));
- Assert.assertEquals(
+ Assertions.assertEquals(
"com.foo.jobs.Abc",
StringUtils.getArgumentValue(" --class 'com.foo.jobs.Abc' ", "--class"));
- Assert.assertEquals(
+ Assertions.assertEquals(
"com.foo.jobs.Abc",
StringUtils.getArgumentValue(" --class \"com.foo.jobs.Abc\" ", "--class"));
- Assert.assertEquals(
+ Assertions.assertEquals(
" com.foo.jobs.Abc ",
StringUtils.getArgumentValue(" --class ' com.foo.jobs.Abc ' ", "--class"));
- Assert.assertEquals(
+ Assertions.assertEquals(
"com.foo.jobs.Abc",
StringUtils.getArgumentValue(
"xyz --class com.foo.jobs.Abc --jar file:/home/test/hi.jar --others world", "--class"));
@@ -138,25 +139,25 @@ public class StringUtilsTest {
@Test
public void getArgumentValues() {
- Assert.assertArrayEquals(new String[0], StringUtils.getArgumentValues(null, null));
- Assert.assertArrayEquals(new String[0], StringUtils.getArgumentValues(null, ""));
- Assert.assertArrayEquals(new String[0], StringUtils.getArgumentValues("", null));
+ Assertions.assertArrayEquals(new String[0], StringUtils.getArgumentValues(null, null));
+ Assertions.assertArrayEquals(new String[0], StringUtils.getArgumentValues(null, ""));
+ Assertions.assertArrayEquals(new String[0], StringUtils.getArgumentValues("", null));
- Assert.assertArrayEquals(new String[0], StringUtils.getArgumentValues("", ""));
- Assert.assertArrayEquals(new String[0], StringUtils.getArgumentValues("test", ""));
- Assert.assertArrayEquals(new String[0], StringUtils.getArgumentValues("", "test"));
+ Assertions.assertArrayEquals(new String[0], StringUtils.getArgumentValues("", ""));
+ Assertions.assertArrayEquals(new String[0], StringUtils.getArgumentValues("test", ""));
+ Assertions.assertArrayEquals(new String[0], StringUtils.getArgumentValues("", "test"));
- Assert.assertArrayEquals(
- new String[]{"com.foo.jobs.Abc"},
+ Assertions.assertArrayEquals(
+ new String[] {"com.foo.jobs.Abc"},
StringUtils.getArgumentValues("--class com.foo.jobs.Abc", "--class"));
- Assert.assertArrayEquals(
- new String[]{"com.foo.jobs.Abc", "com.foo.jobs.Abc", " com.foo.jobs.Abc "},
+ Assertions.assertArrayEquals(
+ new String[] {"com.foo.jobs.Abc", "com.foo.jobs.Abc", " com.foo.jobs.Abc "},
StringUtils.getArgumentValues(
" --class \"com.foo.jobs.Abc\" --class com.foo.jobs.Abc --class ' com.foo.jobs.Abc ' ",
"--class"));
- Assert.assertArrayEquals(
- new String[]{"com.foo.jobs.Abc"},
+ Assertions.assertArrayEquals(
+ new String[] {"com.foo.jobs.Abc"},
StringUtils.getArgumentValues(
"xyz --class com.foo.jobs.Abc --jar file:/home/test/hi.jar --others world", "--class"));
}
diff --git a/streampark-storage/pom.xml b/streampark-storage/pom.xml
index 74141a10e..21342b016 100644
--- a/streampark-storage/pom.xml
+++ b/streampark-storage/pom.xml
@@ -53,12 +53,12 @@
<artifactId>guava</artifactId>
</dependency>
+ <!--test-->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
-
</dependencies>
</project>
diff --git a/streampark-storage/src/test/java/org/apache/streampark/storage/oss/OssStorageServiceTest.java b/streampark-storage/src/test/java/org/apache/streampark/storage/oss/OssStorageServiceTest.java
index 5290c7407..4ccbbd710 100644
--- a/streampark-storage/src/test/java/org/apache/streampark/storage/oss/OssStorageServiceTest.java
+++ b/streampark-storage/src/test/java/org/apache/streampark/storage/oss/OssStorageServiceTest.java
@@ -19,8 +19,8 @@ package org.apache.streampark.storage.oss;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSSException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class OssStorageServiceTest {
@@ -28,10 +28,10 @@ public class OssStorageServiceTest {
public void testHandleException() throws Exception {
OSSException ossException = new OSSException("mock error", "MOCK_CODE", "requestId", "hostId", "header", "resource", "GET");
RuntimeException exp = OssStorageService.handleOssException(ossException);
- Assert.assertEquals("Caught an OSSException. Error Message: mock error. Error Code: MOCK_CODE. Request ID: requestId", exp.getMessage());
+ Assertions.assertEquals("Caught an OSSException. Error Message: mock error. Error Code: MOCK_CODE. Request ID: requestId", exp.getMessage());
ClientException ossClientException = new ClientException("Client ERROR");
exp = OssStorageService.handleOssException(ossClientException);
- Assert.assertTrue(exp.getMessage().startsWith("Caught an ClientException. Error Message: Client ERROR"));
+ Assertions.assertTrue(exp.getMessage().startsWith("Caught an ClientException. Error Message: Client ERROR"));
}
}