You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/17 07:22:50 UTC

[GitHub] [shardingsphere] cenyu00 opened a new pull request #7822: add test case for DataSourceConnectionUrlUtil

cenyu00 opened a new pull request #7822:
URL: https://github.com/apache/shardingsphere/pull/7822


   Fixes #7735.
   
   Changes proposed in this pull request:
   - add test class DataSourceConnectionUrlUtilTest
   -
   -
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on a change in pull request #7822: add test case for DataSourceConnectionUrlUtil

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #7822:
URL: https://github.com/apache/shardingsphere/pull/7822#discussion_r507394024



##########
File path: shardingsphere-rdl-parser/shardingsphere-rdl-parser-binder/src/test/java/org/apache/shardingsphere/rdl/parser/binder/util/DataSourceConnectionUrlUtilTest.java
##########
@@ -0,0 +1,61 @@
+/*
+ * 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 = String.format("%s//%s:%s/%s", "jdbc:mysql:",
+                segment.getHostName(), segment.getPort(), segment.getDb());
+        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("%s//%s:%s/%s", "jdbc:postgresql:",

Review comment:
       I think the `expected` is supposed to be an actual string value like `jdbc:mysql//xxxxxxxxxxxx`. As your expected value is the same as the expression in `DataSourceConnectionUrlUtil `, the assertion will always be true.

##########
File path: shardingsphere-rdl-parser/shardingsphere-rdl-parser-binder/src/test/java/org/apache/shardingsphere/rdl/parser/binder/util/DataSourceConnectionUrlUtilTest.java
##########
@@ -0,0 +1,61 @@
+/*
+ * 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 = String.format("%s//%s:%s/%s", "jdbc:mysql:",
+                segment.getHostName(), segment.getPort(), segment.getDb());
+        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");
+

Review comment:
       Please remove the redundant blank line.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #7822: add test case for DataSourceConnectionUrlUtil

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #7822:
URL: https://github.com/apache/shardingsphere/pull/7822#issuecomment-711974502


   @cenyu00 BTW, would you like to continue with #7849, which is a subsequent task for this PR? If you want, please comment on that issue there, and I will assign it to you. Otherwise, please let me know here, and I will give it to other volunteer guys. :)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero merged pull request #7822: add test case for DataSourceConnectionUrlUtil

Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #7822:
URL: https://github.com/apache/shardingsphere/pull/7822


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] cenyu00 commented on pull request #7822: add test case for DataSourceConnectionUrlUtil

Posted by GitBox <gi...@apache.org>.
cenyu00 commented on pull request #7822:
URL: https://github.com/apache/shardingsphere/pull/7822#issuecomment-711721664


   @tristaZero ,Thank you.
   Due to insufficient understanding of the project, it takes a long time.
   I feel that the ss community is friendly to newcomers and the pursuit of high-quality code.
   I will do more for the ss community.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org