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/06/26 20:56:49 UTC

[GitHub] [shardingsphere] tain198127 opened a new pull request, #18618: Fix issue 18446

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

   Fixes #18446 .
   
   Changes proposed in this pull request:
   - 增加了相关的单元测试
   - 修复了一个隐患:在shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java中,第50行,未初始化InstanceContext的情况下获取Resource将报空指针。
   
   
   unit test Converage
   ![image](https://user-images.githubusercontent.com/1415402/175833415-e47ef822-a9c6-4428-b547-2edf6fd2b037.png)
   


-- 
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] tain198127 commented on pull request #18618: Fix issue 18446

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

   ![image](https://user-images.githubusercontent.com/1415402/175874486-4758e1c2-3df6-4765-8345-977365016745.png)
   


-- 
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] terrymanu commented on a diff in pull request #18618: Fix issue 18446

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


##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);

Review Comment:
   Please use static import for `Assert`



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+

Review Comment:
   Please remove unnecessary  blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        ResponseHeader testRespHeader = alterTransactionRuleHandler.execute();
+        Assert.assertNotNull(testRespHeader);
+    }
+
+    /**
+     * Method: getConnectionSession()
+     */
+    @Test
+    public void testGetConnectionSession() {
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+

Review Comment:
   Please remove unnecessary blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        ResponseHeader testRespHeader = alterTransactionRuleHandler.execute();
+        Assert.assertNotNull(testRespHeader);
+    }
+
+    /**
+     * Method: getConnectionSession()
+     */
+    @Test
+    public void testGetConnectionSession() {
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        ConnectionSession session = alterTransactionRuleHandler.getConnectionSession();
+        Assert.assertNotNull(session);

Review Comment:
   Please use static import for `Assert`



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+

Review Comment:
   Please remove unnecessary  blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+

Review Comment:
   Please remove unnecessary  blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        ResponseHeader testRespHeader = alterTransactionRuleHandler.execute();
+        Assert.assertNotNull(testRespHeader);
+    }
+
+    /**
+     * Method: getConnectionSession()
+     */
+    @Test
+    public void testGetConnectionSession() {

Review Comment:
   Please rename `testGetConnectionSession` to `assertGetConnectionSession`



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        ResponseHeader testRespHeader = alterTransactionRuleHandler.execute();
+        Assert.assertNotNull(testRespHeader);
+    }
+
+    /**
+     * Method: getConnectionSession()
+     */
+    @Test
+    public void testGetConnectionSession() {
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+

Review Comment:
   Please remove unnecessary blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        ResponseHeader testRespHeader = alterTransactionRuleHandler.execute();
+        Assert.assertNotNull(testRespHeader);
+    }
+
+    /**
+     * Method: getConnectionSession()
+     */

Review Comment:
   Test method do not need javadoc



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java:
##########
@@ -47,6 +47,8 @@ private void replaceNewRule(final ContextManager contextManager) {
         globalRules.removeIf(each -> each instanceof TransactionRule);
         Map<String, ShardingSphereDatabase> databases = contextManager.getMetaDataContexts().getMetaData().getDatabases();
         TransactionRule transactionRule = new TransactionRule(toBeAlteredRuleConfig, databases);
+        //need add InstanceContext before call getResources

Review Comment:
   please remove unnecessary comment



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */

Review Comment:
   Test method do not need javadoc



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+

Review Comment:
   Please remove unnecessary  blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+

Review Comment:
   Please remove unnecessary  blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        ResponseHeader testRespHeader = alterTransactionRuleHandler.execute();
+        Assert.assertNotNull(testRespHeader);
+    }
+
+    /**
+     * Method: getConnectionSession()
+     */
+    @Test
+    public void testGetConnectionSession() {
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+

Review Comment:
   Please remove unnecessary blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+

Review Comment:
   Please remove unnecessary  blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);
+
+    }
+
+    /**
+     * Method: execute()
+     */
+    @Test
+    public void testExecute() throws Exception {
+        ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ProxyContext.init(contextManager);
+        AlterTransactionRuleStatement statement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        ResponseHeader testRespHeader = alterTransactionRuleHandler.execute();
+        Assert.assertNotNull(testRespHeader);
+    }
+
+    /**
+     * Method: getConnectionSession()
+     */
+    @Test
+    public void testGetConnectionSession() {
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        ConnectionSession session = alterTransactionRuleHandler.getConnectionSession();
+        Assert.assertNotNull(session);
+    }
+
+

Review Comment:
   Please remove unnecessary blank lines



##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {

Review Comment:
   class should be final if not design for extension



-- 
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] tain198127 commented on a diff in pull request #18618: Fix issue 18446

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


##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandler.java:
##########
@@ -47,6 +47,8 @@ private void replaceNewRule(final ContextManager contextManager) {
         globalRules.removeIf(each -> each instanceof TransactionRule);
         Map<String, ShardingSphereDatabase> databases = contextManager.getMetaDataContexts().getMetaData().getDatabases();
         TransactionRule transactionRule = new TransactionRule(toBeAlteredRuleConfig, databases);
+        //need add InstanceContext before call getResources

Review Comment:
   fixed



-- 
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 #18618: Fix issue 18446

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

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/18618?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 [#18618](https://codecov.io/gh/apache/shardingsphere/pull/18618?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8bf2d10) into [master](https://codecov.io/gh/apache/shardingsphere/commit/53973fc6395a5add5ad8c4c3cdbf76494d9ee04e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (53973fc) will **increase** coverage by `0.03%`.
   > The diff coverage is `66.66%`.
   
   > :exclamation: Current head 8bf2d10 differs from pull request most recent head 33fb50e. Consider uploading reports for the commit 33fb50e to get more accurate results
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #18618      +/-   ##
   ============================================
   + Coverage     59.36%   59.40%   +0.03%     
   - Complexity     2257     2258       +1     
   ============================================
     Files          3722     3723       +1     
     Lines         54721    54718       -3     
     Branches       9316     9314       -2     
   ============================================
   + Hits          32487    32505      +18     
   + Misses        19491    19470      -21     
     Partials       2743     2743              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/18618?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...data/database/rule/ShardingSphereRuleMetaData.java](https://codecov.io/gh/apache/shardingsphere/pull/18618/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-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9kYXRhYmFzZS9ydWxlL1NoYXJkaW5nU3BoZXJlUnVsZU1ldGFEYXRhLmphdmE=) | `73.33% <ø> (+20.95%)` | :arrow_up: |
   | [...nt/opengauss/ddl/OpenGaussDropServerStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/18618/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-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvZGlhbGVjdC9zdGF0ZW1lbnQvb3BlbmdhdXNzL2RkbC9PcGVuR2F1c3NEcm9wU2VydmVyU3RhdGVtZW50LmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../common/updatable/AlterTransactionRuleHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/18618/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi91cGRhdGFibGUvQWx0ZXJUcmFuc2FjdGlvblJ1bGVIYW5kbGVyLmphdmE=) | `100.00% <100.00%> (+100.00%)` | :arrow_up: |
   | [...tatement/impl/OpenGaussDDLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/18618/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-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1vcGVuZ2F1c3Mvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NxbC9wYXJzZXIvb3BlbmdhdXNzL3Zpc2l0b3Ivc3RhdGVtZW50L2ltcGwvT3BlbkdhdXNzRERMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `80.38% <100.00%> (+0.05%)` | :arrow_up: |
   | [...d/text/distsql/ral/common/hint/HintSourceType.java](https://codecov.io/gh/apache/shardingsphere/pull/18618/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-c2hhcmRpbmdzcGhlcmUtcHJveHkvc2hhcmRpbmdzcGhlcmUtcHJveHktYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC90ZXh0L2Rpc3RzcWwvcmFsL2NvbW1vbi9oaW50L0hpbnRTb3VyY2VUeXBlLmphdmE=) | `0.00% <0.00%> (-42.86%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/18618?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/18618?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [53973fc...33fb50e](https://codecov.io/gh/apache/shardingsphere/pull/18618?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?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] tain198127 commented on a diff in pull request #18618: Fix issue 18446

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


##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+        ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+        alterTransactionRuleHandler.init(ralStatement, connectionSession);
+        AlterTransactionRuleStatement testAlterStatement = alterTransactionRuleHandler.getSqlStatement();
+        Assert.assertNotNull(testAlterStatement);

Review Comment:
   fixed



-- 
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] terrymanu merged pull request #18618: Fix issue 18446

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


-- 
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] tain198127 commented on a diff in pull request #18618: Fix issue 18446

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


##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTransactionRuleHandlerTest.java:
##########
@@ -0,0 +1,181 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.updatable;
+
+import com.atomikos.jdbc.AtomikosDataSourceBean;
+import org.apache.shardingsphere.distsql.parser.statement.ral.common.updatable.AlterTransactionRuleStatement;
+import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.infra.database.DefaultDatabase;
+import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
+import org.apache.shardingsphere.infra.federation.optimizer.context.OptimizerContext;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.mode.metadata.persist.service.impl.GlobalRulePersistService;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.apache.shardingsphere.transaction.ShardingSphereTransactionManagerEngine;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlterTransactionRuleHandlerTest {
+    ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+
+    @Before
+    public void before() {
+        GlobalRulePersistService globalRulePersistService = mock(GlobalRulePersistService.class, RETURNS_DEEP_STUBS);
+        MetaDataPersistService metaDataPersistService = mock(MetaDataPersistService.class, RETURNS_DEEP_STUBS);
+        when(metaDataPersistService.getGlobalRuleService()).thenReturn(globalRulePersistService);
+        when(contextManager.getInstanceContext()).thenReturn(mock(InstanceContext.class, RETURNS_DEEP_STUBS));
+        ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class, RETURNS_DEEP_STUBS);
+        List<ShardingSphereRule> mockRules = new ArrayList<>();
+        mockRules.add(getLocalTransactionRule());
+        when(shardingSphereRuleMetaData.getRules()).thenReturn(mockRules);
+
+        MetaDataContexts metaDataContexts = new MetaDataContexts(metaDataPersistService, new ShardingSphereMetaData(getDatabases(), shardingSphereRuleMetaData, new ConfigurationProperties(new Properties())), mock(OptimizerContext.class, RETURNS_DEEP_STUBS));
+
+        when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
+
+        ProxyContext.init(contextManager);
+    }
+
+    @After
+    public void after() {
+    }
+
+    private TransactionRule getLocalTransactionRule() {
+        TransactionRule result = new TransactionRule(new TransactionRuleConfiguration("LOCAL", null, new Properties()), Collections.emptyMap());
+        result.setInstanceContext(mock(InstanceContext.class));
+        result.getResources().put(DefaultDatabase.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        return result;
+    }
+
+    private Map<String, ShardingSphereDatabase> getDatabases() {
+        ShardingSphereDatabase result = mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS);
+        when(result.getResource().getDatabaseType()).thenReturn(new H2DatabaseType());
+        when(result.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
+        when(result.getResource().getDataSources()).thenReturn(Collections.singletonMap(DefaultDatabase.LOGIC_NAME, mock(AtomikosDataSourceBean.class, RETURNS_DEEP_STUBS)));
+        return Collections.singletonMap("db", result);
+    }
+
+    /**
+     * Method: update(final ContextManager contextManager, final AlterTransactionRuleStatement sqlStatement)
+     */
+    @Test
+    public void testUpdate() {
+        try {
+            AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+            AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+            when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+
+            ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
+
+            alterTransactionRuleHandler.init(ralStatement, connectionSession);
+
+            alterTransactionRuleHandler.update(contextManager);
+        }
+        catch (Exception ex){
+            Assert.fail();
+        }
+
+    }
+
+    /**
+     * Method: getStatement()
+     */
+    @Test
+    public void testGetStatement() {
+
+        AlterTransactionRuleHandler alterTransactionRuleHandler = new AlterTransactionRuleHandler();
+        AlterTransactionRuleStatement ralStatement = mock(AlterTransactionRuleStatement.class, RETURNS_DEEP_STUBS);
+
+        when(ralStatement.getDefaultType()).thenReturn("LOCAL");
+
+

Review Comment:
   fixed



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