This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 a9efcc5 Add test case for TransactionStatus (#7516)
a9efcc5 is described below
commit a9efcc5c0603aee50df2c1b20db6169260d81523
Author: Serendipity <[email protected]>
AuthorDate: Fri Sep 18 23:51:06 2020 +0800
Add test case for TransactionStatus (#7516)
Change the package name from trnasaction to transaction
---
.../BackendTransactionManagerTest.java | 10 ++---
.../jdbc/transaction/TransactionStatusTest.java | 50 ++++++++++++++++++++++
2 files changed, 53 insertions(+), 7 deletions(-)
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/trnasaction/BackendTransactionManagerTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java
similarity index 95%
rename from
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/trnasaction/BackendTransactionManagerTest.java
rename to
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java
index 83d8158..5d3e627 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/trnasaction/BackendTransactionManagerTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/BackendTransactionManagerTest.java
@@ -15,13 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.proxy.backend.communication.jdbc.trnasaction;
+package org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction;
+import java.lang.reflect.Field;
+import java.sql.SQLException;
import lombok.SneakyThrows;
import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
-import
org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.BackendTransactionManager;
-import
org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.LocalTransactionManager;
-import
org.apache.shardingsphere.proxy.backend.communication.jdbc.transaction.TransactionStatus;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.transaction.ShardingTransactionManagerEngine;
import org.apache.shardingsphere.transaction.context.TransactionContexts;
@@ -33,9 +32,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import java.lang.reflect.Field;
-import java.sql.SQLException;
-
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/TransactionStatusTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/TransactionStatusTest.java
new file mode 100644
index 0000000..581670d
--- /dev/null
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/transaction/TransactionStatusTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.communication.jdbc.transaction;
+
+import org.apache.shardingsphere.transaction.core.TransactionType;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public final class TransactionStatusTest {
+
+ private TransactionStatus transactionStatus;
+
+ @Before
+ public void setUp() {
+ transactionStatus = new TransactionStatus(TransactionType.XA);
+ }
+
+ @Test
+ public void assertSetTransactionType() {
+ transactionStatus.setTransactionType(TransactionType.BASE);
+ TransactionType actual = transactionStatus.getTransactionType();
+ assertThat(actual, is(TransactionType.BASE));
+ }
+
+ @Test
+ public void assertSetInTransaction() {
+ transactionStatus.setInTransaction(true);
+ boolean actual = transactionStatus.isInConnectionHeldTransaction();
+ assertTrue(actual);
+ }
+}