XAShardingTransactionManager implements ShardingTransactionManager { @Override public void close() throws Exception { for (XATransactionDataSource each : cachedDataSources.values()) { each.close(); } cachedDataSources.clear(); xaTransactionManager.close(); }  @Override void init(final DatabaseType databaseType, final Collection<ResourceDataSource> resourceDataSources); @Override TransactionType getTransactionType(); @SneakyThrows(SystemException.class) @Override boolean isInTransaction(); @Override Connection getConnection(final String dataSourceName); @SneakyThrows({SystemException.class, NotSupportedException.class}) @Override void begin(); @SneakyThrows({SystemException.class, RollbackException.class, HeuristicMixedException.class, HeuristicRollbackException.class}) @Override void commit(); @SneakyThrows(SystemException.class) @Override void rollback(); @Override void close();  }
@Test public void assertClose() throws Exception { xaShardingTransactionManager.close(); Map<String, XATransactionDataSource> cachedSingleXADataSourceMap = getCachedDataSources(); verify(xaTransactionManager, times(2)).removeRecoveryResource(anyString(), any(XADataSource.class)); assertThat(cachedSingleXADataSourceMap.size(), is(0)); }