This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 9a398fd Use assertTrue to instead of assertThat(xxx, is(true))
(#11528)
9a398fd is described below
commit 9a398fd85fea49169bfae411db0fc5080906a708
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jul 27 13:27:26 2021 +0800
Use assertTrue to instead of assertThat(xxx, is(true)) (#11528)
---
.../agent/core/plugin/loader/PluginLoaderTest.java | 12 +--
.../advice/CommandExecutorTaskAdviceTest.java | 3 +-
.../jaeger/advice/SQLParserEngineAdviceTest.java | 3 +-
.../JaegerTracingPluginBootServiceTest.java | 8 +-
.../advice/CommandExecutorTaskAdviceTest.java | 3 +-
.../advice/SQLParserEngineAdviceTest.java | 13 +--
.../service/OpenTracingPluginBootServiceTest.java | 6 +-
.../PostgreSQLArrayParameterDecoderTest.java | 7 +-
...ationsForYamlShardingRuleConfigurationTest.java | 2 +-
.../watcher/PropertiesChangedWatcherTest.java | 4 +-
.../zookeeper/CuratorZookeeperRepositoryTest.java | 10 +-
.../authority/checker/AuthorityCheckerTest.java | 103 +++++++--------------
.../NativeAuthorityProviderAlgorithmTest.java | 15 +--
.../builder/StoragePrivilegeBuilderTest.java | 27 +++---
.../dialect/OraclePrivilegeHandlerTest.java | 3 +-
.../dialect/PostgreSQLPrivilegeHandlerTest.java | 2 +-
.../dialect/SQLServerPrivilegeHandlerTest.java | 31 +++----
.../jdbc/metadata/JDBCQueryResultMetaDataTest.java | 7 +-
.../engine/single/SingleTableRouteEngineTest.java | 6 +-
.../jdbc/core/resultset/ResultSetUtilTest.java | 6 +-
.../jdbc/connection/ConnectionStatusTest.java | 14 +--
.../PostgreSQLAuthenticationEngineTest.java | 5 +-
22 files changed, 132 insertions(+), 158 deletions(-)
diff --git
a/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/PluginLoaderTest.java
b/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/PluginLoaderTest.java
index 973b2c5..8d0511f 100644
---
a/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/PluginLoaderTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-core/src/test/java/org/apache/shardingsphere/agent/core/plugin/loader/PluginLoaderTest.java
@@ -35,9 +35,9 @@ import org.mockito.internal.util.reflection.FieldSetter;
import java.util.Collections;
import java.util.Map;
-import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
@Category(PluginLoaderTest.class)
public final class PluginLoaderTest {
@@ -75,14 +75,14 @@ public final class PluginLoaderTest {
@Test
public void assertTypeMatcher() {
- assertThat(PLUGIN_LOADER.typeMatcher().matches(MATERIAL), is(true));
- assertThat(PLUGIN_LOADER.typeMatcher().matches(FAKE), is(false));
+ assertTrue(PLUGIN_LOADER.typeMatcher().matches(MATERIAL));
+ assertFalse(PLUGIN_LOADER.typeMatcher().matches(FAKE));
}
@Test
public void assertContainsType() {
- assertThat(PLUGIN_LOADER.containsType(MATERIAL), is(true));
- assertThat(PLUGIN_LOADER.containsType(FAKE), is(false));
+ assertTrue(PLUGIN_LOADER.containsType(MATERIAL));
+ assertFalse(PLUGIN_LOADER.containsType(FAKE));
}
@Test
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
index c8b1af7..d9453e3 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/CommandExecutorTaskAdviceTest.java
@@ -36,6 +36,7 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class CommandExecutorTaskAdviceTest extends
AbstractCommandExecutorTaskAdviceTest {
@@ -71,7 +72,7 @@ public final class CommandExecutorTaskAdviceTest extends
AbstractCommandExecutor
List<MockSpan> spans = COLLECTOR.finishedSpans();
assertThat(spans.size(), is(1));
MockSpan span = spans.get(0);
- assertThat(span.tags().get("error"), is(true));
+ assertTrue((boolean) span.tags().get("error"));
List<LogEntry> entries = span.logEntries();
assertThat(entries.size(), is(1));
Map<String, ?> fields = entries.get(0).fields();
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
index 89c74be..ab61663 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/advice/SQLParserEngineAdviceTest.java
@@ -31,6 +31,7 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class SQLParserEngineAdviceTest extends
AbstractSQLParserEngineAdviceTest {
@@ -57,7 +58,7 @@ public final class SQLParserEngineAdviceTest extends
AbstractSQLParserEngineAdvi
List<MockSpan> spans = COLLECTOR.finishedSpans();
assertThat(spans.size(), is(1));
MockSpan span = spans.get(0);
- assertThat(span.tags().get("error"), is(true));
+ assertTrue((boolean) span.tags().get("error"));
List<MockSpan.LogEntry> entries = span.logEntries();
assertThat(entries.size(), is(1));
Map<String, ?> fields = entries.get(0).fields();
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
index 07cf666..dcd27e7 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-jaeger/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/jaeger/service/JaegerTracingPluginBootServiceTest.java
@@ -19,15 +19,17 @@ package
org.apache.shardingsphere.agent.plugin.tracing.jaeger.service;
import io.opentracing.noop.NoopTracerFactory;
import io.opentracing.util.GlobalTracer;
-import java.lang.reflect.Field;
-import java.util.Properties;
import lombok.SneakyThrows;
import org.apache.shardingsphere.agent.config.PluginConfiguration;
import org.junit.After;
import org.junit.Test;
+import java.lang.reflect.Field;
+import java.util.Properties;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class JaegerTracingPluginBootServiceTest {
@@ -42,7 +44,7 @@ public final class JaegerTracingPluginBootServiceTest {
props.setProperty("JAEGER_REPORTER_FLUSH_INTERVAL", "1");
PluginConfiguration configuration = new
PluginConfiguration("localhost", 5775, "", props);
jaegerTracingPluginBootService.start(configuration);
- assertThat(GlobalTracer.isRegistered(), is(true));
+ assertTrue(GlobalTracer.isRegistered());
}
@Test
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
index ff3c3e6..1fe3294 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/CommandExecutorTaskAdviceTest.java
@@ -40,6 +40,7 @@ import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class CommandExecutorTaskAdviceTest {
@@ -85,7 +86,7 @@ public final class CommandExecutorTaskAdviceTest {
List<MockSpan> spans = tracer.finishedSpans();
assertThat(spans.size(), is(1));
MockSpan span = spans.get(0);
- assertThat(span.tags().get("error"), is(true));
+ assertTrue((boolean) span.tags().get("error"));
List<LogEntry> entries = span.logEntries();
assertThat(entries.size(), is(1));
Map<String, ?> fields = entries.get(0).fields();
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/SQLParserEngineAdviceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/SQLParserEngineAdviceTest.java
index 838f3b5..51e3341 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/SQLParserEngineAdviceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/advice/SQLParserEngineAdviceTest.java
@@ -20,21 +20,22 @@ package
org.apache.shardingsphere.agent.plugin.tracing.opentracing.advice;
import io.opentracing.mock.MockSpan;
import io.opentracing.mock.MockTracer;
import io.opentracing.util.GlobalTracer;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
import org.apache.shardingsphere.agent.api.result.MethodInvocationResult;
import
org.apache.shardingsphere.agent.plugin.tracing.opentracing.constant.ErrorLogTagKeys;
import org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine;
-
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.internal.util.reflection.FieldReader;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class SQLParserEngineAdviceTest {
@@ -79,7 +80,7 @@ public final class SQLParserEngineAdviceTest {
List<MockSpan> spans = tracer.finishedSpans();
assertThat(spans.size(), is(1));
MockSpan span = spans.get(0);
- assertThat(span.tags().get("error"), is(true));
+ assertTrue((boolean) span.tags().get("error"));
List<MockSpan.LogEntry> entries = span.logEntries();
assertThat(entries.size(), is(1));
Map<String, ?> fields = entries.get(0).fields();
diff --git
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootServiceTest.java
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootSer
[...]
index 553dddc..e64681b 100644
---
a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootServiceTest.java
+++
b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-opentracing/src/test/java/org/apache/shardingsphere/agent/plugin/tracing/opentracing/service/OpenTracingPluginBootServiceTest.java
@@ -18,13 +18,15 @@
package org.apache.shardingsphere.agent.plugin.tracing.opentracing.service;
import io.opentracing.util.GlobalTracer;
-import java.util.Properties;
import org.apache.shardingsphere.agent.config.PluginConfiguration;
import org.junit.After;
import org.junit.Test;
+import java.util.Properties;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class OpenTracingPluginBootServiceTest {
@@ -36,7 +38,7 @@ public final class OpenTracingPluginBootServiceTest {
props.setProperty("OPENTRACING_TRACER_CLASS_NAME",
"io.opentracing.mock.MockTracer");
PluginConfiguration configuration = new
PluginConfiguration("localhost", 8090, "", props);
openTracingPluginBootService.start(configuration);
- assertThat(GlobalTracer.isRegistered(), is(true));
+ assertTrue(GlobalTracer.isRegistered());
}
@Test
diff --git
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLArrayParameterDecoderTest.java
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLArrayParameterDecoderTest.java
index 58718cf..ff6232f 100644
---
a/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLArrayParameterDecoderTest.java
+++
b/shardingsphere-db-protocol/shardingsphere-db-protocol-postgresql/src/test/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/binary/bind/protocol/PostgreSQLArrayParameterDecoderTest.java
@@ -20,9 +20,11 @@ package
org.apache.shardingsphere.db.protocol.postgresql.packet.command.query.bi
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class PostgreSQLArrayParameterDecoderTest {
@@ -82,8 +84,8 @@ public final class PostgreSQLArrayParameterDecoderTest {
boolean[] result =
DECODER.decodeBoolArray("{\"true\",\"false\"}".getBytes(), false);
assertNotNull(result);
assertThat(result.length, is(2));
- assertThat(result[0], is(true));
- assertThat(result[1], is(false));
+ assertTrue(result[0]);
+ assertFalse(result[1]);
}
@Test
@@ -114,5 +116,4 @@ public final class PostgreSQLArrayParameterDecoderTest {
assertThat(result[1], is("b"));
assertNull(result[2]);
}
-
}
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/swapper/YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/swapper/YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTest.java
index 83e8170..24e5e78 100644
---
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/swapper/YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTest.java
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/swapper/YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTest.java
@@ -123,6 +123,6 @@ public final class
YamlRootRuleConfigurationsForYamlShardingRuleConfigurationTes
private void assertProps(final YamlRootRuleConfigurations actual) {
assertThat(actual.getProps().size(), is(1));
-
assertThat(actual.getProps().get(ConfigurationPropertyKey.SQL_SHOW.getKey()),
is(true));
+ assertTrue((boolean)
actual.getProps().get(ConfigurationPropertyKey.SQL_SHOW.getKey()));
}
}
diff --git
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/config/watcher/PropertiesChangedWatcherTest.java
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/config/watcher/PropertiesChangedWatcherTest.java
index f193e95..ab13312 100644
---
a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/config/watcher/PropertiesChangedWatcherTest.java
+++
b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/config/watcher/PropertiesChangedWatcherTest.java
@@ -25,8 +25,6 @@ import org.junit.Test;
import java.util.Optional;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public final class PropertiesChangedWatcherTest {
@@ -37,6 +35,6 @@ public final class PropertiesChangedWatcherTest {
public void assertCreateEvent() {
Optional<PropertiesChangedEvent> actual = new
PropertiesChangedWatcher().createGovernanceEvent(new DataChangedEvent("test",
PROPERTIES_YAML, Type.UPDATED));
assertTrue(actual.isPresent());
-
assertThat(actual.get().getProps().get(ConfigurationPropertyKey.SQL_SHOW.getKey()),
is(true));
+ assertTrue((boolean)
actual.get().getProps().get(ConfigurationPropertyKey.SQL_SHOW.getKey()));
}
}
diff --git
a/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/governance/repository/zookeeper/CuratorZookeeperRepositoryTest.java
b/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/go
[...]
index 504f96b..ad82dae 100644
---
a/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/governance/repository/zookeeper/CuratorZookeeperRepositoryTest.java
+++
b/shardingsphere-governance/shardingsphere-governance-repository/shardingsphere-governance-repository-provider/shardingsphere-governance-repository-zookeeper-curator/src/test/java/org/apache/shardingsphere/governance/repository/zookeeper/CuratorZookeeperRepositoryTest.java
@@ -68,8 +68,10 @@ import java.util.Properties;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
@@ -281,8 +283,8 @@ public final class CuratorZookeeperRepositoryTest {
when(curatorCache.listenable()).thenReturn(listenable);
}
- private VoidAnswer1 getListenerAnswer(final CuratorCacheListener.Type
type, final ChildData oldData, final ChildData data) {
- return (VoidAnswer1<CuratorCacheListener>) listener ->
listener.event(type, oldData, data);
+ private VoidAnswer1<CuratorCacheListener> getListenerAnswer(final
CuratorCacheListener.Type type, final ChildData oldData, final ChildData data) {
+ return listener -> listener.event(type, oldData, data);
}
@Test
@@ -352,13 +354,13 @@ public final class CuratorZookeeperRepositoryTest {
@SneakyThrows
public void assertTryLock() {
when(interProcessLock.acquire(5L, TimeUnit.SECONDS)).thenReturn(true);
- assertThat(REPOSITORY.tryLock("/locks/glock", 5, TimeUnit.SECONDS),
is(true));
+ assertTrue(REPOSITORY.tryLock("/locks/glock", 5, TimeUnit.SECONDS));
}
@Test
@SneakyThrows
public void assertTryLockFailed() {
when(interProcessLock.acquire(5L, TimeUnit.SECONDS)).thenReturn(false);
- assertThat(REPOSITORY.tryLock("/locks/glock", 5, TimeUnit.SECONDS),
is(false));
+ assertFalse(REPOSITORY.tryLock("/locks/glock", 5, TimeUnit.SECONDS));
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/checker/AuthorityCheckerTest.java
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/checker/AuthorityCheckerTest.java
index fc64c58..f9080b2 100644
---
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/checker/AuthorityCheckerTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/checker/AuthorityCheckerTest.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.authority.rule.AuthorityRule;
import
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
import org.apache.shardingsphere.infra.executor.check.SQLChecker;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
@@ -46,23 +45,26 @@ import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
-import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@RunWith(MockitoJUnitRunner.Silent.class)
+@RunWith(MockitoJUnitRunner.class)
public final class AuthorityCheckerTest {
-
+
static {
ShardingSphereServiceLoader.register(SQLChecker.class);
}
-
+
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ShardingSphereMetaData metaData;
-
+
+ @SuppressWarnings("unchecked")
@Test
public void testCheckSchemaByAllPrivilegesPermitted() {
Collection<ShardingSphereUser> users = new LinkedList<>();
@@ -72,10 +74,10 @@ public final class AuthorityCheckerTest {
AuthorityRule rule = new AuthorityRule(ruleConfig,
Collections.emptyMap(), users);
SQLChecker<AuthorityRule> sqlChecker =
OrderedSPIRegistry.getRegisteredServices(Collections.singleton(rule),
SQLChecker.class).get(rule);
assertThat(sqlChecker, notNullValue());
- // any schema
- assertThat(sqlChecker.check("db0", new Grantee("root", "localhost"),
rule), is(true));
+ assertTrue(sqlChecker.check("db0", new Grantee("root", "localhost"),
rule));
}
-
+
+ @SuppressWarnings("unchecked")
@Test
public void testCheckSchemaByNative() throws SQLException {
Collection<ShardingSphereUser> users = new LinkedList<>();
@@ -85,11 +87,12 @@ public final class AuthorityCheckerTest {
AuthorityRule rule = new AuthorityRule(ruleConfig,
createMetaDataMap(users), users);
SQLChecker<AuthorityRule> sqlChecker =
OrderedSPIRegistry.getRegisteredServices(Collections.singleton(rule),
SQLChecker.class).get(rule);
assertThat(sqlChecker, notNullValue());
- assertThat(sqlChecker.check("db0", new Grantee("root", "localhost"),
rule), is(true));
- assertThat(sqlChecker.check("db1", new Grantee("root", "localhost"),
rule), is(false));
- assertThat(sqlChecker.check("db0", new Grantee("other", "localhost"),
rule), is(false));
+ assertTrue(sqlChecker.check("db0", new Grantee("root", "localhost"),
rule));
+ assertFalse(sqlChecker.check("db1", new Grantee("root", "localhost"),
rule));
+ assertFalse(sqlChecker.check("db0", new Grantee("other", "localhost"),
rule));
}
-
+
+ @SuppressWarnings("unchecked")
@Test
public void testCheckUser() {
Collection<ShardingSphereUser> users = new LinkedList<>();
@@ -98,12 +101,13 @@ public final class AuthorityCheckerTest {
AuthorityRuleConfiguration ruleConfig = new
AuthorityRuleConfiguration(Collections.emptyList(), new
ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
AuthorityRule rule = new AuthorityRule(ruleConfig,
Collections.emptyMap(), users);
SQLChecker<AuthorityRule> sqlChecker =
OrderedSPIRegistry.getRegisteredServices(Collections.singleton(rule),
SQLChecker.class).get(rule);
- assertThat(sqlChecker, notNullValue());
- assertThat(sqlChecker.check(new Grantee("root", "localhost"), rule),
is(true));
- assertThat(sqlChecker.check(new Grantee("root", "192.168.0.1"), rule),
is(false));
- assertThat(sqlChecker.check(new Grantee("admin", "localhost"), rule),
is(false));
+ assertNotNull(sqlChecker);
+ assertTrue(sqlChecker.check(new Grantee("root", "localhost"), rule));
+ assertFalse(sqlChecker.check(new Grantee("root", "192.168.0.1"),
rule));
+ assertFalse(sqlChecker.check(new Grantee("admin", "localhost"), rule));
}
-
+
+ @SuppressWarnings("unchecked")
@Test
public void testCheckSqlStatement() {
Collection<ShardingSphereUser> users = new LinkedList<>();
@@ -112,24 +116,23 @@ public final class AuthorityCheckerTest {
AuthorityRuleConfiguration ruleConfig = new
AuthorityRuleConfiguration(Collections.emptyList(), new
ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
AuthorityRule rule = new AuthorityRule(ruleConfig,
Collections.emptyMap(), users);
SQLChecker<AuthorityRule> sqlChecker =
OrderedSPIRegistry.getRegisteredServices(Collections.singleton(rule),
SQLChecker.class).get(rule);
- assertThat(sqlChecker, notNullValue());
+ assertNotNull(sqlChecker);
SelectStatement selectStatement = mock(SelectStatement.class);
CreateTableStatement createTableStatement =
mock(CreateTableStatement.class);
InsertStatement insertStatement = mock(InsertStatement.class);
- assertThat(sqlChecker.check(selectStatement, Collections.emptyList(),
new Grantee("root", "localhost"), "db0", Collections.emptyMap(),
rule).isPassed(), is(true));
- assertThat(sqlChecker.check(insertStatement, Collections.emptyList(),
new Grantee("root", "localhost"), "db0", Collections.emptyMap(),
rule).isPassed(), is(true));
- assertThat(sqlChecker.check(createTableStatement,
Collections.emptyList(), new Grantee("root", "localhost"), "db0",
Collections.emptyMap(), rule).isPassed(), is(true));
+ assertTrue(sqlChecker.check(selectStatement, Collections.emptyList(),
new Grantee("root", "localhost"), "db0", Collections.emptyMap(),
rule).isPassed());
+ assertTrue(sqlChecker.check(insertStatement, Collections.emptyList(),
new Grantee("root", "localhost"), "db0", Collections.emptyMap(),
rule).isPassed());
+ assertTrue(sqlChecker.check(createTableStatement,
Collections.emptyList(), new Grantee("root", "localhost"), "db0",
Collections.emptyMap(), rule).isPassed());
}
-
+
private Map<String, ShardingSphereMetaData> createMetaDataMap(final
Collection<ShardingSphereUser> users) throws SQLException {
when(metaData.getName()).thenReturn("db0");
DataSource dataSource = mockDataSourceForPrivileges(users);
when(metaData.getResource().getAllInstanceDataSources()).thenReturn(Collections.singletonList(dataSource));
-
when(metaData.getSchema()).thenReturn(mock(ShardingSphereSchema.class));
when(metaData.getRuleMetaData().getRules()).thenReturn(Collections.emptyList());
return Collections.singletonMap("db0", metaData);
}
-
+
private DataSource mockDataSourceForPrivileges(final
Collection<ShardingSphereUser> users) throws SQLException {
ResultSet globalPrivilegeResultSet = mockGlobalPrivilegeResultSet();
ResultSet schemaPrivilegeResultSet = mockSchemaPrivilegeResultSet();
@@ -145,44 +148,15 @@ public final class AuthorityCheckerTest {
when(result.getConnection().getMetaData().getURL()).thenReturn("jdbc:mysql://localhost:3306/test");
return result;
}
-
+
private ResultSet mockGlobalPrivilegeResultSet() throws SQLException {
ResultSet result = mock(ResultSet.class);
when(result.next()).thenReturn(true, false);
- when(result.getBoolean("Super_priv")).thenReturn(false);
- when(result.getBoolean("Reload_priv")).thenReturn(false);
- when(result.getBoolean("Shutdown_priv")).thenReturn(false);
- when(result.getBoolean("Process_priv")).thenReturn(false);
- when(result.getBoolean("File_priv")).thenReturn(false);
- when(result.getBoolean("Show_db_priv")).thenReturn(false);
- when(result.getBoolean("Repl_slave_priv")).thenReturn(false);
- when(result.getBoolean("Repl_client_priv")).thenReturn(false);
- when(result.getBoolean("Create_user_priv")).thenReturn(false);
- when(result.getBoolean("Create_tablespace_priv")).thenReturn(false);
- when(result.getBoolean("Select_priv")).thenReturn(false);
- when(result.getBoolean("Insert_priv")).thenReturn(false);
- when(result.getBoolean("Update_priv")).thenReturn(false);
- when(result.getBoolean("Delete_priv")).thenReturn(false);
- when(result.getBoolean("Create_priv")).thenReturn(false);
- when(result.getBoolean("Alter_priv")).thenReturn(false);
- when(result.getBoolean("Drop_priv")).thenReturn(false);
- when(result.getBoolean("Grant_priv")).thenReturn(false);
- when(result.getBoolean("Index_priv")).thenReturn(false);
- when(result.getBoolean("References_priv")).thenReturn(false);
- when(result.getBoolean("Create_tmp_table_priv")).thenReturn(false);
- when(result.getBoolean("Lock_tables_priv")).thenReturn(false);
- when(result.getBoolean("Execute_priv")).thenReturn(false);
- when(result.getBoolean("Create_view_priv")).thenReturn(false);
- when(result.getBoolean("Show_view_priv")).thenReturn(false);
- when(result.getBoolean("Create_routine_priv")).thenReturn(false);
- when(result.getBoolean("Alter_routine_priv")).thenReturn(false);
- when(result.getBoolean("Event_priv")).thenReturn(false);
- when(result.getBoolean("Trigger_priv")).thenReturn(false);
when(result.getString("user")).thenReturn("root");
when(result.getString("host")).thenReturn("localhost");
return result;
}
-
+
private ResultSet mockSchemaPrivilegeResultSet() throws SQLException {
ResultSet result = mock(ResultSet.class);
when(result.next()).thenReturn(true, false);
@@ -191,26 +165,11 @@ public final class AuthorityCheckerTest {
when(result.getBoolean("Insert_priv")).thenReturn(true);
when(result.getBoolean("Update_priv")).thenReturn(true);
when(result.getBoolean("Delete_priv")).thenReturn(true);
- when(result.getBoolean("Create_priv")).thenReturn(false);
- when(result.getBoolean("Alter_priv")).thenReturn(false);
- when(result.getBoolean("Drop_priv")).thenReturn(false);
- when(result.getBoolean("Grant_priv")).thenReturn(false);
- when(result.getBoolean("Index_priv")).thenReturn(false);
- when(result.getBoolean("References_priv")).thenReturn(false);
- when(result.getBoolean("Create_tmp_table_priv")).thenReturn(false);
- when(result.getBoolean("Lock_tables_priv")).thenReturn(false);
- when(result.getBoolean("Execute_priv")).thenReturn(false);
- when(result.getBoolean("Create_view_priv")).thenReturn(false);
- when(result.getBoolean("Show_view_priv")).thenReturn(false);
- when(result.getBoolean("Create_routine_priv")).thenReturn(false);
- when(result.getBoolean("Alter_routine_priv")).thenReturn(false);
- when(result.getBoolean("Event_priv")).thenReturn(false);
- when(result.getBoolean("Trigger_priv")).thenReturn(false);
when(result.getString("user")).thenReturn("root");
when(result.getString("host")).thenReturn("localhost");
return result;
}
-
+
private ResultSet mockTablePrivilegeResultSet() throws SQLException {
ResultSet result = mock(ResultSet.class, RETURNS_DEEP_STUBS);
when(result.next()).thenReturn(true, false);
diff --git
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithmTest.java
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithmTest.java
index 759496a..8554325 100644
---
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithmTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/NativeAuthorityProviderAlgorithmTest.java
@@ -53,13 +53,14 @@ public final class NativeAuthorityProviderAlgorithmTest {
}
@Test
- public void testAlgorithmType() {
- NativeAuthorityProviderAlgorithm algorithm =
(NativeAuthorityProviderAlgorithm)
TypedSPIRegistry.findRegisteredService(AuthorityProvideAlgorithm.class,
"NATIVE", new Properties()).get();
- assertThat(algorithm.getType(), is("NATIVE"));
+ public void assertAlgorithmType() {
+ Optional<AuthorityProvideAlgorithm> algorithm =
TypedSPIRegistry.findRegisteredService(AuthorityProvideAlgorithm.class,
"NATIVE", new Properties());
+ assertTrue(algorithm.isPresent());
+ assertThat(algorithm.get().getType(), is("NATIVE"));
}
@Test
- public void testFindPrivileges() throws SQLException {
+ public void assertFindPrivileges() throws SQLException {
NativeAuthorityProviderAlgorithm algorithm = new
NativeAuthorityProviderAlgorithm();
Collection<ShardingSphereUser> users = new LinkedList<>();
ShardingSphereUser root = new ShardingSphereUser("root", "",
"localhost");
@@ -72,13 +73,13 @@ public final class NativeAuthorityProviderAlgorithmTest {
}
@Test
- public void testRefreshPrivileges() throws SQLException {
+ public void assertRefreshPrivileges() throws SQLException {
NativeAuthorityProviderAlgorithm algorithm = new
NativeAuthorityProviderAlgorithm();
Collection<ShardingSphereUser> users = Collections.singletonList(new
ShardingSphereUser("root", "", "localhost"));
algorithm.init(Collections.emptyMap(), users);
Optional<ShardingSpherePrivileges> privileges1 =
algorithm.findPrivileges(new Grantee("root", "localhost"));
assertTrue(privileges1.isPresent());
-
assertThat(privileges1.get().hasPrivileges(Collections.singletonList(PrivilegeType.SUPER)),
is(true));
+
assertTrue(privileges1.get().hasPrivileges(Collections.singletonList(PrivilegeType.SUPER)));
algorithm.refresh(Collections.singletonMap("db0",
mockShardingSphereMetaData(users)), users);
Optional<ShardingSpherePrivileges> privileges2 =
algorithm.findPrivileges(new Grantee("root", "localhost"));
assertTrue(privileges2.isPresent());
@@ -93,7 +94,7 @@ public final class NativeAuthorityProviderAlgorithmTest {
expected.add(PrivilegeType.UPDATE);
expected.add(PrivilegeType.RELOAD);
expected.add(PrivilegeType.SHUTDOWN);
- assertThat(privileges.hasPrivileges(expected), is(true));
+ assertTrue(privileges.hasPrivileges(expected));
}
private ShardingSphereMetaData mockShardingSphereMetaData(final
Collection<ShardingSphereUser> users) throws SQLException {
diff --git
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeBuilderTest.java
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeBuilderTest.java
index a27c62e..1233a67 100644
---
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeBuilderTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeBuilderTest.java
@@ -35,12 +35,13 @@ import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public final class StoragePrivilegeBuilderTest {
-
+
@Test
public void testBuildInCache() {
Collection<ShardingSphereMetaData> metaDataList = new LinkedList<>();
@@ -49,9 +50,9 @@ public final class StoragePrivilegeBuilderTest {
users.add(root);
Map<ShardingSphereUser, NativePrivileges> result =
StoragePrivilegeBuilder.build(metaDataList, users);
assertThat(result.size(), is(1));
-
assertThat(result.get(root).hasPrivileges(Collections.singletonList(PrivilegeType.SUPER)),
is(true));
+
assertTrue(result.get(root).hasPrivileges(Collections.singletonList(PrivilegeType.SUPER)));
}
-
+
@Test
public void testBuildPrivilegesInStorage() throws SQLException {
Collection<ShardingSphereUser> users = new LinkedList<>();
@@ -67,19 +68,19 @@ public final class StoragePrivilegeBuilderTest {
expected.add(PrivilegeType.UPDATE);
expected.add(PrivilegeType.RELOAD);
expected.add(PrivilegeType.SHUTDOWN);
- assertThat(result.get(root).hasPrivileges(expected), is(true));
+ assertTrue(result.get(root).hasPrivileges(expected));
}
-
+
private ShardingSphereMetaData mockShardingSphereMetaData(final
Collection<ShardingSphereUser> users) throws SQLException {
- ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class,
RETURNS_DEEP_STUBS);
+ ShardingSphereMetaData result = mock(ShardingSphereMetaData.class,
RETURNS_DEEP_STUBS);
DataSource dataSource = mockDataSourceForPrivileges(users);
Collection<DataSource> dataSourceList =
Collections.singletonList(dataSource);
-
when(metaData.getResource().getAllInstanceDataSources()).thenReturn(dataSourceList);
+
when(result.getResource().getAllInstanceDataSources()).thenReturn(dataSourceList);
Collection<ShardingSphereRule> empty = Collections.emptyList();
- when(metaData.getRuleMetaData().getRules()).thenReturn(empty);
- return metaData;
+ when(result.getRuleMetaData().getRules()).thenReturn(empty);
+ return result;
}
-
+
private DataSource mockDataSourceForPrivileges(final
Collection<ShardingSphereUser> users) throws SQLException {
ResultSet globalPrivilegeResultSet = mockGlobalPrivilegeResultSet();
ResultSet schemaPrivilegeResultSet = mockSchemaPrivilegeResultSet();
@@ -95,7 +96,7 @@ public final class StoragePrivilegeBuilderTest {
when(result.getConnection().getMetaData().getURL()).thenReturn("jdbc:mysql://localhost:3306/test");
return result;
}
-
+
private ResultSet mockGlobalPrivilegeResultSet() throws SQLException {
ResultSet result = mock(ResultSet.class);
when(result.next()).thenReturn(true, true, false, true, true, false);
@@ -132,7 +133,7 @@ public final class StoragePrivilegeBuilderTest {
when(result.getString("host")).thenReturn("localhost");
return result;
}
-
+
private ResultSet mockSchemaPrivilegeResultSet() throws SQLException {
ResultSet result = mock(ResultSet.class);
when(result.next()).thenReturn(true, false);
@@ -160,7 +161,7 @@ public final class StoragePrivilegeBuilderTest {
when(result.getString("host")).thenReturn("localhost");
return result;
}
-
+
private ResultSet mockTablePrivilegeResultSet() throws SQLException {
ResultSet result = mock(ResultSet.class, RETURNS_DEEP_STUBS);
when(result.next()).thenReturn(true, false);
diff --git
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandlerTest.java
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandlerTest.java
index 9b57735..f8e58cb 100644
---
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandlerTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/OraclePrivilegeHandlerTest.java
@@ -42,6 +42,7 @@ import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -110,7 +111,7 @@ public final class OraclePrivilegeHandlerTest {
assertThat(actual.get(user).getDatabasePrivileges().getSpecificPrivileges().size(),
is(1));
Collection<PrivilegeType> expectedSpecificPrivilege = new
CopyOnWriteArraySet<>(Arrays.asList(PrivilegeType.INSERT, PrivilegeType.SELECT,
PrivilegeType.UPDATE));
SchemaPrivileges schemaPrivileges =
actual.get(user).getDatabasePrivileges().getSpecificPrivileges().get("sys");
-
assertThat(schemaPrivileges.getSpecificPrivileges().get("t_order").hasPrivileges(expectedSpecificPrivilege),
is(true));
+
assertTrue(schemaPrivileges.getSpecificPrivileges().get("t_order").hasPrivileges(expectedSpecificPrivilege));
assertThat(actual.get(user).getAdministrativePrivileges().getPrivileges().size(),
is(3));
Collection<PrivilegeType> expectedAdminPrivileges = new
CopyOnWriteArraySet<>(Arrays.asList(PrivilegeType.SUPER,
PrivilegeType.CREATE_ROLE, PrivilegeType.CREATE_TABLESPACE));
assertThat(actual.get(user).getAdministrativePrivileges().getPrivileges(),
is(expectedAdminPrivileges));
diff --git
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandlerTest.java
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandlerTest.java
index de93da2..560786e 100644
---
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandlerTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/PostgreSQLPrivilegeHandlerTest.java
@@ -93,7 +93,7 @@ public final class PostgreSQLPrivilegeHandlerTest {
assertThat(actual.get(user).getDatabasePrivileges().getSpecificPrivileges().size(),
is(1));
Collection<PrivilegeType> expectedSpecificPrivilege = new
CopyOnWriteArraySet<>(Arrays.asList(PrivilegeType.INSERT, PrivilegeType.SELECT,
PrivilegeType.UPDATE, PrivilegeType.DELETE));
SchemaPrivileges schemaPrivileges =
actual.get(user).getDatabasePrivileges().getSpecificPrivileges().get("db0");
-
assertThat(schemaPrivileges.getSpecificPrivileges().get("t_order").hasPrivileges(expectedSpecificPrivilege),
is(true));
+
assertTrue(schemaPrivileges.getSpecificPrivileges().get("t_order").hasPrivileges(expectedSpecificPrivilege));
assertThat(actual.get(user).getAdministrativePrivileges().getPrivileges().size(),
is(4));
Collection<PrivilegeType> expectedAdminPrivileges = new
CopyOnWriteArraySet<>(
Arrays.asList(PrivilegeType.SUPER, PrivilegeType.CREATE_ROLE,
PrivilegeType.CREATE_DATABASE, PrivilegeType.CAN_LOGIN));
diff --git
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/SQLServerPrivilegeHandlerTest.java
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/SQLServerPrivilegeHandlerTest.java
index e23fab2..eef7b89 100644
---
a/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/SQLServerPrivilegeHandlerTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-authority/shardingsphere-infra-authority-common/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/SQLServerPrivilegeHandlerTest.java
@@ -29,10 +29,10 @@ import org.junit.Test;
import javax.sql.DataSource;
import java.sql.Connection;
+import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.sql.DatabaseMetaData;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
@@ -43,10 +43,11 @@ import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
public final class SQLServerPrivilegeHandlerTest {
@@ -92,12 +93,9 @@ public final class SQLServerPrivilegeHandlerTest {
assertThat(actual.get(dbo).getAdministrativePrivileges().getPrivileges().size(),
is(2));
Collection<PrivilegeType> expectedAdminPrivileges = new
CopyOnWriteArraySet<>(Arrays.asList(PrivilegeType.CONNECT,
PrivilegeType.SHUTDOWN));
assertThat(actual.get(dbo).getAdministrativePrivileges().getPrivileges(),
is(expectedAdminPrivileges));
-
- Collection<PrivilegeType> expectedSpecificPrivilege = new
CopyOnWriteArraySet(Arrays.asList(PrivilegeType.INSERT, PrivilegeType.SELECT,
PrivilegeType.UPDATE,
- PrivilegeType.DELETE));
+ Collection<PrivilegeType> expectedSpecificPrivilege = new
CopyOnWriteArraySet<>(Arrays.asList(PrivilegeType.INSERT, PrivilegeType.SELECT,
PrivilegeType.UPDATE, PrivilegeType.DELETE));
SchemaPrivileges schemaPrivileges =
actual.get(dbo).getDatabasePrivileges().getSpecificPrivileges().get("db0");
-
assertThat(schemaPrivileges.getSpecificPrivileges().get("t_order").hasPrivileges(expectedSpecificPrivilege),
is(true));
-
+
assertTrue(schemaPrivileges.getSpecificPrivileges().get("t_order").hasPrivileges(expectedSpecificPrivilege));
ShardingSphereUser testUser = new ShardingSphereUser("testUser", "",
"");
assertThat(actual.get(testUser).getAdministrativePrivileges().getPrivileges().size(),
is(0));
assertThat(actual.get(testUser).getDatabasePrivileges().getGlobalPrivileges().size(),
is(0));
@@ -105,7 +103,7 @@ public final class SQLServerPrivilegeHandlerTest {
}
private Collection<ShardingSphereUser> createUsers() {
- LinkedList<ShardingSphereUser> result = new LinkedList<>();
+ Collection<ShardingSphereUser> result = new LinkedList<>();
result.add(new ShardingSphereUser("dbo", "password", ""));
result.add(new ShardingSphereUser("testUser", "password", ""));
return result;
@@ -194,12 +192,12 @@ public final class SQLServerPrivilegeHandlerTest {
private void assertCreateUsers(final Collection<ShardingSphereUser> users,
final Statement statement) throws SQLException {
for (ShardingSphereUser each : users) {
- StringBuilder result = new StringBuilder();
- result.append(String.format("CREATE LOGIN %s WITH PASSWORD =
'%s';", each.getGrantee().getUsername(), each.getPassword())).append("\n");
- result.append("GO").append("\n");
- result.append(String.format("CREATE USER %s FOR LOGIN %s;\n",
each.getGrantee().getUsername(), each.getGrantee().getUsername()));
- result.append("GO");
- verify(statement).execute(result.toString());
+ StringBuilder sql = new StringBuilder();
+ sql.append(String.format("CREATE LOGIN %s WITH PASSWORD = '%s';",
each.getGrantee().getUsername(), each.getPassword())).append("\n");
+ sql.append("GO").append("\n");
+ sql.append(String.format("CREATE USER %s FOR LOGIN %s;\n",
each.getGrantee().getUsername(), each.getGrantee().getUsername()));
+ sql.append("GO");
+ verify(statement).execute(sql.toString());
}
}
@@ -211,9 +209,6 @@ public final class SQLServerPrivilegeHandlerTest {
}
private String getDatabaseName(final String url) {
- if (url.contains("?")) {
- return url.substring(url.indexOf("DatabaseName=") + 1,
url.indexOf("?"));
- }
- return url.substring(url.indexOf("DatabaseName=") + 1);
+ return url.contains("?") ? url.substring(url.indexOf("DatabaseName=")
+ 1, url.indexOf("?")) : url.substring(url.indexOf("DatabaseName=") + 1);
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/metadata/JDBCQueryResultMetaDataTest.java
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/metadata/JDBCQueryResultMetaDataTest.java
index 4d3901f..8cd5e14 100644
---
a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/metadata/JDBCQueryResultMetaDataTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/result/query/impl/driver/jdbc/metadata/JDBCQueryResultMetaDataTest.java
@@ -26,6 +26,7 @@ import java.sql.Types;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -96,16 +97,16 @@ public final class JDBCQueryResultMetaDataTest {
@Test
public void assertIsSigned() throws SQLException {
- assertThat(queryResultMetaData.isSigned(1), is(true));
+ assertTrue(queryResultMetaData.isSigned(1));
}
@Test
public void assertIsNotNull() throws SQLException {
- assertThat(queryResultMetaData.isNotNull(1), is(true));
+ assertTrue(queryResultMetaData.isNotNull(1));
}
@Test
public void assertIsAutoIncrement() throws SQLException {
- assertThat(queryResultMetaData.isAutoIncrement(1), is(true));
+ assertTrue(queryResultMetaData.isAutoIncrement(1));
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/engine/single/SingleTableRouteEngineTest.java
b/shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/engine/single/SingleTableRouteEngineTest.java
index f783957..efc5f28 100644
---
a/shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/engine/single/SingleTableRouteEngineTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-route/src/test/java/org/apache/shardingsphere/infra/route/engine/single/SingleTableRouteEngineTest.java
@@ -36,7 +36,9 @@ import java.util.List;
import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -61,7 +63,7 @@ public final class SingleTableRouteEngineTest {
RouteMapper tableMapper1 = tableMappers.next();
assertThat(tableMapper1.getActualName(), is("t_order"));
assertThat(tableMapper1.getLogicName(), is("t_order"));
- assertThat(routeContext.isFederated(), is(false));
+ assertFalse(routeContext.isFederated());
}
@Test
@@ -84,7 +86,7 @@ public final class SingleTableRouteEngineTest {
RouteMapper tableMapper1 =
routeUnits.get(1).getTableMappers().iterator().next();
assertThat(tableMapper1.getActualName(), is("t_order_item"));
assertThat(tableMapper1.getLogicName(), is("t_order_item"));
- assertThat(routeContext.isFederated(), is(true));
+ assertTrue(routeContext.isFederated());
}
@Test
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtilTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtilTest.java
index d1e747c..05b0bfc 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtilTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/resultset/ResultSetUtilTest.java
@@ -33,9 +33,11 @@ import java.time.LocalDateTime;
import java.util.Date;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public final class ResultSetUtilTest {
@Test
@@ -56,7 +58,7 @@ public final class ResultSetUtilTest {
@Test
public void assertConvertNumberValueSuccess() {
assertThat(ResultSetUtil.convertValue("1", String.class), is("1"));
- assertThat(ResultSetUtil.convertValue(1, boolean.class), is(true));
+ assertTrue((boolean) ResultSetUtil.convertValue(1, boolean.class));
assertThat(ResultSetUtil.convertValue((byte) 1, byte.class), is((byte)
1));
assertThat(ResultSetUtil.convertValue((short) 1, short.class),
is((short) 1));
assertThat(ResultSetUtil.convertValue(new BigDecimal("1"), int.class),
is(1));
@@ -77,7 +79,7 @@ public final class ResultSetUtilTest {
@Test
public void assertConvertNullValue() {
- assertThat(ResultSetUtil.convertValue(null, boolean.class), is(false));
+ assertFalse((boolean) ResultSetUtil.convertValue(null, boolean.class));
assertThat(ResultSetUtil.convertValue(null, byte.class), is((byte) 0));
assertThat(ResultSetUtil.convertValue(null, short.class), is((short)
0));
assertThat(ResultSetUtil.convertValue(null, int.class), is(0));
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/ConnectionStatusTest.java
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/ConnectionStatusTest.java
index 2acda4f..78cf064 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/ConnectionStatusTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/ConnectionStatusTest.java
@@ -28,11 +28,13 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
-public class ConnectionStatusTest {
+public final class ConnectionStatusTest {
- private int numberOfThreads = 10;
+ private final int numberOfThreads = 10;
private ExecutorService service;
@@ -63,7 +65,7 @@ public class ConnectionStatusTest {
}
latch.await();
assertThat(numberOfThreads, is(counter.get()));
- assertThat(usingField.getBoolean(connectionStatus), is(true));
+ assertTrue(usingField.getBoolean(connectionStatus));
}
@Test
@@ -80,7 +82,7 @@ public class ConnectionStatusTest {
}
latch.await();
assertThat(counter.get(), is(0));
- assertThat(usingField.getBoolean(connectionStatus), is(false));
+ assertFalse(usingField.getBoolean(connectionStatus));
}
@Test
@@ -97,9 +99,9 @@ public class ConnectionStatusTest {
}
latch.await(200, TimeUnit.MILLISECONDS);
assertThat(counter.get(), is(10));
- assertThat(usingField.getBoolean(connectionStatus), is(true));
+ assertTrue(usingField.getBoolean(connectionStatus));
connectionStatus.switchToReleased();
- assertThat(usingField.getBoolean(connectionStatus), is(false));
+ assertFalse(usingField.getBoolean(connectionStatus));
latch.await(300, TimeUnit.MILLISECONDS);
assertThat(counter.get(), is(0));
}
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
index 15413d2..128f4f1 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
+++
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationEngineTest.java
@@ -52,6 +52,7 @@ import java.util.LinkedHashMap;
import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -73,7 +74,7 @@ public final class PostgreSQLAuthenticationEngineTest {
byteBuf.writeInt(80877103);
PacketPayload payload = new PostgreSQLPacketPayload(byteBuf);
AuthenticationResult actual = new
PostgreSQLAuthenticationEngine().authenticate(mock(ChannelHandlerContext.class),
payload);
- assertThat(actual.isFinished(), is(false));
+ assertFalse(actual.isFinished());
}
@Test(expected = InvalidAuthorizationSpecificationException.class)
@@ -121,7 +122,7 @@ public final class PostgreSQLAuthenticationEngineTest {
ChannelHandlerContext channelHandlerContext =
mock(ChannelHandlerContext.class);
PostgreSQLAuthenticationEngine engine = new
PostgreSQLAuthenticationEngine();
AuthenticationResult actual =
engine.authenticate(channelHandlerContext, payload);
- assertThat(actual.isFinished(), is(false));
+ assertFalse(actual.isFinished());
assertThat(actual.getUsername(), is(username));
ArgumentCaptor<PostgreSQLAuthenticationMD5PasswordPacket>
argumentCaptor =
ArgumentCaptor.forClass(PostgreSQLAuthenticationMD5PasswordPacket.class);
verify(channelHandlerContext).writeAndFlush(argumentCaptor.capture());