提交 48f71354 编写于 作者: S sluk3r 提交者: Liang Zhang

improved coverage for package of transaction (#3200)

* test case added for method of begin, commit, rollback

* test case added for method of begin, commit, rollback

* copyright added

* final added
上级 45fcc20b
...@@ -147,6 +147,30 @@ public final class XAShardingTransactionManagerTest { ...@@ -147,6 +147,30 @@ public final class XAShardingTransactionManagerTest {
assertThat(cachedSingleXADataSourceMap.size(), is(0)); assertThat(cachedSingleXADataSourceMap.size(), is(0));
} }
@Test
public void assertBegin() throws Exception {
setCachedSingleXADataSourceMap("ds1");
xaShardingTransactionManager.begin();
verify(xaTransactionManager).getTransactionManager();
verify(xaTransactionManager.getTransactionManager()).begin();
}
@Test
public void assertCommit() throws Exception {
setCachedSingleXADataSourceMap("ds1");
xaShardingTransactionManager.commit();
verify(xaTransactionManager).getTransactionManager();
verify(xaTransactionManager.getTransactionManager()).commit();
}
@Test
public void assertRollback() throws Exception {
setCachedSingleXADataSourceMap("ds1");
xaShardingTransactionManager.rollback();
verify(xaTransactionManager).getTransactionManager();
verify(xaTransactionManager.getTransactionManager()).rollback();
}
@SneakyThrows @SneakyThrows
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Map<String, SingleXADataSource> getCachedSingleXADataSourceMap() { private Map<String, SingleXADataSource> getCachedSingleXADataSourceMap() {
......
/*
* 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.core;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public final class ResourceIDGeneratorTest {
@Test
public void assertNextIdProperly() {
assertTrue(ResourceIDGenerator.getInstance().nextId().contains("resource"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册