Browse Source

[Migrate][Test] Migrate all UT cases from jUnit 4 to 5 in datasource, registry and data-quality modules (#12352)

* Migrate all UT cases from jUnit 4 to 5 in datasource, registry and data-quality modules

* Fix etcd registry test
3.2.0-release
Eric Gao 2 years ago committed by GitHub
parent
commit
ac845046e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/SparkApplicationTestBase.java
  2. 9
      dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/configuration/ConfigurationParserTest.java
  3. 24
      dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/flow/reader/JdbcReaderTest.java
  4. 22
      dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/flow/reader/ReaderFactoryTest.java
  5. 26
      dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/flow/writer/JdbcWriterTest.java
  6. 8
      dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/flow/writer/WriterFactoryTest.java
  7. 12
      dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/utils/ConfigUtilsTest.java
  8. 12
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/client/CommonDataSourceClientTest.java
  9. 2
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessorTest.java
  10. 50
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtilsTest.java
  11. 36
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-athena/src/test/java/org/apache/dolphinscheduler/plugin/datasource/athena/param/AthenaDataSourceProcessorTest.java
  12. 6
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-clickhouse/src/test/java/org/apache/dolphinscheduler/plugin/datasource/clickhouse/ClickHouseDataSourceChannelFactoryTest.java
  13. 13
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-clickhouse/src/test/java/org/apache/dolphinscheduler/plugin/datasource/clickhouse/ClickHouseDataSourceChannelTest.java
  14. 6
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/DB2DataSourceChannelFactoryTest.java
  15. 12
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/DB2DataSourceChannelTest.java
  16. 28
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessorTest.java
  17. 6
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/test/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceChannelFactoryTest.java
  18. 12
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/test/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceChannelTest.java
  19. 27
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/test/java/org/apache/dolphinscheduler/plugin/datasource/hive/param/HiveDataSourceProcessorTest.java
  20. 6
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/MySQLDataSourceChannelFactoryTest.java
  21. 12
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/MySQLDataSourceChannelTest.java
  22. 28
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/param/MySQLDataSourceProcessorTest.java
  23. 15
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/provider/JDBCDataSourceProviderTest.java
  24. 28
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/utils/DataSourceUtilsTest.java
  25. 6
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-oracle/src/test/java/org/apache/dolphinscheduler/plugin/datasource/oracle/OracleDataSourceChannelFactoryTest.java
  26. 12
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-oracle/src/test/java/org/apache/dolphinscheduler/plugin/datasource/oracle/OracleDataSourceChannelTest.java
  27. 28
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-oracle/src/test/java/org/apache/dolphinscheduler/plugin/datasource/oracle/param/OracleDataSourceProcessorTest.java
  28. 6
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-postgresql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/postgresql/PostgreSQLDataSourceChannelFactoryTest.java
  29. 13
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-postgresql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/postgresql/PostgreSQLDataSourceChannelTest.java
  30. 29
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-postgresql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/postgresql/param/PostgreSQLDataSourceProcessorTest.java
  31. 6
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-presto/src/test/java/org/apache/dolphinscheduler/plugin/datasource/presto/PrestoDataSourceChannelFactoryTest.java
  32. 12
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-presto/src/test/java/org/apache/dolphinscheduler/plugin/datasource/presto/PrestoDataSourceChannelTest.java
  33. 26
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-presto/src/test/java/org/apache/dolphinscheduler/plugin/datasource/presto/param/PrestoDataSourceProcessorTest.java
  34. 26
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-redshift/src/test/java/org/apache/dolphinscheduler/plugin/datasource/redshift/param/RedshiftDataSourceProcessorTest.java
  35. 6
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-spark/src/test/java/org/apache/dolphinscheduler/plugin/datasource/spark/SparkDataSourceChannelFactoryTest.java
  36. 12
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-spark/src/test/java/org/apache/dolphinscheduler/plugin/datasource/spark/SparkDataSourceChannelTest.java
  37. 28
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-spark/src/test/java/org/apache/dolphinscheduler/plugin/datasource/spark/param/SparkDataSourceProcessorTest.java
  38. 6
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-sqlserver/src/test/java/org/apache/dolphinscheduler/plugin/datasource/sqlserver/SQLServerDataSourceChannelFactoryTest.java
  39. 13
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-sqlserver/src/test/java/org/apache/dolphinscheduler/plugin/datasource/sqlserver/SQLServerDataSourceChannelTest.java
  40. 31
      dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-sqlserver/src/test/java/org/apache/dolphinscheduler/plugin/datasource/sqlserver/param/SQLServerDataSourceProcessorTest.java
  41. 41
      dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-etcd/src/test/java/org/apache/dolphinscheduler/plugin/registry/etcd/EtcdRegistryTest.java
  42. 26
      dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/test/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistryTest.java

16
dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/SparkApplicationTestBase.java

@ -23,7 +23,7 @@ import org.apache.dolphinscheduler.data.quality.execution.SparkRuntimeEnvironmen
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
/**
* SparkApplicationTestBase
@ -32,14 +32,14 @@ public class SparkApplicationTestBase {
protected SparkRuntimeEnvironment sparkRuntimeEnvironment;
@Before
@BeforeEach
public void init() {
Map<String,Object> config = new HashMap<>();
config.put("spark.app.name","data quality test");
config.put("spark.sql.crossJoin.enabled","true");
config.put("spark.driver.bindAddress","127.0.0.1");
config.put("spark.ui.port",13000);
config.put("spark.master","local[4]");
Map<String, Object> config = new HashMap<>();
config.put("spark.app.name", "data quality test");
config.put("spark.sql.crossJoin.enabled", "true");
config.put("spark.driver.bindAddress", "127.0.0.1");
config.put("spark.ui.port", 13000);
config.put("spark.master", "local[4]");
sparkRuntimeEnvironment = new SparkRuntimeEnvironment(new Config(config));
}

9
dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/configuration/ConfigurationParserTest.java

@ -20,8 +20,8 @@ package org.apache.dolphinscheduler.data.quality.configuration;
import org.apache.dolphinscheduler.data.quality.config.DataQualityConfiguration;
import org.apache.dolphinscheduler.data.quality.utils.JsonUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* ConfigurationParserTest
@ -30,7 +30,7 @@ public class ConfigurationParserTest {
@Test
public void testConfigurationValidate() {
Assert.assertEquals(1,verifyConfigurationValidate());
Assertions.assertEquals(1, verifyConfigurationValidate());
}
private int verifyConfigurationValidate() {
@ -50,7 +50,8 @@ public class ConfigurationParserTest {
+ " threshold, 3 as operator, 0 as failure_strategy, '2021-06-29 10:18:59' as create_time,'2021-06-29 10:18:59' as update_time "
+ "from miss_count FULL JOIN total_count\"} }]}";
DataQualityConfiguration dataQualityConfiguration = JsonUtils.fromJson(parameterStr,DataQualityConfiguration.class);
DataQualityConfiguration dataQualityConfiguration =
JsonUtils.fromJson(parameterStr, DataQualityConfiguration.class);
dataQualityConfiguration.validate();
} catch (Exception e) {
flag = 0;

24
dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/flow/reader/JdbcReaderTest.java

@ -32,16 +32,16 @@ import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* JdbcConnectorTest
*/
public class JdbcReaderTest extends FlowTestBase {
@Before
@BeforeEach
public void before() {
super.init();
createConnectorTable();
@ -50,17 +50,17 @@ public class JdbcReaderTest extends FlowTestBase {
@Test
public void testJdbcConnectorExecute() {
JdbcReader jdbcReader = new JdbcReader(buildReaderConfig());
Assert.assertNotNull(jdbcReader.read(sparkRuntimeEnvironment));
Assertions.assertNotNull(jdbcReader.read(sparkRuntimeEnvironment));
}
private Config buildReaderConfig() {
Map<String,Object> config = new HashMap<>();
config.put(DATABASE,"test");
config.put(TABLE,"test.test1");
config.put(URL,url);
config.put(USER,"test");
config.put(PASSWORD,"123456");
config.put(DRIVER,driver);
Map<String, Object> config = new HashMap<>();
config.put(DATABASE, "test");
config.put(TABLE, "test.test1");
config.put(URL, url);
config.put(USER, "test");
config.put(PASSWORD, "123456");
config.put(DRIVER, driver);
return new Config(config);
}

22
dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/flow/reader/ReaderFactoryTest.java

@ -34,8 +34,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* ConnectorFactoryTest
@ -48,23 +48,23 @@ public class ReaderFactoryTest {
List<ReaderConfig> readerConfigs = new ArrayList<>();
ReaderConfig readerConfig = new ReaderConfig();
readerConfig.setType("JDBC");
Map<String,Object> config = new HashMap<>();
config.put(DATABASE,"test");
config.put(TABLE,"test1");
config.put(URL,"jdbc:mysql://localhost:3306/test");
config.put(USER,"test");
config.put(PASSWORD,"123456");
config.put(DRIVER,"com.mysql.cj.jdbc.Driver");
Map<String, Object> config = new HashMap<>();
config.put(DATABASE, "test");
config.put(TABLE, "test1");
config.put(URL, "jdbc:mysql://localhost:3306/test");
config.put(USER, "test");
config.put(PASSWORD, "123456");
config.put(DRIVER, "com.mysql.cj.jdbc.Driver");
readerConfig.setConfig(config);
readerConfigs.add(readerConfig);
int flag = 0;
List<BatchReader> readers = ReaderFactory.getInstance().getReaders(null,readerConfigs);
List<BatchReader> readers = ReaderFactory.getInstance().getReaders(null, readerConfigs);
if (readers != null && readers.size() >= 1) {
flag = 1;
}
Assert.assertEquals(1,flag);
Assertions.assertEquals(1, flag);
}
}

26
dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/flow/writer/JdbcWriterTest.java

@ -33,15 +33,15 @@ import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* JdbcWriterTest
*/
public class JdbcWriterTest extends FlowTestBase {
@Before
@BeforeEach
public void before() {
super.init();
createWriterTable();
@ -51,24 +51,24 @@ public class JdbcWriterTest extends FlowTestBase {
public void testJdbcWriterExecute() {
JdbcReader jdbcConnector = new JdbcReader(buildJdbcReaderConfig());
JdbcWriter jdbcWriter = new JdbcWriter(buildJdbcConfig());
jdbcWriter.write(jdbcConnector.read(sparkRuntimeEnvironment),sparkRuntimeEnvironment);
jdbcWriter.write(jdbcConnector.read(sparkRuntimeEnvironment), sparkRuntimeEnvironment);
}
private Config buildJdbcConfig() {
Map<String,Object> config = new HashMap<>();
config.put(DATABASE,"test");
config.put(TABLE,"test.test2");
config.put(URL,url);
config.put(USER,"test");
config.put(PASSWORD,"123456");
config.put(DRIVER,driver);
config.put("save_mode","append");
Map<String, Object> config = new HashMap<>();
config.put(DATABASE, "test");
config.put(TABLE, "test.test2");
config.put(URL, url);
config.put(USER, "test");
config.put(PASSWORD, "123456");
config.put(DRIVER, driver);
config.put("save_mode", "append");
return new Config(config);
}
private Config buildJdbcReaderConfig() {
Config config = buildJdbcConfig();
config.put("sql","SELECT '1' as company,'1' as date,'2' as c1,'2' as c2,'2' as c3, 2 as c4");
config.put("sql", "SELECT '1' as company,'1' as date,'2' as c1,'2' as c2,'2' as c3, 2 as c4");
return config;
}

8
dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/flow/writer/WriterFactoryTest.java

@ -25,8 +25,8 @@ import org.apache.dolphinscheduler.data.quality.flow.batch.writer.WriterFactory;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
/**
* WriterFactoryTest
@ -44,11 +44,11 @@ public class WriterFactoryTest {
int flag = 0;
List<BatchWriter> writers = WriterFactory.getInstance().getWriters(null,writerConfigs);
List<BatchWriter> writers = WriterFactory.getInstance().getWriters(null, writerConfigs);
if (writers != null && writers.size() >= 1) {
flag = 1;
}
Assert.assertEquals(1,flag);
Assertions.assertEquals(1, flag);
}
}

12
dolphinscheduler-data-quality/src/test/java/org/apache/dolphinscheduler/data/quality/utils/ConfigUtilsTest.java

@ -22,17 +22,17 @@ import org.apache.dolphinscheduler.data.quality.config.Config;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class ConfigUtilsTest {
@Test
public void testExtractSubConfig() {
// Setup
Map<String,Object> configMap = new HashMap<>();
configMap.put("aaa.www","1");
configMap.put("bbb.www","1");
Map<String, Object> configMap = new HashMap<>();
configMap.put("aaa.www", "1");
configMap.put("bbb.www", "1");
final Config source = new Config(configMap);
@ -41,6 +41,6 @@ public class ConfigUtilsTest {
int expect = 1;
int actual = result.entrySet().size();
Assert.assertEquals(expect,actual);
Assertions.assertEquals(expect, actual);
}
}

12
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/client/CommonDataSourceClientTest.java

@ -23,14 +23,14 @@ import org.apache.dolphinscheduler.spi.enums.DbType;
import java.sql.Connection;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class CommonDataSourceClientTest {
@Mock
@ -83,6 +83,6 @@ public class CommonDataSourceClientTest {
public void testGetConnection() {
Connection connection = Mockito.mock(Connection.class);
Mockito.when(commonDataSourceClient.getConnection()).thenReturn(connection);
Assert.assertNotNull(commonDataSourceClient.getConnection());
Assertions.assertNotNull(commonDataSourceClient.getConnection());
}
}

2
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/AbstractDataSourceProcessorTest.java

@ -24,7 +24,7 @@ import static org.mockito.Mockito.mock;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class AbstractDataSourceProcessorTest {

50
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/utils/CommonUtilsTest.java

@ -25,15 +25,15 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.stubbing.Answer;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class CommonUtilsTest {
@Test
@ -44,7 +44,7 @@ public class CommonUtilsTest {
mockedCommonUtils.when(CommonUtils::getKerberosStartupState)
.thenAnswer((Answer<Boolean>) invocation -> false);
boolean kerberosStartupState = CommonUtils.getKerberosStartupState();
Assert.assertFalse(kerberosStartupState);
Assertions.assertFalse(kerberosStartupState);
mockedPropertyUtils.when(() -> PropertyUtils.getUpperCaseString(Constants.RESOURCE_STORAGE_TYPE))
.thenAnswer((Answer<String>) invocation -> "HDFS");
@ -52,7 +52,7 @@ public class CommonUtilsTest {
.when(() -> PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, true))
.thenAnswer((Answer<Boolean>) invocation -> Boolean.TRUE);
kerberosStartupState = CommonUtils.getKerberosStartupState();
Assert.assertFalse(kerberosStartupState);
Assertions.assertFalse(kerberosStartupState);
}
}
@ -76,12 +76,12 @@ public class CommonUtilsTest {
.thenAnswer((Answer<String>) invocation -> "/opt/hdfs.headless.keytab");
Configuration configuration = Mockito.mock(Configuration.class);
boolean result = CommonUtils.loadKerberosConf(configuration);
Assert.assertTrue(result);
Assertions.assertTrue(result);
CommonUtils.loadKerberosConf(null, null, null);
} catch (Exception e) {
Assert.fail("load Kerberos Conf failed" + e.getMessage());
Assertions.fail("load Kerberos Conf failed" + e.getMessage());
}
}
}
@ -92,18 +92,18 @@ public class CommonUtilsTest {
Mockito.when(PropertyUtils.getBoolean(DATASOURCE_ENCRYPTION_ENABLE, false))
.thenReturn(Boolean.TRUE);
Assert.assertEquals("", PasswordUtils.encodePassword(""));
Assert.assertEquals("bnVsbE1USXpORFUy", PasswordUtils.encodePassword("123456"));
Assert.assertEquals("bnVsbElWRkJXbGhUVjBBPQ==", PasswordUtils.encodePassword("!QAZXSW@"));
Assert.assertEquals("bnVsbE5XUm1aMlZ5S0VBPQ==", PasswordUtils.encodePassword("5dfger(@"));
Assertions.assertEquals("", PasswordUtils.encodePassword(""));
Assertions.assertEquals("bnVsbE1USXpORFUy", PasswordUtils.encodePassword("123456"));
Assertions.assertEquals("bnVsbElWRkJXbGhUVjBBPQ==", PasswordUtils.encodePassword("!QAZXSW@"));
Assertions.assertEquals("bnVsbE5XUm1aMlZ5S0VBPQ==", PasswordUtils.encodePassword("5dfger(@"));
mockedPropertyUtils.when(() -> PropertyUtils.getBoolean(DATASOURCE_ENCRYPTION_ENABLE, false))
.thenReturn(Boolean.FALSE);
Assert.assertEquals("", PasswordUtils.encodePassword(""));
Assert.assertEquals("123456", PasswordUtils.encodePassword("123456"));
Assert.assertEquals("!QAZXSW@", PasswordUtils.encodePassword("!QAZXSW@"));
Assert.assertEquals("5dfger(@", PasswordUtils.encodePassword("5dfger(@"));
Assertions.assertEquals("", PasswordUtils.encodePassword(""));
Assertions.assertEquals("123456", PasswordUtils.encodePassword("123456"));
Assertions.assertEquals("!QAZXSW@", PasswordUtils.encodePassword("!QAZXSW@"));
Assertions.assertEquals("5dfger(@", PasswordUtils.encodePassword("5dfger(@"));
}
}
@ -123,10 +123,10 @@ public class CommonUtilsTest {
mockedPasswordUtils.when(() -> PasswordUtils.decodePassword("bnVsbE5XUm1aMlZ5S0VBPQ=="))
.thenReturn("5dfger(@");
Assert.assertEquals(null, PasswordUtils.decodePassword(""));
Assert.assertEquals("123456", PasswordUtils.decodePassword("bnVsbE1USXpORFUy"));
Assert.assertEquals("!QAZXSW@", PasswordUtils.decodePassword("bnVsbElWRkJXbGhUVjBBPQ=="));
Assert.assertEquals("5dfger(@", PasswordUtils.decodePassword("bnVsbE5XUm1aMlZ5S0VBPQ=="));
Assertions.assertEquals(null, PasswordUtils.decodePassword(""));
Assertions.assertEquals("123456", PasswordUtils.decodePassword("bnVsbE1USXpORFUy"));
Assertions.assertEquals("!QAZXSW@", PasswordUtils.decodePassword("bnVsbElWRkJXbGhUVjBBPQ=="));
Assertions.assertEquals("5dfger(@", PasswordUtils.decodePassword("bnVsbE5XUm1aMlZ5S0VBPQ=="));
Mockito.when(PropertyUtils.getBoolean(DATASOURCE_ENCRYPTION_ENABLE, false))
.thenAnswer((Answer<Boolean>) invocation -> Boolean.FALSE);
@ -135,10 +135,10 @@ public class CommonUtilsTest {
mockedPasswordUtils.when(() -> PasswordUtils.decodePassword("!QAZXSW@")).thenReturn("!QAZXSW@");
mockedPasswordUtils.when(() -> PasswordUtils.decodePassword("5dfger(@")).thenReturn("5dfger(@");
Assert.assertEquals(null, PasswordUtils.decodePassword(""));
Assert.assertEquals("123456", PasswordUtils.decodePassword("123456"));
Assert.assertEquals("!QAZXSW@", PasswordUtils.decodePassword("!QAZXSW@"));
Assert.assertEquals("5dfger(@", PasswordUtils.decodePassword("5dfger(@"));
Assertions.assertEquals(null, PasswordUtils.decodePassword(""));
Assertions.assertEquals("123456", PasswordUtils.decodePassword("123456"));
Assertions.assertEquals("!QAZXSW@", PasswordUtils.decodePassword("!QAZXSW@"));
Assertions.assertEquals("5dfger(@", PasswordUtils.decodePassword("5dfger(@"));
}
}

36
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-athena/src/test/java/org/apache/dolphinscheduler/plugin/datasource/athena/param/AthenaDataSourceProcessorTest.java

@ -24,14 +24,14 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class AthenaDataSourceProcessorTest {
private final AthenaDataSourceProcessor athenaDataSourceProcessor = new AthenaDataSourceProcessor();
@ -50,8 +50,8 @@ public class AthenaDataSourceProcessorTest {
mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test");
AthenaConnectionParam connectionParams = (AthenaConnectionParam) this.athenaDataSourceProcessor
.createConnectionParams(athenaDataSourceParamDTO);
Assert.assertEquals("jdbc:awsathena://AwsRegion=cn-north-1;", connectionParams.getAddress());
Assert.assertEquals("jdbc:awsathena://AwsRegion=cn-north-1;", connectionParams.getJdbcUrl());
Assertions.assertEquals("jdbc:awsathena://AwsRegion=cn-north-1;", connectionParams.getAddress());
Assertions.assertEquals("jdbc:awsathena://AwsRegion=cn-north-1;", connectionParams.getJdbcUrl());
}
}
@ -62,14 +62,14 @@ public class AthenaDataSourceProcessorTest {
+ ",\"database\":\"\",\"jdbcUrl\":\"jdbc:awsathena://AwsRegion=cn-north-1;\", \"awsRegion\":\"cn-north-1\"}";
AthenaConnectionParam connectionParams = (AthenaConnectionParam) this.athenaDataSourceProcessor
.createConnectionParams(connectionJson);
Assert.assertNotNull(connectionParams);
Assert.assertEquals("awsuser", connectionParams.getUser());
Assert.assertEquals("cn-north-1", connectionParams.getAwsRegion());
Assertions.assertNotNull(connectionParams);
Assertions.assertEquals("awsuser", connectionParams.getUser());
Assertions.assertEquals("cn-north-1", connectionParams.getAwsRegion());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.COM_ATHENA_JDBC_DRIVER, this.athenaDataSourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.COM_ATHENA_JDBC_DRIVER, this.athenaDataSourceProcessor.getDatasourceDriver());
}
@Test
@ -77,7 +77,7 @@ public class AthenaDataSourceProcessorTest {
AthenaConnectionParam athenaConnectionParam = new AthenaConnectionParam();
athenaConnectionParam.setJdbcUrl("jdbc:awsathena://AwsRegion=cn-north-1;");
athenaConnectionParam.setOther("LogLevel=6;LogPath=/tmp;");
Assert.assertEquals("jdbc:awsathena://AwsRegion=cn-north-1;LogLevel=6;LogPath=/tmp;",
Assertions.assertEquals("jdbc:awsathena://AwsRegion=cn-north-1;LogLevel=6;LogPath=/tmp;",
this.athenaDataSourceProcessor.getJdbcUrl(athenaConnectionParam));
}
@ -87,19 +87,19 @@ public class AthenaDataSourceProcessorTest {
AthenaConnectionParam athenaConnectionParam = new AthenaConnectionParam();
athenaConnectionParam.setJdbcUrl("jdbc:awsathena://AwsRegion=cn-north-1;");
athenaConnectionParam.setOther("");
Assert.assertEquals("jdbc:awsathena://AwsRegion=cn-north-1;",
Assertions.assertEquals("jdbc:awsathena://AwsRegion=cn-north-1;",
this.athenaDataSourceProcessor.getJdbcUrl(athenaConnectionParam));
}
@Test
public void testGetDbType() {
Assert.assertEquals(DbType.ATHENA, this.athenaDataSourceProcessor.getDbType());
Assertions.assertEquals(DbType.ATHENA, this.athenaDataSourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.ATHENA_VALIDATION_QUERY, this.athenaDataSourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.ATHENA_VALIDATION_QUERY, this.athenaDataSourceProcessor.getValidationQuery());
}
@ -110,8 +110,8 @@ public class AthenaDataSourceProcessorTest {
+ ",\"database\":\"\",\"jdbcUrl\":\"jdbc:awsathena://AwsRegion=cn-north-1;\", \"awsRegion\":\"cn-north-1\"}";
AthenaDataSourceParamDTO athenaDataSourceParamDTO = (AthenaDataSourceParamDTO) this.athenaDataSourceProcessor
.createDatasourceParamDTO(connectionJson);
Assert.assertEquals("awsuser", athenaDataSourceParamDTO.getUserName());
Assert.assertEquals("cn-north-1", athenaDataSourceParamDTO.getAwsRegion());
Assert.assertEquals("", athenaDataSourceParamDTO.getDatabase());
Assertions.assertEquals("awsuser", athenaDataSourceParamDTO.getUserName());
Assertions.assertEquals("cn-north-1", athenaDataSourceParamDTO.getAwsRegion());
Assertions.assertEquals("", athenaDataSourceParamDTO.getDatabase());
}
}

6
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-clickhouse/src/test/java/org/apache/dolphinscheduler/plugin/datasource/clickhouse/ClickHouseDataSourceChannelFactoryTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.plugin.datasource.clickhouse;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class ClickHouseDataSourceChannelFactoryTest {
@ -28,6 +28,6 @@ public class ClickHouseDataSourceChannelFactoryTest {
public void testCreate() {
ClickHouseDataSourceChannelFactory sourceChannelFactory = new ClickHouseDataSourceChannelFactory();
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
Assert.assertNotNull(dataSourceChannel);
Assertions.assertNotNull(dataSourceChannel);
}
}

13
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-clickhouse/src/test/java/org/apache/dolphinscheduler/plugin/datasource/clickhouse/ClickHouseDataSourceChannelTest.java

@ -20,13 +20,13 @@ package org.apache.dolphinscheduler.plugin.datasource.clickhouse;
import org.apache.dolphinscheduler.plugin.datasource.clickhouse.param.ClickHouseConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ClickHouseDataSourceChannelTest {
@Test
@ -34,6 +34,7 @@ public class ClickHouseDataSourceChannelTest {
ClickHouseDataSourceChannel sourceChannel = Mockito.mock(ClickHouseDataSourceChannel.class);
ClickHouseDataSourceClient dataSourceClient = Mockito.mock(ClickHouseDataSourceClient.class);
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
Assert.assertNotNull(sourceChannel.createDataSourceClient(new ClickHouseConnectionParam(), DbType.CLICKHOUSE));
Assertions.assertNotNull(
sourceChannel.createDataSourceClient(new ClickHouseConnectionParam(), DbType.CLICKHOUSE));
}
}

6
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/DB2DataSourceChannelFactoryTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.plugin.datasource.db2;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class DB2DataSourceChannelFactoryTest {
@ -28,6 +28,6 @@ public class DB2DataSourceChannelFactoryTest {
public void testCreate() {
DB2DataSourceChannelFactory sourceChannelFactory = new DB2DataSourceChannelFactory();
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
Assert.assertNotNull(dataSourceChannel);
Assertions.assertNotNull(dataSourceChannel);
}
}

12
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/DB2DataSourceChannelTest.java

@ -20,13 +20,13 @@ package org.apache.dolphinscheduler.plugin.datasource.db2;
import org.apache.dolphinscheduler.plugin.datasource.db2.param.Db2ConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class DB2DataSourceChannelTest {
@Test
@ -34,6 +34,6 @@ public class DB2DataSourceChannelTest {
DB2DataSourceChannel sourceChannel = Mockito.mock(DB2DataSourceChannel.class);
DB2DataSourceClient dataSourceClient = Mockito.mock(DB2DataSourceClient.class);
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
Assert.assertNotNull(sourceChannel.createDataSourceClient(new Db2ConnectionParam(), DbType.DB2));
Assertions.assertNotNull(sourceChannel.createDataSourceClient(new Db2ConnectionParam(), DbType.DB2));
}
}

28
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-db2/src/test/java/org/apache/dolphinscheduler/plugin/datasource/db2/param/Db2DataSourceProcessorTest.java

@ -24,14 +24,14 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class Db2DataSourceProcessorTest {
private Db2DataSourceProcessor db2DatasourceProcessor = new Db2DataSourceProcessor();
@ -52,9 +52,9 @@ public class Db2DataSourceProcessorTest {
Db2ConnectionParam connectionParams = (Db2ConnectionParam) db2DatasourceProcessor
.createConnectionParams(db2DatasourceParamDTO);
Assert.assertNotNull(connectionParams);
Assert.assertEquals("jdbc:db2://localhost:5142", connectionParams.getAddress());
Assert.assertEquals("jdbc:db2://localhost:5142/default", connectionParams.getJdbcUrl());
Assertions.assertNotNull(connectionParams);
Assertions.assertEquals("jdbc:db2://localhost:5142", connectionParams.getAddress());
Assertions.assertEquals("jdbc:db2://localhost:5142/default", connectionParams.getJdbcUrl());
}
}
@ -64,14 +64,14 @@ public class Db2DataSourceProcessorTest {
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:db2://localhost:5142/default\"}";
Db2ConnectionParam connectionParams = (Db2ConnectionParam) db2DatasourceProcessor
.createConnectionParams(connectionJson);
Assert.assertNotNull(connectionJson);
Assert.assertEquals("root", connectionParams.getUser());
Assertions.assertNotNull(connectionJson);
Assertions.assertEquals("root", connectionParams.getUser());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.COM_DB2_JDBC_DRIVER, db2DatasourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.COM_DB2_JDBC_DRIVER, db2DatasourceProcessor.getDatasourceDriver());
}
@Test
@ -80,16 +80,16 @@ public class Db2DataSourceProcessorTest {
db2ConnectionParam.setJdbcUrl("jdbc:db2://localhost:5142/default");
db2ConnectionParam.setOther("other=other");
String jdbcUrl = db2DatasourceProcessor.getJdbcUrl(db2ConnectionParam);
Assert.assertEquals("jdbc:db2://localhost:5142/default;other=other", jdbcUrl);
Assertions.assertEquals("jdbc:db2://localhost:5142/default;other=other", jdbcUrl);
}
@Test
public void testGetDbType() {
Assert.assertEquals(DbType.DB2, db2DatasourceProcessor.getDbType());
Assertions.assertEquals(DbType.DB2, db2DatasourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.DB2_VALIDATION_QUERY, db2DatasourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.DB2_VALIDATION_QUERY, db2DatasourceProcessor.getValidationQuery());
}
}

6
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/test/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceChannelFactoryTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.plugin.datasource.hive;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class HiveDataSourceChannelFactoryTest {
@ -28,6 +28,6 @@ public class HiveDataSourceChannelFactoryTest {
public void testCreate() {
HiveDataSourceChannelFactory sourceChannelFactory = new HiveDataSourceChannelFactory();
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
Assert.assertNotNull(dataSourceChannel);
Assertions.assertNotNull(dataSourceChannel);
}
}

12
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/test/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceChannelTest.java

@ -20,13 +20,13 @@ package org.apache.dolphinscheduler.plugin.datasource.hive;
import org.apache.dolphinscheduler.plugin.datasource.hive.param.HiveConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class HiveDataSourceChannelTest {
@Test
@ -34,6 +34,6 @@ public class HiveDataSourceChannelTest {
HiveDataSourceChannel sourceChannel = Mockito.mock(HiveDataSourceChannel.class);
HiveDataSourceClient dataSourceClient = Mockito.mock(HiveDataSourceClient.class);
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
Assert.assertNotNull(sourceChannel.createDataSourceClient(new HiveConnectionParam(), DbType.HIVE));
Assertions.assertNotNull(sourceChannel.createDataSourceClient(new HiveConnectionParam(), DbType.HIVE));
}
}

27
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/test/java/org/apache/dolphinscheduler/plugin/datasource/hive/param/HiveDataSourceProcessorTest.java

@ -25,14 +25,14 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class HiveDataSourceProcessorTest {
private HiveDataSourceProcessor hiveDatasourceProcessor = new HiveDataSourceProcessor();
@ -55,8 +55,8 @@ public class HiveDataSourceProcessorTest {
mockedStaticCommonUtils.when(CommonUtils::getKerberosStartupState).thenReturn(false);
HiveConnectionParam connectionParams = (HiveConnectionParam) hiveDatasourceProcessor
.createConnectionParams(hiveDataSourceParamDTO);
Assert.assertNotNull(connectionParams);
Assert.assertEquals("jdbc:hive2://localhost1:5142,localhost2:5142", connectionParams.getAddress());
Assertions.assertNotNull(connectionParams);
Assertions.assertEquals("jdbc:hive2://localhost1:5142,localhost2:5142", connectionParams.getAddress());
}
}
@ -66,30 +66,31 @@ public class HiveDataSourceProcessorTest {
+ ",\"jdbcUrl\":\"jdbc:hive2://localhost1:5142,localhost2:5142/default\"}";
HiveConnectionParam connectionParams = (HiveConnectionParam) hiveDatasourceProcessor
.createConnectionParams(connectionParam);
Assert.assertNotNull(connectionParam);
Assert.assertEquals("default", connectionParams.getUser());
Assertions.assertNotNull(connectionParam);
Assertions.assertEquals("default", connectionParams.getUser());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.ORG_APACHE_HIVE_JDBC_HIVE_DRIVER, hiveDatasourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.ORG_APACHE_HIVE_JDBC_HIVE_DRIVER,
hiveDatasourceProcessor.getDatasourceDriver());
}
@Test
public void testGetJdbcUrl() {
HiveConnectionParam connectionParam = new HiveConnectionParam();
connectionParam.setJdbcUrl("jdbc:hive2://localhost1:5142,localhost2:5142/default");
Assert.assertEquals("jdbc:hive2://localhost1:5142,localhost2:5142/default",
Assertions.assertEquals("jdbc:hive2://localhost1:5142,localhost2:5142/default",
hiveDatasourceProcessor.getJdbcUrl(connectionParam));
}
@Test
public void testGetDbType() {
Assert.assertEquals(DbType.HIVE, hiveDatasourceProcessor.getDbType());
Assertions.assertEquals(DbType.HIVE, hiveDatasourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.HIVE_VALIDATION_QUERY, hiveDatasourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.HIVE_VALIDATION_QUERY, hiveDatasourceProcessor.getValidationQuery());
}
}

6
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/MySQLDataSourceChannelFactoryTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.plugin.datasource.mysql;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class MySQLDataSourceChannelFactoryTest {
@ -28,6 +28,6 @@ public class MySQLDataSourceChannelFactoryTest {
public void testCreate() {
MySQLDataSourceChannelFactory sourceChannelFactory = new MySQLDataSourceChannelFactory();
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
Assert.assertNotNull(dataSourceChannel);
Assertions.assertNotNull(dataSourceChannel);
}
}

12
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/MySQLDataSourceChannelTest.java

@ -20,13 +20,13 @@ package org.apache.dolphinscheduler.plugin.datasource.mysql;
import org.apache.dolphinscheduler.plugin.datasource.mysql.param.MySQLConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MySQLDataSourceChannelTest {
@Test
@ -34,6 +34,6 @@ public class MySQLDataSourceChannelTest {
MySQLDataSourceChannel sourceChannel = Mockito.mock(MySQLDataSourceChannel.class);
MySQLDataSourceClient dataSourceClient = Mockito.mock(MySQLDataSourceClient.class);
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
Assert.assertNotNull(sourceChannel.createDataSourceClient(new MySQLConnectionParam(), DbType.MYSQL));
Assertions.assertNotNull(sourceChannel.createDataSourceClient(new MySQLConnectionParam(), DbType.MYSQL));
}
}

28
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/param/MySQLDataSourceProcessorTest.java

@ -24,14 +24,14 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MySQLDataSourceProcessorTest {
private MySQLDataSourceProcessor mysqlDatasourceProcessor = new MySQLDataSourceProcessor();
@ -51,8 +51,8 @@ public class MySQLDataSourceProcessorTest {
Mockito.when(PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test");
MySQLConnectionParam connectionParams = (MySQLConnectionParam) mysqlDatasourceProcessor
.createConnectionParams(mysqlDatasourceParamDTO);
Assert.assertEquals("jdbc:mysql://localhost:3306", connectionParams.getAddress());
Assert.assertEquals("jdbc:mysql://localhost:3306/default", connectionParams.getJdbcUrl());
Assertions.assertEquals("jdbc:mysql://localhost:3306", connectionParams.getAddress());
Assertions.assertEquals("jdbc:mysql://localhost:3306/default", connectionParams.getJdbcUrl());
}
}
@ -62,32 +62,32 @@ public class MySQLDataSourceProcessorTest {
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:mysql://localhost:3306/default\"}";
MySQLConnectionParam connectionParams = (MySQLConnectionParam) mysqlDatasourceProcessor
.createConnectionParams(connectionJson);
Assert.assertNotNull(connectionJson);
Assert.assertEquals("root", connectionParams.getUser());
Assertions.assertNotNull(connectionJson);
Assertions.assertEquals("root", connectionParams.getUser());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.COM_MYSQL_CJ_JDBC_DRIVER, mysqlDatasourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.COM_MYSQL_CJ_JDBC_DRIVER, mysqlDatasourceProcessor.getDatasourceDriver());
}
@Test
public void testGetJdbcUrl() {
MySQLConnectionParam mysqlConnectionParam = new MySQLConnectionParam();
mysqlConnectionParam.setJdbcUrl("jdbc:mysql://localhost:3306/default");
Assert.assertEquals(
Assertions.assertEquals(
"jdbc:mysql://localhost:3306/default?allowLoadLocalInfile=false&autoDeserialize=false&allowLocalInfile=false&allowUrlInLocalInfile=false",
mysqlDatasourceProcessor.getJdbcUrl(mysqlConnectionParam));
}
@Test
public void testGetDbType() {
Assert.assertEquals(DbType.MYSQL, mysqlDatasourceProcessor.getDbType());
Assertions.assertEquals(DbType.MYSQL, mysqlDatasourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.MYSQL_VALIDATION_QUERY, mysqlDatasourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.MYSQL_VALIDATION_QUERY, mysqlDatasourceProcessor.getValidationQuery());
}
@Test
@ -98,7 +98,7 @@ public class MySQLDataSourceProcessorTest {
mysqlConnectionParam.setPassword("123456");
try (MockedStatic<PasswordUtils> mockedPasswordUtils = Mockito.mockStatic(PasswordUtils.class)) {
Mockito.when(PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("123456");
Assert.assertEquals("mysql@root@123456@jdbc:mysql://localhost:3306/default",
Assertions.assertEquals("mysql@root@123456@jdbc:mysql://localhost:3306/default",
mysqlDatasourceProcessor.getDatasourceUniqueId(mysqlConnectionParam, DbType.MYSQL));
}
}

15
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/provider/JDBCDataSourceProviderTest.java

@ -21,16 +21,16 @@ import org.apache.dolphinscheduler.plugin.datasource.api.provider.JDBCDataSource
import org.apache.dolphinscheduler.plugin.datasource.mysql.param.MySQLConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import com.zaxxer.hikari.HikariDataSource;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class JDBCDataSourceProviderTest {
@Test
@ -42,7 +42,8 @@ public class JDBCDataSourceProviderTest {
mockedJDBCDataSourceProvider
.when(() -> JDBCDataSourceProvider.createJdbcDataSource(Mockito.any(), Mockito.any()))
.thenReturn(dataSource);
Assert.assertNotNull(JDBCDataSourceProvider.createJdbcDataSource(new MySQLConnectionParam(), DbType.MYSQL));
Assertions.assertNotNull(
JDBCDataSourceProvider.createJdbcDataSource(new MySQLConnectionParam(), DbType.MYSQL));
}
}
@ -55,7 +56,7 @@ public class JDBCDataSourceProviderTest {
mockedJDBCDataSourceProvider
.when(() -> JDBCDataSourceProvider.createOneSessionJdbcDataSource(Mockito.any(), Mockito.any()))
.thenReturn(dataSource);
Assert.assertNotNull(
Assertions.assertNotNull(
JDBCDataSourceProvider.createOneSessionJdbcDataSource(new MySQLConnectionParam(), DbType.MYSQL));
}
}

28
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/mysql/utils/DataSourceUtilsTest.java

@ -33,14 +33,14 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class DataSourceUtilsTest {
@Test
@ -54,7 +54,7 @@ public class DataSourceUtilsTest {
other.put("characterEncoding", "utf8");
mysqlDatasourceParamDTO.setOther(other);
DataSourceUtils.checkDatasourceParam(mysqlDatasourceParamDTO);
Assert.assertTrue(true);
Assertions.assertTrue(true);
}
@Test
@ -73,7 +73,7 @@ public class DataSourceUtilsTest {
.thenReturn("123456");
mockedStaticCommonUtils.when(CommonUtils::getKerberosStartupState).thenReturn(false);
ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(mysqlDatasourceParamDTO);
Assert.assertNotNull(connectionParam);
Assertions.assertNotNull(connectionParam);
}
}
@ -87,7 +87,7 @@ public class DataSourceUtilsTest {
mysqlDatasourceParamDTO.setPassword("123456");
ConnectionParam connectionParam =
DataSourceUtils.buildConnectionParams(DbType.MYSQL, JSONUtils.toJsonString(mysqlDatasourceParamDTO));
Assert.assertNotNull(connectionParam);
Assertions.assertNotNull(connectionParam);
}
@Test
@ -108,7 +108,7 @@ public class DataSourceUtilsTest {
connectionParam.setPassword("123456");
connection = DataSourceClientProvider.getInstance().getConnection(DbType.MYSQL, connectionParam);
Assert.assertNotNull(connection);
Assertions.assertNotNull(connection);
}
}
@ -117,7 +117,7 @@ public class DataSourceUtilsTest {
MySQLConnectionParam mysqlConnectionParam = new MySQLConnectionParam();
mysqlConnectionParam.setJdbcUrl("jdbc:mysql://localhost:3308");
String jdbcUrl = DataSourceUtils.getJdbcUrl(DbType.MYSQL, mysqlConnectionParam);
Assert.assertEquals(
Assertions.assertEquals(
"jdbc:mysql://localhost:3308?allowLoadLocalInfile=false&autoDeserialize=false&allowLocalInfile=false&allowUrlInLocalInfile=false",
jdbcUrl);
}
@ -131,18 +131,20 @@ public class DataSourceUtilsTest {
connectionParam.setUser("root");
connectionParam.setPassword("123456");
Assert.assertNotNull(
Assertions.assertNotNull(
DataSourceUtils.buildDatasourceParamDTO(DbType.MYSQL, JSONUtils.toJsonString(connectionParam)));
}
@Test
public void testGetDatasourceProcessor() {
Assert.assertNotNull(DataSourceUtils.getDatasourceProcessor(DbType.MYSQL));
Assertions.assertNotNull(DataSourceUtils.getDatasourceProcessor(DbType.MYSQL));
}
@Test(expected = Exception.class)
@Test
public void testGetDatasourceProcessorError() {
Assertions.assertThrows(Exception.class, () -> {
DataSourceUtils.getDatasourceProcessor(null);
});
}
}

6
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-oracle/src/test/java/org/apache/dolphinscheduler/plugin/datasource/oracle/OracleDataSourceChannelFactoryTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.plugin.datasource.oracle;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class OracleDataSourceChannelFactoryTest {
@ -28,6 +28,6 @@ public class OracleDataSourceChannelFactoryTest {
public void testCreate() {
OracleDataSourceChannelFactory sourceChannelFactory = new OracleDataSourceChannelFactory();
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
Assert.assertNotNull(dataSourceChannel);
Assertions.assertNotNull(dataSourceChannel);
}
}

12
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-oracle/src/test/java/org/apache/dolphinscheduler/plugin/datasource/oracle/OracleDataSourceChannelTest.java

@ -20,13 +20,13 @@ package org.apache.dolphinscheduler.plugin.datasource.oracle;
import org.apache.dolphinscheduler.plugin.datasource.oracle.param.OracleConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class OracleDataSourceChannelTest {
@Test
@ -34,6 +34,6 @@ public class OracleDataSourceChannelTest {
OracleDataSourceChannel sourceChannel = Mockito.mock(OracleDataSourceChannel.class);
OracleDataSourceClient dataSourceClient = Mockito.mock(OracleDataSourceClient.class);
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
Assert.assertNotNull(sourceChannel.createDataSourceClient(new OracleConnectionParam(), DbType.ORACLE));
Assertions.assertNotNull(sourceChannel.createDataSourceClient(new OracleConnectionParam(), DbType.ORACLE));
}
}

28
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-oracle/src/test/java/org/apache/dolphinscheduler/plugin/datasource/oracle/param/OracleDataSourceProcessorTest.java

@ -25,14 +25,14 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class OracleDataSourceProcessorTest {
private OracleDataSourceProcessor oracleDatasourceProcessor = new OracleDataSourceProcessor();
@ -54,9 +54,9 @@ public class OracleDataSourceProcessorTest {
mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test");
OracleConnectionParam connectionParams = (OracleConnectionParam) oracleDatasourceProcessor
.createConnectionParams(oracleDatasourceParamDTO);
Assert.assertNotNull(connectionParams);
Assert.assertEquals("jdbc:oracle:thin:@localhost:3308", connectionParams.getAddress());
Assert.assertEquals("jdbc:oracle:thin:@localhost:3308:default", connectionParams.getJdbcUrl());
Assertions.assertNotNull(connectionParams);
Assertions.assertEquals("jdbc:oracle:thin:@localhost:3308", connectionParams.getAddress());
Assertions.assertEquals("jdbc:oracle:thin:@localhost:3308:default", connectionParams.getJdbcUrl());
}
}
@ -67,13 +67,13 @@ public class OracleDataSourceProcessorTest {
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:oracle:thin:@localhost:3308:default\",\"connectType\":\"ORACLE_SID\"}";
OracleConnectionParam connectionParams = (OracleConnectionParam) oracleDatasourceProcessor
.createConnectionParams(connectionJson);
Assert.assertNotNull(connectionParams);
Assert.assertEquals("root", connectionParams.getUser());
Assertions.assertNotNull(connectionParams);
Assertions.assertEquals("root", connectionParams.getUser());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.COM_ORACLE_JDBC_DRIVER, oracleDatasourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.COM_ORACLE_JDBC_DRIVER, oracleDatasourceProcessor.getDatasourceDriver());
}
@Test
@ -81,17 +81,17 @@ public class OracleDataSourceProcessorTest {
OracleConnectionParam oracleConnectionParam = new OracleConnectionParam();
oracleConnectionParam.setJdbcUrl("jdbc:oracle:thin:@localhost:3308:default");
oracleConnectionParam.setOther("other=other");
Assert.assertEquals("jdbc:oracle:thin:@localhost:3308:default?other=other",
Assertions.assertEquals("jdbc:oracle:thin:@localhost:3308:default?other=other",
oracleDatasourceProcessor.getJdbcUrl(oracleConnectionParam));
}
@Test
public void getDbType() {
Assert.assertEquals(DbType.ORACLE, oracleDatasourceProcessor.getDbType());
Assertions.assertEquals(DbType.ORACLE, oracleDatasourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.ORACLE_VALIDATION_QUERY, oracleDatasourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.ORACLE_VALIDATION_QUERY, oracleDatasourceProcessor.getValidationQuery());
}
}

6
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-postgresql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/postgresql/PostgreSQLDataSourceChannelFactoryTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.plugin.datasource.postgresql;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class PostgreSQLDataSourceChannelFactoryTest {
@ -28,6 +28,6 @@ public class PostgreSQLDataSourceChannelFactoryTest {
public void testCreate() {
PostgreSQLDataSourceChannelFactory sourceChannelFactory = new PostgreSQLDataSourceChannelFactory();
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
Assert.assertNotNull(dataSourceChannel);
Assertions.assertNotNull(dataSourceChannel);
}
}

13
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-postgresql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/postgresql/PostgreSQLDataSourceChannelTest.java

@ -20,13 +20,13 @@ package org.apache.dolphinscheduler.plugin.datasource.postgresql;
import org.apache.dolphinscheduler.plugin.datasource.postgresql.param.PostgreSQLConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PostgreSQLDataSourceChannelTest {
@Test
@ -34,6 +34,7 @@ public class PostgreSQLDataSourceChannelTest {
PostgreSQLDataSourceChannel sourceChannel = Mockito.mock(PostgreSQLDataSourceChannel.class);
PostgreSQLDataSourceClient dataSourceClient = Mockito.mock(PostgreSQLDataSourceClient.class);
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
Assert.assertNotNull(sourceChannel.createDataSourceClient(new PostgreSQLConnectionParam(), DbType.POSTGRESQL));
Assertions.assertNotNull(
sourceChannel.createDataSourceClient(new PostgreSQLConnectionParam(), DbType.POSTGRESQL));
}
}

29
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-postgresql/src/test/java/org/apache/dolphinscheduler/plugin/datasource/postgresql/param/PostgreSQLDataSourceProcessorTest.java

@ -24,14 +24,14 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PostgreSQLDataSourceProcessorTest {
private PostgreSQLDataSourceProcessor postgreSqlDatasourceProcessor = new PostgreSQLDataSourceProcessor();
@ -51,9 +51,9 @@ public class PostgreSQLDataSourceProcessorTest {
mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test");
PostgreSQLConnectionParam connectionParams = (PostgreSQLConnectionParam) postgreSqlDatasourceProcessor
.createConnectionParams(postgreSqlDatasourceParamDTO);
Assert.assertEquals("jdbc:postgresql://localhost:3308", connectionParams.getAddress());
Assert.assertEquals("jdbc:postgresql://localhost:3308/default", connectionParams.getJdbcUrl());
Assert.assertEquals("root", connectionParams.getUser());
Assertions.assertEquals("jdbc:postgresql://localhost:3308", connectionParams.getAddress());
Assertions.assertEquals("jdbc:postgresql://localhost:3308/default", connectionParams.getJdbcUrl());
Assertions.assertEquals("root", connectionParams.getUser());
}
}
@ -64,13 +64,13 @@ public class PostgreSQLDataSourceProcessorTest {
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:postgresql://localhost:3308/default\"}";
PostgreSQLConnectionParam connectionParams = (PostgreSQLConnectionParam) postgreSqlDatasourceProcessor
.createConnectionParams(connectionJson);
Assert.assertNotNull(connectionParams);
Assert.assertEquals("root", connectionParams.getUser());
Assertions.assertNotNull(connectionParams);
Assertions.assertEquals("root", connectionParams.getUser());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.ORG_POSTGRESQL_DRIVER, postgreSqlDatasourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.ORG_POSTGRESQL_DRIVER, postgreSqlDatasourceProcessor.getDatasourceDriver());
}
@Test
@ -80,17 +80,18 @@ public class PostgreSQLDataSourceProcessorTest {
postgreSqlConnectionParam.setOther("other");
String jdbcUrl = postgreSqlDatasourceProcessor.getJdbcUrl(postgreSqlConnectionParam);
Assert.assertEquals("jdbc:postgresql://localhost:3308/default?other", jdbcUrl);
Assertions.assertEquals("jdbc:postgresql://localhost:3308/default?other", jdbcUrl);
}
@Test
public void testGetDbType() {
Assert.assertEquals(DbType.POSTGRESQL, postgreSqlDatasourceProcessor.getDbType());
Assertions.assertEquals(DbType.POSTGRESQL, postgreSqlDatasourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.POSTGRESQL_VALIDATION_QUERY, postgreSqlDatasourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.POSTGRESQL_VALIDATION_QUERY,
postgreSqlDatasourceProcessor.getValidationQuery());
}
}

6
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-presto/src/test/java/org/apache/dolphinscheduler/plugin/datasource/presto/PrestoDataSourceChannelFactoryTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.plugin.datasource.presto;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class PrestoDataSourceChannelFactoryTest {
@ -28,6 +28,6 @@ public class PrestoDataSourceChannelFactoryTest {
public void testCreate() {
PrestoDataSourceChannelFactory sourceChannelFactory = new PrestoDataSourceChannelFactory();
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
Assert.assertNotNull(dataSourceChannel);
Assertions.assertNotNull(dataSourceChannel);
}
}

12
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-presto/src/test/java/org/apache/dolphinscheduler/plugin/datasource/presto/PrestoDataSourceChannelTest.java

@ -20,13 +20,13 @@ package org.apache.dolphinscheduler.plugin.datasource.presto;
import org.apache.dolphinscheduler.plugin.datasource.presto.param.PrestoConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PrestoDataSourceChannelTest {
@Test
@ -34,6 +34,6 @@ public class PrestoDataSourceChannelTest {
PrestoDataSourceChannel sourceChannel = Mockito.mock(PrestoDataSourceChannel.class);
PrestoDataSourceClient dataSourceClient = Mockito.mock(PrestoDataSourceClient.class);
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
Assert.assertNotNull(sourceChannel.createDataSourceClient(new PrestoConnectionParam(), DbType.PRESTO));
Assertions.assertNotNull(sourceChannel.createDataSourceClient(new PrestoConnectionParam(), DbType.PRESTO));
}
}

26
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-presto/src/test/java/org/apache/dolphinscheduler/plugin/datasource/presto/param/PrestoDataSourceProcessorTest.java

@ -24,14 +24,14 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class PrestoDataSourceProcessorTest {
private PrestoDataSourceProcessor prestoDatasourceProcessor = new PrestoDataSourceProcessor();
@ -51,8 +51,8 @@ public class PrestoDataSourceProcessorTest {
mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test");
PrestoConnectionParam connectionParams = (PrestoConnectionParam) prestoDatasourceProcessor
.createConnectionParams(prestoDatasourceParamDTO);
Assert.assertEquals("jdbc:presto://localhost:1234", connectionParams.getAddress());
Assert.assertEquals("jdbc:presto://localhost:1234/default", connectionParams.getJdbcUrl());
Assertions.assertEquals("jdbc:presto://localhost:1234", connectionParams.getAddress());
Assertions.assertEquals("jdbc:presto://localhost:1234/default", connectionParams.getJdbcUrl());
}
}
@ -63,13 +63,13 @@ public class PrestoDataSourceProcessorTest {
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:presto://localhost:1234/default\"}";
PrestoConnectionParam connectionParams = (PrestoConnectionParam) prestoDatasourceProcessor
.createConnectionParams(connectionJson);
Assert.assertNotNull(connectionParams);
Assert.assertEquals("root", connectionParams.getUser());
Assertions.assertNotNull(connectionParams);
Assertions.assertEquals("root", connectionParams.getUser());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.COM_PRESTO_JDBC_DRIVER, prestoDatasourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.COM_PRESTO_JDBC_DRIVER, prestoDatasourceProcessor.getDatasourceDriver());
}
@Test
@ -77,18 +77,18 @@ public class PrestoDataSourceProcessorTest {
PrestoConnectionParam prestoConnectionParam = new PrestoConnectionParam();
prestoConnectionParam.setJdbcUrl("jdbc:postgresql://localhost:1234/default");
prestoConnectionParam.setOther("other");
Assert.assertEquals("jdbc:postgresql://localhost:1234/default?other",
Assertions.assertEquals("jdbc:postgresql://localhost:1234/default?other",
prestoDatasourceProcessor.getJdbcUrl(prestoConnectionParam));
}
@Test
public void testGetDbType() {
Assert.assertEquals(DbType.PRESTO, prestoDatasourceProcessor.getDbType());
Assertions.assertEquals(DbType.PRESTO, prestoDatasourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.PRESTO_VALIDATION_QUERY, prestoDatasourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.PRESTO_VALIDATION_QUERY, prestoDatasourceProcessor.getValidationQuery());
}
}

26
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-redshift/src/test/java/org/apache/dolphinscheduler/plugin/datasource/redshift/param/RedshiftDataSourceProcessorTest.java

@ -24,14 +24,14 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class RedshiftDataSourceProcessorTest {
private RedshiftDataSourceProcessor redshiftDatasourceProcessor = new RedshiftDataSourceProcessor();
@ -52,8 +52,8 @@ public class RedshiftDataSourceProcessorTest {
mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test");
RedshiftConnectionParam connectionParams = (RedshiftConnectionParam) redshiftDatasourceProcessor
.createConnectionParams(redshiftDatasourceParamDTO);
Assert.assertEquals("jdbc:redshift://localhost:5439", connectionParams.getAddress());
Assert.assertEquals("jdbc:redshift://localhost:5439/dev", connectionParams.getJdbcUrl());
Assertions.assertEquals("jdbc:redshift://localhost:5439", connectionParams.getAddress());
Assertions.assertEquals("jdbc:redshift://localhost:5439/dev", connectionParams.getJdbcUrl());
}
}
@ -64,13 +64,13 @@ public class RedshiftDataSourceProcessorTest {
+ ",\"database\":\"dev\",\"jdbcUrl\":\"jdbc:redshift://localhost:5439/dev\"}";
RedshiftConnectionParam connectionParams = (RedshiftConnectionParam) redshiftDatasourceProcessor
.createConnectionParams(connectionJson);
Assert.assertNotNull(connectionParams);
Assert.assertEquals("awsuser", connectionParams.getUser());
Assertions.assertNotNull(connectionParams);
Assertions.assertEquals("awsuser", connectionParams.getUser());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.COM_REDSHIFT_JDBC_DRIVER, redshiftDatasourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.COM_REDSHIFT_JDBC_DRIVER, redshiftDatasourceProcessor.getDatasourceDriver());
}
@Test
@ -78,18 +78,18 @@ public class RedshiftDataSourceProcessorTest {
RedshiftConnectionParam redshiftConnectionParam = new RedshiftConnectionParam();
redshiftConnectionParam.setJdbcUrl("jdbc:redshift://localhost:5439/default");
redshiftConnectionParam.setOther("DSILogLevel=6;defaultRowFetchSize=100");
Assert.assertEquals("jdbc:redshift://localhost:5439/default?DSILogLevel=6;defaultRowFetchSize=100",
Assertions.assertEquals("jdbc:redshift://localhost:5439/default?DSILogLevel=6;defaultRowFetchSize=100",
redshiftDatasourceProcessor.getJdbcUrl(redshiftConnectionParam));
}
@Test
public void testGetDbType() {
Assert.assertEquals(DbType.REDSHIFT, redshiftDatasourceProcessor.getDbType());
Assertions.assertEquals(DbType.REDSHIFT, redshiftDatasourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.REDHIFT_VALIDATION_QUERY, redshiftDatasourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.REDHIFT_VALIDATION_QUERY, redshiftDatasourceProcessor.getValidationQuery());
}
}

6
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-spark/src/test/java/org/apache/dolphinscheduler/plugin/datasource/spark/SparkDataSourceChannelFactoryTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.plugin.datasource.spark;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class SparkDataSourceChannelFactoryTest {
@ -28,6 +28,6 @@ public class SparkDataSourceChannelFactoryTest {
public void testCreate() {
SparkDataSourceChannelFactory sourceChannelFactory = new SparkDataSourceChannelFactory();
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
Assert.assertNotNull(dataSourceChannel);
Assertions.assertNotNull(dataSourceChannel);
}
}

12
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-spark/src/test/java/org/apache/dolphinscheduler/plugin/datasource/spark/SparkDataSourceChannelTest.java

@ -20,13 +20,13 @@ package org.apache.dolphinscheduler.plugin.datasource.spark;
import org.apache.dolphinscheduler.plugin.datasource.spark.param.SparkConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class SparkDataSourceChannelTest {
@Test
@ -34,6 +34,6 @@ public class SparkDataSourceChannelTest {
SparkDataSourceChannel sourceChannel = Mockito.mock(SparkDataSourceChannel.class);
SparkDataSourceClient dataSourceClient = Mockito.mock(SparkDataSourceClient.class);
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
Assert.assertNotNull(sourceChannel.createDataSourceClient(new SparkConnectionParam(), DbType.SPARK));
Assertions.assertNotNull(sourceChannel.createDataSourceClient(new SparkConnectionParam(), DbType.SPARK));
}
}

28
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-spark/src/test/java/org/apache/dolphinscheduler/plugin/datasource/spark/param/SparkDataSourceProcessorTest.java

@ -25,14 +25,14 @@ import org.apache.dolphinscheduler.spi.utils.Constants;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class SparkDataSourceProcessorTest {
private SparkDataSourceProcessor sparkDatasourceProcessor = new SparkDataSourceProcessor();
@ -56,8 +56,9 @@ public class SparkDataSourceProcessorTest {
mockedStaticCommonUtils.when(CommonUtils::getKerberosStartupState).thenReturn(false);
SparkConnectionParam connectionParams = (SparkConnectionParam) sparkDatasourceProcessor
.createConnectionParams(sparkDatasourceParamDTO);
Assert.assertEquals("jdbc:hive2://localhost1:1234,localhost2:1234", connectionParams.getAddress());
Assert.assertEquals("jdbc:hive2://localhost1:1234,localhost2:1234/default", connectionParams.getJdbcUrl());
Assertions.assertEquals("jdbc:hive2://localhost1:1234,localhost2:1234", connectionParams.getAddress());
Assertions.assertEquals("jdbc:hive2://localhost1:1234,localhost2:1234/default",
connectionParams.getJdbcUrl());
}
}
@ -68,13 +69,14 @@ public class SparkDataSourceProcessorTest {
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:hive2://localhost1:1234,localhost2:1234/default\"}";
SparkConnectionParam connectionParams = (SparkConnectionParam) sparkDatasourceProcessor
.createConnectionParams(connectionJson);
Assert.assertNotNull(connectionParams);
Assert.assertEquals("root", connectionParams.getUser());
Assertions.assertNotNull(connectionParams);
Assertions.assertEquals("root", connectionParams.getUser());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.ORG_APACHE_HIVE_JDBC_HIVE_DRIVER, sparkDatasourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.ORG_APACHE_HIVE_JDBC_HIVE_DRIVER,
sparkDatasourceProcessor.getDatasourceDriver());
}
@Test
@ -82,17 +84,17 @@ public class SparkDataSourceProcessorTest {
SparkConnectionParam sparkConnectionParam = new SparkConnectionParam();
sparkConnectionParam.setJdbcUrl("jdbc:hive2://localhost1:1234,localhost2:1234/default");
sparkConnectionParam.setOther("other");
Assert.assertEquals("jdbc:hive2://localhost1:1234,localhost2:1234/default;other",
Assertions.assertEquals("jdbc:hive2://localhost1:1234,localhost2:1234/default;other",
sparkDatasourceProcessor.getJdbcUrl(sparkConnectionParam));
}
@Test
public void testGetDbType() {
Assert.assertEquals(DbType.SPARK, sparkDatasourceProcessor.getDbType());
Assertions.assertEquals(DbType.SPARK, sparkDatasourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.HIVE_VALIDATION_QUERY, sparkDatasourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.HIVE_VALIDATION_QUERY, sparkDatasourceProcessor.getValidationQuery());
}
}

6
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-sqlserver/src/test/java/org/apache/dolphinscheduler/plugin/datasource/sqlserver/SQLServerDataSourceChannelFactoryTest.java

@ -19,8 +19,8 @@ package org.apache.dolphinscheduler.plugin.datasource.sqlserver;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class SQLServerDataSourceChannelFactoryTest {
@ -28,6 +28,6 @@ public class SQLServerDataSourceChannelFactoryTest {
public void testCreate() {
SQLServerDataSourceChannelFactory sourceChannelFactory = new SQLServerDataSourceChannelFactory();
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
Assert.assertNotNull(dataSourceChannel);
Assertions.assertNotNull(dataSourceChannel);
}
}

13
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-sqlserver/src/test/java/org/apache/dolphinscheduler/plugin/datasource/sqlserver/SQLServerDataSourceChannelTest.java

@ -20,13 +20,13 @@ package org.apache.dolphinscheduler.plugin.datasource.sqlserver;
import org.apache.dolphinscheduler.plugin.datasource.sqlserver.param.SQLServerConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class SQLServerDataSourceChannelTest {
@Test
@ -34,6 +34,7 @@ public class SQLServerDataSourceChannelTest {
SQLServerDataSourceChannel sourceChannel = Mockito.mock(SQLServerDataSourceChannel.class);
SQLServerDataSourceClient dataSourceClient = Mockito.mock(SQLServerDataSourceClient.class);
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
Assert.assertNotNull(sourceChannel.createDataSourceClient(new SQLServerConnectionParam(), DbType.SQLSERVER));
Assertions
.assertNotNull(sourceChannel.createDataSourceClient(new SQLServerConnectionParam(), DbType.SQLSERVER));
}
}

31
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-sqlserver/src/test/java/org/apache/dolphinscheduler/plugin/datasource/sqlserver/param/SQLServerDataSourceProcessorTest.java

@ -25,14 +25,14 @@ import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class SQLServerDataSourceProcessorTest {
private SQLServerDataSourceProcessor sqlServerDatasourceProcessor = new SQLServerDataSourceProcessor();
@ -53,9 +53,10 @@ public class SQLServerDataSourceProcessorTest {
mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test");
SQLServerConnectionParam connectionParams = (SQLServerConnectionParam) sqlServerDatasourceProcessor
.createConnectionParams(sqlServerDatasourceParamDTO);
Assert.assertEquals("jdbc:sqlserver://localhost:1234", connectionParams.getAddress());
Assert.assertEquals("jdbc:sqlserver://localhost:1234;databaseName=default", connectionParams.getJdbcUrl());
Assert.assertEquals("root", connectionParams.getUser());
Assertions.assertEquals("jdbc:sqlserver://localhost:1234", connectionParams.getAddress());
Assertions.assertEquals("jdbc:sqlserver://localhost:1234;databaseName=default",
connectionParams.getJdbcUrl());
Assertions.assertEquals("root", connectionParams.getUser());
}
}
@ -66,13 +67,14 @@ public class SQLServerDataSourceProcessorTest {
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:sqlserver://localhost:1234;databaseName=default\"}";
SQLServerConnectionParam sqlServerConnectionParam =
JSONUtils.parseObject(connectionJson, SQLServerConnectionParam.class);
Assert.assertNotNull(sqlServerConnectionParam);
Assert.assertEquals("root", sqlServerConnectionParam.getUser());
Assertions.assertNotNull(sqlServerConnectionParam);
Assertions.assertEquals("root", sqlServerConnectionParam.getUser());
}
@Test
public void testGetDatasourceDriver() {
Assert.assertEquals(Constants.COM_SQLSERVER_JDBC_DRIVER, sqlServerDatasourceProcessor.getDatasourceDriver());
Assertions.assertEquals(Constants.COM_SQLSERVER_JDBC_DRIVER,
sqlServerDatasourceProcessor.getDatasourceDriver());
}
@Test
@ -80,17 +82,18 @@ public class SQLServerDataSourceProcessorTest {
SQLServerConnectionParam sqlServerConnectionParam = new SQLServerConnectionParam();
sqlServerConnectionParam.setJdbcUrl("jdbc:sqlserver://localhost:1234;databaseName=default");
sqlServerConnectionParam.setOther("other");
Assert.assertEquals("jdbc:sqlserver://localhost:1234;databaseName=default;other",
Assertions.assertEquals("jdbc:sqlserver://localhost:1234;databaseName=default;other",
sqlServerDatasourceProcessor.getJdbcUrl(sqlServerConnectionParam));
}
@Test
public void testGetDbType() {
Assert.assertEquals(DbType.SQLSERVER, sqlServerDatasourceProcessor.getDbType());
Assertions.assertEquals(DbType.SQLSERVER, sqlServerDatasourceProcessor.getDbType());
}
@Test
public void testGetValidationQuery() {
Assert.assertEquals(Constants.SQLSERVER_VALIDATION_QUERY, sqlServerDatasourceProcessor.getValidationQuery());
Assertions.assertEquals(Constants.SQLSERVER_VALIDATION_QUERY,
sqlServerDatasourceProcessor.getValidationQuery());
}
}

41
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-etcd/src/test/java/org/apache/dolphinscheduler/plugin/registry/etcd/EtcdRegistryTest.java

@ -27,28 +27,27 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.etcd.jetcd.test.EtcdClusterExtension;
public class EtcdRegistryTest {
private static final Logger logger = LoggerFactory.getLogger(EtcdRegistryTest.class);
@RegisterExtension
public static final EtcdClusterExtension server = EtcdClusterExtension.builder()
.withNodes(1)
.withImage("ibmcom/etcd:3.2.24")
.build();
public static EtcdRegistry registry;
@BeforeClass
@BeforeAll
public static void before() throws Exception {
EtcdClusterExtension server = EtcdClusterExtension.builder()
.withNodes(1)
.withImage("ibmcom/etcd:3.2.24")
.build();
EtcdRegistryProperties properties = new EtcdRegistryProperties();
server.restart();
properties.setEndpoints(String.valueOf(server.clientEndpoints().get(0)));
@ -60,12 +59,12 @@ public class EtcdRegistryTest {
public void persistTest() {
registry.put("/nodes/m1", "", false);
registry.put("/nodes/m2", "", false);
Assert.assertEquals(Arrays.asList("m1", "m2"), registry.children("/nodes"));
Assert.assertTrue(registry.exists("/nodes/m1"));
Assertions.assertEquals(Arrays.asList("m1", "m2"), registry.children("/nodes"));
Assertions.assertTrue(registry.exists("/nodes/m1"));
registry.delete("/nodes/m2");
Assert.assertFalse(registry.exists("/nodes/m2"));
Assertions.assertFalse(registry.exists("/nodes/m2"));
registry.delete("/nodes");
Assert.assertFalse(registry.exists("/nodes/m1"));
Assertions.assertFalse(registry.exists("/nodes/m1"));
}
@Test
@ -76,7 +75,8 @@ public class EtcdRegistryTest {
new Thread(() -> {
registry.acquireLock("/lock");
preCountDownLatch.countDown();
logger.info(Thread.currentThread().getName() + " :I got the lock, but I don't want to work. I want to rest for a while");
logger.info(Thread.currentThread().getName()
+ " :I got the lock, but I don't want to work. I want to rest for a while");
try {
Thread.sleep(1000);
logger.info(Thread.currentThread().getName() + " :I'm going to start working");
@ -91,7 +91,7 @@ public class EtcdRegistryTest {
}
}).start();
try {
preCountDownLatch.await(5,TimeUnit.SECONDS);
preCountDownLatch.await(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
@ -113,7 +113,7 @@ public class EtcdRegistryTest {
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Assert.assertEquals(testData, Arrays.asList("thread1", "thread2"));
Assertions.assertEquals(testData, Arrays.asList("thread1", "thread2"));
}
@Test
@ -124,18 +124,19 @@ public class EtcdRegistryTest {
registry.put("/sub/m2", "tt", false);
registry.delete("/sub/m2");
registry.delete("/sub");
Assert.assertTrue(status);
Assertions.assertTrue(status);
}
static class TestListener implements SubscribeListener {
@Override
public void notify(Event event) {
logger.info("I'm test listener");
}
}
@AfterClass
@AfterAll
public static void after() throws IOException {
registry.close();
}

26
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/test/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistryTest.java

@ -29,10 +29,10 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Assert;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -44,7 +44,7 @@ public class ZookeeperRegistryTest {
ZookeeperRegistry registry;
@Before
@BeforeEach
public void before() throws Exception {
server = new TestingServer(true);
@ -59,10 +59,10 @@ public class ZookeeperRegistryTest {
public void persistTest() {
registry.put("/nodes/m1", "", false);
registry.put("/nodes/m2", "", false);
Assert.assertEquals(Arrays.asList("m2", "m1"), registry.children("/nodes"));
Assert.assertTrue(registry.exists("/nodes/m1"));
Assertions.assertEquals(Arrays.asList("m2", "m1"), registry.children("/nodes"));
Assertions.assertTrue(registry.exists("/nodes/m1"));
registry.delete("/nodes/m2");
Assert.assertFalse(registry.exists("/nodes/m2"));
Assertions.assertFalse(registry.exists("/nodes/m2"));
}
@Test
@ -73,7 +73,8 @@ public class ZookeeperRegistryTest {
new Thread(() -> {
registry.acquireLock("/lock");
preCountDownLatch.countDown();
logger.info(Thread.currentThread().getName() + " :I got the lock, but I don't want to work. I want to rest for a while");
logger.info(Thread.currentThread().getName()
+ " :I got the lock, but I don't want to work. I want to rest for a while");
try {
Thread.sleep(1000);
logger.info(Thread.currentThread().getName() + " :I'm going to start working");
@ -102,25 +103,26 @@ public class ZookeeperRegistryTest {
}).start();
allCountDownLatch.await(5, TimeUnit.SECONDS);
Assert.assertEquals(testData, Arrays.asList("thread1", "thread2"));
Assertions.assertEquals(testData, Arrays.asList("thread1", "thread2"));
}
@Test
public void subscribeTest() {
boolean status = registry.subscribe("/sub", new TestListener());
Assert.assertTrue(status);
Assertions.assertTrue(status);
}
static class TestListener implements SubscribeListener {
@Override
public void notify(Event event) {
logger.info("I'm test listener");
}
}
@After
@AfterEach
public void after() throws IOException {
registry.close();
server.close();

Loading…
Cancel
Save