You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2020/10/19 09:26:50 UTC
[shardingsphere] branch master updated: add test case for
DataSourceConnectionUrlUtil (#7822)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 3b9942a add test case for DataSourceConnectionUrlUtil (#7822)
3b9942a is described below
commit 3b9942a9292cbc0e06ac5e87e80fed99c1b02981
Author: 岑宇 <lu...@163.com>
AuthorDate: Mon Oct 19 17:26:19 2020 +0800
add test case for DataSourceConnectionUrlUtil (#7822)
* add DataSourceConnectionUrlUtil test case
* modify expected value to string expression
---
.../util/DataSourceConnectionUrlUtilTest.java | 58 ++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/shardingsphere-rdl-parser/shardingsphere-rdl-parser-binder/src/test/java/org/apache/shardingsphere/rdl/parser/binder/util/DataSourceConnectionUrlUtilTest.java b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-binder/src/test/java/org/apache/shardingsphere/rdl/parser/binder/util/DataSourceConnectionUrlUtilTest.java
new file mode 100644
index 0000000..ed718e1
--- /dev/null
+++ b/shardingsphere-rdl-parser/shardingsphere-rdl-parser-binder/src/test/java/org/apache/shardingsphere/rdl/parser/binder/util/DataSourceConnectionUrlUtilTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.shardingsphere.rdl.parser.binder.util;
+
+import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
+import org.apache.shardingsphere.rdl.parser.statement.rdl.DataSourceConnectionSegment;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class DataSourceConnectionUrlUtilTest {
+
+ @Test
+ public void assertMySQLGetUrl() {
+ DataSourceConnectionSegment segment = new DataSourceConnectionSegment();
+ segment.setHostName("127.0.0.1");
+ segment.setDb("test");
+ segment.setUser("root");
+ segment.setPort("3306");
+ MySQLDatabaseType databaseType = new MySQLDatabaseType();
+ String actual = DataSourceConnectionUrlUtil.getUrl(segment, databaseType);
+ String expected = "jdbc:mysql://127.0.0.1:3306/test";
+ assertThat(actual, is(expected));
+ }
+
+ @Test
+ public void assertPostgreSQLGetUrl() {
+ DataSourceConnectionSegment segment = new DataSourceConnectionSegment();
+ segment.setHostName("127.0.0.1");
+ segment.setDb("test");
+ segment.setUser("root");
+ segment.setPort("3306");
+ PostgreSQLDatabaseType databaseType = new PostgreSQLDatabaseType();
+ String actual = DataSourceConnectionUrlUtil.getUrl(segment, databaseType);
+ String expected = String.format("jdbc:postgresql://127.0.0.1:3306/test");
+ assertThat(actual, is(expected));
+ }
+}