You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2021/10/09 02:09:22 UTC

[shardingsphere] branch master updated: Adding test to ConnectionTransaction.getDistributedTransactionOperationType() (#12909)

This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new d80f318  Adding test to ConnectionTransaction.getDistributedTransactionOperationType() (#12909)
d80f318 is described below

commit d80f318a2b41aaa4ae0dac2c894a91e7cf8069e7
Author: Gabriel Cunha <cu...@gmail.com>
AuthorDate: Fri Oct 8 22:08:44 2021 -0400

    Adding test to ConnectionTransaction.getDistributedTransactionOperationType() (#12909)
    
    * Adding test to ConnectionTransaction
    
    * Making test class final
    
    * Code review
    
    * Adding license to test file
    
    * Removing static import
    
    * Fixing checkstyle
---
 .../transaction/ConnectionTransactionTest.java     | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ConnectionTransactionTest.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ConnectionTransactionTest.java
new file mode 100644
index 0000000..a67c47b
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/ConnectionTransactionTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.transaction;
+
+import org.apache.shardingsphere.infra.database.DefaultSchema;
+import org.apache.shardingsphere.transaction.ConnectionTransaction.DistributedTransactionOperationType;
+import org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
+import org.apache.shardingsphere.transaction.context.TransactionContexts;
+import org.apache.shardingsphere.transaction.rule.TransactionRule;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+public final class ConnectionTransactionTest {
+
+    private ConnectionTransaction connectionTransaction;
+
+    @Before
+    public void init() {
+        Map<String, ShardingSphereTransactionManagerEngine> actualEngines = Collections.singletonMap(DefaultSchema.LOGIC_NAME, new ShardingSphereTransactionManagerEngine());
+        TransactionContexts transactionContexts = new TransactionContexts(actualEngines);
+        connectionTransaction = new ConnectionTransaction(
+                DefaultSchema.LOGIC_NAME,
+                new TransactionRule(new TransactionRuleConfiguration("XA", "Atomikos")),
+                transactionContexts
+        );
+    }
+
+    @Test
+    public void assertDistributedTransactionOperationTypeIgnore() {
+        DistributedTransactionOperationType operationType = connectionTransaction.getDistributedTransactionOperationType(false);
+        assertEquals(operationType, DistributedTransactionOperationType.IGNORE);
+    }
+}