Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
3fdee3f2
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
3fdee3f2
编写于
10月 04, 2020
作者:
L
Liang Zhang
提交者:
GitHub
10月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove useless @SneakyThrows (#7697)
上级
f349cef9
变更
85
隐藏空白更改
内联
并排
Showing
85 changed file
with
218 addition
and
295 deletion
+218
-295
shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/fixture/BinaryStatementRegistryUtil.java
...and/query/binary/fixture/BinaryStatementRegistryUtil.java
+1
-1
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
...shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
+3
-2
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
...shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
+0
-2
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/DecoratedEncryptColumnsMergedResultTest.java
...rge/dal/impl/DecoratedEncryptColumnsMergedResultTest.java
+1
-3
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/impl/EncryptColumnsMergedResultTest.java
...ncrypt/merge/dql/impl/EncryptColumnsMergedResultTest.java
+11
-19
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
...rding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
+1
-1
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
...g/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
+4
-6
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/RuleSchemaMetaDataYamlSwapperTest.java
.../core/yaml/swapper/RuleSchemaMetaDataYamlSwapperTest.java
+5
-4
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
...ardingsphere/governance/core/config/ConfigCenterTest.java
+3
-1
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/ConfigurationListenerManagerTest.java
...ore/config/listener/ConfigurationListenerManagerTest.java
+2
-2
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListenerTest.java
...nance/core/config/listener/SchemaChangedListenerTest.java
+3
-1
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java
...vernance/context/schema/GovernanceSchemaContextsTest.java
+4
-8
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/transaction/GovernanceTransactionContextsTest.java
...ontext/transaction/GovernanceTransactionContextsTest.java
+2
-5
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-facade/src/test/java/org/apache/shardingsphere/governance/core/facade/util/FieldUtil.java
...shardingsphere/governance/core/facade/util/FieldUtil.java
+1
-1
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-registry/src/test/java/org/apache/shardingsphere/governance/core/registry/util/FieldUtil.java
...ardingsphere/governance/core/registry/util/FieldUtil.java
+1
-1
shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-etcd/src/test/java/org/apache/shardingsphere/governance/repository/etcd/EtcdRepositoryTest.java
...sphere/governance/repository/etcd/EtcdRepositoryTest.java
+4
-8
shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-nacos/src/test/java/org/apache/shardingsphere/governance/repository/nacos/NacosRepositoryTest.java
...here/governance/repository/nacos/NacosRepositoryTest.java
+3
-6
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/constructor/ShardingSphereYamlConstructor.java
...aml/engine/constructor/ShardingSphereYamlConstructor.java
+0
-2
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/representer/ShardingSphereYamlRepresenter.java
...aml/engine/representer/ShardingSphereYamlRepresenter.java
+0
-2
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
...nfra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
+2
-2
shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/queryresult/MemoryQueryResult.java
...tor/sql/resourced/jdbc/queryresult/MemoryQueryResult.java
+2
-1
shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/ExecutorExceptionHandlerTest.java
...cutor/sql/jdbc/executor/ExecutorExceptionHandlerTest.java
+1
-3
shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/impl/DefaultSQLExecutorCallbackTest.java
...ql/jdbc/executor/impl/DefaultSQLExecutorCallbackTest.java
+1
-3
shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/queryresult/MemoryQueryResultTest.java
.../executor/sql/jdbc/queryresult/MemoryQueryResultTest.java
+3
-5
shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutorTest.java
...e/infra/executor/sql/raw/execute/RawJDBCExecutorTest.java
+5
-11
shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/hook/SPIRoutingHookTest.java
...e/shardingsphere/infra/route/hook/SPIRoutingHookTest.java
+1
-1
shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/cases/assertion/IntegrateTestCasesLoader.java
...here/dbtest/cases/assertion/IntegrateTestCasesLoader.java
+2
-2
shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/util/IntegrateTestParameters.java
...ingsphere/dbtest/engine/util/IntegrateTestParameters.java
+1
-1
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootPrimaryReplicaReplicationTest.java
...pe/GovernanceSpringBootPrimaryReplicaReplicationTest.java
+1
-3
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
...ernance/type/GovernanceSpringBootRegistryEncryptTest.java
+3
-1
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryPrimaryReplicaReplicationTest.java
...nanceSpringBootRegistryPrimaryReplicaReplicationTest.java
+4
-3
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
...rnance/type/GovernanceSpringBootRegistryShardingTest.java
+3
-1
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/test/java/org/apache/shardingsphere/spring/boot/datasource/DataSourceMapSetterTest.java
...phere/spring/boot/datasource/DataSourceMapSetterTest.java
+3
-5
shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/BaseOpenTracingHookTest.java
...ere/tracing/opentracing/hook/BaseOpenTracingHookTest.java
+1
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineFactoryTest.java
...nication/jdbc/DatabaseCommunicationEngineFactoryTest.java
+1
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
.../communication/jdbc/connection/BackendConnectionTest.java
+22
-31
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MethodInvocationTest.java
...d/communication/jdbc/connection/MethodInvocationTest.java
+1
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java
...impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java
+2
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java
...PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java
+2
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandlerTest.java
...proxy/backend/text/admin/BroadcastBackendHandlerTest.java
+1
-2
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DALBackendHandlerFactoryTest.java
...roxy/backend/text/admin/DALBackendHandlerFactoryTest.java
+2
-1
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
...phere/proxy/backend/text/admin/RDLBackendHandlerTest.java
+1
-2
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowDatabasesBackendHandlerTest.java
...y/backend/text/admin/ShowDatabasesBackendHandlerTest.java
+1
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandlerTest.java
...roxy/backend/text/admin/ShowTablesBackendHandlerTest.java
+1
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
...xt/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
+1
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
...end/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
+1
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
...ckend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
+1
-3
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java
...ext/transaction/TransactionBackendHandlerFactoryTest.java
+3
-2
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/AbstractBootstrapInitializerTest.java
...ere/proxy/init/impl/AbstractBootstrapInitializerTest.java
+2
-3
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/GovernanceBootstrapInitializerTest.java
...e/proxy/init/impl/GovernanceBootstrapInitializerTest.java
+3
-2
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/StandardBootstrapInitializerTest.java
...ere/proxy/init/impl/StandardBootstrapInitializerTest.java
+1
-3
shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameterMerger.java
...here/proxy/config/yaml/YamlDataSourceParameterMerger.java
+2
-2
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
...y/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
+2
-3
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
...ostgresql/command/PostgreSQLCommandExecuteEngineTest.java
+3
-3
shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java
...dingsphere/scaling/core/datasource/DataSourceFactory.java
+2
-1
shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java
...e/scaling/core/execute/executor/dumper/DumperFactory.java
+2
-4
shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/ImporterFactory.java
...aling/core/execute/executor/importer/ImporterFactory.java
+1
-1
shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/ScalingJobControllerTest.java
...shardingsphere/scaling/core/ScalingJobControllerTest.java
+1
-3
shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/channel/DistributionChannelTest.java
...ore/execute/executor/channel/DistributionChannelTest.java
+4
-5
shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java
...e/execute/executor/importer/AbstractJDBCImporterTest.java
+1
-3
shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractSqlBuilderTest.java
...ore/execute/executor/importer/AbstractSqlBuilderTest.java
+7
-9
shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLJdbcDumperTest.java
...che/shardingsphere/scaling/mysql/MySQLJdbcDumperTest.java
+2
-4
shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLPositionManagerTest.java
...hardingsphere/scaling/mysql/MySQLPositionManagerTest.java
+1
-3
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataSourceCheckerTest.java
...e/scaling/postgresql/PostgreSQLDataSourceCheckerTest.java
+1
-3
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLJdbcDumperTest.java
...ngsphere/scaling/postgresql/PostgreSQLJdbcDumperTest.java
+1
-2
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLPositionManagerTest.java
...ere/scaling/postgresql/PostgreSQLPositionManagerTest.java
+4
-8
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLWalDumperTest.java
...ingsphere/scaling/postgresql/PostgreSQLWalDumperTest.java
+1
-3
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/wal/LogicalReplicationTest.java
...sphere/scaling/postgresql/wal/LogicalReplicationTest.java
+2
-4
shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/ParseTreeVisitorFactory.java
...here/sql/parser/core/visitor/ParseTreeVisitorFactory.java
+1
-1
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SafeNumberOperationUtils.java
.../sql/parser/sql/common/util/SafeNumberOperationUtils.java
+1
-1
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-atomikos/src/main/java/org/apache/shardingsphere/transaction/xa/atomikos/manager/AtomikosTransactionManager.java
...ction/xa/atomikos/manager/AtomikosTransactionManager.java
+3
-1
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixRecoveryResource.java
...saction/xa/bitronix/manager/BitronixRecoveryResource.java
+3
-2
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManager.java
...ion/xa/bitronix/manager/BitronixXATransactionManager.java
+5
-3
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/test/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManagerTest.java
...xa/bitronix/manager/BitronixXATransactionManagerTest.java
+5
-5
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingTransactionManager.java
...ngsphere/transaction/xa/XAShardingTransactionManager.java
+7
-4
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapper.java
...tion/xa/jta/connection/dialect/H2XAConnectionWrapper.java
+4
-3
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapper.java
...xa/jta/connection/dialect/MariaDBXAConnectionWrapper.java
+3
-2
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapper.java
...n/xa/jta/connection/dialect/MySQLXAConnectionWrapper.java
+3
-2
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapper.java
.../xa/jta/connection/dialect/OracleXAConnectionWrapper.java
+2
-1
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapper.java
...jta/connection/dialect/PostgreSQLXAConnectionWrapper.java
+2
-1
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManager.java
...ion/xa/narayana/manager/NarayanaXATransactionManager.java
+3
-1
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/test/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManagerTest.java
...xa/narayana/manager/NarayanaXATransactionManagerTest.java
+4
-7
shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/main/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManager.java
...tion/base/seata/at/SeataATShardingTransactionManager.java
+4
-3
shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManagerTest.java
.../base/seata/at/SeataATShardingTransactionManagerTest.java
+2
-2
shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/fixture/MockSeataServer.java
...re/transaction/base/seata/at/fixture/MockSeataServer.java
+1
-2
未找到文件。
shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/query/binary/fixture/BinaryStatementRegistryUtil.java
浏览文件 @
3fdee3f2
...
...
@@ -32,7 +32,7 @@ public final class BinaryStatementRegistryUtil {
/**
* Reset {@code MySQLBinaryStatementRegistry}.
*/
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
static
void
reset
()
{
Field
statementIdAssignerField
=
MySQLBinaryStatementRegistry
.
class
.
getDeclaredField
(
"statementIdAssigner"
);
statementIdAssignerField
.
setAccessible
(
true
);
...
...
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
浏览文件 @
3fdee3f2
...
...
@@ -30,6 +30,7 @@ import javax.crypto.Cipher;
import
javax.crypto.NoSuchPaddingException
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.nio.charset.StandardCharsets
;
import
java.security.GeneralSecurityException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Arrays
;
...
...
@@ -58,7 +59,7 @@ public final class AESEncryptAlgorithm implements EncryptAlgorithm {
return
Arrays
.
copyOf
(
DigestUtils
.
sha1
(
props
.
getProperty
(
AES_KEY
)),
16
);
}
@SneakyThrows
@SneakyThrows
(
GeneralSecurityException
.
class
)
@Override
public
String
encrypt
(
final
Object
plaintext
)
{
if
(
null
==
plaintext
)
{
...
...
@@ -68,7 +69,7 @@ public final class AESEncryptAlgorithm implements EncryptAlgorithm {
return
Base64
.
encodeBase64String
(
result
);
}
@SneakyThrows
@SneakyThrows
(
GeneralSecurityException
.
class
)
@Override
public
Object
decrypt
(
final
String
ciphertext
)
{
if
(
null
==
ciphertext
)
{
...
...
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/algorithm/RC4EncryptAlgorithm.java
浏览文件 @
3fdee3f2
...
...
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.encrypt.algorithm;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.SneakyThrows
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.binary.StringUtils
;
import
org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
;
...
...
@@ -49,7 +48,6 @@ public final class RC4EncryptAlgorithm implements EncryptAlgorithm {
private
Properties
props
=
new
Properties
();
@Override
@SneakyThrows
public
void
init
()
{
reset
();
setKey
(
StringUtils
.
getBytesUtf8
(
props
.
getProperty
(
RC4_KEY
)));
...
...
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/impl/DecoratedEncryptColumnsMergedResultTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.encrypt.merge.dal.impl
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.encrypt.merge.dal.impl.fixture.TestStatementContext
;
import
org.apache.shardingsphere.infra.merge.result.MergedResult
;
import
org.apache.shardingsphere.sql.parser.binder.metadata.schema.SchemaMetaData
;
...
...
@@ -41,8 +40,7 @@ import static org.mockito.Mockito.when;
public
final
class
DecoratedEncryptColumnsMergedResultTest
{
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertNewValidResult
()
{
public
void
assertNewValidResult
()
throws
SQLException
{
TestStatementContext
testStatementContext
=
mock
(
TestStatementContext
.
class
);
SimpleTableSegment
simpleTableSegment
=
mock
(
SimpleTableSegment
.
class
);
IdentifierValue
identifierValue
=
mock
(
IdentifierValue
.
class
);
...
...
shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-merge/src/test/java/org/apache/shardingsphere/encrypt/merge/dql/impl/EncryptColumnsMergedResultTest.java
浏览文件 @
3fdee3f2
...
...
@@ -18,7 +18,6 @@
package
org.apache.shardingsphere.encrypt.merge.dql.impl
;
import
com.google.common.collect.Lists
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.encrypt.merge.dql.fixture.EncryptColumnsMergedResultFixture
;
import
org.apache.shardingsphere.encrypt.merge.dql.fixture.TableAvailableAndSqlStatementContextFixture
;
import
org.apache.shardingsphere.encrypt.metadata.EncryptColumnMetaData
;
...
...
@@ -34,6 +33,7 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
java.sql.SQLException
;
import
java.sql.SQLFeatureNotSupportedException
;
import
java.util.Calendar
;
import
java.util.Collections
;
...
...
@@ -61,10 +61,9 @@ public final class EncryptColumnsMergedResultTest {
private
EncryptColumnsMergedResultFixture
encryptColumnsMergedResultFixture
;
@SneakyThrows
@Before
public
void
setUp
()
{
Map
<
String
,
ColumnMetaData
>
columns
=
new
HashMap
<>();
Map
<
String
,
ColumnMetaData
>
columns
=
new
HashMap
<>(
1
,
1
);
EncryptColumnMetaData
encryptColumnMetaData
=
new
EncryptColumnMetaData
(
"order"
,
1
,
"Integer"
,
false
,
"status"
,
"status"
,
"status"
);
columns
.
put
(
""
,
encryptColumnMetaData
);
SimpleTableSegment
simpleTableSegment
=
mock
(
SimpleTableSegment
.
class
);
...
...
@@ -80,9 +79,8 @@ public final class EncryptColumnsMergedResultTest {
encryptColumnsMergedResultFixture
=
spy
(
new
EncryptColumnsMergedResultFixture
(
tableAvailableAndSqlStatementContextFixture
,
schemaMetaData
));
}
@SneakyThrows
@Test
public
void
assertHasNextWithEmptyColumnMetaData
()
{
public
void
assertHasNextWithEmptyColumnMetaData
()
throws
SQLException
{
when
(
schemaMetaData
.
get
(
anyString
())).
thenReturn
(
tableMetaData
);
when
(
tableMetaData
.
getColumns
()).
thenReturn
(
Collections
.
emptyMap
());
EncryptColumnsMergedResultFixture
encryptColumnsMergedResultFixture
=
spy
(
new
EncryptColumnsMergedResultFixture
(
tableAvailableAndSqlStatementContextFixture
,
schemaMetaData
));
...
...
@@ -90,18 +88,16 @@ public final class EncryptColumnsMergedResultTest {
assertThat
(
encryptColumnsMergedResultFixture
.
next
(),
is
(
true
));
}
@SneakyThrows
@Test
public
void
assertWithoutHasNext
()
{
public
void
assertWithoutHasNext
()
throws
SQLException
{
EncryptColumnsMergedResultFixture
encryptColumnsMergedResultFixture
=
spy
(
new
EncryptColumnsMergedResultFixture
(
tableAvailableAndSqlStatementContextFixture
,
schemaMetaData
));
when
(
encryptColumnsMergedResultFixture
.
nextValue
()).
thenReturn
(
false
);
assertThat
(
encryptColumnsMergedResultFixture
.
next
(),
is
(
false
));
}
@Test
@SneakyThrows
public
void
assertContainerColumnName
()
{
Map
<
String
,
ColumnMetaData
>
columns
=
new
HashMap
<>();
public
void
assertContainerColumnName
()
throws
SQLException
{
Map
<
String
,
ColumnMetaData
>
columns
=
new
HashMap
<>(
1
,
1
);
EncryptColumnMetaData
encryptColumnMetaData
=
new
EncryptColumnMetaData
(
"order"
,
1
,
"Integer"
,
false
,
"status"
,
"status"
,
"status"
);
columns
.
put
(
""
,
encryptColumnMetaData
);
when
(
schemaMetaData
.
get
(
anyString
())).
thenReturn
(
tableMetaData
);
...
...
@@ -112,10 +108,9 @@ public final class EncryptColumnsMergedResultTest {
assertThat
(
encryptColumnsMergedResultFixture
.
next
(),
is
(
true
));
}
@SneakyThrows
@Test
public
void
assertGetValueWithColumnIndex
()
{
Map
<
String
,
ColumnMetaData
>
columns
=
new
HashMap
<>();
public
void
assertGetValueWithColumnIndex
()
throws
SQLException
{
Map
<
String
,
ColumnMetaData
>
columns
=
new
HashMap
<>(
1
,
1
);
EncryptColumnMetaData
encryptColumnMetaData
=
new
EncryptColumnMetaData
(
"order"
,
1
,
"Integer"
,
false
,
"status"
,
"status"
,
"status"
);
columns
.
put
(
"key"
,
encryptColumnMetaData
);
when
(
schemaMetaData
.
get
(
anyString
())).
thenReturn
(
tableMetaData
);
...
...
@@ -124,22 +119,19 @@ public final class EncryptColumnsMergedResultTest {
assertThat
(
encryptColumnsMergedResultFixture
.
getValue
(
1
,
String
.
class
),
is
(
"key"
));
}
@SneakyThrows
@Test
public
void
assertGetValueWithOutColumnIndex
()
{
public
void
assertGetValueWithOutColumnIndex
()
throws
SQLException
{
when
(
encryptColumnsMergedResultFixture
.
getOriginalValue
(
2
,
String
.
class
)).
thenReturn
(
"status"
);
assertThat
(
encryptColumnsMergedResultFixture
.
getValue
(
2
,
String
.
class
),
is
(
"status"
));
}
@SneakyThrows
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
assertGetCalendarValue
()
{
public
void
assertGetCalendarValue
()
throws
SQLException
{
encryptColumnsMergedResultFixture
.
getCalendarValue
(
1
,
String
.
class
,
Calendar
.
getInstance
());
}
@SneakyThrows
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
assertGetInputStream
()
{
public
void
assertGetInputStream
()
throws
SQLException
{
encryptColumnsMergedResultFixture
.
getInputStream
(
1
,
"whateverString"
);
}
}
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithm.java
浏览文件 @
3fdee3f2
...
...
@@ -135,7 +135,7 @@ public final class SnowflakeKeyGenerateAlgorithm implements KeyGenerateAlgorithm
return
((
currentMilliseconds
-
EPOCH
)
<<
TIMESTAMP_LEFT_SHIFT_BITS
)
|
(
workerId
<<
WORKER_ID_LEFT_SHIFT_BITS
)
|
sequence
;
}
@SneakyThrows
@SneakyThrows
(
InterruptedException
.
class
)
private
boolean
waitTolerateTimeDifferenceIfNeed
(
final
long
currentMilliseconds
)
{
if
(
lastMilliseconds
<=
currentMilliseconds
)
{
return
false
;
...
...
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/algorithm/keygen/SnowflakeKeyGenerateAlgorithmTest.java
浏览文件 @
3fdee3f2
...
...
@@ -161,14 +161,14 @@ public final class SnowflakeKeyGenerateAlgorithmTest {
assertThat
(
actual
,
is
(
expected
));
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
void
setSequence
(
final
SnowflakeKeyGenerateAlgorithm
keyGenerateAlgorithm
,
final
Number
value
)
{
Field
sequence
=
SnowflakeKeyGenerateAlgorithm
.
class
.
getDeclaredField
(
"sequence"
);
sequence
.
setAccessible
(
true
);
sequence
.
set
(
keyGenerateAlgorithm
,
value
);
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
void
setLastMilliseconds
(
final
SnowflakeKeyGenerateAlgorithm
keyGenerateAlgorithm
,
final
Number
value
)
{
Field
lastMilliseconds
=
SnowflakeKeyGenerateAlgorithm
.
class
.
getDeclaredField
(
"lastMilliseconds"
);
lastMilliseconds
.
setAccessible
(
true
);
...
...
@@ -216,8 +216,7 @@ public final class SnowflakeKeyGenerateAlgorithmTest {
}
@Test
@SneakyThrows
public
void
assertSetWorkerIdSuccess
()
{
public
void
assertSetWorkerIdSuccess
()
throws
NoSuchFieldException
,
IllegalAccessException
{
SnowflakeKeyGenerateAlgorithm
keyGenerateAlgorithm
=
new
SnowflakeKeyGenerateAlgorithm
();
Properties
props
=
new
Properties
();
props
.
setProperty
(
"worker-id"
,
String
.
valueOf
(
1L
));
...
...
@@ -229,8 +228,7 @@ public final class SnowflakeKeyGenerateAlgorithmTest {
}
@Test
@SneakyThrows
public
void
assertSetMaxTolerateTimeDifferenceMilliseconds
()
{
public
void
assertSetMaxTolerateTimeDifferenceMilliseconds
()
throws
NoSuchFieldException
,
IllegalAccessException
{
SnowflakeKeyGenerateAlgorithm
keyGenerateAlgorithm
=
new
SnowflakeKeyGenerateAlgorithm
();
Properties
props
=
new
Properties
();
props
.
setProperty
(
"max-tolerate-time-difference-milliseconds"
,
String
.
valueOf
(
1
));
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/RuleSchemaMetaDataYamlSwapperTest.java
浏览文件 @
3fdee3f2
...
...
@@ -23,9 +23,10 @@ import org.apache.shardingsphere.infra.metadata.schema.RuleSchemaMetaData;
import
org.apache.shardingsphere.infra.yaml.engine.YamlEngine
;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.stream.Collectors
;
...
...
@@ -48,7 +49,7 @@ public final class RuleSchemaMetaDataYamlSwapperTest {
assertThat
(
yamlRuleSchemaMetaData
.
getConfiguredSchemaMetaData
().
getTables
().
get
(
"t_order"
).
getIndexes
().
keySet
(),
is
(
Collections
.
singleton
(
"primary"
)));
assertThat
(
yamlRuleSchemaMetaData
.
getConfiguredSchemaMetaData
().
getTables
().
get
(
"t_order"
).
getColumns
().
keySet
(),
is
(
Collections
.
singleton
(
"id"
)));
assertThat
(
yamlRuleSchemaMetaData
.
getUnconfiguredSchemaMetaDataMap
().
keySet
(),
is
(
Collections
.
singleton
(
"ds_0"
)));
assertThat
(
yamlRuleSchemaMetaData
.
getUnconfiguredSchemaMetaDataMap
().
get
(
"ds_0"
),
is
(
Arrays
.
as
List
(
"t_user"
)));
assertThat
(
yamlRuleSchemaMetaData
.
getUnconfiguredSchemaMetaDataMap
().
get
(
"ds_0"
),
is
(
Collections
.
singleton
List
(
"t_user"
)));
}
@Test
...
...
@@ -63,10 +64,10 @@ public final class RuleSchemaMetaDataYamlSwapperTest {
assertThat
(
ruleSchemaMetaData
.
getConfiguredSchemaMetaData
().
getAllColumnNames
(
"t_order"
).
size
(),
is
(
1
));
assertThat
(
ruleSchemaMetaData
.
getConfiguredSchemaMetaData
().
get
(
"t_order"
).
getColumns
().
keySet
(),
is
(
Collections
.
singleton
(
"id"
)));
assertThat
(
ruleSchemaMetaData
.
getUnconfiguredSchemaMetaDataMap
().
keySet
(),
is
(
Collections
.
singleton
(
"ds_0"
)));
assertThat
(
ruleSchemaMetaData
.
getUnconfiguredSchemaMetaDataMap
().
get
(
"ds_0"
),
is
(
Arrays
.
as
List
(
"t_user"
)));
assertThat
(
ruleSchemaMetaData
.
getUnconfiguredSchemaMetaDataMap
().
get
(
"ds_0"
),
is
(
Collections
.
singleton
List
(
"t_user"
)));
}
@SneakyThrows
@SneakyThrows
({
URISyntaxException
.
class
,
IOException
.
class
})
private
String
readYAML
(
final
String
yamlFile
)
{
return
Files
.
readAllLines
(
Paths
.
get
(
ClassLoader
.
getSystemResource
(
yamlFile
).
toURI
()))
.
stream
().
filter
(
each
->
!
each
.
startsWith
(
"#"
)).
map
(
each
->
each
+
System
.
lineSeparator
()).
collect
(
Collectors
.
joining
());
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/ConfigCenterTest.java
浏览文件 @
3fdee3f2
...
...
@@ -48,6 +48,8 @@ import org.mockito.Mock;
import
org.mockito.junit.MockitoJUnitRunner
;
import
javax.sql.DataSource
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.Arrays
;
...
...
@@ -431,7 +433,7 @@ public final class ConfigCenterTest {
assertThat
(
actual
.
getProps
().
get
(
"connectionInitSqls"
),
is
(
expected
.
getProps
().
get
(
"connectionInitSqls"
)));
}
@SneakyThrows
@SneakyThrows
({
IOException
.
class
,
URISyntaxException
.
class
})
private
String
readYAML
(
final
String
yamlFile
)
{
return
Files
.
readAllLines
(
Paths
.
get
(
ClassLoader
.
getSystemResource
(
yamlFile
).
toURI
()))
.
stream
().
filter
(
each
->
!
each
.
startsWith
(
"#"
)).
map
(
each
->
each
+
System
.
lineSeparator
()).
collect
(
Collectors
.
joining
());
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/ConfigurationListenerManagerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -55,8 +55,8 @@ public final class ConfigurationListenerManagerTest {
verify
(
propertiesChangedListener
).
watch
(
ChangedType
.
UPDATED
);
verify
(
authenticationChangedListener
).
watch
(
ChangedType
.
UPDATED
);
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
static
void
setField
(
final
Object
target
,
final
String
fieldName
,
final
Object
fieldValue
)
{
Field
field
=
target
.
getClass
().
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-config/src/test/java/org/apache/shardingsphere/governance/core/config/listener/SchemaChangedListenerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -38,6 +38,8 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.Arrays
;
...
...
@@ -258,7 +260,7 @@ public final class SchemaChangedListenerTest {
assertTrue
(((
MetaDataChangedEvent
)
actual
.
get
()).
getRuleSchemaMetaData
().
getConfiguredSchemaMetaData
().
getAllTableNames
().
contains
(
"t_order"
));
}
@SneakyThrows
@SneakyThrows
({
IOException
.
class
,
URISyntaxException
.
class
})
private
String
readYAML
(
final
String
yamlFile
)
{
return
Files
.
readAllLines
(
Paths
.
get
(
ClassLoader
.
getSystemResource
(
yamlFile
).
toURI
())).
stream
().
map
(
each
->
each
+
System
.
lineSeparator
()).
collect
(
Collectors
.
joining
());
}
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.governance.context.schema
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.governance.core.config.ConfigCenter
;
import
org.apache.shardingsphere.governance.core.event.model.auth.AuthenticationChangedEvent
;
import
org.apache.shardingsphere.governance.core.event.model.datasource.DataSourceChangedEvent
;
...
...
@@ -52,6 +51,7 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
java.sql.SQLException
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
...
...
@@ -110,7 +110,6 @@ public final class GovernanceSchemaContextsTest {
new
StandardSchemaContexts
(
createSchemas
(),
mock
(
ShardingSphereSQLParserEngine
.
class
),
mock
(
ExecutorKernel
.
class
),
authentication
,
props
,
databaseType
),
governanceFacade
);
}
@SneakyThrows
private
Map
<
String
,
ShardingSphereSchema
>
createSchemas
()
{
when
(
schema
.
getName
()).
thenReturn
(
"schema"
);
when
(
schema
.
getMetaData
()).
thenReturn
(
mock
(
ShardingSphereMetaData
.
class
));
...
...
@@ -149,8 +148,7 @@ public final class GovernanceSchemaContextsTest {
}
@Test
@SneakyThrows
public
void
assertSchemaAdd
()
{
public
void
assertSchemaAdd
()
throws
SQLException
{
SchemaAddedEvent
event
=
new
SchemaAddedEvent
(
"schema_add"
,
new
HashMap
<>(),
new
LinkedList
<>());
when
(
configCenter
.
loadDataSourceConfigurations
(
"schema_add"
)).
thenReturn
(
getDataSourceConfigurations
());
governanceSchemaContexts
.
renew
(
event
);
...
...
@@ -207,8 +205,7 @@ public final class GovernanceSchemaContextsTest {
}
@Test
@SneakyThrows
public
void
assertRuleConfigurationsChanged
()
{
public
void
assertRuleConfigurationsChanged
()
throws
SQLException
{
assertThat
(
governanceSchemaContexts
.
getSchemas
().
get
(
"schema"
),
is
(
schema
));
RuleConfigurationsChangedEvent
event
=
new
RuleConfigurationsChangedEvent
(
"schema"
,
new
LinkedList
<>());
governanceSchemaContexts
.
renew
(
event
);
...
...
@@ -223,8 +220,7 @@ public final class GovernanceSchemaContextsTest {
}
@Test
@SneakyThrows
public
void
assertDataSourceChanged
()
{
public
void
assertDataSourceChanged
()
throws
SQLException
{
DataSourceChangedEvent
event
=
new
DataSourceChangedEvent
(
"schema"
,
getChangedDataSourceConfigurations
());
governanceSchemaContexts
.
renew
(
event
);
assertTrue
(
governanceSchemaContexts
.
getSchemas
().
get
(
"schema"
).
getDataSources
().
containsKey
(
"ds_2"
));
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/transaction/GovernanceTransactionContextsTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.governance.context.transaction
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.governance.core.event.model.datasource.DataSourceChangeCompletedEvent
;
import
org.apache.shardingsphere.transaction.ShardingTransactionManagerEngine
;
import
org.apache.shardingsphere.transaction.context.TransactionContexts
;
...
...
@@ -61,16 +60,14 @@ public final class GovernanceTransactionContextsTest {
}
@Test
@SneakyThrows
public
void
assertClose
()
{
public
void
assertClose
()
throws
Exception
{
GovernanceTransactionContexts
actual
=
new
GovernanceTransactionContexts
(
transactionContexts
);
actual
.
close
();
verify
(
transactionContexts
).
close
();
}
@Test
@SneakyThrows
public
void
assertRenew
()
{
public
void
assertRenew
()
throws
Exception
{
when
(
event
.
getSchemaName
()).
thenReturn
(
"name"
);
when
(
transactionContexts
.
getEngines
()).
thenReturn
(
engineMap
);
when
(
engineMap
.
remove
(
eq
(
"name"
))).
thenReturn
(
engine
);
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-facade/src/test/java/org/apache/shardingsphere/governance/core/facade/util/FieldUtil.java
浏览文件 @
3fdee3f2
...
...
@@ -36,7 +36,7 @@ public final class FieldUtil {
* @param fieldName field name to be settled
* @param fieldValue field value to be settled
*/
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
static
void
setField
(
final
Object
target
,
final
String
fieldName
,
final
Object
fieldValue
)
{
Field
field
=
target
.
getClass
().
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-registry/src/test/java/org/apache/shardingsphere/governance/core/registry/util/FieldUtil.java
浏览文件 @
3fdee3f2
...
...
@@ -36,7 +36,7 @@ public final class FieldUtil {
* @param fieldName field name to be settled
* @param fieldValue field value to be settled
*/
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
static
void
setField
(
final
Object
target
,
final
String
fieldName
,
final
Object
fieldValue
)
{
Field
field
=
target
.
getClass
().
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
...
...
shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-etcd/src/test/java/org/apache/shardingsphere/governance/repository/etcd/EtcdRepositoryTest.java
浏览文件 @
3fdee3f2
...
...
@@ -228,8 +228,7 @@ public final class EtcdRepositoryTest {
}
@Test
@SneakyThrows
public
void
assertGetKeyWhenThrowInterruptedException
()
{
public
void
assertGetKeyWhenThrowInterruptedException
()
throws
ExecutionException
,
InterruptedException
{
doThrow
(
InterruptedException
.
class
).
when
(
getFuture
).
get
();
try
{
repository
.
get
(
"key"
);
...
...
@@ -241,8 +240,7 @@ public final class EtcdRepositoryTest {
}
@Test
@SneakyThrows
public
void
assertGetKeyWhenThrowExecutionException
()
{
public
void
assertGetKeyWhenThrowExecutionException
()
throws
ExecutionException
,
InterruptedException
{
doThrow
(
ExecutionException
.
class
).
when
(
getFuture
).
get
();
try
{
repository
.
get
(
"key"
);
...
...
@@ -254,8 +252,7 @@ public final class EtcdRepositoryTest {
}
@Test
@SneakyThrows
public
void
assertGetChildrenKeysWhenThrowInterruptedException
()
{
public
void
assertGetChildrenKeysWhenThrowInterruptedException
()
throws
ExecutionException
,
InterruptedException
{
doThrow
(
InterruptedException
.
class
).
when
(
getFuture
).
get
();
try
{
repository
.
getChildrenKeys
(
"/key/key1"
);
...
...
@@ -267,8 +264,7 @@ public final class EtcdRepositoryTest {
}
@Test
@SneakyThrows
public
void
assertGetChildrenKeysWhenThrowExecutionException
()
{
public
void
assertGetChildrenKeysWhenThrowExecutionException
()
throws
ExecutionException
,
InterruptedException
{
doThrow
(
ExecutionException
.
class
).
when
(
getFuture
).
get
();
try
{
repository
.
getChildrenKeys
(
"/key/key1"
);
...
...
shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-nacos/src/test/java/org/apache/shardingsphere/governance/repository/nacos/NacosRepositoryTest.java
浏览文件 @
3fdee3f2
...
...
@@ -144,18 +144,16 @@ public final class NacosRepositoryTest {
verify
(
configService
).
removeConfig
(
"sharding.test"
,
group
);
}
@SneakyThrows
@Test
public
void
assertDeleteWhenThrowException
()
{
public
void
assertDeleteWhenThrowException
()
throws
NacosException
{
when
(
configService
.
getConfig
(
eq
(
"sharding.test"
),
eq
(
group
),
anyLong
())).
thenReturn
(
"value"
);
doThrow
(
NacosException
.
class
).
when
(
configService
).
removeConfig
(
eq
(
"sharding.test"
),
eq
(
group
));
REPOSITORY
.
delete
(
"/sharding/test"
);
assertNotNull
(
REPOSITORY
.
get
(
"/sharding/test"
));
}
@SneakyThrows
@Test
public
void
assertWatchWhenThrowException
()
{
public
void
assertWatchWhenThrowException
()
throws
NacosException
{
ChangedType
[]
actualType
=
{
null
};
doThrow
(
NacosException
.
class
).
when
(
configService
).
addListener
(
anyString
(),
anyString
(),
any
(
Listener
.
class
));
DataChangedEventListener
listener
=
dataChangedEvent
->
actualType
[
0
]
=
dataChangedEvent
.
getChangedType
();
...
...
@@ -164,8 +162,7 @@ public final class NacosRepositoryTest {
}
@Test
@SneakyThrows
public
void
assertPersistWhenThrowException
()
{
public
void
assertPersistWhenThrowException
()
throws
NacosException
{
String
value
=
"value"
;
doThrow
(
NacosException
.
class
).
when
(
configService
).
publishConfig
(
eq
(
"sharding.test"
),
eq
(
group
),
eq
(
value
));
REPOSITORY
.
persist
(
"/sharding/test"
,
value
);
...
...
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/constructor/ShardingSphereYamlConstructor.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.infra.yaml.engine.constructor
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader
;
import
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapperEngine
;
import
org.yaml.snakeyaml.TypeDescription
;
...
...
@@ -39,7 +38,6 @@ public final class ShardingSphereYamlConstructor extends Constructor {
private
final
Map
<
Class
,
Construct
>
typeConstructs
=
new
HashMap
<>();
@SneakyThrows
public
ShardingSphereYamlConstructor
(
final
Class
<?>
rootClass
)
{
super
(
rootClass
);
ShardingSphereServiceLoader
.
newServiceInstances
(
ShardingSphereYamlConstruct
.
class
).
forEach
(
each
->
typeConstructs
.
put
(
each
.
getType
(),
each
));
...
...
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/engine/representer/ShardingSphereYamlRepresenter.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.infra.yaml.engine.representer
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader
;
import
org.apache.shardingsphere.infra.yaml.engine.representer.processor.DefaultYamlTupleProcessor
;
import
org.apache.shardingsphere.infra.yaml.engine.representer.processor.ShardingSphereYamlTupleProcessor
;
...
...
@@ -36,7 +35,6 @@ public final class ShardingSphereYamlRepresenter extends Representer {
ShardingSphereServiceLoader
.
register
(
ShardingSphereYamlTupleProcessor
.
class
);
}
@SneakyThrows
public
ShardingSphereYamlRepresenter
()
{
YamlRuleConfigurationSwapperEngine
.
getYamlShortcuts
().
forEach
((
key
,
value
)
->
addClassTag
(
value
,
new
Tag
(
key
)));
}
...
...
shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/swapper/YamlRuleConfigurationSwapperEngine.java
浏览文件 @
3fdee3f2
...
...
@@ -18,9 +18,9 @@
package
org.apache.shardingsphere.infra.yaml.swapper
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.config.RuleConfiguration
;
import
org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader
;
import
org.apache.shardingsphere.infra.spi.order.OrderedSPIRegistry
;
import
org.apache.shardingsphere.infra.config.RuleConfiguration
;
import
org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration
;
import
java.lang.reflect.ParameterizedType
;
...
...
@@ -87,7 +87,7 @@ public final class YamlRuleConfigurationSwapperEngine {
*
* @return YAML shortcuts
*/
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
static
Map
<
String
,
Class
<?>>
getYamlShortcuts
()
{
Map
<
String
,
Class
<?>>
result
=
new
HashMap
<>();
for
(
YamlRuleConfigurationSwapper
each
:
ShardingSphereServiceLoader
.
newServiceInstances
(
YamlRuleConfigurationSwapper
.
class
))
{
...
...
shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/resourced/jdbc/queryresult/MemoryQueryResult.java
浏览文件 @
3fdee3f2
...
...
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.infra.executor.sql.QueryResult;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.ObjectOutputStream
;
import
java.math.BigDecimal
;
...
...
@@ -144,7 +145,7 @@ public final class MemoryQueryResult implements QueryResult {
return
getInputStream
(
currentRow
.
get
(
columnIndex
-
1
));
}
@SneakyThrows
@SneakyThrows
(
IOException
.
class
)
private
InputStream
getInputStream
(
final
Object
value
)
{
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
ObjectOutputStream
objectOutputStream
=
new
ObjectOutputStream
(
byteArrayOutputStream
);
...
...
shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/ExecutorExceptionHandlerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.infra.executor.sql.jdbc.executor
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.ExecutorExceptionHandler
;
import
org.junit.After
;
import
org.junit.Test
;
...
...
@@ -31,8 +30,7 @@ import static org.junit.Assert.assertTrue;
public
final
class
ExecutorExceptionHandlerTest
{
@After
@SneakyThrows
public
void
tearDown
()
{
public
void
tearDown
()
throws
NoSuchFieldException
,
IllegalAccessException
{
Field
field
=
ExecutorExceptionHandler
.
class
.
getDeclaredField
(
"IS_EXCEPTION_THROWN"
);
field
.
setAccessible
(
true
);
((
ThreadLocal
)
field
.
get
(
ExecutorExceptionHandler
.
class
)).
remove
();
...
...
shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/executor/impl/DefaultSQLExecutorCallbackTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.infra.executor.sql.jdbc.executor.impl
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData
;
import
org.apache.shardingsphere.infra.database.type.DatabaseTypes
;
import
org.apache.shardingsphere.infra.executor.sql.ConnectionMode
;
...
...
@@ -71,8 +70,7 @@ public final class DefaultSQLExecutorCallbackTest {
@SuppressWarnings
(
"unchecked"
)
@Test
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
execute
()
throws
SQLException
{
public
void
assertExecute
()
throws
SQLException
,
NoSuchFieldException
,
IllegalAccessException
{
SQLExecutorCallback
<?>
sqlExecutorCallback
=
new
DefaultSQLExecutorCallback
<
Integer
>(
DatabaseTypes
.
getActualDatabaseType
(
"MySQL"
),
true
)
{
@Override
...
...
shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/jdbc/queryresult/MemoryQueryResultTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,13 +17,13 @@
package
org.apache.shardingsphere.infra.executor.sql.jdbc.queryresult
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.queryresult.MemoryQueryResult
;
import
org.hamcrest.core.Is
;
import
org.junit.Test
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.ObjectOutputStream
;
import
java.math.BigDecimal
;
...
...
@@ -336,16 +336,14 @@ public final class MemoryQueryResultTest {
}
@Test
@SneakyThrows
public
void
assertGetInputStream
()
{
public
void
assertGetInputStream
()
throws
SQLException
,
IOException
{
MemoryQueryResult
queryResult
=
new
MemoryQueryResult
(
getResultSet
());
queryResult
.
next
();
InputStream
inputStream
=
queryResult
.
getInputStream
(
1
,
"Unicode"
);
assertThat
(
inputStream
.
read
(),
is
(
getInputStream
(
1
).
read
()));
}
@SneakyThrows
private
InputStream
getInputStream
(
final
Object
value
)
{
private
InputStream
getInputStream
(
final
Object
value
)
throws
IOException
{
ByteArrayOutputStream
byteArrayOutputStream
=
new
ByteArrayOutputStream
();
ObjectOutputStream
objectOutputStream
=
new
ObjectOutputStream
(
byteArrayOutputStream
);
objectOutputStream
.
writeObject
(
value
);
...
...
shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/raw/execute/RawJDBCExecutorTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.infra.executor.sql.raw.execute
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.executor.kernel.ExecutorKernel
;
import
org.apache.shardingsphere.infra.executor.sql.QueryResult
;
import
org.apache.shardingsphere.infra.executor.sql.raw.execute.result.query.ExecuteQueryResult
;
...
...
@@ -42,16 +41,14 @@ import static org.mockito.Mockito.when;
public
final
class
RawJDBCExecutorTest
{
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertExecuteForResultEmpty
()
{
public
void
assertExecuteForResultEmpty
()
throws
SQLException
{
ExecutorKernel
kernel
=
mock
(
ExecutorKernel
.
class
);
RawJDBCExecutor
executor
=
new
RawJDBCExecutor
(
kernel
,
true
);
assertFalse
(
executor
.
execute
(
null
,
null
));
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertExecuteForExecuteQueryResult
()
{
public
void
assertExecuteForExecuteQueryResult
()
throws
SQLException
{
ExecutorKernel
kernel
=
mock
(
ExecutorKernel
.
class
);
when
(
kernel
.
execute
(
any
(),
any
(),
any
(),
anyBoolean
())).
thenReturn
(
Collections
.
singletonList
(
new
ExecuteQueryResult
(
null
,
null
)));
RawJDBCExecutor
executor
=
new
RawJDBCExecutor
(
kernel
,
true
);
...
...
@@ -59,8 +56,7 @@ public final class RawJDBCExecutorTest {
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertExecuteQueryForExecuteQueryResult
()
{
public
void
assertExecuteQueryForExecuteQueryResult
()
throws
SQLException
{
ExecutorKernel
kernel
=
mock
(
ExecutorKernel
.
class
);
ExecuteQueryResult
executeQueryResult
=
mock
(
ExecuteQueryResult
.
class
);
QueryResult
queryResult
=
mock
(
QueryResult
.
class
);
...
...
@@ -72,8 +68,7 @@ public final class RawJDBCExecutorTest {
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertExecuteUpdate
()
{
public
void
assertExecuteUpdate
()
throws
SQLException
{
ExecutorKernel
kernel
=
mock
(
ExecutorKernel
.
class
);
ExecuteUpdateResult
executeUpdateResult1
=
new
ExecuteUpdateResult
(
1
,
2
);
ExecuteUpdateResult
executeUpdateResult2
=
new
ExecuteUpdateResult
(
3
,
4
);
...
...
@@ -83,8 +78,7 @@ public final class RawJDBCExecutorTest {
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertExecuteNotThrownSQLException
()
{
public
void
assertExecuteNotThrownSQLException
()
throws
SQLException
{
ExecutorKernel
kernel
=
mock
(
ExecutorKernel
.
class
);
when
(
kernel
.
execute
(
any
(),
any
(),
any
(),
anyBoolean
())).
thenThrow
(
new
SQLException
(
"TestSQLException"
));
RawJDBCExecutor
rawJDBCExecutor
=
new
RawJDBCExecutor
(
kernel
,
false
);
...
...
shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/hook/SPIRoutingHookTest.java
浏览文件 @
3fdee3f2
...
...
@@ -74,7 +74,7 @@ public final class SPIRoutingHookTest {
}
@SuppressWarnings
(
"unchecked"
)
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
RoutingHook
getFixtureHook
()
{
Field
routingHooksField
=
SPIRoutingHook
.
class
.
getDeclaredField
(
"routingHooks"
);
routingHooksField
.
setAccessible
(
true
);
...
...
shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/cases/assertion/IntegrateTestCasesLoader.java
浏览文件 @
3fdee3f2
...
...
@@ -69,13 +69,13 @@ public final class IntegrateTestCasesLoader {
* @param sqlType SQL type
* @return integrate test cases
*/
@SneakyThrows
public
List
<?
extends
IntegrateTestCase
>
getTestCases
(
final
SQLType
sqlType
)
{
integrateTestCases
.
putIfAbsent
(
sqlType
,
loadIntegrateTestCases
(
sqlType
));
return
integrateTestCases
.
get
(
sqlType
);
}
private
List
<?
extends
IntegrateTestCase
>
loadIntegrateTestCases
(
final
SQLType
sqlType
)
throws
IOException
,
URISyntaxException
,
JAXBException
{
@SneakyThrows
({
IOException
.
class
,
URISyntaxException
.
class
,
JAXBException
.
class
})
private
List
<?
extends
IntegrateTestCase
>
loadIntegrateTestCases
(
final
SQLType
sqlType
)
{
URL
url
=
IntegrateTestCasesLoader
.
class
.
getClassLoader
().
getResource
(
"integrate/cases/"
);
Preconditions
.
checkNotNull
(
url
,
"Cannot found integrate test cases."
);
return
loadIntegrateTestCases
(
url
,
sqlType
);
...
...
shardingsphere-integration-test/shardingsphere-test-suite/src/test/java/org/apache/shardingsphere/dbtest/engine/util/IntegrateTestParameters.java
浏览文件 @
3fdee3f2
...
...
@@ -161,7 +161,7 @@ public final class IntegrateTestParameters {
log
.
info
(
summary
);
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
static
long
calculateRunnableTestAnnotation
()
{
long
result
=
0
;
StackTraceElement
[]
stackTraceElements
=
Thread
.
currentThread
().
getStackTrace
();
...
...
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootPrimaryReplicaReplicationTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.spring.boot.governance.type
;
import
lombok.SneakyThrows
;
import
org.apache.commons.dbcp2.BasicDataSource
;
import
org.apache.shardingsphere.driver.governance.internal.datasource.GovernanceShardingSphereDataSource
;
import
org.apache.shardingsphere.infra.context.schema.SchemaContexts
;
...
...
@@ -57,8 +56,7 @@ public class GovernanceSpringBootPrimaryReplicaReplicationTest {
}
@Test
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
assertDataSource
()
{
public
void
assertDataSource
()
throws
NoSuchFieldException
,
IllegalAccessException
{
assertTrue
(
dataSource
instanceof
GovernanceShardingSphereDataSource
);
Field
field
=
GovernanceShardingSphereDataSource
.
class
.
getDeclaredField
(
"schemaContexts"
);
field
.
setAccessible
(
true
);
...
...
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryEncryptTest.java
浏览文件 @
3fdee3f2
...
...
@@ -36,7 +36,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
javax.annotation.Resource
;
import
javax.sql.DataSource
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.net.URISyntaxException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.stream.Collectors
;
...
...
@@ -87,7 +89,7 @@ public class GovernanceSpringBootRegistryEncryptTest {
assertThat
(
encryptAlgorithmConfig
.
getType
(),
is
(
"AES"
));
}
@SneakyThrows
@SneakyThrows
({
IOException
.
class
,
URISyntaxException
.
class
})
private
static
String
readYAML
(
final
String
yamlFile
)
{
return
Files
.
readAllLines
(
Paths
.
get
(
ClassLoader
.
getSystemResource
(
yamlFile
).
toURI
())).
stream
().
map
(
each
->
each
+
System
.
lineSeparator
()).
collect
(
Collectors
.
joining
());
}
...
...
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryPrimaryReplicaReplicationTest.java
浏览文件 @
3fdee3f2
...
...
@@ -33,7 +33,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
javax.annotation.Resource
;
import
javax.sql.DataSource
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.net.URISyntaxException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.stream.Collectors
;
...
...
@@ -66,8 +68,7 @@ public class GovernanceSpringBootRegistryPrimaryReplicaReplicationTest {
}
@Test
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
assertWithPrimaryReplicaReplicationDataSource
()
{
public
void
assertWithPrimaryReplicaReplicationDataSource
()
throws
NoSuchFieldException
,
IllegalAccessException
{
assertTrue
(
dataSource
instanceof
GovernanceShardingSphereDataSource
);
Field
field
=
GovernanceShardingSphereDataSource
.
class
.
getDeclaredField
(
"schemaContexts"
);
field
.
setAccessible
(
true
);
...
...
@@ -78,7 +79,7 @@ public class GovernanceSpringBootRegistryPrimaryReplicaReplicationTest {
}
}
@SneakyThrows
@SneakyThrows
({
URISyntaxException
.
class
,
IOException
.
class
})
private
static
String
readYAML
(
final
String
yamlFile
)
{
return
Files
.
readAllLines
(
Paths
.
get
(
ClassLoader
.
getSystemResource
(
yamlFile
).
toURI
())).
stream
().
map
(
each
->
each
+
System
.
lineSeparator
()).
collect
(
Collectors
.
joining
());
}
...
...
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-boot-starter/src/test/java/org/apache/shardingsphere/spring/boot/governance/type/GovernanceSpringBootRegistryShardingTest.java
浏览文件 @
3fdee3f2
...
...
@@ -38,7 +38,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
javax.annotation.Resource
;
import
javax.sql.DataSource
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.net.URISyntaxException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.stream.Collectors
;
...
...
@@ -168,7 +170,7 @@ public class GovernanceSpringBootRegistryShardingTest {
return
(
T
)
field
.
get
(
target
);
}
@SneakyThrows
@SneakyThrows
({
URISyntaxException
.
class
,
IOException
.
class
})
private
static
String
readYAML
(
final
String
yamlFile
)
{
return
Files
.
readAllLines
(
Paths
.
get
(
ClassLoader
.
getSystemResource
(
yamlFile
).
toURI
())).
stream
().
map
(
each
->
each
+
System
.
lineSeparator
()).
collect
(
Collectors
.
joining
());
}
...
...
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/test/java/org/apache/shardingsphere/spring/boot/datasource/DataSourceMapSetterTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,12 +17,12 @@
package
org.apache.shardingsphere.spring.boot.datasource
;
import
lombok.SneakyThrows
;
import
org.junit.Test
;
import
org.springframework.core.env.StandardEnvironment
;
import
org.springframework.mock.env.MockEnvironment
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
import
java.util.Map
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
...
...
@@ -30,9 +30,8 @@ import static org.junit.Assert.assertThat;
public
final
class
DataSourceMapSetterTest
{
@SneakyThrows
@Test
public
void
assetMergedAll
()
{
public
void
assetMergedAll
()
throws
SQLException
{
MockEnvironment
mockEnvironment
=
new
MockEnvironment
();
mockEnvironment
.
setProperty
(
"spring.shardingsphere.datasource.names"
,
"ds0,ds1"
);
mockEnvironment
.
setProperty
(
"spring.shardingsphere.datasource.common.type"
,
"org.apache.commons.dbcp2.BasicDataSource"
);
...
...
@@ -50,9 +49,8 @@ public final class DataSourceMapSetterTest {
assertThat
(
dataSourceMap
.
get
(
"ds1"
).
getConnection
().
getMetaData
().
getURL
(),
is
(
"jdbc:h2:mem:ds"
));
}
@SneakyThrows
@Test
public
void
assetMergedReplaceAndAdd
()
{
public
void
assetMergedReplaceAndAdd
()
throws
SQLException
{
MockEnvironment
mockEnvironment
=
new
MockEnvironment
();
mockEnvironment
.
setProperty
(
"spring.shardingsphere.datasource.names"
,
"ds0,ds1"
);
mockEnvironment
.
setProperty
(
"spring.shardingsphere.datasource.common.type"
,
"org.apache.commons.dbcp2.BasicDataSource"
);
...
...
shardingsphere-observability/shardingsphere-tracing/shardingsphere-tracing-opentracing/src/test/java/org/apache/shardingsphere/tracing/opentracing/hook/BaseOpenTracingHookTest.java
浏览文件 @
3fdee3f2
...
...
@@ -23,7 +23,6 @@ import io.opentracing.mock.MockTracer;
import
io.opentracing.tag.Tags
;
import
io.opentracing.util.GlobalTracer
;
import
io.opentracing.util.ThreadLocalActiveSpanSource
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.tracing.opentracing.OpenTracingTracer
;
import
org.apache.shardingsphere.tracing.opentracing.constant.ShardingErrorLogTags
;
import
org.junit.AfterClass
;
...
...
@@ -47,8 +46,7 @@ public abstract class BaseOpenTracingHookTest {
}
@AfterClass
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
static
void
releaseTracer
()
{
public
static
void
releaseTracer
()
throws
NoSuchFieldException
,
IllegalAccessException
{
Field
field
=
GlobalTracer
.
class
.
getDeclaredField
(
"tracer"
);
field
.
setAccessible
(
true
);
field
.
set
(
GlobalTracer
.
class
,
NoopTracerFactory
.
create
());
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/DatabaseCommunicationEngineFactoryTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.proxy.backend.communication.jdbc
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.auth.Authentication
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
;
import
org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts
;
...
...
@@ -48,8 +47,7 @@ import static org.mockito.Mockito.when;
public
final
class
DatabaseCommunicationEngineFactoryTest
{
@Before
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
setUp
()
{
public
void
setUp
()
throws
IllegalAccessException
,
NoSuchFieldException
{
Field
schemaContexts
=
ProxyContext
.
getInstance
().
getClass
().
getDeclaredField
(
"schemaContexts"
);
schemaContexts
.
setAccessible
(
true
);
schemaContexts
.
set
(
ProxyContext
.
getInstance
(),
new
StandardSchemaContexts
(
getSchemas
(),
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
浏览文件 @
3fdee3f2
...
...
@@ -42,6 +42,7 @@ import org.mockito.Mock;
import
org.mockito.junit.MockitoJUnitRunner
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
...
...
@@ -198,7 +199,7 @@ public final class BackendConnectionTest {
thread2
.
join
();
}
@SneakyThrows
@SneakyThrows
(
SQLException
.
class
)
private
void
assertOneThreadResult
()
{
backendConnection
.
getTransactionStatus
().
setInTransaction
(
true
);
List
<
Connection
>
actualConnections
=
backendConnection
.
getConnections
(
"ds1"
,
12
,
ConnectionMode
.
MEMORY_STRICTLY
);
...
...
@@ -248,9 +249,8 @@ public final class BackendConnectionTest {
assertTrue
(
backendConnection
.
isSerialExecute
());
}
@SneakyThrows
@Test
public
void
assertSetFetchSizeAsExpected
()
{
public
void
assertSetFetchSizeAsExpected
()
throws
InvocationTargetException
,
IllegalAccessException
,
NoSuchMethodException
,
SQLException
{
Statement
statement
=
mock
(
Statement
.
class
);
Method
setFetchSizeMethod
=
backendConnection
.
getClass
().
getDeclaredMethod
(
"setFetchSize"
,
Statement
.
class
);
setFetchSizeMethod
.
setAccessible
(
true
);
...
...
@@ -258,9 +258,8 @@ public final class BackendConnectionTest {
verify
(
statement
,
times
(
1
)).
setFetchSize
(
Integer
.
MIN_VALUE
);
}
@SneakyThrows
@Test
public
void
assertAddStatementCorrectly
()
{
public
void
assertAddStatementCorrectly
()
throws
NoSuchFieldException
,
IllegalAccessException
{
Statement
statement
=
mock
(
Statement
.
class
);
backendConnection
.
add
(
statement
);
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"cachedStatements"
);
...
...
@@ -268,9 +267,8 @@ public final class BackendConnectionTest {
assertTrue
(((
Collection
<
Statement
>)
field
.
get
(
backendConnection
)).
contains
(
statement
));
}
@SneakyThrows
@Test
public
void
assertAddResultSetCorrectly
()
{
public
void
assertAddResultSetCorrectly
()
throws
NoSuchFieldException
,
IllegalAccessException
{
ResultSet
resultSet
=
mock
(
ResultSet
.
class
);
backendConnection
.
add
(
resultSet
);
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"cachedResultSets"
);
...
...
@@ -278,9 +276,8 @@ public final class BackendConnectionTest {
assertTrue
(((
Collection
<
ResultSet
>)
field
.
get
(
backendConnection
)).
contains
(
resultSet
));
}
@SneakyThrows
@Test
public
void
assertCloseResultSetsCorrectly
()
{
public
void
assertCloseResultSetsCorrectly
()
throws
NoSuchFieldException
,
SQLException
,
IllegalAccessException
{
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"cachedResultSets"
);
field
.
setAccessible
(
true
);
Collection
<
ResultSet
>
cachedResultSets
=
(
Collection
<
ResultSet
>)
field
.
get
(
backendConnection
);
...
...
@@ -291,9 +288,8 @@ public final class BackendConnectionTest {
assertTrue
(
cachedResultSets
.
isEmpty
());
}
@SneakyThrows
@Test
public
void
assertCloseResultSetsWithExceptionThrown
()
{
public
void
assertCloseResultSetsWithExceptionThrown
()
throws
NoSuchFieldException
,
SQLException
,
IllegalAccessException
{
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"cachedResultSets"
);
field
.
setAccessible
(
true
);
Collection
<
ResultSet
>
cachedResultSets
=
(
Collection
<
ResultSet
>)
field
.
get
(
backendConnection
);
...
...
@@ -307,9 +303,8 @@ public final class BackendConnectionTest {
assertTrue
(
result
.
contains
(
sqlException
));
}
@SneakyThrows
@Test
public
void
assertCloseStatementsCorrectly
()
{
public
void
assertCloseStatementsCorrectly
()
throws
NoSuchFieldException
,
SQLException
,
IllegalAccessException
{
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"cachedStatements"
);
field
.
setAccessible
(
true
);
Collection
<
Statement
>
cachedStatement
=
(
Collection
<
Statement
>)
field
.
get
(
backendConnection
);
...
...
@@ -320,9 +315,8 @@ public final class BackendConnectionTest {
assertTrue
(
cachedStatement
.
isEmpty
());
}
@SneakyThrows
@Test
public
void
assertCloseStatementsWithExceptionThrown
()
{
public
void
assertCloseStatementsWithExceptionThrown
()
throws
SQLException
,
NoSuchFieldException
,
IllegalAccessException
{
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"cachedStatements"
);
field
.
setAccessible
(
true
);
Collection
<
Statement
>
cachedStatement
=
(
Collection
<
Statement
>)
field
.
get
(
backendConnection
);
...
...
@@ -336,9 +330,8 @@ public final class BackendConnectionTest {
assertTrue
(
result
.
contains
(
sqlException
));
}
@SneakyThrows
@Test
public
void
assertCloseConnectionsCorrectlyWhenNotForceRollback
()
{
public
void
assertCloseConnectionsCorrectlyWhenNotForceRollback
()
throws
NoSuchFieldException
,
IllegalAccessException
,
SQLException
{
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"cachedConnections"
);
field
.
setAccessible
(
true
);
Multimap
<
String
,
Connection
>
cachedConnections
=
(
Multimap
<
String
,
Connection
>)
field
.
get
(
backendConnection
);
...
...
@@ -353,9 +346,8 @@ public final class BackendConnectionTest {
verify
(
connectionStatus
,
times
(
1
)).
switchToReleased
();
}
@SneakyThrows
@Test
public
void
assertCloseConnectionsCorrectlyWhenForceRollbackAndNotInTransaction
()
{
public
void
assertCloseConnectionsCorrectlyWhenForceRollbackAndNotInTransaction
()
throws
SQLException
{
ConnectionStatus
connectionStatus
=
mock
(
ConnectionStatus
.
class
);
prepareConnectionStatus
(
connectionStatus
);
backendConnection
.
getTransactionStatus
().
setInTransaction
(
false
);
...
...
@@ -365,9 +357,8 @@ public final class BackendConnectionTest {
verify
(
connectionStatus
,
times
(
1
)).
switchToReleased
();
}
@SneakyThrows
@Test
public
void
assertCloseConnectionsCorrectlyWhenForceRollbackAndInTransaction
()
{
public
void
assertCloseConnectionsCorrectlyWhenForceRollbackAndInTransaction
()
throws
SQLException
{
ConnectionStatus
connectionStatus
=
mock
(
ConnectionStatus
.
class
);
prepareConnectionStatus
(
connectionStatus
);
backendConnection
.
getTransactionStatus
().
setInTransaction
(
true
);
...
...
@@ -377,9 +368,8 @@ public final class BackendConnectionTest {
verify
(
connectionStatus
,
times
(
1
)).
switchToReleased
();
}
@SneakyThrows
@Test
public
void
assertCloseConnectionsCorrectlyWhenSQLExceptionThrown
()
{
public
void
assertCloseConnectionsCorrectlyWhenSQLExceptionThrown
()
throws
SQLException
{
ConnectionStatus
connectionStatus
=
mock
(
ConnectionStatus
.
class
);
prepareConnectionStatus
(
connectionStatus
);
Connection
connection
=
prepareCachedConnections
();
...
...
@@ -388,9 +378,8 @@ public final class BackendConnectionTest {
assertTrue
(
backendConnection
.
closeConnections
(
false
).
contains
(
sqlException
));
}
@SneakyThrows
@Test
public
void
assertCreateStorageResourceCorrectlyWhenConnectionModeMemoryStrictly
()
{
public
void
assertCreateStorageResourceCorrectlyWhenConnectionModeMemoryStrictly
()
throws
SQLException
{
Connection
connection
=
mock
(
Connection
.
class
);
Statement
statement
=
mock
(
Statement
.
class
);
when
(
connection
.
createStatement
()).
thenReturn
(
statement
);
...
...
@@ -398,9 +387,8 @@ public final class BackendConnectionTest {
verify
(
connection
,
times
(
1
)).
createStatement
();
}
@SneakyThrows
@Test
public
void
assertGetConnectionsWithoutTransactions
()
{
public
void
assertGetConnectionsWithoutTransactions
()
throws
SQLException
{
backendConnection
.
getTransactionStatus
().
setInTransaction
(
false
);
List
<
Connection
>
connectionList
=
MockConnectionUtil
.
mockNewConnections
(
1
);
when
(
backendDataSource
.
getConnections
(
anyString
(),
anyString
(),
eq
(
1
),
any
())).
thenReturn
(
connectionList
);
...
...
@@ -410,7 +398,8 @@ public final class BackendConnectionTest {
assertConnectionsCached
(
"ds1"
,
connectionList
);
}
@SneakyThrows
@SuppressWarnings
(
"unchecked"
)
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
void
assertConnectionsCached
(
final
String
dataSourceName
,
final
Collection
<
Connection
>
collectionList
)
{
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"cachedConnections"
);
field
.
setAccessible
(
true
);
...
...
@@ -419,7 +408,8 @@ public final class BackendConnectionTest {
assertArrayEquals
(
cachedConnections
.
get
(
dataSourceName
).
toArray
(),
collectionList
.
toArray
());
}
@SneakyThrows
@SuppressWarnings
(
"unchecked"
)
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
Connection
prepareCachedConnections
()
{
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"cachedConnections"
);
field
.
setAccessible
(
true
);
...
...
@@ -429,14 +419,15 @@ public final class BackendConnectionTest {
return
connection
;
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
void
prepareConnectionStatus
(
final
ConnectionStatus
connectionStatus
)
{
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"connectionStatus"
);
field
.
setAccessible
(
true
);
field
.
set
(
backendConnection
,
connectionStatus
);
}
@SneakyThrows
@SuppressWarnings
(
"unchecked"
)
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
void
verifyMethodInvocationsEmpty
()
{
Field
field
=
backendConnection
.
getClass
().
getDeclaredField
(
"methodInvocations"
);
field
.
setAccessible
(
true
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/MethodInvocationTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.fixture.MethodInvocationFixture
;
import
org.junit.Test
;
...
...
@@ -26,9 +25,8 @@ import static org.junit.Assert.assertThat;
public
final
class
MethodInvocationTest
{
@SneakyThrows
@Test
public
void
assertInvoke
()
{
public
void
assertInvoke
()
throws
NoSuchMethodException
{
MethodInvocationFixture
methodInvocationFixture
=
new
MethodInvocationFixture
();
MethodInvocation
methodInvocation
=
new
MethodInvocation
(
MethodInvocationFixture
.
class
.
getMethod
(
"setId"
,
Integer
.
class
),
new
Object
[]{
1
});
methodInvocation
.
invoke
(
methodInvocationFixture
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/MySQLStatementMemoryStrictlyFetchSizeSetterTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,9 +17,9 @@
package
org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.fetchsize.impl
;
import
lombok.SneakyThrows
;
import
org.junit.Test
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
...
...
@@ -30,9 +30,8 @@ import static org.mockito.Mockito.verify;
public
final
class
MySQLStatementMemoryStrictlyFetchSizeSetterTest
{
@SneakyThrows
@Test
public
void
assertSetFetchSize
()
{
public
void
assertSetFetchSize
()
throws
SQLException
{
Statement
statement
=
mock
(
Statement
.
class
);
new
MySQLStatementMemoryStrictlyFetchSizeSetter
().
setFetchSize
(
statement
);
verify
(
statement
,
times
(
1
)).
setFetchSize
(
Integer
.
MIN_VALUE
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fetchsize/impl/PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,9 +17,9 @@
package
org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.fetchsize.impl
;
import
lombok.SneakyThrows
;
import
org.junit.Test
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
...
...
@@ -30,9 +30,8 @@ import static org.mockito.Mockito.verify;
public
final
class
PostgreSQLStatementMemoryStrictlyFetchSizeSetterTest
{
@SneakyThrows
@Test
public
void
assertSetFetchSize
()
{
public
void
assertSetFetchSize
()
throws
SQLException
{
Statement
statement
=
mock
(
Statement
.
class
);
new
PostgreSQLStatementMemoryStrictlyFetchSizeSetter
().
setFetchSize
(
statement
);
verify
(
statement
,
times
(
1
)).
setFetchSize
(
1
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/BroadcastBackendHandlerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -70,8 +70,7 @@ public final class BroadcastBackendHandlerTest {
private
DatabaseCommunicationEngine
databaseCommunicationEngine
;
@Before
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
setUp
()
{
public
void
setUp
()
throws
IllegalAccessException
,
NoSuchFieldException
{
Field
schemaContexts
=
ProxyContext
.
getInstance
().
getClass
().
getDeclaredField
(
"schemaContexts"
);
schemaContexts
.
setAccessible
(
true
);
schemaContexts
.
set
(
ProxyContext
.
getInstance
(),
new
StandardSchemaContexts
(
getSchemas
(),
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DALBackendHandlerFactoryTest.java
浏览文件 @
3fdee3f2
...
...
@@ -93,7 +93,8 @@ public final class DALBackendHandlerFactoryTest {
assertFieldOfInstance
(
unicastBackendHandler
,
"backendConnection"
,
is
(
backendConnection
));
}
@SneakyThrows
@SuppressWarnings
(
"unchecked"
)
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
<
S
,
T
>
void
assertFieldOfInstance
(
final
S
classInstance
,
final
String
fieldName
,
final
Matcher
<
T
>
matcher
)
{
Field
field
=
classInstance
.
getClass
().
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -59,8 +59,7 @@ import static org.mockito.Mockito.when;
public
final
class
RDLBackendHandlerTest
{
@Before
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
setUp
()
{
public
void
setUp
()
throws
IllegalAccessException
,
NoSuchFieldException
{
Field
schemaContexts
=
ProxyContext
.
getInstance
().
getClass
().
getDeclaredField
(
"schemaContexts"
);
schemaContexts
.
setAccessible
(
true
);
schemaContexts
.
set
(
ProxyContext
.
getInstance
(),
new
StandardSchemaContexts
(
getSchemas
(),
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowDatabasesBackendHandlerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.proxy.backend.text.admin
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.auth.Authentication
;
import
org.apache.shardingsphere.infra.auth.ProxyUser
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
;
...
...
@@ -57,8 +56,7 @@ public final class ShowDatabasesBackendHandlerTest {
private
ShowDatabasesBackendHandler
showDatabasesBackendHandler
;
@Before
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
setUp
()
{
public
void
setUp
()
throws
IllegalAccessException
,
NoSuchFieldException
{
BackendConnection
backendConnection
=
mock
(
BackendConnection
.
class
);
when
(
backendConnection
.
getUsername
()).
thenReturn
(
"root"
);
showDatabasesBackendHandler
=
new
ShowDatabasesBackendHandler
(
backendConnection
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/ShowTablesBackendHandlerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.proxy.backend.text.admin
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.auth.Authentication
;
import
org.apache.shardingsphere.infra.auth.ProxyUser
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
;
...
...
@@ -56,8 +55,7 @@ public final class ShowTablesBackendHandlerTest {
private
ShowTablesBackendHandler
tablesBackendHandler
;
@Before
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
setUp
()
{
public
void
setUp
()
throws
NoSuchFieldException
,
IllegalAccessException
{
BackendConnection
backendConnection
=
mock
(
BackendConnection
.
class
);
when
(
backendConnection
.
getUsername
()).
thenReturn
(
"root"
);
tablesBackendHandler
=
new
ShowTablesBackendHandler
(
"show tables"
,
mock
(
SQLStatement
.
class
),
backendConnection
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
浏览文件 @
3fdee3f2
package
org.apache.shardingsphere.proxy.backend.text.sctl.explain
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.auth.Authentication
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
;
import
org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts
;
...
...
@@ -50,8 +49,7 @@ public final class ShardingCTLExplainBackendHandlerTest {
private
ShardingCTLExplainBackendHandler
handler
;
@Before
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
setUp
()
{
public
void
setUp
()
throws
IllegalAccessException
,
NoSuchFieldException
{
BackendConnection
connection
=
mock
(
BackendConnection
.
class
);
when
(
connection
.
getSchemaName
()).
thenReturn
(
"schema"
);
handler
=
new
ShardingCTLExplainBackendHandler
(
"sctl:explain select 1"
,
connection
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -18,7 +18,6 @@
package
org.apache.shardingsphere.proxy.backend.text.sctl.hint
;
import
com.google.common.collect.ImmutableMap
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.auth.Authentication
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey
;
...
...
@@ -168,8 +167,7 @@ public final class ShardingCTLHintBackendHandlerTest {
}
@Test
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
assertShowTableStatus
()
throws
SQLException
{
public
void
assertShowTableStatus
()
throws
SQLException
,
NoSuchFieldException
,
IllegalAccessException
{
clearThreadLocal
();
when
(
backendConnection
.
getSchemaName
()).
thenReturn
(
"schema"
);
Field
schemaContexts
=
ProxyContext
.
getInstance
().
getClass
().
getDeclaredField
(
"schemaContexts"
);
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/set/ShardingCTLSetBackendHandlerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.proxy.backend.text.sctl.set
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.auth.Authentication
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
;
import
org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts
;
...
...
@@ -52,8 +51,7 @@ public final class ShardingCTLSetBackendHandlerTest {
private
final
BackendConnection
backendConnection
=
new
BackendConnection
(
TransactionType
.
LOCAL
);
@Before
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
setUp
()
{
public
void
setUp
()
throws
NoSuchFieldException
,
IllegalAccessException
{
Field
schemaContexts
=
ProxyContext
.
getInstance
().
getClass
().
getDeclaredField
(
"schemaContexts"
);
schemaContexts
.
setAccessible
(
true
);
schemaContexts
.
set
(
ProxyContext
.
getInstance
(),
new
StandardSchemaContexts
(
getSchemas
(),
...
...
shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionBackendHandlerFactoryTest.java
浏览文件 @
3fdee3f2
...
...
@@ -64,7 +64,8 @@ public final class TransactionBackendHandlerFactoryTest {
assertThat
(
TransactionBackendHandlerFactory
.
newInstance
(
null
,
mock
(
TCLStatement
.
class
),
null
),
instanceOf
(
BroadcastBackendHandler
.
class
));
}
@SneakyThrows
@SuppressWarnings
(
"unchecked"
)
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
<
S
,
T
>
void
assertFieldOfInstance
(
final
S
classInstance
,
final
String
fieldName
,
final
Matcher
<
T
>
matcher
)
{
Field
field
=
classInstance
.
getClass
().
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
...
...
@@ -72,7 +73,7 @@ public final class TransactionBackendHandlerFactoryTest {
assertThat
(
value
,
matcher
);
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
BackendTransactionManager
getBackendTransactionManager
(
final
TransactionBackendHandler
transactionBackendHandler
)
{
Field
field
=
transactionBackendHandler
.
getClass
().
getDeclaredField
(
"backendTransactionManager"
);
field
.
setAccessible
(
true
);
...
...
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/AbstractBootstrapInitializerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.proxy.init.impl;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
;
import
org.apache.shardingsphere.infra.context.schema.SchemaContexts
;
import
org.apache.shardingsphere.proxy.config.ProxyConfiguration
;
...
...
@@ -33,6 +32,7 @@ import org.mockito.Mockito;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Modifier
;
import
java.sql.SQLException
;
import
java.util.Properties
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
...
...
@@ -64,9 +64,8 @@ public abstract class AbstractBootstrapInitializerTest {
protected
abstract
void
prepareSpecifiedInitializer
();
@SneakyThrows
@Test
public
final
void
assertInit
()
{
public
final
void
assertInit
()
throws
NoSuchFieldException
,
IllegalAccessException
,
SQLException
{
Field
field
=
AbstractBootstrapInitializer
.
class
.
getDeclaredField
(
"shardingSphereProxy"
);
field
.
setAccessible
(
true
);
Field
modifiersField
=
Field
.
class
.
getDeclaredField
(
"modifiers"
);
...
...
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/GovernanceBootstrapInitializerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -39,6 +39,7 @@ import org.apache.shardingsphere.transaction.context.TransactionContexts;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.Collection
;
...
...
@@ -74,7 +75,7 @@ public final class GovernanceBootstrapInitializerTest extends AbstractBootstrapI
closeConfigCenter
();
}
@SneakyThrows
@SneakyThrows
(
IOException
.
class
)
protected
YamlProxyConfiguration
makeProxyConfiguration
()
{
return
ProxyConfigurationLoader
.
load
(
"/conf/reg_center/"
);
}
...
...
@@ -88,7 +89,7 @@ public final class GovernanceBootstrapInitializerTest extends AbstractBootstrapI
configurationRepository
.
persist
(
node
.
getRulePath
(
"db"
),
readYAML
(
SHARDING_RULE_YAML
));
}
@SneakyThrows
@SneakyThrows
({
URISyntaxException
.
class
,
IOException
.
class
})
private
String
readYAML
(
final
String
yamlFile
)
{
return
Files
.
readAllLines
(
Paths
.
get
(
ClassLoader
.
getSystemResource
(
yamlFile
).
toURI
()))
.
stream
().
map
(
each
->
each
+
System
.
lineSeparator
()).
collect
(
Collectors
.
joining
());
...
...
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/init/impl/StandardBootstrapInitializerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,14 +17,13 @@
package
org.apache.shardingsphere.proxy.init.impl
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.infra.auth.Authentication
;
import
org.apache.shardingsphere.infra.auth.ProxyUser
;
import
org.apache.shardingsphere.infra.auth.yaml.config.YamlAuthenticationConfiguration
;
import
org.apache.shardingsphere.infra.auth.yaml.config.YamlProxyUserConfiguration
;
import
org.apache.shardingsphere.infra.config.RuleConfiguration
;
import
org.apache.shardingsphere.infra.context.schema.SchemaContexts
;
import
org.apache.shardingsphere.infra.config.datasource.DataSourceParameter
;
import
org.apache.shardingsphere.infra.context.schema.SchemaContexts
;
import
org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader
;
import
org.apache.shardingsphere.infra.yaml.config.YamlRuleConfiguration
;
import
org.apache.shardingsphere.infra.yaml.swapper.YamlRuleConfigurationSwapper
;
...
...
@@ -54,7 +53,6 @@ import static org.mockito.Mockito.mock;
public
final
class
StandardBootstrapInitializerTest
extends
AbstractBootstrapInitializerTest
{
@SneakyThrows
protected
YamlProxyConfiguration
makeProxyConfiguration
()
{
return
new
YamlProxyConfiguration
(
createYamlProxyServerConfiguration
(),
createYamlProxyRuleConfigurationMap
());
}
...
...
shardingsphere-proxy/shardingsphere-proxy-common/src/main/java/org/apache/shardingsphere/proxy/config/yaml/YamlDataSourceParameterMerger.java
浏览文件 @
3fdee3f2
...
...
@@ -59,7 +59,7 @@ public final class YamlDataSourceParameterMerger {
}
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
static
Object
getValue
(
final
Field
field
,
final
Class
<?>
clazz
,
final
Object
source
)
{
String
fieldName
=
field
.
getName
();
String
firstLetter
=
fieldName
.
substring
(
0
,
1
).
toUpperCase
();
...
...
@@ -73,7 +73,7 @@ public final class YamlDataSourceParameterMerger {
return
getMethod
.
invoke
(
source
);
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
static
void
setValue
(
final
Field
field
,
final
Class
<?>
clazz
,
final
Object
source
,
final
Map
<
String
,
Object
>
commonProps
)
{
String
fieldName
=
field
.
getName
();
String
firstLetter
=
fieldName
.
substring
(
0
,
1
).
toUpperCase
();
...
...
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -60,7 +60,7 @@ public final class MySQLAuthenticationHandlerTest {
initAuthPluginDataForAuthenticationHandler
();
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
void
initAuthPluginDataForAuthenticationHandler
()
{
MySQLAuthPluginData
authPluginData
=
new
MySQLAuthPluginData
(
part1
,
part2
);
Field
field
=
MySQLAuthenticationHandler
.
class
.
getDeclaredField
(
"authPluginData"
);
...
...
@@ -108,14 +108,13 @@ public final class MySQLAuthenticationHandlerTest {
assertThat
(
authenticationHandler
.
getAuthPluginData
().
getAuthPluginData
(),
is
(
Bytes
.
concat
(
part1
,
part2
)));
}
@SneakyThrows
private
void
setAuthentication
(
final
ProxyUser
proxyUser
)
{
Authentication
authentication
=
new
Authentication
();
authentication
.
getUsers
().
put
(
"root"
,
proxyUser
);
initProxyContext
(
authentication
);
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
void
initProxyContext
(
final
Authentication
authentication
)
{
Field
field
=
ProxyContext
.
getInstance
().
getClass
().
getDeclaredField
(
"schemaContexts"
);
field
.
setAccessible
(
true
);
...
...
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
浏览文件 @
3fdee3f2
...
...
@@ -18,7 +18,6 @@
package
org.apache.shardingsphere.proxy.frontend.postgresql.command
;
import
io.netty.channel.ChannelHandlerContext
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket
;
import
org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor
;
import
org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType
;
...
...
@@ -27,6 +26,8 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
java.sql.SQLException
;
import
static
org
.
mockito
.
ArgumentMatchers
.
isA
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
...
...
@@ -42,8 +43,7 @@ public final class PostgreSQLCommandExecuteEngineTest {
private
QueryCommandExecutor
queryCommandExecutor
;
@Test
@SneakyThrows
public
void
assertWriteQueryDataWithUpdate
()
{
public
void
assertWriteQueryDataWithUpdate
()
throws
SQLException
{
PostgreSQLCommandExecuteEngine
postgreSQLCommandExecuteEngine
=
new
PostgreSQLCommandExecuteEngine
();
when
(
queryCommandExecutor
.
getResponseType
()).
thenReturn
(
ResponseType
.
UPDATE
);
postgreSQLCommandExecuteEngine
.
writeQueryData
(
channelHandlerContext
,
null
,
queryCommandExecutor
,
0
);
...
...
shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/datasource/DataSourceFactory.java
浏览文件 @
3fdee3f2
...
...
@@ -29,6 +29,7 @@ import org.apache.shardingsphere.scaling.core.utils.ConfigurationYamlConverter;
import
org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
import
java.util.Map
;
/**
...
...
@@ -59,7 +60,7 @@ public final class DataSourceFactory {
return
new
DataSourceWrapper
(
result
);
}
@SneakyThrows
@SneakyThrows
(
SQLException
.
class
)
private
DataSourceWrapper
newInstanceDataSourceByShardingSphereJDBC
(
final
ShardingSphereJDBCConfiguration
dataSourceConfig
)
{
Map
<
String
,
DataSource
>
dataSourceMap
=
DataSourceConverter
.
getDataSourceMap
(
ConfigurationYamlConverter
.
loadDataSourceConfigurations
(
dataSourceConfig
.
getDataSource
()));
...
...
shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/dumper/DumperFactory.java
浏览文件 @
3fdee3f2
...
...
@@ -40,7 +40,6 @@ public final class DumperFactory {
* @param dataSourceManager data source factory
* @return JDBC dumper
*/
@SneakyThrows
public
static
JDBCDumper
newInstanceJdbcDumper
(
final
InventoryDumperConfiguration
inventoryDumperConfig
,
final
DataSourceManager
dataSourceManager
)
{
return
newInstanceJdbcDumper
(
inventoryDumperConfig
.
getDataSourceConfiguration
().
getDatabaseType
().
getName
(),
inventoryDumperConfig
,
dataSourceManager
);
}
...
...
@@ -53,7 +52,7 @@ public final class DumperFactory {
* @param dataSourceManager data source factory
* @return JDBC dumper
*/
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
static
JDBCDumper
newInstanceJdbcDumper
(
final
String
databaseType
,
final
InventoryDumperConfiguration
inventoryDumperConfig
,
final
DataSourceManager
dataSourceManager
)
{
ScalingEntry
scalingEntry
=
ScalingEntryLoader
.
getScalingEntryByDatabaseType
(
databaseType
);
return
scalingEntry
.
getJdbcDumperClass
().
getConstructor
(
InventoryDumperConfiguration
.
class
,
DataSourceManager
.
class
).
newInstance
(
inventoryDumperConfig
,
dataSourceManager
);
...
...
@@ -66,7 +65,6 @@ public final class DumperFactory {
* @param position position
* @return log dumper
*/
@SneakyThrows
public
static
LogDumper
newInstanceLogDumper
(
final
DumperConfiguration
dumperConfig
,
final
Position
position
)
{
return
newInstanceLogDumper
(
dumperConfig
.
getDataSourceConfiguration
().
getDatabaseType
().
getName
(),
dumperConfig
,
position
);
}
...
...
@@ -79,7 +77,7 @@ public final class DumperFactory {
* @param position position
* @return log dumper
*/
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
static
LogDumper
newInstanceLogDumper
(
final
String
databaseType
,
final
DumperConfiguration
dumperConfig
,
final
Position
position
)
{
ScalingEntry
scalingEntry
=
ScalingEntryLoader
.
getScalingEntryByDatabaseType
(
databaseType
);
return
scalingEntry
.
getLogDumperClass
().
getConstructor
(
DumperConfiguration
.
class
,
Position
.
class
).
newInstance
(
dumperConfig
,
position
);
...
...
shardingsphere-scaling/shardingsphere-scaling-core/src/main/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/ImporterFactory.java
浏览文件 @
3fdee3f2
...
...
@@ -50,7 +50,7 @@ public final class ImporterFactory {
* @param dataSourceManager data source factory
* @return importer
*/
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
static
Importer
newInstance
(
final
String
databaseType
,
final
ImporterConfiguration
importerConfig
,
final
DataSourceManager
dataSourceManager
)
{
ScalingEntry
scalingEntry
=
ScalingEntryLoader
.
getScalingEntryByDatabaseType
(
databaseType
);
return
scalingEntry
.
getImporterClass
().
getConstructor
(
ImporterConfiguration
.
class
,
DataSourceManager
.
class
).
newInstance
(
importerConfig
,
dataSourceManager
);
...
...
shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/ScalingJobControllerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.scaling.core
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.scaling.core.config.DataSourceConfiguration
;
import
org.apache.shardingsphere.scaling.core.config.DumperConfiguration
;
import
org.apache.shardingsphere.scaling.core.config.ImporterConfiguration
;
...
...
@@ -110,8 +109,7 @@ public final class ScalingJobControllerTest {
}
@Test
@SneakyThrows
(
ReflectiveOperationException
.
class
)
public
void
assertOnlyIncrementalDataTasks
()
{
public
void
assertOnlyIncrementalDataTasks
()
throws
NoSuchFieldException
,
IllegalAccessException
{
ReflectionUtil
.
setFieldValue
(
ResumeBreakPointManagerFactory
.
class
,
null
,
"clazz"
,
IncrementalPositionResumeBreakPointManager
.
class
);
ShardingScalingJob
shardingScalingJob
=
mockShardingScalingJob
();
scalingJobController
.
start
(
shardingScalingJob
);
...
...
shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/channel/DistributionChannelTest.java
浏览文件 @
3fdee3f2
...
...
@@ -20,7 +20,6 @@ package org.apache.shardingsphere.scaling.core.execute.executor.channel;
import
com.google.gson.JsonElement
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.scaling.core.config.ScalingContext
;
import
org.apache.shardingsphere.scaling.core.config.ServerConfiguration
;
import
org.apache.shardingsphere.scaling.core.execute.executor.record.FinishedRecord
;
...
...
@@ -33,6 +32,8 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.lang.reflect.InvocationTargetException
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
@@ -47,8 +48,7 @@ public final class DistributionChannelTest {
}
@Test
@SneakyThrows
({
InterruptedException
.
class
,
ReflectiveOperationException
.
class
})
public
void
assertAckCallbackResultSortable
()
{
public
void
assertAckCallbackResultSortable
()
throws
InterruptedException
,
NoSuchMethodException
,
IllegalAccessException
,
InvocationTargetException
{
distributionChannel
=
new
DistributionChannel
(
2
,
records
->
{
assertThat
(
records
.
size
(),
is
(
2
));
assertTrue
(((
IntPosition
)
records
.
get
(
0
).
getPosition
()).
getId
()
<
((
IntPosition
)
records
.
get
(
1
).
getPosition
()).
getId
());
...
...
@@ -71,8 +71,7 @@ public final class DistributionChannelTest {
}
@Test
@SneakyThrows
(
InterruptedException
.
class
)
public
void
assertBroadcastFinishedRecord
()
{
public
void
assertBroadcastFinishedRecord
()
throws
InterruptedException
{
distributionChannel
=
new
DistributionChannel
(
2
,
records
->
assertThat
(
records
.
size
(),
is
(
2
)));
distributionChannel
.
pushRecord
(
new
FinishedRecord
(
new
NopPosition
()));
}
...
...
shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractJDBCImporterTest.java
浏览文件 @
3fdee3f2
...
...
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.scaling.core.execute.executor.importer;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Sets
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.scaling.core.config.DataSourceConfiguration
;
import
org.apache.shardingsphere.scaling.core.config.ImporterConfiguration
;
import
org.apache.shardingsphere.scaling.core.datasource.DataSourceManager
;
...
...
@@ -98,8 +97,7 @@ public final class AbstractJDBCImporterTest {
}
@Test
@SneakyThrows
public
void
assertWriteInsertDataRecord
()
{
public
void
assertWriteInsertDataRecord
()
throws
SQLException
{
DataRecord
insertRecord
=
getDataRecord
(
"INSERT"
);
when
(
sqlBuilder
.
buildInsertSQL
(
insertRecord
)).
thenReturn
(
INSERT_SQL
);
when
(
connection
.
prepareStatement
(
INSERT_SQL
)).
thenReturn
(
preparedStatement
);
...
...
shardingsphere-scaling/shardingsphere-scaling-core/src/test/java/org/apache/shardingsphere/scaling/core/execute/executor/importer/AbstractSqlBuilderTest.java
浏览文件 @
3fdee3f2
...
...
@@ -18,11 +18,10 @@
package
org.apache.shardingsphere.scaling.core.execute.executor.importer
;
import
com.google.common.collect.Sets
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.scaling.core.execute.executor.record.RecordUtil
;
import
org.apache.shardingsphere.scaling.core.job.position.NopPosition
;
import
org.apache.shardingsphere.scaling.core.execute.executor.record.Column
;
import
org.apache.shardingsphere.scaling.core.execute.executor.record.DataRecord
;
import
org.apache.shardingsphere.scaling.core.execute.executor.record.RecordUtil
;
import
org.apache.shardingsphere.scaling.core.job.position.NopPosition
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -36,7 +35,6 @@ public class AbstractSqlBuilderTest {
private
AbstractSQLBuilder
sqlBuilder
;
@Before
@SneakyThrows
public
void
setUp
()
{
sqlBuilder
=
new
AbstractSQLBuilder
()
{
...
...
@@ -53,32 +51,32 @@ public class AbstractSqlBuilderTest {
}
@Test
public
void
assertBuildInsertS
ql
()
{
public
void
assertBuildInsertS
QL
()
{
String
actual
=
sqlBuilder
.
buildInsertSQL
(
mockDataRecord
(
"t1"
));
assertThat
(
actual
,
is
(
"INSERT INTO `t1`(`id`,`sc`,`c1`,`c2`,`c3`) VALUES(?,?,?,?,?)"
));
}
@Test
public
void
assertBuildUpdateS
ql
WithPrimaryKey
()
{
public
void
assertBuildUpdateS
QL
WithPrimaryKey
()
{
String
actual
=
sqlBuilder
.
buildUpdateSQL
(
mockDataRecord
(
"t2"
),
RecordUtil
.
extractPrimaryColumns
(
mockDataRecord
(
"t2"
)));
assertThat
(
actual
,
is
(
"UPDATE `t2` SET `c1` = ?,`c2` = ?,`c3` = ? WHERE `id` = ?"
));
}
@Test
public
void
assertBuildUpdateS
ql
WithShardingColumns
()
{
public
void
assertBuildUpdateS
QL
WithShardingColumns
()
{
DataRecord
dataRecord
=
mockDataRecord
(
"t2"
);
String
actual
=
sqlBuilder
.
buildUpdateSQL
(
dataRecord
,
mockConditionColumns
(
dataRecord
));
assertThat
(
actual
,
is
(
"UPDATE `t2` SET `c1` = ?,`c2` = ?,`c3` = ? WHERE `id` = ? and `sc` = ?"
));
}
@Test
public
void
assertBuildDeleteS
ql
WithPrimaryKey
()
{
public
void
assertBuildDeleteS
QL
WithPrimaryKey
()
{
String
actual
=
sqlBuilder
.
buildDeleteSQL
(
mockDataRecord
(
"t3"
),
RecordUtil
.
extractPrimaryColumns
(
mockDataRecord
(
"t3"
)));
assertThat
(
actual
,
is
(
"DELETE FROM `t3` WHERE `id` = ?"
));
}
@Test
public
void
assertBuildDeleteS
ql
WithConditionColumns
()
{
public
void
assertBuildDeleteS
QL
WithConditionColumns
()
{
DataRecord
dataRecord
=
mockDataRecord
(
"t3"
);
String
actual
=
sqlBuilder
.
buildDeleteSQL
(
dataRecord
,
mockConditionColumns
(
dataRecord
));
assertThat
(
actual
,
is
(
"DELETE FROM `t3` WHERE `id` = ? and `sc` = ?"
));
...
...
shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLJdbcDumperTest.java
浏览文件 @
3fdee3f2
...
...
@@ -78,8 +78,7 @@ public final class MySQLJdbcDumperTest {
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertReadValue
()
{
public
void
assertReadValue
()
throws
SQLException
{
ResultSet
resultSet
=
mock
(
ResultSet
.
class
);
ResultSetMetaData
resultSetMetaData
=
mock
(
ResultSetMetaData
.
class
);
when
(
resultSet
.
getMetaData
()).
thenReturn
(
resultSetMetaData
);
...
...
@@ -92,8 +91,7 @@ public final class MySQLJdbcDumperTest {
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertCreatePreparedStatement
()
{
public
void
assertCreatePreparedStatement
()
throws
SQLException
{
DataSource
dataSource
=
dataSourceManager
.
getDataSource
(
mockDumperConfiguration
().
getDataSourceConfiguration
());
try
(
Connection
connection
=
dataSource
.
getConnection
();
PreparedStatement
preparedStatement
=
mySQLJdbcDumper
.
createPreparedStatement
(
connection
,
"SELECT * FROM t_order"
))
{
...
...
shardingsphere-scaling/shardingsphere-scaling-mysql/src/test/java/org/apache/shardingsphere/scaling/mysql/MySQLPositionManagerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.scaling.mysql
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.scaling.mysql.binlog.BinlogPosition
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -52,8 +51,7 @@ public final class MySQLPositionManagerTest {
private
Connection
connection
;
@Before
@SneakyThrows
(
SQLException
.
class
)
public
void
setUp
()
{
public
void
setUp
()
throws
SQLException
{
when
(
dataSource
.
getConnection
()).
thenReturn
(
connection
);
PreparedStatement
positionStatement
=
mockPositionStatement
();
when
(
connection
.
prepareStatement
(
"SHOW MASTER STATUS"
)).
thenReturn
(
positionStatement
);
...
...
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLDataSourceCheckerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.scaling.postgresql
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.scaling.core.exception.PrepareFailedException
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -67,8 +66,7 @@ public final class PostgreSQLDataSourceCheckerTest {
dataSources
.
add
(
dataSource
);
}
@SneakyThrows
private
Connection
mockConnection
()
{
private
Connection
mockConnection
()
throws
SQLException
{
when
(
connection
.
getMetaData
()).
thenReturn
(
metaData
);
when
(
connection
.
getCatalog
()).
thenReturn
(
CATALOG
);
when
(
connection
.
prepareStatement
(
"SELECT * FROM test LIMIT 1"
)).
thenReturn
(
preparedStatement
);
...
...
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLJdbcDumperTest.java
浏览文件 @
3fdee3f2
...
...
@@ -66,8 +66,7 @@ public final class PostgreSQLJdbcDumperTest {
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertCreatePreparedStatement
()
{
public
void
assertCreatePreparedStatement
()
throws
SQLException
{
DataSource
dataSource
=
dataSourceManager
.
getDataSource
(
mockDumperConfiguration
().
getDataSourceConfiguration
());
try
(
Connection
connection
=
dataSource
.
getConnection
();
PreparedStatement
preparedStatement
=
postgreSQLJdbcDumper
.
createPreparedStatement
(
connection
,
"SELECT * FROM t_order"
))
{
...
...
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLPositionManagerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -55,8 +55,7 @@ public final class PostgreSQLPositionManagerTest {
private
DatabaseMetaData
databaseMetaData
;
@Before
@SneakyThrows
(
SQLException
.
class
)
public
void
setUp
()
{
public
void
setUp
()
throws
SQLException
{
when
(
dataSource
.
getConnection
()).
thenReturn
(
connection
);
when
(
connection
.
getMetaData
()).
thenReturn
(
databaseMetaData
);
PreparedStatement
postgreSQL96LsnPs
=
mockPostgreSQL96Lsn
();
...
...
@@ -75,8 +74,7 @@ public final class PostgreSQLPositionManagerTest {
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertGetCurrentPositionOnPostgreSQL96
()
{
public
void
assertGetCurrentPositionOnPostgreSQL96
()
throws
SQLException
{
PostgreSQLPositionManager
postgreSQLPositionManager
=
new
PostgreSQLPositionManager
(
dataSource
);
when
(
databaseMetaData
.
getDatabaseMajorVersion
()).
thenReturn
(
9
);
when
(
databaseMetaData
.
getDatabaseMinorVersion
()).
thenReturn
(
6
);
...
...
@@ -85,8 +83,7 @@ public final class PostgreSQLPositionManagerTest {
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertGetCurrentPositionOnPostgreSQL10
()
{
public
void
assertGetCurrentPositionOnPostgreSQL10
()
throws
SQLException
{
PostgreSQLPositionManager
postgreSQLPositionManager
=
new
PostgreSQLPositionManager
(
dataSource
);
when
(
databaseMetaData
.
getDatabaseMajorVersion
()).
thenReturn
(
10
);
WalPosition
actual
=
postgreSQLPositionManager
.
getPosition
();
...
...
@@ -94,8 +91,7 @@ public final class PostgreSQLPositionManagerTest {
}
@Test
(
expected
=
RuntimeException
.
class
)
@SneakyThrows
(
SQLException
.
class
)
public
void
assertGetCurrentPositionThrowException
()
{
public
void
assertGetCurrentPositionThrowException
()
throws
SQLException
{
PostgreSQLPositionManager
postgreSQLPositionManager
=
new
PostgreSQLPositionManager
(
dataSource
);
when
(
databaseMetaData
.
getDatabaseMajorVersion
()).
thenReturn
(
9
);
when
(
databaseMetaData
.
getDatabaseMinorVersion
()).
thenReturn
(
4
);
...
...
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/PostgreSQLWalDumperTest.java
浏览文件 @
3fdee3f2
...
...
@@ -17,7 +17,6 @@
package
org.apache.shardingsphere.scaling.postgresql
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.scaling.core.config.DumperConfiguration
;
import
org.apache.shardingsphere.scaling.core.config.JDBCDataSourceConfiguration
;
import
org.apache.shardingsphere.scaling.core.config.ScalingContext
;
...
...
@@ -81,8 +80,7 @@ public final class PostgreSQLWalDumperTest {
}
@Test
@SneakyThrows
({
ReflectiveOperationException
.
class
,
SQLException
.
class
})
public
void
assertStart
()
{
public
void
assertStart
()
throws
SQLException
,
NoSuchFieldException
,
IllegalAccessException
{
try
{
ReflectionUtil
.
setFieldValueToClass
(
postgreSQLWalDumper
,
"logicalReplication"
,
logicalReplication
);
when
(
logicalReplication
.
createPgConnection
(
jdbcDataSourceConfig
)).
thenReturn
(
pgConnection
);
...
...
shardingsphere-scaling/shardingsphere-scaling-postgresql/src/test/java/org/apache/shardingsphere/scaling/postgresql/wal/LogicalReplicationTest.java
浏览文件 @
3fdee3f2
...
...
@@ -63,16 +63,14 @@ public final class LogicalReplicationTest {
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertCreatePgConnectionSuccess
()
{
public
void
assertCreatePgConnectionSuccess
()
throws
SQLException
{
Connection
pgConnection
=
logicalReplication
.
createPgConnection
(
new
JDBCDataSourceConfiguration
(
"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=PostgreSQL"
,
"root"
,
"root"
));
assertFalse
(
pgConnection
.
isClosed
());
}
@Test
@SneakyThrows
(
SQLException
.
class
)
public
void
assertCreateReplicationStreamSuccess
()
{
public
void
assertCreateReplicationStreamSuccess
()
throws
SQLException
{
LogSequenceNumber
startPosition
=
LogSequenceNumber
.
valueOf
(
100L
);
when
(
pgConnection
.
unwrap
(
PGConnection
.
class
)).
thenReturn
(
pgConnection
);
when
(
pgConnection
.
getReplicationAPI
()).
thenReturn
(
pgReplicationConnection
);
...
...
shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/ParseTreeVisitorFactory.java
浏览文件 @
3fdee3f2
...
...
@@ -44,7 +44,7 @@ public final class ParseTreeVisitorFactory {
return
createParseTreeVisitor
(
SQLParserConfigurationRegistry
.
getInstance
().
getSQLParserConfiguration
(
databaseTypeName
),
visitorRule
.
getType
());
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
static
ParseTreeVisitor
createParseTreeVisitor
(
final
SQLParserConfiguration
config
,
final
SQLStatementType
type
)
{
SQLVisitorFacade
visitorFacade
=
config
.
getVisitorFacadeClass
().
getConstructor
().
newInstance
();
switch
(
type
)
{
...
...
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/SafeNumberOperationUtils.java
浏览文件 @
3fdee3f2
...
...
@@ -164,7 +164,7 @@ public final class SafeNumberOperationUtils {
return
null
;
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
static
Comparable
<?>
parseNumberByClazz
(
final
String
number
,
final
Class
<?>
clazz
)
{
return
(
Comparable
<?>)
clazz
.
getConstructor
(
String
.
class
).
newInstance
(
number
);
}
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-atomikos/src/main/java/org/apache/shardingsphere/transaction/xa/atomikos/manager/AtomikosTransactionManager.java
浏览文件 @
3fdee3f2
...
...
@@ -25,6 +25,8 @@ import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import
org.apache.shardingsphere.transaction.xa.spi.XATransactionManager
;
import
javax.sql.XADataSource
;
import
javax.transaction.RollbackException
;
import
javax.transaction.SystemException
;
import
javax.transaction.TransactionManager
;
/**
...
...
@@ -51,8 +53,8 @@ public final class AtomikosTransactionManager implements XATransactionManager {
userTransactionService
.
removeResource
(
new
AtomikosXARecoverableResource
(
dataSourceName
,
xaDataSource
));
}
@SneakyThrows
({
SystemException
.
class
,
RollbackException
.
class
})
@Override
@SneakyThrows
public
void
enlistResource
(
final
SingleXAResource
xaResource
)
{
transactionManager
.
getTransaction
().
enlistResource
(
xaResource
);
}
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixRecoveryResource.java
浏览文件 @
3fdee3f2
...
...
@@ -30,6 +30,7 @@ import javax.naming.Reference;
import
javax.sql.XAConnection
;
import
javax.sql.XADataSource
;
import
javax.transaction.xa.XAResource
;
import
java.sql.SQLException
;
/**
* Bitronix recovery resource.
...
...
@@ -54,7 +55,7 @@ public final class BitronixRecoveryResource extends ResourceBean implements XARe
return
resourceName
;
}
@SneakyThrows
@SneakyThrows
(
SQLException
.
class
)
@Override
public
XAResourceHolderState
startRecovery
()
{
xaConnection
=
xaDataSource
.
getXAConnection
();
...
...
@@ -62,7 +63,7 @@ public final class BitronixRecoveryResource extends ResourceBean implements XARe
return
new
XAResourceHolderState
(
singleXAResourceHolder
,
this
);
}
@SneakyThrows
@SneakyThrows
(
SQLException
.
class
)
@Override
public
void
endRecovery
()
{
if
(
null
!=
xaConnection
)
{
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/main/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManager.java
浏览文件 @
3fdee3f2
...
...
@@ -19,12 +19,15 @@ package org.apache.shardingsphere.transaction.xa.bitronix.manager;
import
bitronix.tm.BitronixTransactionManager
;
import
bitronix.tm.TransactionManagerServices
;
import
bitronix.tm.recovery.RecoveryException
;
import
bitronix.tm.resource.ResourceRegistrar
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.transaction.xa.spi.SingleXAResource
;
import
org.apache.shardingsphere.transaction.xa.spi.XATransactionManager
;
import
javax.sql.XADataSource
;
import
javax.transaction.RollbackException
;
import
javax.transaction.SystemException
;
import
javax.transaction.TransactionManager
;
/**
...
...
@@ -38,19 +41,18 @@ public final class BitronixXATransactionManager implements XATransactionManager
public
void
init
()
{
}
@SneakyThrows
@SneakyThrows
(
RecoveryException
.
class
)
@Override
public
void
registerRecoveryResource
(
final
String
dataSourceName
,
final
XADataSource
xaDataSource
)
{
ResourceRegistrar
.
register
(
new
BitronixRecoveryResource
(
dataSourceName
,
xaDataSource
));
}
@SneakyThrows
@Override
public
void
removeRecoveryResource
(
final
String
dataSourceName
,
final
XADataSource
xaDataSource
)
{
ResourceRegistrar
.
unregister
(
new
BitronixRecoveryResource
(
dataSourceName
,
xaDataSource
));
}
@SneakyThrows
@SneakyThrows
({
SystemException
.
class
,
RollbackException
.
class
})
@Override
public
void
enlistResource
(
final
SingleXAResource
singleXAResource
)
{
bitronixTransactionManager
.
getTransaction
().
enlistResource
(
singleXAResource
);
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-bitronix/src/test/java/org/apache/shardingsphere/transaction/xa/bitronix/manager/BitronixXATransactionManagerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.transaction.xa.bitronix.manager;
import
bitronix.tm.BitronixTransactionManager
;
import
bitronix.tm.resource.ResourceRegistrar
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.transaction.xa.bitronix.manager.fixture.ReflectiveUtil
;
import
org.apache.shardingsphere.transaction.xa.spi.SingleXAResource
;
import
org.junit.Before
;
...
...
@@ -30,8 +29,11 @@ import org.mockito.junit.MockitoJUnitRunner;
import
javax.sql.XAConnection
;
import
javax.sql.XADataSource
;
import
javax.transaction.RollbackException
;
import
javax.transaction.SystemException
;
import
javax.transaction.Transaction
;
import
javax.transaction.xa.XAResource
;
import
java.sql.SQLException
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
...
@@ -52,9 +54,8 @@ public final class BitronixXATransactionManagerTest {
@Mock
private
XADataSource
xaDataSource
;
@SneakyThrows
@Before
public
void
setUp
()
{
public
void
setUp
()
throws
SQLException
{
ReflectiveUtil
.
setProperty
(
bitronixXATransactionManager
,
"bitronixTransactionManager"
,
bitronixTransactionManager
);
XAConnection
xaConnection
=
mock
(
XAConnection
.
class
);
XAResource
xaResource
=
mock
(
XAResource
.
class
);
...
...
@@ -70,9 +71,8 @@ public final class BitronixXATransactionManagerTest {
assertNull
(
ResourceRegistrar
.
get
(
"ds1"
));
}
@SneakyThrows
@Test
public
void
assertEnlistResource
()
{
public
void
assertEnlistResource
()
throws
SystemException
,
RollbackException
{
SingleXAResource
singleXAResource
=
mock
(
SingleXAResource
.
class
);
Transaction
transaction
=
mock
(
Transaction
.
class
);
when
(
bitronixTransactionManager
.
getTransaction
()).
thenReturn
(
transaction
);
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/XAShardingTransactionManager.java
浏览文件 @
3fdee3f2
...
...
@@ -26,6 +26,9 @@ import org.apache.shardingsphere.transaction.xa.jta.datasource.XATransactionData
import
org.apache.shardingsphere.transaction.xa.manager.XATransactionManagerLoader
;
import
org.apache.shardingsphere.transaction.xa.spi.XATransactionManager
;
import
javax.transaction.HeuristicMixedException
;
import
javax.transaction.HeuristicRollbackException
;
import
javax.transaction.NotSupportedException
;
import
javax.transaction.RollbackException
;
import
javax.transaction.Status
;
import
javax.transaction.SystemException
;
...
...
@@ -57,7 +60,7 @@ public final class XAShardingTransactionManager implements ShardingTransactionMa
return
TransactionType
.
XA
;
}
@SneakyThrows
@SneakyThrows
(
SystemException
.
class
)
@Override
public
boolean
isInTransaction
()
{
return
Status
.
STATUS_NO_TRANSACTION
!=
xaTransactionManager
.
getTransactionManager
().
getStatus
();
...
...
@@ -72,19 +75,19 @@ public final class XAShardingTransactionManager implements ShardingTransactionMa
}
}
@SneakyThrows
@SneakyThrows
({
SystemException
.
class
,
NotSupportedException
.
class
})
@Override
public
void
begin
()
{
xaTransactionManager
.
getTransactionManager
().
begin
();
}
@SneakyThrows
@SneakyThrows
({
SystemException
.
class
,
RollbackException
.
class
,
HeuristicMixedException
.
class
,
HeuristicRollbackException
.
class
})
@Override
public
void
commit
()
{
xaTransactionManager
.
getTransactionManager
().
commit
();
}
@SneakyThrows
@SneakyThrows
(
SystemException
.
class
)
@Override
public
void
rollback
()
{
xaTransactionManager
.
getTransactionManager
().
rollback
();
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/H2XAConnectionWrapper.java
浏览文件 @
3fdee3f2
...
...
@@ -29,6 +29,7 @@ import javax.sql.XADataSource;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
/**
* XA connection wrapper for H2.
...
...
@@ -43,21 +44,21 @@ public final class H2XAConnectionWrapper implements XAConnectionWrapper {
private
static
final
JdbcDataSourceFactory
FACTORY
=
new
JdbcDataSourceFactory
();
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
static
Constructor
<
JdbcXAConnection
>
getH2JdbcXAConstructor
()
{
Constructor
<
JdbcXAConnection
>
result
=
JdbcXAConnection
.
class
.
getDeclaredConstructor
(
JdbcDataSourceFactory
.
class
,
Integer
.
TYPE
,
JdbcConnection
.
class
);
result
.
setAccessible
(
true
);
return
result
;
}
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
private
static
Method
getNextIdMethod
()
{
Method
result
=
TraceObject
.
class
.
getDeclaredMethod
(
"getNextId"
,
Integer
.
TYPE
);
result
.
setAccessible
(
true
);
return
result
;
}
@SneakyThrows
@SneakyThrows
({
SQLException
.
class
,
ReflectiveOperationException
.
class
})
@Override
public
XAConnection
wrap
(
final
XADataSource
xaDataSource
,
final
Connection
connection
)
{
Connection
physicalConnection
=
connection
.
unwrap
(
JdbcConnection
.
class
);
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MariaDBXAConnectionWrapper.java
浏览文件 @
3fdee3f2
...
...
@@ -26,14 +26,15 @@ import org.mariadb.jdbc.MariaXaConnection;
import
javax.sql.XAConnection
;
import
javax.sql.XADataSource
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
/**
* XA connection wrapper for MariaDB.
*/
@RequiredArgsConstructor
public
final
class
MariaDBXAConnectionWrapper
implements
XAConnectionWrapper
{
@SneakyThrows
@SneakyThrows
({
SQLException
.
class
,
ReflectiveOperationException
.
class
})
@Override
public
XAConnection
wrap
(
final
XADataSource
xaDataSource
,
final
Connection
connection
)
{
MariaDbConnection
physicalConnection
=
(
MariaDbConnection
)
connection
.
unwrap
(
Class
.
forName
(
"org.mariadb.jdbc.MariaDbConnection"
));
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/MySQLXAConnectionWrapper.java
浏览文件 @
3fdee3f2
...
...
@@ -25,6 +25,7 @@ import javax.sql.XAConnection;
import
javax.sql.XADataSource
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
/**
* XA connection wrapper for MySQL.
...
...
@@ -36,7 +37,7 @@ public final class MySQLXAConnectionWrapper implements XAConnectionWrapper {
private
static
final
String
MYSQL_XA_DATASOURCE_8
=
"com.mysql.cj.jdbc.MysqlXADataSource"
;
@SneakyThrows
@SneakyThrows
(
ReflectiveOperationException
.
class
)
@Override
public
XAConnection
wrap
(
final
XADataSource
xaDataSource
,
final
Connection
connection
)
{
Connection
physicalConnection
=
unwrapPhysicalConnection
(
xaDataSource
.
getClass
().
getName
(),
connection
);
...
...
@@ -45,7 +46,7 @@ public final class MySQLXAConnectionWrapper implements XAConnectionWrapper {
return
(
XAConnection
)
method
.
invoke
(
xaDataSource
,
physicalConnection
);
}
@SneakyThrows
@SneakyThrows
({
SQLException
.
class
,
ClassNotFoundException
.
class
})
private
Connection
unwrapPhysicalConnection
(
final
String
xaDataSourceClassName
,
final
Connection
connection
)
{
switch
(
xaDataSourceClassName
)
{
case
MYSQL_XA_DATASOURCE_5:
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/OracleXAConnectionWrapper.java
浏览文件 @
3fdee3f2
...
...
@@ -25,6 +25,7 @@ import javax.sql.XAConnection;
import
javax.sql.XADataSource
;
import
java.lang.reflect.Constructor
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
/**
* XA connection wrapper for Oracle.
...
...
@@ -33,7 +34,7 @@ import java.sql.Connection;
public
final
class
OracleXAConnectionWrapper
implements
XAConnectionWrapper
{
@SuppressWarnings
(
"unchecked"
)
@SneakyThrows
@SneakyThrows
({
SQLException
.
class
,
ReflectiveOperationException
.
class
})
@Override
public
XAConnection
wrap
(
final
XADataSource
xaDataSource
,
final
Connection
connection
)
{
Connection
physicalConnection
=
(
Connection
)
connection
.
unwrap
(
Class
.
forName
(
"oracle.jdbc.internal.OracleConnection"
));
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/dialect/PostgreSQLXAConnectionWrapper.java
浏览文件 @
3fdee3f2
...
...
@@ -25,13 +25,14 @@ import org.postgresql.xa.PGXAConnection;
import
javax.sql.XAConnection
;
import
javax.sql.XADataSource
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
/**
* PostgreSQL XA connection wrapper.
*/
public
final
class
PostgreSQLXAConnectionWrapper
implements
XAConnectionWrapper
{
@SneakyThrows
@SneakyThrows
({
SQLException
.
class
,
ClassNotFoundException
.
class
})
@Override
public
XAConnection
wrap
(
final
XADataSource
xaDataSource
,
final
Connection
connection
)
{
BaseConnection
physicalConnection
=
(
BaseConnection
)
connection
.
unwrap
(
Class
.
forName
(
"org.postgresql.core.BaseConnection"
));
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManager.java
浏览文件 @
3fdee3f2
...
...
@@ -26,6 +26,8 @@ import org.apache.shardingsphere.transaction.xa.spi.SingleXAResource;
import
org.apache.shardingsphere.transaction.xa.spi.XATransactionManager
;
import
javax.sql.XADataSource
;
import
javax.transaction.RollbackException
;
import
javax.transaction.SystemException
;
import
javax.transaction.TransactionManager
;
/**
...
...
@@ -56,7 +58,7 @@ public final class NarayanaXATransactionManager implements XATransactionManager
xaRecoveryModule
.
removeXAResourceRecoveryHelper
(
new
DataSourceXAResourceRecoveryHelper
(
xaDataSource
));
}
@SneakyThrows
@SneakyThrows
({
SystemException
.
class
,
RollbackException
.
class
})
@Override
public
void
enlistResource
(
final
SingleXAResource
singleXAResource
)
{
transactionManager
.
getTransaction
().
enlistResource
(
singleXAResource
.
getDelegate
());
...
...
shardingsphere-transaction/shardingsphere-transaction-2pc/shardingsphere-transaction-xa/shardingsphere-transaction-xa-narayana/src/test/java/org/apache/shardingsphere/transaction/xa/narayana/manager/NarayanaXATransactionManagerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.transaction.xa.narayana.manager;
import
com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule
;
import
com.arjuna.ats.jbossatx.jta.RecoveryManagerService
;
import
lombok.SneakyThrows
;
import
org.apache.shardingsphere.transaction.xa.narayana.manager.fixture.ReflectiveUtil
;
import
org.apache.shardingsphere.transaction.xa.spi.SingleXAResource
;
import
org.junit.Before
;
...
...
@@ -29,6 +28,8 @@ import org.mockito.Mock;
import
org.mockito.junit.MockitoJUnitRunner
;
import
javax.sql.XADataSource
;
import
javax.transaction.RollbackException
;
import
javax.transaction.SystemException
;
import
javax.transaction.Transaction
;
import
javax.transaction.TransactionManager
;
...
...
@@ -56,7 +57,6 @@ public final class NarayanaXATransactionManagerTest {
@Mock
private
XADataSource
xaDataSource
;
@SneakyThrows
@Before
public
void
setUp
()
{
ReflectiveUtil
.
setProperty
(
narayanaXATransactionManager
,
"xaRecoveryModule"
,
xaRecoveryModule
);
...
...
@@ -64,7 +64,6 @@ public final class NarayanaXATransactionManagerTest {
ReflectiveUtil
.
setProperty
(
narayanaXATransactionManager
,
"recoveryManagerService"
,
recoveryManagerService
);
}
@SneakyThrows
@Test
public
void
assertInit
()
{
narayanaXATransactionManager
.
init
();
...
...
@@ -84,9 +83,8 @@ public final class NarayanaXATransactionManagerTest {
verify
(
xaRecoveryModule
).
removeXAResourceRecoveryHelper
(
any
(
DataSourceXAResourceRecoveryHelper
.
class
));
}
@SneakyThrows
@Test
public
void
assertEnlistResource
()
{
public
void
assertEnlistResource
()
throws
SystemException
,
RollbackException
{
SingleXAResource
singleXAResource
=
mock
(
SingleXAResource
.
class
);
Transaction
transaction
=
mock
(
Transaction
.
class
);
when
(
transactionManager
.
getTransaction
()).
thenReturn
(
transaction
);
...
...
@@ -99,9 +97,8 @@ public final class NarayanaXATransactionManagerTest {
assertThat
(
narayanaXATransactionManager
.
getTransactionManager
(),
is
(
transactionManager
));
}
@SneakyThrows
@Test
public
void
assertClose
()
{
public
void
assertClose
()
throws
Exception
{
narayanaXATransactionManager
.
close
();
verify
(
recoveryManagerService
).
stop
();
verify
(
recoveryManagerService
).
destroy
();
...
...
shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/main/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManager.java
浏览文件 @
3fdee3f2
...
...
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.transaction.base.seata.at;
import
com.google.common.base.Preconditions
;
import
io.seata.config.FileConfiguration
;
import
io.seata.core.context.RootContext
;
import
io.seata.core.exception.TransactionException
;
import
io.seata.core.rpc.netty.RmRpcClient
;
import
io.seata.core.rpc.netty.TmRpcClient
;
import
io.seata.rm.RMClient
;
...
...
@@ -94,7 +95,7 @@ public final class SeataATShardingTransactionManager implements ShardingTransact
}
@Override
@SneakyThrows
@SneakyThrows
(
TransactionException
.
class
)
public
void
begin
()
{
Preconditions
.
checkState
(
enableSeataAT
,
"sharding seata-at transaction has been disabled."
);
GlobalTransaction
globalTransaction
=
GlobalTransactionContext
.
getCurrentOrCreate
();
...
...
@@ -103,7 +104,7 @@ public final class SeataATShardingTransactionManager implements ShardingTransact
}
@Override
@SneakyThrows
@SneakyThrows
(
TransactionException
.
class
)
public
void
commit
()
{
Preconditions
.
checkState
(
enableSeataAT
,
"sharding seata-at transaction has been disabled."
);
try
{
...
...
@@ -115,7 +116,7 @@ public final class SeataATShardingTransactionManager implements ShardingTransact
}
@Override
@SneakyThrows
@SneakyThrows
(
TransactionException
.
class
)
public
void
rollback
()
{
Preconditions
.
checkState
(
enableSeataAT
,
"sharding seata-at transaction has been disabled."
);
try
{
...
...
shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/SeataATShardingTransactionManagerTest.java
浏览文件 @
3fdee3f2
...
...
@@ -47,6 +47,7 @@ import org.mockito.junit.MockitoJUnitRunner;
import
javax.sql.DataSource
;
import
java.lang.reflect.Field
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Map
;
...
...
@@ -124,8 +125,7 @@ public final class SeataATShardingTransactionManagerTest {
}
@Test
@SneakyThrows
public
void
assertGetConnection
()
{
public
void
assertGetConnection
()
throws
SQLException
{
Connection
actual
=
seataATShardingTransactionManager
.
getConnection
(
"demo_ds"
);
assertThat
(
actual
,
instanceOf
(
ConnectionProxy
.
class
));
}
...
...
shardingsphere-transaction/shardingsphere-transaction-base/shardingsphere-transaction-base-seata-at/src/test/java/org/apache/shardingsphere/transaction/base/seata/at/fixture/MockSeataServer.java
浏览文件 @
3fdee3f2
...
...
@@ -64,7 +64,7 @@ public final class MockSeataServer {
/**
* start.
*/
@SneakyThrows
@SneakyThrows
(
InterruptedException
.
class
)
public
void
start
()
{
bootstrap
.
group
(
bossGroup
,
workerGroup
)
.
channel
(
NioServerSocketChannel
.
class
)
...
...
@@ -90,7 +90,6 @@ public final class MockSeataServer {
/**
* shutdown.
*/
@SneakyThrows
public
void
shutdown
()
{
if
(
initialized
.
get
())
{
bossGroup
.
shutdownGracefully
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录