Zinway
1 year ago
committed by
GitHub
31 changed files with 1042 additions and 2 deletions
@ -0,0 +1,21 @@ |
|||||||
|
# Vertica |
||||||
|
|
||||||
|
![vertica](../../../../img/new_ui/dev/datasource/vertica.png) |
||||||
|
|
||||||
|
## Datasource Parameters |
||||||
|
|
||||||
|
| **Parameter** | **Description** | |
||||||
|
|----------------------------|------------------------------------------------------------| |
||||||
|
| Datasource | Select VERTICA. | |
||||||
|
| Datasource Name | Enter the name of the DataSource. | |
||||||
|
| Description | Enter a description of the DataSource. | |
||||||
|
| IP/Host Name | Enter the Vertica service IP. | |
||||||
|
| Port | Enter the Vertica service port. | |
||||||
|
| Username | Set the username for Vertica connection. | |
||||||
|
| Password | Set the password for Vertica connection. | |
||||||
|
| Database name | Enter the database name of the Vertica connection. | |
||||||
|
| Jdbc connection parameters | Parameter settings for Vertica connection, in JSON format. | |
||||||
|
|
||||||
|
## Native Supported |
||||||
|
|
||||||
|
Yes, could use this datasource by default. |
@ -0,0 +1,19 @@ |
|||||||
|
# VERTICA 数据源 |
||||||
|
|
||||||
|
![vertica](../../../../img/new_ui/dev/datasource/vertica.png) |
||||||
|
|
||||||
|
| **参数名称** | **参数描述** | |
||||||
|
|-----------|--------------------------------| |
||||||
|
| 数据源 | 选择 VERTICA | |
||||||
|
| 数据源名称 | 输入数据源的名称 | |
||||||
|
| 描述 | 输入数据源的描述 | |
||||||
|
| IP 主机名 | 输入连接 VERTICA 的 IP | |
||||||
|
| 端口 | 输入连接 VERTICA 的端口 | |
||||||
|
| 用户名 | 设置连接 VERTICA 的用户名 | |
||||||
|
| 密码 | 设置连接 VERTICA 的密码 | |
||||||
|
| 数据库名 | 输入连接 VERTICA 的数据库名称 | |
||||||
|
| JDBC 连接参数 | 用于 VERTICA 连接的参数设置,以 JSON 形式填写 | |
||||||
|
|
||||||
|
## 是否原生支持 |
||||||
|
|
||||||
|
是,数据源不需要任务附加操作即可使用。 |
After Width: | Height: | Size: 236 KiB |
@ -0,0 +1,80 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.api.datasource; |
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows; |
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
/** |
||||||
|
* Use MySQLDataSourceParamDTO extends BaseDataSourceParamDTO for test. |
||||||
|
*/ |
||||||
|
public class BaseDataSourceParamDTOTest { |
||||||
|
|
||||||
|
private MySQLDataSourceParamDTO mockDataSourceParamDTO; |
||||||
|
|
||||||
|
@BeforeEach |
||||||
|
public void setUp() { |
||||||
|
mockDataSourceParamDTO = new MySQLDataSourceParamDTO(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void setHostAndPortByAddressTest1() { |
||||||
|
mockDataSourceParamDTO.setHostAndPortByAddress("jdbc:mysql://1.2.3.4:3306"); |
||||||
|
assertEquals("1.2.3.4", mockDataSourceParamDTO.getHost()); |
||||||
|
assertEquals(3306, mockDataSourceParamDTO.getPort()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void setHostAndPortByAddressTest2() { |
||||||
|
mockDataSourceParamDTO.setHostAndPortByAddress("jdbc:mysql://1.2.3.4:3306/database"); |
||||||
|
assertEquals("1.2.3.4", mockDataSourceParamDTO.getHost()); |
||||||
|
assertEquals(3306, mockDataSourceParamDTO.getPort()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void setHostAndPortByAddressTest3() { |
||||||
|
mockDataSourceParamDTO.setHostAndPortByAddress("jdbc:mysql://h1,h2,h3:3306"); |
||||||
|
assertEquals("h1,h2,h3", mockDataSourceParamDTO.getHost()); |
||||||
|
assertEquals(3306, mockDataSourceParamDTO.getPort()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void setHostAndPortByAddressTest4() { |
||||||
|
mockDataSourceParamDTO.setHostAndPortByAddress("jdbc:mysql://h1:3306,h2:3306,h3:3306"); |
||||||
|
assertEquals("h1,h2,h3", mockDataSourceParamDTO.getHost()); |
||||||
|
assertEquals(3306, mockDataSourceParamDTO.getPort()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void setHostAndPortByAddressTest5() { |
||||||
|
Throwable exception = assertThrows(IllegalArgumentException.class, |
||||||
|
() -> mockDataSourceParamDTO.setHostAndPortByAddress("jdbc:mysql://h1")); |
||||||
|
assertEquals("host:port 'h1' illegal.", exception.getMessage()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void setHostAndPortByAddressTest6() { |
||||||
|
Throwable exception = assertThrows(NumberFormatException.class, |
||||||
|
() -> mockDataSourceParamDTO.setHostAndPortByAddress("jdbc:mysql://h1:port")); |
||||||
|
assertEquals("For input string: \"port\"", exception.getMessage()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.api.datasource; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
|
||||||
|
/** |
||||||
|
* Used for test in BaseDataSourceParamDTOTest. |
||||||
|
*/ |
||||||
|
public class MySQLDataSourceParamDTO extends BaseDataSourceParamDTO { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "MySQLDataSourceParamDTO{" |
||||||
|
+ "name='" + name + '\'' |
||||||
|
+ ", note='" + note + '\'' |
||||||
|
+ ", host='" + host + '\'' |
||||||
|
+ ", port=" + port |
||||||
|
+ ", database='" + database + '\'' |
||||||
|
+ ", userName='" + userName + '\'' |
||||||
|
+ ", password='" + password + '\'' |
||||||
|
+ ", other='" + other + '\'' |
||||||
|
+ '}'; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DbType getType() { |
||||||
|
return DbType.MYSQL; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!-- |
||||||
|
~ Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
~ contributor license agreements. See the NOTICE file distributed with |
||||||
|
~ this work for additional information regarding copyright ownership. |
||||||
|
~ The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
~ (the "License"); you may not use this file except in compliance with |
||||||
|
~ the License. You may obtain a copy of the License at |
||||||
|
~ |
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
~ |
||||||
|
~ Unless required by applicable law or agreed to in writing, software |
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
~ See the License for the specific language governing permissions and |
||||||
|
~ limitations under the License. |
||||||
|
--> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<parent> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<artifactId>dolphinscheduler-datasource-plugin</artifactId> |
||||||
|
<version>dev-SNAPSHOT</version> |
||||||
|
</parent> |
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-datasource-vertica</artifactId> |
||||||
|
<packaging>jar</packaging> |
||||||
|
<name>${project.artifactId}</name> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<artifactId>dolphinscheduler-spi</artifactId> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<artifactId>dolphinscheduler-datasource-api</artifactId> |
||||||
|
<version>${project.version}</version> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>com.vertica.jdbc</groupId> |
||||||
|
<artifactId>vertica-jdbc</artifactId> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
</project> |
@ -0,0 +1,31 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceClient; |
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
|
||||||
|
public class VerticaDataSourceChannel implements DataSourceChannel { |
||||||
|
|
||||||
|
@Override |
||||||
|
public DataSourceClient createDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) { |
||||||
|
return new VerticaDataSourceClient(baseConnectionParam, dbType); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory; |
||||||
|
|
||||||
|
import com.google.auto.service.AutoService; |
||||||
|
|
||||||
|
@AutoService(DataSourceChannelFactory.class) |
||||||
|
public class VerticaDataSourceChannelFactory implements DataSourceChannelFactory { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
return "vertica"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DataSourceChannel create() { |
||||||
|
return new VerticaDataSourceChannel(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
|
||||||
|
public class VerticaDataSourceClient extends CommonDataSourceClient { |
||||||
|
|
||||||
|
public VerticaDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) { |
||||||
|
super(baseConnectionParam, dbType); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica.param; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||||
|
|
||||||
|
public class VerticaConnectionParam extends BaseConnectionParam { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "VerticaConnectionParam{" |
||||||
|
+ "user='" + user + '\'' |
||||||
|
+ ", password='" + password + '\'' |
||||||
|
+ ", address='" + address + '\'' |
||||||
|
+ ", database='" + database + '\'' |
||||||
|
+ ", jdbcUrl='" + jdbcUrl + '\'' |
||||||
|
+ ", driverLocation='" + driverLocation + '\'' |
||||||
|
+ ", driverClassName='" + driverClassName + '\'' |
||||||
|
+ ", validationQuery='" + validationQuery + '\'' |
||||||
|
+ ", other='" + other + '\'' |
||||||
|
+ '}'; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica.param; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; |
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
|
||||||
|
public class VerticaDataSourceParamDTO extends BaseDataSourceParamDTO { |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "VerticaDataSourceParamDTO{" |
||||||
|
+ "name='" + name + '\'' |
||||||
|
+ ", note='" + note + '\'' |
||||||
|
+ ", host='" + host + '\'' |
||||||
|
+ ", port=" + port |
||||||
|
+ ", database='" + database + '\'' |
||||||
|
+ ", userName='" + userName + '\'' |
||||||
|
+ ", password='" + password + '\'' |
||||||
|
+ ", other='" + other + '\'' |
||||||
|
+ '}'; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DbType getType() { |
||||||
|
return DbType.VERTICA; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,134 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica.param; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.constants.DataSourceConstants; |
||||||
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.AbstractDataSourceProcessor; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.DataSourceProcessor; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
|
||||||
|
import org.apache.commons.collections4.MapUtils; |
||||||
|
|
||||||
|
import java.sql.Connection; |
||||||
|
import java.sql.DriverManager; |
||||||
|
import java.sql.SQLException; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import com.google.auto.service.AutoService; |
||||||
|
|
||||||
|
@AutoService(DataSourceProcessor.class) |
||||||
|
public class VerticaDataSourceProcessor extends AbstractDataSourceProcessor { |
||||||
|
|
||||||
|
@Override |
||||||
|
public BaseDataSourceParamDTO castDatasourceParamDTO(String paramJson) { |
||||||
|
return JSONUtils.parseObject(paramJson, VerticaDataSourceParamDTO.class); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BaseDataSourceParamDTO createDatasourceParamDTO(String connectionJson) { |
||||||
|
VerticaConnectionParam connectionParams = (VerticaConnectionParam) createConnectionParams(connectionJson); |
||||||
|
VerticaDataSourceParamDTO verticaDatasourceParamDTO = new VerticaDataSourceParamDTO(); |
||||||
|
|
||||||
|
verticaDatasourceParamDTO.setHostAndPortByAddress(connectionParams.getAddress()); |
||||||
|
verticaDatasourceParamDTO.setUserName(connectionParams.getUser()); |
||||||
|
verticaDatasourceParamDTO.setDatabase(connectionParams.getDatabase()); |
||||||
|
verticaDatasourceParamDTO.setOther(connectionParams.getOther()); |
||||||
|
|
||||||
|
return verticaDatasourceParamDTO; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public BaseConnectionParam createConnectionParams(BaseDataSourceParamDTO dataSourceParam) { |
||||||
|
VerticaDataSourceParamDTO verticaDatasourceParam = (VerticaDataSourceParamDTO) dataSourceParam; |
||||||
|
// address format: "jdbc:vertica://VerticaHost:portNumber"
|
||||||
|
String address = String.format("%s%s:%s", DataSourceConstants.JDBC_VERTICA, verticaDatasourceParam.getHost(), |
||||||
|
verticaDatasourceParam.getPort()); |
||||||
|
// jdbc format: "jdbc:vertica://VerticaHost:portNumber/databaseName"
|
||||||
|
String jdbcUrl = String.format("%s/%s", address, verticaDatasourceParam.getDatabase()); |
||||||
|
|
||||||
|
VerticaConnectionParam verticaConnectionParam = new VerticaConnectionParam(); |
||||||
|
verticaConnectionParam.setJdbcUrl(jdbcUrl); |
||||||
|
verticaConnectionParam.setDatabase(verticaDatasourceParam.getDatabase()); |
||||||
|
verticaConnectionParam.setAddress(address); |
||||||
|
verticaConnectionParam.setUser(verticaDatasourceParam.getUserName()); |
||||||
|
verticaConnectionParam.setPassword(PasswordUtils.encodePassword(verticaDatasourceParam.getPassword())); |
||||||
|
verticaConnectionParam.setDriverClassName(getDatasourceDriver()); |
||||||
|
verticaConnectionParam.setValidationQuery(getValidationQuery()); |
||||||
|
|
||||||
|
return verticaConnectionParam; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ConnectionParam createConnectionParams(String connectionJson) { |
||||||
|
return JSONUtils.parseObject(connectionJson, VerticaConnectionParam.class); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getDatasourceDriver() { |
||||||
|
return DataSourceConstants.COM_VERTICA_JDBC_DRIVER; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getValidationQuery() { |
||||||
|
return DataSourceConstants.VERTICA_VALIDATION_QUERY; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getJdbcUrl(ConnectionParam connectionParam) { |
||||||
|
VerticaConnectionParam verticaConnectionParam = (VerticaConnectionParam) connectionParam; |
||||||
|
String jdbcUrl = verticaConnectionParam.getJdbcUrl(); |
||||||
|
if (MapUtils.isNotEmpty(verticaConnectionParam.getOther())) { |
||||||
|
jdbcUrl = String.format("%s?%s", jdbcUrl, transformOther(verticaConnectionParam.getOther())); |
||||||
|
} |
||||||
|
return jdbcUrl; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Connection getConnection(ConnectionParam connectionParam) throws ClassNotFoundException, SQLException { |
||||||
|
VerticaConnectionParam verticaConnectionParam = (VerticaConnectionParam) connectionParam; |
||||||
|
Class.forName(getDatasourceDriver()); |
||||||
|
String user = verticaConnectionParam.getUser(); |
||||||
|
String password = PasswordUtils.decodePassword(verticaConnectionParam.getPassword()); |
||||||
|
return DriverManager.getConnection(getJdbcUrl(connectionParam), user, password); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DbType getDbType() { |
||||||
|
return DbType.VERTICA; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DataSourceProcessor create() { |
||||||
|
return new VerticaDataSourceProcessor(); |
||||||
|
} |
||||||
|
|
||||||
|
private String transformOther(Map<String, String> otherMap) { |
||||||
|
if (MapUtils.isEmpty(otherMap)) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||||
|
otherMap.forEach((key, value) -> stringBuilder.append(String.format("%s=%s&", key, value))); |
||||||
|
return stringBuilder.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel; |
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
public class VerticaDataSourceChannelFactoryTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreate() { |
||||||
|
VerticaDataSourceChannelFactory sourceChannelFactory = new VerticaDataSourceChannelFactory(); |
||||||
|
DataSourceChannel dataSourceChannel = sourceChannelFactory.create(); |
||||||
|
Assertions.assertNotNull(dataSourceChannel); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.vertica.param.VerticaConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
|
||||||
|
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.jupiter.MockitoExtension; |
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class) |
||||||
|
public class VerticaDataSourceChannelTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreateDataSourceClient() { |
||||||
|
VerticaDataSourceChannel sourceChannel = Mockito.mock(VerticaDataSourceChannel.class); |
||||||
|
VerticaDataSourceClient dataSourceClient = Mockito.mock(VerticaDataSourceClient.class); |
||||||
|
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient); |
||||||
|
Assertions.assertNotNull(sourceChannel.createDataSourceClient(new VerticaConnectionParam(), DbType.VERTICA)); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,108 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica.param; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.constants.DataSourceConstants; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils; |
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
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.jupiter.MockitoExtension; |
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class) |
||||||
|
public class VerticaDataSourceProcessorTest { |
||||||
|
|
||||||
|
private VerticaDataSourceProcessor verticaDatasourceProcessor = new VerticaDataSourceProcessor(); |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreateConnectionParams() { |
||||||
|
Map<String, String> props = new HashMap<>(); |
||||||
|
props.put("serverTimezone", "utc"); |
||||||
|
VerticaDataSourceParamDTO verticaDatasourceParamDTO = new VerticaDataSourceParamDTO(); |
||||||
|
verticaDatasourceParamDTO.setUserName("root"); |
||||||
|
verticaDatasourceParamDTO.setPassword("123456"); |
||||||
|
verticaDatasourceParamDTO.setHost("localhost"); |
||||||
|
verticaDatasourceParamDTO.setPort(5433); |
||||||
|
verticaDatasourceParamDTO.setDatabase("default"); |
||||||
|
verticaDatasourceParamDTO.setOther(props); |
||||||
|
try (MockedStatic<PasswordUtils> mockedStaticPasswordUtils = Mockito.mockStatic(PasswordUtils.class)) { |
||||||
|
mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test"); |
||||||
|
VerticaConnectionParam connectionParams = (VerticaConnectionParam) verticaDatasourceProcessor |
||||||
|
.createConnectionParams(verticaDatasourceParamDTO); |
||||||
|
Assertions.assertEquals("jdbc:vertica://localhost:5433", connectionParams.getAddress()); |
||||||
|
Assertions.assertEquals("jdbc:vertica://localhost:5433/default", connectionParams.getJdbcUrl()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreateConnectionParams2() { |
||||||
|
String connectionJson = |
||||||
|
"{\"user\":\"root\",\"password\":\"123456\",\"address\":\"jdbc:vertica://localhost:5433\"" |
||||||
|
+ ",\"database\":\"default\",\"jdbcUrl\":\"jdbc:vertica://localhost:5433/default\"}"; |
||||||
|
VerticaConnectionParam connectionParams = (VerticaConnectionParam) verticaDatasourceProcessor |
||||||
|
.createConnectionParams(connectionJson); |
||||||
|
Assertions.assertNotNull(connectionJson); |
||||||
|
Assertions.assertEquals("root", connectionParams.getUser()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetDatasourceDriver() { |
||||||
|
Assertions.assertEquals(DataSourceConstants.COM_VERTICA_JDBC_DRIVER, |
||||||
|
verticaDatasourceProcessor.getDatasourceDriver()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetJdbcUrl() { |
||||||
|
VerticaConnectionParam verticaConnectionParam = new VerticaConnectionParam(); |
||||||
|
verticaConnectionParam.setJdbcUrl("jdbc:vertica://localhost:5433/default"); |
||||||
|
Assertions.assertEquals( |
||||||
|
"jdbc:vertica://localhost:5433/default", |
||||||
|
verticaDatasourceProcessor.getJdbcUrl(verticaConnectionParam)); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetDbType() { |
||||||
|
Assertions.assertEquals(DbType.VERTICA, verticaDatasourceProcessor.getDbType()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetValidationQuery() { |
||||||
|
Assertions.assertEquals(DataSourceConstants.VERTICA_VALIDATION_QUERY, |
||||||
|
verticaDatasourceProcessor.getValidationQuery()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetDatasourceUniqueId() { |
||||||
|
VerticaConnectionParam verticaConnectionParam = new VerticaConnectionParam(); |
||||||
|
verticaConnectionParam.setJdbcUrl("jdbc:vertica://localhost:5433/default"); |
||||||
|
verticaConnectionParam.setUser("root"); |
||||||
|
verticaConnectionParam.setPassword("123456"); |
||||||
|
try (MockedStatic<PasswordUtils> mockedPasswordUtils = Mockito.mockStatic(PasswordUtils.class)) { |
||||||
|
mockedPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("123456"); |
||||||
|
Assertions.assertEquals("vertica@root@123456@jdbc:vertica://localhost:5433/default", |
||||||
|
verticaDatasourceProcessor.getDatasourceUniqueId(verticaConnectionParam, DbType.VERTICA)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,65 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica.provider; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.provider.JDBCDataSourceProvider; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.vertica.param.VerticaConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
|
||||||
|
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.jupiter.MockitoExtension; |
||||||
|
|
||||||
|
import com.zaxxer.hikari.HikariDataSource; |
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class) |
||||||
|
public class JDBCDataSourceProviderTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreateJdbcDataSource() { |
||||||
|
try ( |
||||||
|
MockedStatic<JDBCDataSourceProvider> mockedJDBCDataSourceProvider = |
||||||
|
Mockito.mockStatic(JDBCDataSourceProvider.class)) { |
||||||
|
HikariDataSource dataSource = Mockito.mock(HikariDataSource.class); |
||||||
|
mockedJDBCDataSourceProvider |
||||||
|
.when(() -> JDBCDataSourceProvider.createJdbcDataSource(Mockito.any(), Mockito.any())) |
||||||
|
.thenReturn(dataSource); |
||||||
|
Assertions.assertNotNull( |
||||||
|
JDBCDataSourceProvider.createJdbcDataSource(new VerticaConnectionParam(), DbType.VERTICA)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreateOneSessionJdbcDataSource() { |
||||||
|
try ( |
||||||
|
MockedStatic<JDBCDataSourceProvider> mockedJDBCDataSourceProvider = |
||||||
|
Mockito.mockStatic(JDBCDataSourceProvider.class)) { |
||||||
|
HikariDataSource dataSource = Mockito.mock(HikariDataSource.class); |
||||||
|
mockedJDBCDataSourceProvider |
||||||
|
.when(() -> JDBCDataSourceProvider.createOneSessionJdbcDataSource(Mockito.any(), Mockito.any())) |
||||||
|
.thenReturn(dataSource); |
||||||
|
Assertions.assertNotNull( |
||||||
|
JDBCDataSourceProvider.createOneSessionJdbcDataSource(new VerticaConnectionParam(), |
||||||
|
DbType.VERTICA)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,149 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.vertica.utils; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||||
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceClientProvider; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.vertica.param.VerticaConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.vertica.param.VerticaDataSourceParamDTO; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
|
||||||
|
import java.sql.Connection; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.concurrent.ExecutionException; |
||||||
|
|
||||||
|
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.jupiter.MockitoExtension; |
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class) |
||||||
|
public class DataSourceUtilsTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCheckDatasourceParam() { |
||||||
|
VerticaDataSourceParamDTO verticaDatasourceParamDTO = new VerticaDataSourceParamDTO(); |
||||||
|
verticaDatasourceParamDTO.setHost("localhost"); |
||||||
|
verticaDatasourceParamDTO.setDatabase("default"); |
||||||
|
Map<String, String> other = new HashMap<>(); |
||||||
|
other.put("serverTimezone", "Asia/Shanghai"); |
||||||
|
other.put("queryTimeout", "-1"); |
||||||
|
other.put("characterEncoding", "utf8"); |
||||||
|
verticaDatasourceParamDTO.setOther(other); |
||||||
|
DataSourceUtils.checkDatasourceParam(verticaDatasourceParamDTO); |
||||||
|
Assertions.assertTrue(true); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testBuildConnectionParams() { |
||||||
|
VerticaDataSourceParamDTO verticaDatasourceParamDTO = new VerticaDataSourceParamDTO(); |
||||||
|
verticaDatasourceParamDTO.setHost("localhost"); |
||||||
|
verticaDatasourceParamDTO.setDatabase("default"); |
||||||
|
verticaDatasourceParamDTO.setUserName("root"); |
||||||
|
verticaDatasourceParamDTO.setPort(5433); |
||||||
|
verticaDatasourceParamDTO.setPassword("123456"); |
||||||
|
|
||||||
|
try ( |
||||||
|
MockedStatic<PasswordUtils> mockedStaticPasswordUtils = Mockito.mockStatic(PasswordUtils.class); |
||||||
|
MockedStatic<CommonUtils> mockedStaticCommonUtils = Mockito.mockStatic(CommonUtils.class)) { |
||||||
|
mockedStaticPasswordUtils.when(() -> PasswordUtils.encodePassword(Mockito.anyString())) |
||||||
|
.thenReturn("123456"); |
||||||
|
mockedStaticCommonUtils.when(CommonUtils::getKerberosStartupState).thenReturn(false); |
||||||
|
ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(verticaDatasourceParamDTO); |
||||||
|
Assertions.assertNotNull(connectionParam); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testBuildConnectionParams2() { |
||||||
|
VerticaDataSourceParamDTO verticaDatasourceParamDTO = new VerticaDataSourceParamDTO(); |
||||||
|
verticaDatasourceParamDTO.setHost("localhost"); |
||||||
|
verticaDatasourceParamDTO.setDatabase("default"); |
||||||
|
verticaDatasourceParamDTO.setUserName("root"); |
||||||
|
verticaDatasourceParamDTO.setPort(5433); |
||||||
|
verticaDatasourceParamDTO.setPassword("123456"); |
||||||
|
ConnectionParam connectionParam = DataSourceUtils.buildConnectionParams(DbType.VERTICA, |
||||||
|
JSONUtils.toJsonString(verticaDatasourceParamDTO)); |
||||||
|
Assertions.assertNotNull(connectionParam); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetConnection() throws ExecutionException { |
||||||
|
try ( |
||||||
|
MockedStatic<PropertyUtils> mockedStaticPropertyUtils = Mockito.mockStatic(PropertyUtils.class); |
||||||
|
MockedStatic<DataSourceClientProvider> mockedStaticDataSourceClientProvider = |
||||||
|
Mockito.mockStatic(DataSourceClientProvider.class)) { |
||||||
|
mockedStaticPropertyUtils.when(() -> PropertyUtils.getLong("kerberos.expire.time", 24L)).thenReturn(24L); |
||||||
|
DataSourceClientProvider clientProvider = Mockito.mock(DataSourceClientProvider.class); |
||||||
|
mockedStaticDataSourceClientProvider.when(DataSourceClientProvider::getInstance).thenReturn(clientProvider); |
||||||
|
|
||||||
|
Connection connection = Mockito.mock(Connection.class); |
||||||
|
Mockito.when(clientProvider.getConnection(Mockito.any(), Mockito.any())).thenReturn(connection); |
||||||
|
|
||||||
|
VerticaConnectionParam connectionParam = new VerticaConnectionParam(); |
||||||
|
connectionParam.setUser("root"); |
||||||
|
connectionParam.setPassword("123456"); |
||||||
|
connection = DataSourceClientProvider.getInstance().getConnection(DbType.VERTICA, connectionParam); |
||||||
|
|
||||||
|
Assertions.assertNotNull(connection); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetJdbcUrl() { |
||||||
|
VerticaConnectionParam verticaConnectionParam = new VerticaConnectionParam(); |
||||||
|
verticaConnectionParam.setJdbcUrl("jdbc:vertica://localhost:5433"); |
||||||
|
String jdbcUrl = DataSourceUtils.getJdbcUrl(DbType.VERTICA, verticaConnectionParam); |
||||||
|
Assertions.assertEquals("jdbc:vertica://localhost:5433", |
||||||
|
jdbcUrl); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testBuildDatasourceParamDTO() { |
||||||
|
VerticaConnectionParam connectionParam = new VerticaConnectionParam(); |
||||||
|
connectionParam.setJdbcUrl("jdbc:vertica://localhost:5433"); |
||||||
|
connectionParam.setAddress("jdbc:vertica://localhost:5433"); |
||||||
|
connectionParam.setUser("root"); |
||||||
|
connectionParam.setPassword("123456"); |
||||||
|
|
||||||
|
Assertions.assertNotNull( |
||||||
|
DataSourceUtils.buildDatasourceParamDTO(DbType.VERTICA, JSONUtils.toJsonString(connectionParam))); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetDatasourceProcessor() { |
||||||
|
Assertions.assertNotNull(DataSourceUtils.getDatasourceProcessor(DbType.VERTICA)); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetDatasourceProcessorError() { |
||||||
|
Assertions.assertThrows(Exception.class, () -> { |
||||||
|
DataSourceUtils.getDatasourceProcessor(null); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
Vertica Client Driver License |
||||||
|
https://www.vertica.com/download/vertica/client-drivers/ |
||||||
|
|
||||||
|
|
||||||
|
End User License Agreement |
||||||
|
BY SELECTING “ACCEPT AND CONTINUE” BELOW, YOU ARE EXPRESSLY ACKNOWLEDGING AND AGREEING THAT THIS AGREEMENT, BETWEEN YOU AND MICRO FOCUS LLC (WITH ITS AFFILIATES, “MICRO FOCUS” OR “WE”), GOVERNS YOUR USE OF THE VERTICA CLIENT DRIVER SOFTWARE (TOGETHER WITH ANY UPDATES AND ENHANCEMENTS TO IT, AND ACCOMPANYING DOCUMENTATION, THE “DRIVERS”) THAT WE MAKE AVAILABLE TO YOU IN CONNECTION WITH MICRO FOCUS’ VERTICA SOFTWARE PRODUCT (OR ANY SUCCESSOR PRODUCT DESIGNATED BY US IN WRITING, THE “SOFTWARE”). THIS AGREEMENT GOVERNS THE LICENSING OF THE DRIVERS ONLY AND IF YOU WISH TO USE THE VERTICA SOFTWARE PRODUCT ITSELF, YOU WILL NEED TO LICENSE IT SEPARATELY UNDER THE APPROPRIATE COMMERCIAL OR COMMUNITY EDITION LICENSE. |
||||||
|
|
||||||
|
1. Except as stated below in this Agreement, the Drivers are governed by the Micro Focus End User License Agreement (the “EULA”) located at https://www.microfocus.com/en-us/legal/software-licensing. In the event of any conflict between the terms of this Agreement and the EULA, this Agreement will control and take precedence. |
||||||
|
2. This Agreement grants you a limited, nonexclusive, non-transferable, non-sublicensable license to install, use, and copy the object code of the Drivers free of charge for the sole purpose of developing a program that can use the Drivers to connect to the Software database. You may generally use the Drivers to connect to the Software. You may also distribute the Drivers, provided that (a) you distribute the Drivers as part of a software program or package that you develop; (b) you require end users to agree to terms that are consistent with, and at least as protective of Micro Focus and the Drivers as, this Agreement; (c) you retain without modification any copyright, patent, trademark, or attribution notices that are present in the Drivers; and (d) you distribute the Drivers for the sole purpose of your program connecting to the Software. |
||||||
|
3. Your rights under this Agreement will immediately and automatically terminate if you do not comply with any term or condition of this Agreement. In the case of termination, you must cease all use and destroy all copies of the Drivers. We may modify, suspend, discontinue, or terminate your right to use part or all of the Drivers at any time without notice to you and Micro Focus will not be liable to you should it exercise those rights. We may amend this Agreement at our sole discretion by posting the revised terms on the Micro Focus website https://www.vertica.com/download/vertica/client-drivers/ or within the Drivers. Your continued use of the Drivers after any amendment’s effective date evidence your agreement to be bound by it. |
||||||
|
4. The Drivers are the sole and exclusive intellectual property of Micro Focus. No support is provided for the Drivers. |
||||||
|
5. Some components of the Drivers may be governed by applicable open source software licenses. Your license rights with respect to these individual components are defined by the applicable open source software licenses, and nothing in this Agreement will restrict, limit, or otherwise affect any rights or obligations you may have, or conditions to which you may be subject, under such open source software licenses. |
||||||
|
6. The Drivers contains third party components, including any run time or other elements licensed to Micro Focus by a third party licensor (“Third Party Components”). Third Party Components are the sole and exclusive intellectual property of the applicable third party licensor. You agree that to the extent required by a third party licensor of a Third Party Component, that third party licensor is an intended third party beneficiary of this Agreement as necessary to protect its intellectual property rights software and limit certain uses thereof. You agree that any third party licensors of Third Party Components will have no liability with respect to the Third Party Components under this agreement. |
||||||
|
7. NOTWITHSTANDING ANYTHING TO THE CONTRARY IN THE EULA, YOU EXPRESSLY ACKNOWLEDGE AND AGREE THAT USE AND DISTRIBUTION OF THE DRIVERS IS AT YOUR SOLE RISK AND ARE DELIVERED TO YOU “AS IS” WITHOUT WARRANTY OF ANY KIND, AND MICRO FOCUS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED. |
||||||
|
8. You are liable for and will defend, indemnify, and hold harmless Micro Focus and its affiliates, officers, directors, agents, and employees, from and against any claims, liability, loss, damage, cost, or expense (including reasonable attorneys’ fees) arising out of (i) your distribution or use of your programs, (ii) your use of the Drivers, (iii) violation of applicable law, or (iv) violation of any right of any person or entity, including without limitation intellectual property rights. |
||||||
|
9. NOTWITHSTANDING ANYTHING TO THE CONTRARY IN THE EULA, TO THE EXTENT NOT PROHIBITED BY LAW, MICRO FOCUS WILL NOT BE LIABLE TO YOU FOR ANY INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR BREACH OF ANY EXPRESS OR IMPLIED WARRANTY, BREACH OF CONTRACT, NEGLIGENCE, STRICT LIABILITY, OR ANY OTHER LEGAL THEORY RELATED TO THE DRIVERS, INCLUDING WITHOUT LIMITATION ANY DAMAGES ARISING OUT OF LOSS OF PROFITS, REVENUE, DATA, OR USE OF THE DRIVERS. IN ANY CASE, MICRO FOCUS’ AGGREGATE LIABILITY UNDER THIS AGREEMENT WILL BE LIMITED TO $100.00. |
||||||
|
|
||||||
|
[ ] I consent and accept the terms and conditions stated in this Agreement. |
Loading…
Reference in new issue