You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/04/26 01:54:23 UTC
[incubator-inlong] branch master updated: [INLONG-3935][Audit][DataProxy] Remove dependency of testng (#3944)
This is an automated email from the ASF dual-hosted git repository.
healchow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 48074d038 [INLONG-3935][Audit][DataProxy] Remove dependency of testng (#3944)
48074d038 is described below
commit 48074d038cc9248f1d33e59b0eef6659079e025f
Author: baomingyu <ba...@163.com>
AuthorDate: Tue Apr 26 09:54:19 2022 +0800
[INLONG-3935][Audit][DataProxy] Remove dependency of testng (#3944)
---
.../apache/inlong/audit/sink/PulsarSinkTest.java | 11 ++++----
.../org/apache/inlong/audit/sink/TubeSinkTest.java | 5 ++--
.../audit/service/ElasticsearchServiceTest.java | 2 +-
.../audit/service/consume/PulsarConsumeTest.java | 6 ++---
inlong-audit/pom.xml | 5 ----
.../loader/TestThirdPartyClusterConfigLoader.java | 27 +++++++++----------
.../inlong/dataproxy/sink/TestPulsarSink.java | 31 ++++------------------
.../inlong/dataproxy/source/UdpSourceTest.java | 4 +--
inlong-dataproxy/pom.xml | 5 ----
pom.xml | 6 -----
10 files changed, 32 insertions(+), 70 deletions(-)
diff --git a/inlong-audit/audit-proxy/src/test/java/org/apache/inlong/audit/sink/PulsarSinkTest.java b/inlong-audit/audit-proxy/src/test/java/org/apache/inlong/audit/sink/PulsarSinkTest.java
index f492572b3..70e217704 100644
--- a/inlong-audit/audit-proxy/src/test/java/org/apache/inlong/audit/sink/PulsarSinkTest.java
+++ b/inlong-audit/audit-proxy/src/test/java/org/apache/inlong/audit/sink/PulsarSinkTest.java
@@ -29,11 +29,11 @@ import org.apache.flume.conf.Configurables;
import org.apache.flume.event.EventBuilder;
import org.apache.flume.lifecycle.LifecycleController;
import org.apache.flume.lifecycle.LifecycleState;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
public class PulsarSinkTest {
private static final Logger logger = LoggerFactory
@@ -47,7 +47,7 @@ public class PulsarSinkTest {
private PulsarSink sink;
private Channel channel;
- @BeforeClass
+ @Before
public void setUp() {
sink = new PulsarSink();
channel = new MemoryChannel();
@@ -64,8 +64,7 @@ public class PulsarSinkTest {
}
@Test
- public void testProcess() throws InterruptedException, EventDeliveryException,
- InstantiationException, IllegalAccessException {
+ public void testProcess() throws InterruptedException, EventDeliveryException {
setUp();
Event event = EventBuilder.withBody("test event 1", Charsets.UTF_8);
sink.start();
diff --git a/inlong-audit/audit-proxy/src/test/java/org/apache/inlong/audit/sink/TubeSinkTest.java b/inlong-audit/audit-proxy/src/test/java/org/apache/inlong/audit/sink/TubeSinkTest.java
index 7b6f68008..cb309a2cb 100644
--- a/inlong-audit/audit-proxy/src/test/java/org/apache/inlong/audit/sink/TubeSinkTest.java
+++ b/inlong-audit/audit-proxy/src/test/java/org/apache/inlong/audit/sink/TubeSinkTest.java
@@ -29,10 +29,10 @@ import org.apache.flume.conf.Configurables;
import org.apache.flume.event.EventBuilder;
import org.apache.flume.lifecycle.LifecycleController;
import org.apache.flume.lifecycle.LifecycleState;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.powermock.api.mockito.PowerMockito;
-import org.testng.Assert;
public class TubeSinkTest {
@@ -62,7 +62,8 @@ public class TubeSinkTest {
public void testProcess() throws InterruptedException, EventDeliveryException {
Event event = EventBuilder.withBody("test", Charsets.UTF_8);
tubeSink.start();
- Assert.assertTrue(LifecycleController.waitForOneOf(tubeSink, LifecycleState.START_OR_ERROR, 5000));
+ Assert.assertTrue(LifecycleController.waitForOneOf(tubeSink,
+ LifecycleState.START_OR_ERROR, 5000));
Transaction transaction = channel.getTransaction();
transaction.begin();
diff --git a/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/ElasticsearchServiceTest.java b/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/ElasticsearchServiceTest.java
index 47abff786..1146d3e92 100644
--- a/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/ElasticsearchServiceTest.java
+++ b/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/ElasticsearchServiceTest.java
@@ -18,6 +18,7 @@
package org.apache.inlong.audit.service;
import org.apache.inlong.audit.db.entities.ESDataPo;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -25,7 +26,6 @@ import org.mockito.Mockito;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-import org.testng.Assert;
import java.io.IOException;
import java.util.Date;
diff --git a/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/consume/PulsarConsumeTest.java b/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/consume/PulsarConsumeTest.java
index 33e55f78b..acc7ccd68 100644
--- a/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/consume/PulsarConsumeTest.java
+++ b/inlong-audit/audit-store/src/test/java/org/apache/inlong/audit/service/consume/PulsarConsumeTest.java
@@ -23,9 +23,9 @@ import org.apache.pulsar.client.impl.conf.ClientConfigurationData;
import org.apache.pulsar.client.util.ExecutorProvider;
import org.apache.pulsar.shade.io.netty.channel.EventLoop;
import org.apache.pulsar.shade.io.netty.util.Timer;
+import org.junit.Before;
+import org.junit.Test;
import org.mockito.Mockito;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -48,7 +48,7 @@ public class PulsarConsumeTest {
return mockClient;
}
- @BeforeMethod
+ @Before
public void setUp() throws Exception {
client = createPulsarClientMock();
ClientConfigurationData clientConf = client.getConfiguration();
diff --git a/inlong-audit/pom.xml b/inlong-audit/pom.xml
index e8642a39c..3eef5debe 100644
--- a/inlong-audit/pom.xml
+++ b/inlong-audit/pom.xml
@@ -71,11 +71,6 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/config/loader/TestThirdPartyClusterConfigLoader.java b/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/config/loader/TestThirdPartyClusterConfigLoader.java
index 8d381cbc2..45ee12f33 100644
--- a/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/config/loader/TestThirdPartyClusterConfigLoader.java
+++ b/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/config/loader/TestThirdPartyClusterConfigLoader.java
@@ -19,55 +19,54 @@ package org.apache.inlong.dataproxy.config.loader;
import org.apache.inlong.dataproxy.config.ConfigManager;
import org.apache.inlong.dataproxy.config.pojo.ThirdPartyClusterConfig;
+import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
-import static org.testng.AssertJUnit.assertEquals;
-
public class TestThirdPartyClusterConfigLoader {
@Test
public void testUpdateUrl() {
Map<String, String> url2token = ConfigManager.getInstance().getThirdPartyClusterUrl2Token();
- assertEquals(url2token.size(), 3);
+ Assert.assertEquals(url2token.size(), 3);
Map<String, String> newUrl = new HashMap<>();
newUrl.put("127.0.0.1:8088", "test");
ConfigManager.getInstance().getThirdPartyClusterHolder().setUrl2token(newUrl);
url2token = ConfigManager.getInstance().getThirdPartyClusterUrl2Token();
- assertEquals(newUrl, url2token);
+ Assert.assertEquals(newUrl, url2token);
}
@Test
public void testCommonConfig() {
ThirdPartyClusterConfig config = ConfigManager.getInstance().getThirdPartyClusterConfig();
- assertEquals(config.getAuthType(), "token");
- assertEquals(config.getThreadNum(), 5);
- assertEquals(config.getEnableBatch(), true);
+ Assert.assertEquals(config.getAuthType(), "token");
+ Assert.assertEquals(config.getThreadNum(), 5);
+ Assert.assertEquals(config.getEnableBatch(), true);
Map<String, String> newConfig = new HashMap<>();
newConfig.put("thread_num", "10");
newConfig.put("disk_io_rate_per_sec", "60000");
ConfigManager.getInstance().getThirdPartyClusterConfig().putAll(newConfig);
config = ConfigManager.getInstance().getThirdPartyClusterConfig();
- assertEquals(config.getAuthType(), "token");
- assertEquals(config.getThreadNum(), 10);
- assertEquals(config.getDiskIoRatePerSec(), 60000);
+ Assert.assertEquals(config.getAuthType(), "token");
+ Assert.assertEquals(config.getThreadNum(), 10);
+ Assert.assertEquals(config.getDiskIoRatePerSec(), 60000);
}
@Test
public void testTubeUrl() {
Map<String, String> url2token = ConfigManager.getInstance().getThirdPartyClusterUrl2Token();
- assertEquals(url2token.size(), 3);
- assertEquals("", url2token.get("127.0.0.1:8080,127.0.0.1:8088"));
+ Assert.assertEquals(url2token.size(), 3);
+ Assert.assertEquals("", url2token.get("127.0.0.1:8080,127.0.0.1:8088"));
}
@Test
public void testPulsarUrl() {
Map<String, String> url2token = ConfigManager.getInstance().getThirdPartyClusterUrl2Token();
- assertEquals("pulsartoken1", url2token.get("pulsar1://127.0.0.1:6650,pulsar2://127.0.0.1:6600"));
- assertEquals("pulsartoken2", url2token.get("pulsar2://127.0.0.1:6680"));
+ Assert.assertEquals("pulsartoken1", url2token.get("pulsar1://127.0.0.1:6650,pulsar2://127.0.0.1:6600"));
+ Assert.assertEquals("pulsartoken2", url2token.get("pulsar2://127.0.0.1:6680"));
}
}
diff --git a/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/sink/TestPulsarSink.java b/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/sink/TestPulsarSink.java
index f8117e432..9127ce3eb 100644
--- a/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/sink/TestPulsarSink.java
+++ b/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/sink/TestPulsarSink.java
@@ -23,37 +23,16 @@ import org.apache.flume.Event;
import org.apache.flume.Transaction;
import org.apache.flume.channel.MemoryChannel;
import org.apache.flume.event.EventBuilder;
-import org.apache.inlong.common.metric.MetricRegister;
-import org.apache.inlong.dataproxy.config.ConfigManager;
-import org.apache.inlong.dataproxy.config.ConfigManager.ReloadConfigWorker;
-import org.apache.inlong.dataproxy.utils.MockUtils;
+import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PowerMockIgnore;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.modules.testng.PowerMockTestCase;
-import static org.apache.inlong.common.reporpter.StreamConfigLogMetric.CONFIG_LOG_REPORT_ENABLE;
-import static org.mockito.ArgumentMatchers.any;
-
-@RunWith(PowerMockRunner.class)
-@PowerMockIgnore("javax.management.*")
-@PrepareForTest({MetricRegister.class, ReloadConfigWorker.class})
-public class TestPulsarSink extends PowerMockTestCase {
+public class TestPulsarSink {
private MemoryChannel channel;
+ @Before
public void setUp() throws Exception {
- // mock
- MockUtils.mockMetricRegister();
- PowerMockito.mockStatic(ReloadConfigWorker.class);
- ReloadConfigWorker worker = PowerMockito.mock(ReloadConfigWorker.class);
- PowerMockito.doNothing().when(worker, "start");
- PowerMockito.when(ReloadConfigWorker.class, "create", any()).thenReturn(worker);
- ConfigManager.getInstance().getCommonProperties().put(CONFIG_LOG_REPORT_ENABLE, "false");
- // prepare
+
PulsarSink sink = new PulsarSink();
channel = new MemoryChannel();
Context context = new Context();
@@ -65,7 +44,7 @@ public class TestPulsarSink extends PowerMockTestCase {
@Test
public void testProcess() throws Exception {
- setUp();
+
Event event = EventBuilder.withBody("test event 1", Charsets.UTF_8);
Transaction transaction = channel.getTransaction();
diff --git a/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/source/UdpSourceTest.java b/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/source/UdpSourceTest.java
index 19d0ede4f..9d56875e0 100644
--- a/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/source/UdpSourceTest.java
+++ b/inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/source/UdpSourceTest.java
@@ -21,8 +21,8 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.flume.Context;
import org.apache.inlong.dataproxy.consts.ConfigConstants;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.Assert;
+import org.junit.Test;
public class UdpSourceTest {
diff --git a/inlong-dataproxy/pom.xml b/inlong-dataproxy/pom.xml
index 6afb10e8b..e299431a7 100644
--- a/inlong-dataproxy/pom.xml
+++ b/inlong-dataproxy/pom.xml
@@ -136,11 +136,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
diff --git a/pom.xml b/pom.xml
index 699ce0c59..9280ea395 100644
--- a/pom.xml
+++ b/pom.xml
@@ -215,7 +215,6 @@
<junit.version>4.13.2</junit.version>
<awaitility.version>4.0.3</awaitility.version>
<mockito.version>3.12.4</mockito.version>
- <testng.version>6.14.3</testng.version>
<powermock.version>2.0.9</powermock.version>
<assertj.version>3.4.1</assertj.version>
@@ -1213,11 +1212,6 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <version>${testng.version}</version>
- </dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>