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 2022/01/22 15:11:58 UTC

[GitHub] [shardingsphere] terrymanu commented on a change in pull request #14994: Add test case for DataSourcePoolMetaDataFactory

terrymanu commented on a change in pull request #14994:
URL: https://github.com/apache/shardingsphere/pull/14994#discussion_r790151658



##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datasource/pool/metadata/DataSourcePoolMetaDataFactoryTest.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.infra.datasource.pool.metadata;
+
+import com.zaxxer.hikari.HikariDataSource;
+import org.apache.shardingsphere.infra.datasource.pool.metadata.impl.DefaultDataSourcePoolMetaData;
+import org.apache.shardingsphere.infra.datasource.pool.metadata.impl.HikariDataSourcePoolMetaData;
+import org.junit.Test;
+
+import java.util.Objects;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public final class DataSourcePoolMetaDataFactoryTest {
+    
+    @Test
+    public void assertNewInstance() {
+        DataSourcePoolMetaData defaultDataSourcePoolMetaData = DataSourcePoolMetaDataFactory.newInstance("");
+        assertTrue(Objects.nonNull(defaultDataSourcePoolMetaData));

Review comment:
       It is unnecessary assertion of nonNull because of the next assertion is include the null juege.
   Could we remove this line?

##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datasource/pool/metadata/DataSourcePoolMetaDataFactoryTest.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.infra.datasource.pool.metadata;
+
+import com.zaxxer.hikari.HikariDataSource;
+import org.apache.shardingsphere.infra.datasource.pool.metadata.impl.DefaultDataSourcePoolMetaData;
+import org.apache.shardingsphere.infra.datasource.pool.metadata.impl.HikariDataSourcePoolMetaData;
+import org.junit.Test;
+
+import java.util.Objects;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public final class DataSourcePoolMetaDataFactoryTest {
+    
+    @Test
+    public void assertNewInstance() {
+        DataSourcePoolMetaData defaultDataSourcePoolMetaData = DataSourcePoolMetaDataFactory.newInstance("");
+        assertTrue(Objects.nonNull(defaultDataSourcePoolMetaData));
+        assertThat(defaultDataSourcePoolMetaData, instanceOf(DefaultDataSourcePoolMetaData.class));
+        DataSourcePoolMetaData hikariDataSourcePoolMetaData = DataSourcePoolMetaDataFactory.newInstance(HikariDataSource.class.getCanonicalName());
+        assertTrue(Objects.nonNull(hikariDataSourcePoolMetaData));
+        assertThat(hikariDataSourcePoolMetaData, instanceOf(HikariDataSourcePoolMetaData.class));

Review comment:
       It is better to split 2 different assertion into 2 methods, please notice one test case only assert one related thing.

##########
File path: shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datasource/pool/metadata/DataSourcePoolMetaDataFactoryTest.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.infra.datasource.pool.metadata;
+
+import com.zaxxer.hikari.HikariDataSource;
+import org.apache.shardingsphere.infra.datasource.pool.metadata.impl.DefaultDataSourcePoolMetaData;
+import org.apache.shardingsphere.infra.datasource.pool.metadata.impl.HikariDataSourcePoolMetaData;
+import org.junit.Test;
+
+import java.util.Objects;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public final class DataSourcePoolMetaDataFactoryTest {
+    
+    @Test
+    public void assertNewInstance() {
+        DataSourcePoolMetaData defaultDataSourcePoolMetaData = DataSourcePoolMetaDataFactory.newInstance("");
+        assertTrue(Objects.nonNull(defaultDataSourcePoolMetaData));
+        assertThat(defaultDataSourcePoolMetaData, instanceOf(DefaultDataSourcePoolMetaData.class));
+        DataSourcePoolMetaData hikariDataSourcePoolMetaData = DataSourcePoolMetaDataFactory.newInstance(HikariDataSource.class.getCanonicalName());
+        assertTrue(Objects.nonNull(hikariDataSourcePoolMetaData));

Review comment:
       It is unnecessary assertion of nonNull because of the next assertion is include the null juege.
   Could we remove this 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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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