Replace Junit with testng (#3675)

Closes #3663 
diff --git a/pulsar-io/debezium/src/test/java/org/apache/pulsar/io/debezium/PulsarDatabaseHistoryTest.java b/pulsar-io/debezium/src/test/java/org/apache/pulsar/io/debezium/PulsarDatabaseHistoryTest.java
index e3b4fd9..db75437 100644
--- a/pulsar-io/debezium/src/test/java/org/apache/pulsar/io/debezium/PulsarDatabaseHistoryTest.java
+++ b/pulsar-io/debezium/src/test/java/org/apache/pulsar/io/debezium/PulsarDatabaseHistoryTest.java
@@ -18,7 +18,7 @@
  */
 package org.apache.pulsar.io.debezium;
 
-import static org.junit.Assert.assertEquals;
+import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 
diff --git a/pulsar-io/netty/pom.xml b/pulsar-io/netty/pom.xml
index 1ca1cd4..6aa8d64 100644
--- a/pulsar-io/netty/pom.xml
+++ b/pulsar-io/netty/pom.xml
@@ -66,9 +66,9 @@
         </dependency>
 
         <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.12</version>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>6.13.1</version>
             <scope>test</scope>
         </dependency>
 
diff --git a/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/NettySourceConfigTest.java b/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/NettySourceConfigTest.java
index 034fa79..5b5b188 100644
--- a/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/NettySourceConfigTest.java
+++ b/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/NettySourceConfigTest.java
@@ -19,15 +19,15 @@
 package org.apache.pulsar.io.netty;
 
 import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
 
 /**
  * Tests for Netty Tcp or Udp Source Config
@@ -53,7 +53,7 @@
         assertEquals(1, nettySourceConfig.getNumberOfThreads());
     }
 
-    @Test(expected = UnrecognizedPropertyException.class)
+    @Test(expectedExceptions = UnrecognizedPropertyException.class)
     public void testNettyTcpConfigLoadWithMapWhenInvalidPropertyIsSet() throws IOException {
         Map<String, Object> map = new HashMap<>();
         map.put("invalidProperty", 1);
@@ -72,7 +72,7 @@
         assertEquals(5, nettySourceConfig.getNumberOfThreads());
     }
 
-    @Test(expected = UnrecognizedPropertyException.class)
+    @Test(expectedExceptions = UnrecognizedPropertyException.class)
     public void testNettyTcpConfigLoadWithYamlFileWhenInvalidPropertyIsSet() throws IOException {
         File yamlFile = getFile("nettySourceConfigWithInvalidProperty.yaml");
         NettySourceConfig.load(yamlFile.getAbsolutePath());
diff --git a/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/http/NettyHttpChannelInitializerTest.java b/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/http/NettyHttpChannelInitializerTest.java
index eae087b..760c333 100644
--- a/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/http/NettyHttpChannelInitializerTest.java
+++ b/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/http/NettyHttpChannelInitializerTest.java
@@ -20,10 +20,10 @@
 
 import io.netty.channel.socket.nio.NioSocketChannel;
 import org.apache.pulsar.io.netty.NettySource;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
 
 /**
  * Tests for Netty Channel Initializer
diff --git a/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/server/NettyChannelInitializerTest.java b/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/server/NettyChannelInitializerTest.java
index b8d6dd4..7fb3b45 100644
--- a/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/server/NettyChannelInitializerTest.java
+++ b/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/server/NettyChannelInitializerTest.java
@@ -20,10 +20,10 @@
 
 import io.netty.channel.socket.nio.NioSocketChannel;
 import org.apache.pulsar.io.netty.NettySource;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
 
 /**
  * Tests for Netty Channel Initializer
diff --git a/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/server/NettyServerTest.java b/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/server/NettyServerTest.java
index 8041570..40b3f93 100644
--- a/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/server/NettyServerTest.java
+++ b/pulsar-io/netty/src/test/java/org/apache/pulsar/io/netty/server/NettyServerTest.java
@@ -20,14 +20,13 @@
 
 import org.apache.pulsar.io.netty.NettySource;
 import org.apache.pulsar.io.netty.NettySourceConfig;
-import org.junit.Test;
+import org.testng.annotations.Test;
 
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.testng.Assert.assertNotNull;
 
 /**
  * Tests for Netty Tcp or Udp Server
@@ -86,7 +85,7 @@
         assertNotNull(nettyTcpServer);
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expectedExceptions = IllegalArgumentException.class)
     public void testNettyTcpServerConstructorWhenHostIsNotSet() {
         new NettyServer.Builder()
                 .setType(NettyServer.Type.valueOf(TCP))
@@ -96,7 +95,7 @@
                 .build();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expectedExceptions = IllegalArgumentException.class)
     public void testNettyTcpServerConstructorWhenPortIsNotSet() {
         new NettyServer.Builder()
                 .setType(NettyServer.Type.valueOf(TCP))
@@ -106,7 +105,7 @@
                 .build();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expectedExceptions = IllegalArgumentException.class)
     public void testNettyTcpServerConstructorWhenNumberOfThreadsIsNotSet() {
         new NettyServer.Builder()
                 .setType(NettyServer.Type.valueOf(TCP))
@@ -116,7 +115,7 @@
                 .build();
     }
 
-    @Test(expected = NullPointerException.class)
+    @Test(expectedExceptions = NullPointerException.class)
     public void testNettyTcpServerConstructorWhenNettyTcpSourceIsNotSet() {
         new NettyServer.Builder()
                 .setType(NettyServer.Type.valueOf(TCP))
@@ -126,7 +125,7 @@
                 .build();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expectedExceptions = IllegalArgumentException.class)
     public void testNettyTcpServerWhenHostIsSetAsBlank() {
         new NettyServer.Builder()
                 .setType(NettyServer.Type.valueOf(TCP))
@@ -137,7 +136,7 @@
                 .build();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expectedExceptions = IllegalArgumentException.class)
     public void testNettyTcpServerWhenPortIsSetAsZero() {
         new NettyServer.Builder()
                 .setType(NettyServer.Type.valueOf(TCP))
@@ -148,7 +147,7 @@
                 .build();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expectedExceptions = IllegalArgumentException.class)
     public void testNettyTcpServerWhenPortIsSetLowerThan1024() {
         new NettyServer.Builder()
                 .setType(NettyServer.Type.valueOf(TCP))
@@ -159,7 +158,7 @@
                 .build();
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expectedExceptions = IllegalArgumentException.class)
     public void testNettyTcpServerWhenNumberOfThreadsIsSetAsZero() {
         new NettyServer.Builder()
                 .setType(NettyServer.Type.valueOf(TCP))