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/10/07 03:57:59 UTC

[GitHub] [shardingsphere] cunhazera opened a new pull request, #21367: Adding test to ConnectionSavepointManager

cunhazera opened a new pull request, #21367:
URL: https://github.com/apache/shardingsphere/pull/21367

   Fixes #20365
   
   Changes proposed in this pull request:
     - Adding test to ConnectionSavepointManager
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [x] I have self-reviewed the commit code.
   - [x] I have passed maven check: `mvn clean install -B -T2C -DskipTests -Dmaven.javadoc.skip=true -e`.
   - [x] I have made corresponding changes to the documentation.
   - [x] I have added corresponding unit tests for my changes.
   


-- 
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


[GitHub] [shardingsphere] TeslaCN commented on a diff in pull request #21367: Adding test to ConnectionSavepointManager

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on code in PR #21367:
URL: https://github.com/apache/shardingsphere/pull/21367#discussion_r1001312782


##########
kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/ConnectionSavepointManagerTest.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.transaction;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.junit.Test;
+
+public class ConnectionSavepointManagerTest {

Review Comment:
   Please add `final` modifier.



##########
kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/ConnectionSavepointManagerTest.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.transaction;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.junit.Test;
+
+public class ConnectionSavepointManagerTest {
+    
+    private final ConnectionSavepointManager connectionSavepointManager = ConnectionSavepointManager.getInstance();
+    
+    @Test
+    public void assertSetSavepoint() throws SQLException {
+        Connection connection = mock(Connection.class);
+        String savingPoint = "SavingPoint";
+        connectionSavepointManager.setSavepoint(connection, savingPoint);
+        verify(connection, times(1)).setSavepoint(savingPoint);
+    }
+

Review Comment:
   This redundant blank line could be removed.



-- 
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


[GitHub] [shardingsphere] codecov-commenter commented on pull request #21367: Adding test to ConnectionSavepointManager

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #21367:
URL: https://github.com/apache/shardingsphere/pull/21367#issuecomment-1279450995

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/21367?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#21367](https://codecov.io/gh/apache/shardingsphere/pull/21367?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d7c60ca) into [master](https://codecov.io/gh/apache/shardingsphere/commit/8224e757dd081d8787864d25d22e7c4197975961?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8224e75) will **decrease** coverage by `0.50%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #21367      +/-   ##
   ============================================
   - Coverage     61.56%   61.05%   -0.51%     
   - Complexity     2507     2509       +2     
   ============================================
     Files          4089     4111      +22     
     Lines         56609    57293     +684     
     Branches       7487     7588     +101     
   ============================================
   + Hits          34853    34983     +130     
   - Misses        18838    19375     +537     
   - Partials       2918     2935      +17     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/21367?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...on/optimizer/converter/SQLNodeConverterEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL3NxbC1mZWRlcmF0aW9uL29wdGltaXplci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsZmVkZXJhdGlvbi9vcHRpbWl6ZXIvY29udmVydGVyL1NRTE5vZGVDb252ZXJ0ZXJFbmdpbmUuamF2YQ==) | `33.33% <0.00%> (-38.10%)` | :arrow_down: |
   | [...m/CRC32MatchDataConsistencyCalculateAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9jb3JlL2NoZWNrL2NvbnNpc3RlbmN5L2FsZ29yaXRobS9DUkMzMk1hdGNoRGF0YUNvbnNpc3RlbmN5Q2FsY3VsYXRlQWxnb3JpdGhtLmphdmE=) | `52.27% <0.00%> (-34.10%)` | :arrow_down: |
   | [...shardingsphere/mode/metadata/MetaDataContexts.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bW9kZS9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21ldGFkYXRhL01ldGFEYXRhQ29udGV4dHMuamF2YQ==) | `75.00% <0.00%> (-25.00%)` | :arrow_down: |
   | [...e/type/standard/ShardingStandardRoutingEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvc2hhcmRpbmcvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcm91dGUvZW5naW5lL3R5cGUvc3RhbmRhcmQvU2hhcmRpbmdTdGFuZGFyZFJvdXRpbmdFbmdpbmUuamF2YQ==) | `78.44% <0.00%> (-18.19%)` | :arrow_down: |
   | [...ra/binder/statement/CommonSQLStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc3RhdGVtZW50L0NvbW1vblNRTFN0YXRlbWVudENvbnRleHQuamF2YQ==) | `68.00% <0.00%> (-17.00%)` | :arrow_down: |
   | [...gsphere/mode/metadata/MetaDataContextsFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bW9kZS9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21ldGFkYXRhL01ldGFEYXRhQ29udGV4dHNGYWN0b3J5LmphdmE=) | `79.48% <0.00%> (-15.97%)` | :arrow_down: |
   | [...he/shardingsphere/infra/hint/SQLHintExtractor.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9oaW50L1NRTEhpbnRFeHRyYWN0b3IuamF2YQ==) | `62.85% <0.00%> (-15.41%)` | :arrow_down: |
   | [.../cluster/zookeeper/CuratorZookeeperRepository.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bW9kZS90eXBlL2NsdXN0ZXIvcmVwb3NpdG9yeS9wcm92aWRlci96b29rZWVwZXItY3VyYXRvci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvbW9kZS9yZXBvc2l0b3J5L2NsdXN0ZXIvem9va2VlcGVyL0N1cmF0b3Jab29rZWVwZXJSZXBvc2l0b3J5LmphdmE=) | `40.47% <0.00%> (-15.27%)` | :arrow_down: |
   | [...e/mode/repository/cluster/etcd/EtcdRepository.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bW9kZS90eXBlL2NsdXN0ZXIvcmVwb3NpdG9yeS9wcm92aWRlci9ldGNkL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL3JlcG9zaXRvcnkvY2x1c3Rlci9ldGNkL0V0Y2RSZXBvc2l0b3J5LmphdmE=) | `55.69% <0.00%> (-9.01%)` | :arrow_down: |
   | [...he/shardingsphere/mode/manager/ContextManager.java](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bW9kZS9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvQ29udGV4dE1hbmFnZXIuamF2YQ==) | `60.64% <0.00%> (-7.80%)` | :arrow_down: |
   | ... and [156 more](https://codecov.io/gh/apache/shardingsphere/pull/21367/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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


[GitHub] [shardingsphere] cunhazera commented on pull request #21367: Adding test to ConnectionSavepointManager

Posted by GitBox <gi...@apache.org>.
cunhazera commented on PR #21367:
URL: https://github.com/apache/shardingsphere/pull/21367#issuecomment-1289508453

   @TeslaCN done


-- 
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


[GitHub] [shardingsphere] cunhazera commented on pull request #21367: Adding test to ConnectionSavepointManager

Posted by GitBox <gi...@apache.org>.
cunhazera commented on PR #21367:
URL: https://github.com/apache/shardingsphere/pull/21367#issuecomment-1284780726

   @terrymanu @TeslaCN could you guys tell me if this PR needs anything else?


-- 
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


[GitHub] [shardingsphere] cunhazera commented on pull request #21367: Adding test to ConnectionSavepointManager

Posted by GitBox <gi...@apache.org>.
cunhazera commented on PR #21367:
URL: https://github.com/apache/shardingsphere/pull/21367#issuecomment-1279409198

   @TeslaCN done. Could you check again?


-- 
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


[GitHub] [shardingsphere] TeslaCN commented on a diff in pull request #21367: Adding test to ConnectionSavepointManager

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on code in PR #21367:
URL: https://github.com/apache/shardingsphere/pull/21367#discussion_r991756141


##########
kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/ConnectionSavepointManagerTest.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.transaction.yaml.swapper;

Review Comment:
   The package should be `org.apache.shardingsphere.transaction`.



##########
kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/ConnectionSavepointManagerTest.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.transaction.yaml.swapper;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.apache.shardingsphere.transaction.ConnectionSavepointManager;
+import org.h2.jdbc.JdbcConnection;
+import org.junit.Test;
+
+public class ConnectionSavepointManagerTest {
+    
+    private final ConnectionSavepointManager connectionSavepointManager = ConnectionSavepointManager.getInstance();
+    
+    @Test
+    public void assertSetSavepoint() throws SQLException {
+        Connection connection = mockConnection();
+        String savingPoint = "SavingPoint";
+        connectionSavepointManager.setSavepoint(connection, savingPoint);
+        verify(connection, times(1)).setSavepoint(savingPoint);
+    }
+    
+    private Connection mockConnection() throws SQLException {
+        Connection result = mock(Connection.class);
+        when(result.unwrap(JdbcConnection.class)).thenReturn(mock(JdbcConnection.class));

Review Comment:
   Why do we need this?



##########
kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/ConnectionSavepointManagerTest.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.transaction.yaml.swapper;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.apache.shardingsphere.transaction.ConnectionSavepointManager;
+import org.h2.jdbc.JdbcConnection;
+import org.junit.Test;
+
+public class ConnectionSavepointManagerTest {
+    
+    private final ConnectionSavepointManager connectionSavepointManager = ConnectionSavepointManager.getInstance();
+    
+    @Test
+    public void assertSetSavepoint() throws SQLException {
+        Connection connection = mockConnection();
+        String savingPoint = "SavingPoint";
+        connectionSavepointManager.setSavepoint(connection, savingPoint);
+        verify(connection, times(1)).setSavepoint(savingPoint);
+    }
+    
+    private Connection mockConnection() throws SQLException {
+        Connection result = mock(Connection.class);
+        when(result.unwrap(JdbcConnection.class)).thenReturn(mock(JdbcConnection.class));
+        return result;
+    }
+    

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.

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

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


[GitHub] [shardingsphere] cunhazera commented on pull request #21367: Adding test to ConnectionSavepointManager

Posted by GitBox <gi...@apache.org>.
cunhazera commented on PR #21367:
URL: https://github.com/apache/shardingsphere/pull/21367#issuecomment-1287346613

   @TeslaCN done


-- 
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


[GitHub] [shardingsphere] TeslaCN merged pull request #21367: Adding test to ConnectionSavepointManager

Posted by GitBox <gi...@apache.org>.
TeslaCN merged PR #21367:
URL: https://github.com/apache/shardingsphere/pull/21367


-- 
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