You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/10/03 05:14:24 UTC

[shardingsphere] branch master updated: [Issue #20382]-Add unit test for SingleXAResourceHolder (#21315)

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 5e0cc20657d [Issue #20382]-Add unit test for SingleXAResourceHolder (#21315)
5e0cc20657d is described below

commit 5e0cc20657d97648a1f7ae7349eef4de5b75fb36
Author: Abhinav Koppula <ab...@gmail.com>
AuthorDate: Mon Oct 3 10:44:16 2022 +0530

    [Issue #20382]-Add unit test for SingleXAResourceHolder (#21315)
---
 .../manager/SingleXAResourceHolderTest.java        | 77 ++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-bitronix/src/test/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/SingleXAResourceHolderTest.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-bitro [...]
new file mode 100644
index 00000000000..3a74369182c
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-bitronix/src/test/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/SingleXAResourceHolderTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.xa.bitronix.manager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertNull;
+
+import bitronix.tm.resource.common.ResourceBean;
+import javax.transaction.xa.XAResource;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class SingleXAResourceHolderTest {
+    
+    @Mock
+    private XAResource xaResource;
+    
+    @Mock
+    private ResourceBean resourceBean;
+    
+    private SingleXAResourceHolder singleXAResourceHolder;
+    
+    @Before
+    public void setUp() {
+        singleXAResourceHolder = new SingleXAResourceHolder(xaResource, resourceBean);
+    }
+    
+    @Test
+    public void assertGetXAResource() {
+        assertThat(singleXAResourceHolder.getXAResource(), is(xaResource));
+    }
+    
+    @Test
+    public void assertGetResourceBean() {
+        assertThat(singleXAResourceHolder.getResourceBean(), is(resourceBean));
+    }
+    
+    @Test
+    public void assertGetXAResourceHolders() {
+        assertNull(singleXAResourceHolder.getXAResourceHolders());
+    }
+    
+    @Test
+    public void assertGetConnectionHandle() {
+        assertNull(singleXAResourceHolder.getConnectionHandle());
+    }
+    
+    @Test
+    public void assertGetLastReleaseDate() {
+        assertNull(singleXAResourceHolder.getLastReleaseDate());
+    }
+    
+    @Test
+    public void assertClose() {
+        singleXAResourceHolder.close();
+    }
+}