You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/05/17 18:35:18 UTC
[shardingsphere] branch master updated: Refactor ProxyContext.init() (#17764)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 37a79d86788 Refactor ProxyContext.init() (#17764)
37a79d86788 is described below
commit 37a79d8678896bca37ac4bf0436a1323c209755b
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed May 18 02:35:05 2022 +0800
Refactor ProxyContext.init() (#17764)
* Refactor ProxyContext.init()
* Refactor ProxyContext.init()
* Refactor ProxyContext.init()
* Fix test case
* Fix test case
* Fix test case
* Fix test cases
* Fix test cases
* Fix test cases
---
.../collector/MetaDataInfoCollectorTest.java | 5 +++++
.../prometheus/collector/ProxyInfoCollectorTest.java | 5 ++++-
.../service/PrometheusPluginBootServiceTest.java | 5 ++++-
.../advice/AbstractCommandExecutorTaskAdviceTest.java | 5 +++++
.../impl/ConditionValueCompareOperatorGenerator.java | 3 ++-
.../infra/metadata/ShardingSphereMetaData.java | 4 ++--
.../rule/builder/fixture/FixtureSchemaRuleBuilder.java | 2 +-
.../rule/builder/schema/SchemaRulesBuilderTest.java | 2 +-
.../proxy/backend/context/ProxyContext.java | 18 +++++++++---------
.../jdbc/JDBCDatabaseCommunicationEngineTest.java | 2 +-
.../backend/context/BackendExecutorContextTest.java | 2 +-
.../proxy/backend/session/ConnectionSessionTest.java | 4 ++--
.../text/TextProtocolBackendHandlerFactoryTest.java | 2 +-
.../admin/DatabaseAdminQueryBackendHandlerTest.java | 2 +-
.../DatabaseOperateBackendHandlerFactoryTest.java | 2 +-
.../admin/mysql/executor/UseDatabaseExecutorTest.java | 4 ++--
.../information/SelectInformationExecutorTest.java | 2 +-
.../executor/SelectDatabaseExecutorTest.java | 2 +-
.../postgresql/executor/SelectTableExecutorTest.java | 2 +-
.../database/CreateDatabaseBackendHandlerTest.java | 2 +-
.../text/database/DropDatabaseBackendHandlerTest.java | 2 +-
.../text/distsql/DistSQLBackendHandlerFactoryTest.java | 2 +-
.../ral/advance/ParseDistSQLBackendHandlerTest.java | 2 +-
.../ral/common/queryable/CountInstanceRulesTest.java | 2 +-
.../ExportDatabaseConfigurationHandlerTest.java | 2 +-
.../common/queryable/ShowAuthorityRuleHandlerTest.java | 2 +-
.../common/queryable/ShowInstanceModeHandlerTest.java | 2 +-
.../common/queryable/ShowSQLParserRuleHandlerTest.java | 2 +-
.../common/queryable/ShowTableMetadataHandlerTest.java | 2 +-
.../common/queryable/ShowTrafficRulesHandlerTest.java | 2 +-
.../queryable/ShowTransactionRuleHandlerTest.java | 4 ++--
.../queryable/ShowVariableBackendHandlerTest.java | 8 ++++----
.../ral/common/updatable/AlterInstanceHandlerTest.java | 4 ++--
.../updatable/AlterSQLParserRuleHandlerTest.java | 4 ++--
.../common/updatable/AlterTrafficRuleHandlerTest.java | 8 ++++----
.../common/updatable/CreateTrafficRuleHandlerTest.java | 8 ++++----
.../common/updatable/DropTrafficRuleHandlerTest.java | 12 ++++++------
.../ImportDatabaseConfigurationHandlerTest.java | 2 +-
.../updatable/SetVariableBackendHandlerTest.java | 4 ++--
.../ral/common/updatable/SetVariableExecutorTest.java | 2 +-
.../rdl/resource/AddResourceBackendHandlerTest.java | 4 ++--
.../rdl/resource/AlterResourceBackendHandlerTest.java | 6 +++---
.../rdl/resource/DropResourceBackendHandlerTest.java | 2 +-
.../text/distsql/rql/RQLBackendHandlerTest.java | 2 +-
.../distsql/rql/RuleDefinitionBackendHandlerTest.java | 2 +-
.../proxy/initializer/BootstrapInitializer.java | 2 +-
.../connection/ConnectionLimitContextTest.java | 4 ++--
.../proxy/frontend/mysql/MySQLFrontendEngineTest.java | 7 +++----
.../OpenGaussAuthenticationEngineTest.java | 2 +-
.../bind/OpenGaussComBatchBindExecutorTest.java | 4 ++--
.../PostgreSQLAuthenticationEngineTest.java | 2 +-
.../command/PostgreSQLCommandExecuteEngineTest.java | 10 ++++++++++
.../command/query/extended/JDBCPortalTest.java | 4 ++--
...AggregatedBatchedStatementsCommandExecutorTest.java | 4 ++--
.../PostgreSQLBatchedStatementsExecutorTest.java | 4 ++--
.../describe/PostgreSQLComDescribeExecutorTest.java | 4 ++--
.../extended/parse/PostgreSQLComParseExecutorTest.java | 4 ++--
57 files changed, 122 insertions(+), 96 deletions(-)
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollectorTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollectorTest.java
index 6184f76f075..86dd9ca447d 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollectorTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/MetaDataInfoCollectorTest.java
@@ -17,14 +17,19 @@
package org.apache.shardingsphere.agent.metrics.prometheus.collector;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
public final class MetaDataInfoCollectorTest {
@Test
public void assertCollect() {
+ ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
assertFalse(new MetaDataInfoCollector().collect().isEmpty());
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollectorTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollectorTest.java
index b640045246a..5d0bf2c01c8 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollectorTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/collector/ProxyInfoCollectorTest.java
@@ -22,6 +22,7 @@ import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
import org.apache.shardingsphere.infra.lock.LockContext;
+import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.memory.workerid.generator.MemoryWorkerIdGenerator;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -35,8 +36,10 @@ public final class ProxyInfoCollectorTest {
@Test
public void assertCollect() {
- ProxyContext.getInstance().getContextManager().init(mock(MetaDataContexts.class), mock(TransactionContexts.class), new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)),
+ ContextManager contextManager = new ContextManager();
+ contextManager.init(mock(MetaDataContexts.class), mock(TransactionContexts.class), new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)),
new MemoryWorkerIdGenerator(), new ModeConfiguration("Memory", null, false), mock(LockContext.class)));
+ ProxyContext.init(contextManager);
assertFalse(new ProxyInfoCollector().collect().isEmpty());
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootServiceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootServiceTest.java
index c09d039509b..8b96146fdb0 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootServiceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/service/PrometheusPluginBootServiceTest.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.infra.instance.ComputeNodeInstance;
import org.apache.shardingsphere.infra.instance.InstanceContext;
import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition;
import org.apache.shardingsphere.infra.lock.LockContext;
+import org.apache.shardingsphere.mode.manager.ContextManager;
import org.apache.shardingsphere.mode.manager.memory.workerid.generator.MemoryWorkerIdGenerator;
import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
@@ -48,8 +49,10 @@ public final class PrometheusPluginBootServiceTest {
@Test
public void assertStart() throws IOException {
- ProxyContext.getInstance().getContextManager().init(mock(MetaDataContexts.class), mock(TransactionContexts.class), new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)),
+ ContextManager contextManager = new ContextManager();
+ contextManager.init(mock(MetaDataContexts.class), mock(TransactionContexts.class), new InstanceContext(new ComputeNodeInstance(mock(InstanceDefinition.class)),
new MemoryWorkerIdGenerator(), new ModeConfiguration("Memory", null, false), mock(LockContext.class)));
+ ProxyContext.init(contextManager);
PROMETHEUS_PLUGIN_BOOT_SERVICE.start(new PluginConfiguration("localhost", 8090, "", createProperties()));
new Socket().connect(new InetSocketAddress("localhost", 8090));
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/advice/AbstractCommandExecutorTaskAdviceTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/advice/AbstractCommandExecutorTaskAdviceTest.java
index 5972d475cda..bf504f39813 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/advice/AbstractCommandExecutorTaskAdviceTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-test/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/advice/AbstractCommandExecutorTaskAdviceTest.java
@@ -22,10 +22,14 @@ import lombok.Getter;
import org.apache.shardingsphere.agent.api.advice.AdviceTargetObject;
import org.apache.shardingsphere.agent.plugin.tracing.AgentRunner;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.frontend.command.CommandExecutorTask;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.junit.runner.RunWith;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@RunWith(AgentRunner.class)
@@ -37,6 +41,7 @@ public abstract class AbstractCommandExecutorTaskAdviceTest implements AdviceTes
@SuppressWarnings("ConstantConditions")
@Override
public final void prepare() {
+ ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
ConnectionSession connectionSession = new ConnectionSession(mock(MySQLDatabaseType.class), TransactionType.BASE, new DefaultAttributeMap());
Object executorTask = new CommandExecutorTask(null, connectionSession, null, null);
targetObject = (AdviceTargetObject) executorTask;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
index d4efe5c276c..e392a165911 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
@@ -30,6 +30,7 @@ import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.Column
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.ExpressionSegment;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -76,7 +77,7 @@ public final class ConditionValueCompareOperatorGenerator implements ConditionVa
String tableName = column.getTableName();
switch (operator) {
case EQUAL:
- return Optional.of(new ListShardingConditionValue<>(columnName, tableName, Collections.singletonList(comparable)));
+ return Optional.of(new ListShardingConditionValue<>(columnName, tableName, new ArrayList<>(Collections.singleton(comparable))));
case GREATER_THAN:
return Optional.of(new RangeShardingConditionValue<>(columnName, tableName, Range.greaterThan(comparable)));
case LESS_THAN:
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java
index 88c4613c200..2a7d0fd3f89 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java
@@ -69,7 +69,7 @@ public final class ShardingSphereMetaData {
* @return ShardingSphere meta data
* @throws SQLException SQL exception
*/
- public static ShardingSphereMetaData create(final String databaseName, final DatabaseType frontendDatabaseType, final DatabaseType backendDatabaseType,
+ public static ShardingSphereMetaData create(final String databaseName, final DatabaseType frontendDatabaseType, final DatabaseType backendDatabaseType,
final DatabaseConfiguration databaseConfig, final ConfigurationProperties props) throws SQLException {
Collection<ShardingSphereRule> databaseRules = SchemaRulesBuilder.buildRules(databaseName, databaseConfig, props);
ShardingSphereDatabase database = DatabaseLoader.load(databaseName, frontendDatabaseType, backendDatabaseType, databaseConfig.getDataSources(), databaseRules, props);
@@ -91,7 +91,7 @@ public final class ShardingSphereMetaData {
}
private static ShardingSphereMetaData create(final DatabaseType frontendDatabaseType,
- final DatabaseConfiguration databaseConfig, final Collection<ShardingSphereRule> rules, final ShardingSphereDatabase database) throws SQLException {
+ final DatabaseConfiguration databaseConfig, final Collection<ShardingSphereRule> rules, final ShardingSphereDatabase database) throws SQLException {
ShardingSphereResource resource = createResource(frontendDatabaseType, databaseConfig.getDataSources());
ShardingSphereRuleMetaData ruleMetaData = new ShardingSphereRuleMetaData(databaseConfig.getRuleConfigurations(), rules);
return new ShardingSphereMetaData(frontendDatabaseType, resource, ruleMetaData, database);
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureSchemaRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureSchemaRuleBuilder.java
index 66362d6bf69..668591b2afa 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureSchemaRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/fixture/FixtureSchemaRuleBuilder.java
@@ -28,7 +28,7 @@ import java.util.Map;
public final class FixtureSchemaRuleBuilder implements SchemaRuleBuilder<FixtureSchemaRuleConfiguration> {
@Override
- public FixtureSchemaRule build(final FixtureSchemaRuleConfiguration config, final String databaseName, final Map<String, DataSource> dataSources,
+ public FixtureSchemaRule build(final FixtureSchemaRuleConfiguration config, final String databaseName, final Map<String, DataSource> dataSources,
final Collection<ShardingSphereRule> builtRules, final ConfigurationProperties props) {
return new FixtureSchemaRule();
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/schema/SchemaRulesBuilderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/schema/SchemaRulesBuilderTest.java
index 6a15e8effb8..bc89e7dd937 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/schema/SchemaRulesBuilderTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/builder/schema/SchemaRulesBuilderTest.java
@@ -37,7 +37,7 @@ public final class SchemaRulesBuilderTest {
@Test
public void assertBuild() {
- Iterator<ShardingSphereRule> actual = SchemaRulesBuilder.buildRules("schema_name",
+ Iterator<ShardingSphereRule> actual = SchemaRulesBuilder.buildRules("schema_name",
new DataSourceProvidedDatabaseConfiguration(Collections.emptyMap(), Collections.singleton(new TestRuleConfiguration())), new ConfigurationProperties(new Properties())).iterator();
assertThat(actual.next(), instanceOf(TestShardingSphereRule.class));
assertThat(actual.next(), instanceOf(FixtureSchemaRule.class));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/context/ProxyContext.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/context/ProxyContext.java
index 5a533b76685..0d98f9a741e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/context/ProxyContext.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/context/ProxyContext.java
@@ -43,24 +43,24 @@ public final class ProxyContext {
private final JDBCBackendDataSource backendDataSource = new JDBCBackendDataSource();
- private volatile ContextManager contextManager = new ContextManager();
+ private ContextManager contextManager;
/**
- * Get instance of proxy schema schemas.
+ * Initialize proxy context.
*
- * @return instance of ShardingSphere schemas.
+ * @param contextManager context manager
*/
- public static ProxyContext getInstance() {
- return INSTANCE;
+ public static void init(final ContextManager contextManager) {
+ INSTANCE.contextManager = contextManager;
}
/**
- * Initialize proxy context.
+ * Get instance of proxy context.
*
- * @param contextManager context manager
+ * @return got instance
*/
- public void init(final ContextManager contextManager) {
- this.contextManager = contextManager;
+ public static ProxyContext getInstance() {
+ return INSTANCE;
}
/**
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
index f65a4b9e14b..9b1037f2ef4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngineTest.java
@@ -100,7 +100,7 @@ public final class JDBCDatabaseCommunicationEngineTest {
mock(OptimizerContext.class, RETURNS_DEEP_STUBS), new ConfigurationProperties(new Properties()));
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
private Map<String, ShardingSphereMetaData> mockMetaDataMap() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/BackendExecutorContextTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/BackendExecutorContextTest.java
index ad1117aaddc..90eba06bbf6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/BackendExecutorContextTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/BackendExecutorContextTest.java
@@ -46,7 +46,7 @@ public final class BackendExecutorContextTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
when(contextManager.getTransactionContexts()).thenReturn(new TransactionContexts());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java
index 0bc38d18343..ef812c02493 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/session/ConnectionSessionTest.java
@@ -62,7 +62,7 @@ public final class ConnectionSessionTest {
@Before
public void setup() {
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
connectionSession = new ConnectionSession(mock(MySQLDatabaseType.class), TransactionType.LOCAL, null);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
}
@@ -102,6 +102,6 @@ public final class ConnectionSessionTest {
@AfterClass
public static void restoreContextManager() {
- ProxyContext.getInstance().init(contextManagerBackup);
+ ProxyContext.init(contextManagerBackup);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
index 16b5dcb4387..cd5a4f83eea 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/TextProtocolBackendHandlerFactoryTest.java
@@ -94,7 +94,7 @@ public final class TextProtocolBackendHandlerFactoryTest {
when(contextManager.getTransactionContexts()).thenReturn(transactionContexts);
CacheOption cacheOption = new CacheOption(1024, 1024);
when(metaDataContexts.getGlobalRuleMetaData().findSingleRule(SQLParserRule.class)).thenReturn(Optional.of(new SQLParserRule(new SQLParserRuleConfiguration(true, cacheOption, cacheOption))));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
private ShardingSphereMetaData mockShardingSphereMetaData() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminQueryBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminQueryBackendHandlerTest.java
index bc79fbb2895..44850e8c84a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminQueryBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseAdminQueryBackendHandlerTest.java
@@ -72,7 +72,7 @@ public final class DatabaseAdminQueryBackendHandlerTest {
mock(ShardingSphereRuleMetaData.class), mock(ExecutorEngine.class), mock(OptimizerContext.class), new ConfigurationProperties(new Properties()));
contextManager.init(metaDataContexts, mock(TransactionContexts.class), mock(InstanceContext.class));
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(connectionSession.getDatabaseName()).thenReturn("db");
SelectTableExecutor executor = mock(SelectTableExecutor.class, RETURNS_DEEP_STUBS);
MergedResult mergedResult = new SingleLocalDataMergedResult(Arrays.asList("demo_ds_0", "demo_ds_1"));
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseOperateBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseOperateBackendHandlerFactoryTest.java
index 683c7a7fa7f..849bf29c2df 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseOperateBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/DatabaseOperateBackendHandlerFactoryTest.java
@@ -73,7 +73,7 @@ public final class DatabaseOperateBackendHandlerFactoryTest {
MetaDataContexts metaDataContexts = new MetaDataContexts(mock(MetaDataPersistService.class), getMetaDataMap(),
mock(ShardingSphereRuleMetaData.class), mock(ExecutorEngine.class), mock(OptimizerContext.class), new ConfigurationProperties(new Properties()));
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(connectionSession.getDatabaseName()).thenReturn("db");
when(metaDataContexts.getGlobalRuleMetaData().getRules()).thenReturn(Collections.emptyList());
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutorTest.java
index 6456bfa4a50..e228bc3298a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/UseDatabaseExecutorTest.java
@@ -84,12 +84,12 @@ public final class UseDatabaseExecutorTest {
MySQLUseStatement useStatement = mock(MySQLUseStatement.class);
when(useStatement.getSchema()).thenReturn(String.format(DATABASE_PATTERN, 0));
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
- when(contextManager.getMetaDataContexts().getAllDatabaseNames().contains(any())).thenReturn(true);
+ when(contextManager.getMetaDataContexts().getAllDatabaseNames().contains(anyString())).thenReturn(true);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().getRules()).thenReturn(Collections.emptyList());
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS);
when(metaData.getRuleMetaData().getRules()).thenReturn(new LinkedList<>());
when(contextManager.getMetaDataContexts().getMetaData(any())).thenReturn(metaData);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
UseDatabaseExecutor useSchemaBackendHandler = new UseDatabaseExecutor(useStatement);
useSchemaBackendHandler.execute(connectionSession);
verify(connectionSession).setCurrentDatabase(anyString());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/SelectInformationExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/SelectInformationExecutorTest.java
index 7f8c73bd2a9..25367369fa9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/SelectInformationExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/SelectInformationExecutorTest.java
@@ -86,7 +86,7 @@ public final class SelectInformationExecutorTest {
MetaDataContexts metaDataContexts = new MetaDataContexts(mock(MetaDataPersistService.class), new HashMap<>(), mock(ShardingSphereRuleMetaData.class),
mock(ExecutorEngine.class), mock(OptimizerContext.class), new ConfigurationProperties(new Properties()));
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(connectionSession.getGrantee()).thenReturn(new Grantee("root", "127.0.0.1"));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectDatabaseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectDatabaseExecutorTest.java
index a0964a4e234..26bb86b08a7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectDatabaseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectDatabaseExecutorTest.java
@@ -79,7 +79,7 @@ public final class SelectDatabaseExecutorTest {
MetaDataContexts metaDataContexts = new MetaDataContexts(mock(MetaDataPersistService.class), new HashMap<>(), mock(ShardingSphereRuleMetaData.class),
mock(ExecutorEngine.class), mock(OptimizerContext.class), new ConfigurationProperties(new Properties()));
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
private void mockResultSet(final Map<String, String> mockMap) throws SQLException {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectTableExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectTableExecutorTest.java
index 5b77664f723..c2376bd3a10 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectTableExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/postgresql/executor/SelectTableExecutorTest.java
@@ -74,7 +74,7 @@ public final class SelectTableExecutorTest {
MetaDataContexts metaDataContexts = new MetaDataContexts(mock(MetaDataPersistService.class), new HashMap<>(), mock(ShardingSphereRuleMetaData.class),
mock(ExecutorEngine.class), mock(OptimizerContext.class), new ConfigurationProperties(new Properties()));
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
private void mockResultSet(final Map<String, String> mockMap, final Boolean... values) throws SQLException {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/CreateDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/CreateDatabaseBackendHandlerTest.java
index a69a62b9274..56a0dfb36f7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/CreateDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/CreateDatabaseBackendHandlerTest.java
@@ -51,7 +51,7 @@ public final class CreateDatabaseBackendHandlerTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
MetaDataContexts metaDataContexts = mock(MetaDataContexts.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
handler = new CreateDatabaseBackendHandler(statement);
when(metaDataContexts.getAllDatabaseNames()).thenReturn(Collections.singleton("test_db"));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandlerTest.java
index bb9ef49f25e..80ad01c6d48 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/database/DropDatabaseBackendHandlerTest.java
@@ -62,7 +62,7 @@ public final class DropDatabaseBackendHandlerTest {
public void setUp() {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
handler = new DropDatabaseBackendHandler(sqlStatement, connectionSession);
when(metaDataContexts.getAllDatabaseNames()).thenReturn(Arrays.asList("test_db", "other_db"));
when(metaDataContexts.getGlobalRuleMetaData().getRules()).thenReturn(Collections.emptyList());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
index 0901a0a632c..48c8260a2b3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/DistSQLBackendHandlerFactoryTest.java
@@ -269,7 +269,7 @@ public final class DistSQLBackendHandlerFactoryTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
MetaDataContexts metaDataContexts = isGovernance ? mockMetaDataContexts() : new MetaDataContexts(mock(MetaDataPersistService.class));
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
private MetaDataContexts mockMetaDataContexts() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advance/ParseDistSQLBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advance/ParseDistSQLBackendHandlerTest.java
index 1de8a459967..2a9ef61aae6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advance/ParseDistSQLBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/advance/ParseDistSQLBackendHandlerTest.java
@@ -56,7 +56,7 @@ public final class ParseDistSQLBackendHandlerTest {
@Before
public void setUp() throws SQLException {
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class)).thenReturn(Optional.of(sqlParserRule));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesTest.java
index 6303ed7b962..e9fb755d6b7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/CountInstanceRulesTest.java
@@ -82,7 +82,7 @@ public final class CountInstanceRulesTest {
when(contextManager.getMetaDataContexts().getAllDatabaseNames()).thenReturn(Arrays.asList("db_1", "db_2"));
when(contextManager.getMetaDataContexts().getMetaData("db_1")).thenReturn(shardingSphereMetaData1);
when(contextManager.getMetaDataContexts().getMetaData("db_2")).thenReturn(shardingSphereMetaData2);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
private SingleTableRule mockSingleTableRule() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandlerTest.java
index 6970c27dc22..cbba5fc750e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ExportDatabaseConfigurationHandlerTest.java
@@ -66,7 +66,7 @@ public final class ExportDatabaseConfigurationHandlerTest {
when(shardingSphereMetaData.getResource().getDataSources()).thenReturn(createDataSourceMap());
when(shardingSphereMetaData.getRuleMetaData().getConfigurations()).thenReturn(Collections.singletonList(createShardingRuleConfiguration()));
when(contextManager.getMetaDataContexts().getMetaData("sharding_db")).thenReturn(shardingSphereMetaData);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java
index 0ad22f3baba..3fbe26a1e18 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowAuthorityRuleHandlerTest.java
@@ -46,7 +46,7 @@ public final class ShowAuthorityRuleHandlerTest {
public void assertAuthorityRule() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData()).thenReturn(getGlobalRuleMetaData());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
handler.execute();
handler.next();
List<Object> data = new ArrayList<>(handler.getRowData());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
index 1c06990bcde..8beb98f766a 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowInstanceModeHandlerTest.java
@@ -44,7 +44,7 @@ public final class ShowInstanceModeHandlerTest {
InstanceContext instanceContext = createInstanceContext();
when(contextManager.getInstanceContext()).thenReturn(instanceContext);
ShowInstanceModeHandler handler = new ShowInstanceModeHandler().initStatement(new ShowInstanceModeStatement());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
handler.execute();
handler.next();
List<Object> data = new ArrayList<>(handler.getRowData());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java
index 4400b2d16d5..cc3552d1e86 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowSQLParserRuleHandlerTest.java
@@ -43,7 +43,7 @@ public final class ShowSQLParserRuleHandlerTest {
public void assertSQLParserRule() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData()).thenReturn(getGlobalRuleMetaData());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
ShowSQLParserRuleHandler handler = new ShowSQLParserRuleHandler().initStatement(new ShowSQLParserRuleStatement());
handler.execute();
handler.next();
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java
index 9ea158022f4..0f435f804c1 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTableMetadataHandlerTest.java
@@ -54,7 +54,7 @@ public final class ShowTableMetadataHandlerTest {
ShardingSphereMetaData shardingSphereMetaData = mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS);
when(shardingSphereMetaData.getSchemaByName("db_name")).thenReturn(new ShardingSphereSchema(createTableMap()));
when(contextManager.getMetaDataContexts().getMetaData("db_name")).thenReturn(shardingSphereMetaData);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
when(connectionSession.getDatabaseName()).thenReturn("db_name");
when(connectionSession.getDatabaseType().getDefaultSchema("db_name")).thenReturn("db_name");
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
index ef4503802ca..dbc2f800520 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTrafficRulesHandlerTest.java
@@ -50,7 +50,7 @@ public class ShowTrafficRulesHandlerTest {
ShowTrafficRulesHandler handler = new ShowTrafficRulesHandler().initStatement(showTrafficRuleStatement);
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
handler.execute();
handler.next();
List<Object> data = new ArrayList<>(handler.getRowData());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
index 1da43c5dbe0..813f5511a47 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowTransactionRuleHandlerTest.java
@@ -45,7 +45,7 @@ public final class ShowTransactionRuleHandlerTest {
public void assertExecutorWithXA() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData()).thenReturn(getGlobalRuleMetaData("XA", "Atomikos", getProperties()));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
handler.execute();
handler.next();
List<Object> data = new ArrayList<>(handler.getRowData());
@@ -61,7 +61,7 @@ public final class ShowTransactionRuleHandlerTest {
public void assertExecutorWithLocal() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData()).thenReturn(getGlobalRuleMetaData("LOCAL", null, null));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
handler.execute();
handler.next();
List<Object> data = new ArrayList<>(handler.getRowData());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java
index 5464939340b..e51cf922bce 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/queryable/ShowVariableBackendHandlerTest.java
@@ -58,7 +58,7 @@ public final class ShowVariableBackendHandlerTest {
@Before
public void setup() {
contextManagerBefore = ProxyContext.getInstance().getContextManager();
- ProxyContext.getInstance().init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
+ ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.PROXY_BACKEND_DRIVER_TYPE)).thenReturn("JDBC");
connectionSession = new ConnectionSession(mock(MySQLDatabaseType.class), TransactionType.LOCAL, new DefaultAttributeMap());
}
@@ -118,7 +118,7 @@ public final class ShowVariableBackendHandlerTest {
public void assertShowPropsVariable() throws SQLException {
connectionSession.setCurrentDatabase("db");
ContextManager contextManager = mock(ContextManager.class);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
MetaDataContexts metaDataContexts = mock(MetaDataContexts.class);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
Properties props = new Properties();
@@ -139,7 +139,7 @@ public final class ShowVariableBackendHandlerTest {
public void assertShowAllVariables() throws SQLException {
connectionSession.setCurrentDatabase("db");
ContextManager contextManager = mock(ContextManager.class);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
MetaDataContexts metaDataContexts = mock(MetaDataContexts.class);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
when(metaDataContexts.getProps()).thenReturn(new ConfigurationProperties(new Properties()));
@@ -156,6 +156,6 @@ public final class ShowVariableBackendHandlerTest {
@After
public void tearDown() {
- ProxyContext.getInstance().init(contextManagerBefore);
+ ProxyContext.init(contextManagerBefore);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandlerTest.java
index 67826a2034b..55e49f57fc5 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterInstanceHandlerTest.java
@@ -45,7 +45,7 @@ public final class AlterInstanceHandlerTest {
public void assertCheckWithNoPersistenceConfigurationFound() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaDataPersistService()).thenReturn(Optional.empty());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
String instanceId = "instance_id";
String key = "xa_recovery_nodes";
String value = "value_1";
@@ -57,7 +57,7 @@ public final class AlterInstanceHandlerTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
MetaDataPersistService metaDataPersistService = new MetaDataPersistService(mock(PersistRepository.class));
when(contextManager.getMetaDataContexts().getMetaDataPersistService()).thenReturn(Optional.of(metaDataPersistService));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
String instanceId = "instance_id";
String key = "xa_recovery_nodes";
String value = "value_1";
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
index 0bbb1220038..fb007a00804 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterSQLParserRuleHandlerTest.java
@@ -48,7 +48,7 @@ public final class AlterSQLParserRuleHandlerTest {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(SQLParserRuleConfiguration.class)).thenReturn(Collections.emptyList());
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations()).thenReturn(new LinkedList<>());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
new AlterSQLParserRuleHandler().initStatement(getSQLStatement()).execute();
SQLParserRuleConfiguration actual = (SQLParserRuleConfiguration) contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations().iterator().next();
assertTrue(actual.isSqlCommentParseEnabled());
@@ -65,7 +65,7 @@ public final class AlterSQLParserRuleHandlerTest {
Collection<RuleConfiguration> globalRuleConfigs = new LinkedList<>(Collections.singleton(sqlParserRuleConfig));
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(SQLParserRuleConfiguration.class)).thenReturn(Collections.singleton(sqlParserRuleConfig));
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations()).thenReturn(globalRuleConfigs);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
new AlterSQLParserRuleHandler().initStatement(getSQLStatement()).execute();
SQLParserRuleConfiguration actual = (SQLParserRuleConfiguration) contextManager.getMetaDataContexts().getGlobalRuleMetaData().getConfigurations().iterator().next();
assertTrue(actual.isSqlCommentParseEnabled());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
index 5f8c218450a..cd4cb961787 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/AlterTrafficRuleHandlerTest.java
@@ -48,7 +48,7 @@ public final class AlterTrafficRuleHandlerTest {
public void assertCheckWithEmptyRule() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(new LinkedList<>());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
new AlterTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment)).execute();
@@ -58,7 +58,7 @@ public final class AlterTrafficRuleHandlerTest {
public void assertCheckWithInvalidAlgorithmType() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
new AlterTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment)).execute();
@@ -68,7 +68,7 @@ public final class AlterTrafficRuleHandlerTest {
public void assertCheckWithNotExistRuleName() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_3", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
new AlterTrafficRuleHandler().initStatement(getSQLStatement(trafficRuleSegment)).execute();
@@ -78,7 +78,7 @@ public final class AlterTrafficRuleHandlerTest {
public void assertCheckSuccess() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(createTrafficRule());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment1 = new TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TrafficRuleSegment trafficRuleSegment2 = new TrafficRuleSegment("rule_name_2", Collections.emptyList(),
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
index 3e958f853bb..4a43b2f43f9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/CreateTrafficRuleHandlerTest.java
@@ -46,7 +46,7 @@ public final class CreateTrafficRuleHandlerTest {
public void assertCheckWithEmptyRuleAndInvalidAlgorithmType() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.emptyList());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
new CreateTrafficRuleHandler().initStatement(new CreateTrafficRuleStatement(Collections.singletonList(trafficRuleSegment))).execute();
@@ -56,7 +56,7 @@ public final class CreateTrafficRuleHandlerTest {
public void assertCheckWithInvalidAlgorithmType() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("input_rule_name", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", new Properties()));
new CreateTrafficRuleHandler().initStatement(new CreateTrafficRuleStatement(Collections.singletonList(trafficRuleSegment))).execute();
@@ -66,7 +66,7 @@ public final class CreateTrafficRuleHandlerTest {
public void assertCheckWithDuplicatedRuleName() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment("rule_name_1", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
new CreateTrafficRuleHandler().initStatement(new CreateTrafficRuleStatement(Collections.singletonList(trafficRuleSegment))).execute();
@@ -76,7 +76,7 @@ public final class CreateTrafficRuleHandlerTest {
public void assertCheckSuccess() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
TrafficRuleSegment trafficRuleSegment1 = new TrafficRuleSegment("rule_name_3", Arrays.asList("olap", "order_by"),
new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()), new AlgorithmSegment("DISTSQL.FIXTURE", new Properties()));
TrafficRuleSegment trafficRuleSegment2 = new TrafficRuleSegment("rule_name_4", Collections.emptyList(),
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java
index 3af9e531a7b..945f88522e9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/DropTrafficRuleHandlerTest.java
@@ -50,7 +50,7 @@ public final class DropTrafficRuleHandlerTest {
public void assertExecuteWithEmptyRuleConfigurationAndNotExistRule() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(new LinkedList<>());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new DropTrafficRuleStatement(Collections.singletonList("rule_name"), false)).execute();
}
@@ -58,7 +58,7 @@ public final class DropTrafficRuleHandlerTest {
public void assertExecuteWithEmptyRuleConfigurationAndNotExistRuleAndIfExists() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(new LinkedList<>());
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new DropTrafficRuleStatement(Collections.singletonList("rule_name"), true)).execute();
}
@@ -66,7 +66,7 @@ public final class DropTrafficRuleHandlerTest {
public void assertExecuteWithNotExistRule() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new DropTrafficRuleStatement(Collections.singletonList("rule_name"), false)).execute();
}
@@ -74,7 +74,7 @@ public final class DropTrafficRuleHandlerTest {
public void assertExecute() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new DropTrafficRuleStatement(Collections.singletonList("rule_name_1"), false)).execute();
Optional<TrafficRuleConfiguration> ruleConfig = contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
assertTrue(ruleConfig.isPresent());
@@ -90,7 +90,7 @@ public final class DropTrafficRuleHandlerTest {
public void assertExecuteWithIfExists() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new DropTrafficRuleStatement(Collections.singletonList("rule_name_1"), false)).execute();
Optional<TrafficRuleConfiguration> ruleConfig = contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
assertTrue(ruleConfig.isPresent());
@@ -106,7 +106,7 @@ public final class DropTrafficRuleHandlerTest {
public void assertExecuteWithNotExistRuleAndIfExists() throws SQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(any())).thenReturn(Collections.singleton(createTrafficRuleConfiguration()));
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
new DropTrafficRuleHandler().initStatement(new DropTrafficRuleStatement(Collections.singletonList("rule_name_3"), true)).execute();
Optional<TrafficRuleConfiguration> ruleConfig = contextManager.getMetaDataContexts().getGlobalRuleMetaData().findRuleConfiguration(TrafficRuleConfiguration.class).stream().findAny();
assertTrue(ruleConfig.isPresent());
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandlerTest.java
index 4d74235e90a..31de8f77d7f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandlerTest.java
@@ -139,7 +139,7 @@ public final class ImportDatabaseConfigurationHandlerTest {
when(shardingSphereMetaData.getSchemaByName(DefaultDatabase.LOGIC_NAME)).thenReturn(new ShardingSphereSchema(createTableMap()));
when(shardingSphereMetaData.getResource().getDataSources()).thenReturn(createDataSourceMap());
when(contextManager.getMetaDataContexts().getMetaData(feature)).thenReturn(shardingSphereMetaData);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
private Map<String, DataSource> createDataSourceMap() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableBackendHandlerTest.java
index eba88f3f7bf..b5fc24bf4d3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableBackendHandlerTest.java
@@ -73,7 +73,7 @@ public final class SetVariableBackendHandlerTest {
contextManagerBefore = ProxyContext.getInstance().getContextManager();
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
connectionSession = new ConnectionSession(mock(MySQLDatabaseType.class), TransactionType.LOCAL, new DefaultAttributeMap());
}
@@ -160,6 +160,6 @@ public final class SetVariableBackendHandlerTest {
@After
public void tearDown() {
- ProxyContext.getInstance().init(contextManagerBefore);
+ ProxyContext.init(contextManagerBefore);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java
index 014ddea3b29..ef1a7274c04 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/SetVariableExecutorTest.java
@@ -67,7 +67,7 @@ public final class SetVariableExecutorTest {
ContextManager contextManager = new ContextManager();
MetaDataContexts metaDataContexts = new MetaDataContexts(null);
contextManager.init(metaDataContexts, null, null);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
SetVariableStatement statement = new SetVariableStatement("proxy_frontend_flush_threshold", "1024");
new SetVariableHandler().init(getParameter(statement, connectionSession)).execute();
Object actualValue = contextManager.getMetaDataContexts().getProps().getProps().get("proxy-frontend-flush-threshold");
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandlerTest.java
index 3e66875a946..a998320560d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AddResourceBackendHandlerTest.java
@@ -86,7 +86,7 @@ public final class AddResourceBackendHandlerTest {
public void assertExecute() throws Exception {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(metaDataContexts.getAllDatabaseNames()).thenReturn(Collections.singleton("test_db"));
when(metaDataContexts.getMetaData("test_db")).thenReturn(metaData);
when(metaData.getResource()).thenReturn(resource);
@@ -99,7 +99,7 @@ public final class AddResourceBackendHandlerTest {
public void assertExecuteWithDuplicateResourceNames() throws DistSQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(metaDataContexts.getAllDatabaseNames()).thenReturn(Collections.singleton("test_db"));
when(metaDataContexts.getMetaData("test_db")).thenReturn(metaData);
when(metaData.getResource()).thenReturn(resource);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
index d74f62a79ba..b6384b7f2c4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/AlterResourceBackendHandlerTest.java
@@ -93,7 +93,7 @@ public final class AlterResourceBackendHandlerTest {
public void assertExecute() throws Exception {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(metaDataContexts.getAllDatabaseNames()).thenReturn(Collections.singleton("test_db"));
when(metaDataContexts.getMetaData("test_db")).thenReturn(metaData);
when(metaData.getResource()).thenReturn(resource);
@@ -110,7 +110,7 @@ public final class AlterResourceBackendHandlerTest {
public void assertExecuteWithNotExistedResourceNames() throws DistSQLException {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(metaDataContexts.getAllDatabaseNames()).thenReturn(Collections.singleton("test_db"));
when(metaDataContexts.getMetaData("test_db")).thenReturn(metaData);
when(metaData.getResource()).thenReturn(resource);
@@ -122,7 +122,7 @@ public final class AlterResourceBackendHandlerTest {
public void assertExecuteWithAlterDatabase() throws Exception {
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(metaDataContexts.getAllDatabaseNames()).thenReturn(Collections.singleton("test_db"));
when(metaDataContexts.getMetaData("test_db")).thenReturn(metaData);
when(metaData.getResource()).thenReturn(resource);
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandlerTest.java
index c597e1c75c5..9ef8ced6d68 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rdl/resource/DropResourceBackendHandlerTest.java
@@ -88,7 +88,7 @@ public final class DropResourceBackendHandlerTest {
when(metaData.getResource()).thenReturn(resource);
contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
dropResourceBackendHandler = new DropResourceBackendHandler(dropResourceStatement, connectionSession);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerTest.java
index fecb2eb93e8..0ab22eeeb47 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RQLBackendHandlerTest.java
@@ -56,7 +56,7 @@ public final class RQLBackendHandlerTest {
when(metaDataContexts.getMetaData("test")).thenReturn(shardingSphereMetaData);
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
}
@Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RuleDefinitionBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RuleDefinitionBackendHandlerTest.java
index 28bbb4d71a1..54e4e4abd9c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RuleDefinitionBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/RuleDefinitionBackendHandlerTest.java
@@ -45,7 +45,7 @@ public final class RuleDefinitionBackendHandlerTest {
@Before
public void setUp() {
- ProxyContext.getInstance().init(mockContextManager());
+ ProxyContext.init(mockContextManager());
}
private ContextManager mockContextManager() {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
index f2688018bcf..6af71d5ad62 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/initializer/BootstrapInitializer.java
@@ -53,7 +53,7 @@ public final class BootstrapInitializer {
public void init(final YamlProxyConfiguration yamlConfig, final int port) throws SQLException {
ModeConfiguration modeConfig = null == yamlConfig.getServerConfiguration().getMode() ? null : new ModeConfigurationYamlSwapper().swapToObject(yamlConfig.getServerConfiguration().getMode());
ContextManager contextManager = createContextManager(yamlConfig, modeConfig, port);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
contextManagerInitializedCallback(modeConfig, contextManager);
ShardingSphereProxyVersion.setVersion(contextManager);
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/connection/ConnectionLimitContextTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/connection/ConnectionLimitContextTest.java
index 544e0e31adf..4148dfecaa1 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/connection/ConnectionLimitContextTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/connection/ConnectionLimitContextTest.java
@@ -37,7 +37,7 @@ public final class ConnectionLimitContextTest {
@Before
public void setup() {
contextManagerBefore = ProxyContext.getInstance().getContextManager();
- ProxyContext.getInstance().init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
+ ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
}
@Test
@@ -62,6 +62,6 @@ public final class ConnectionLimitContextTest {
@After
public void tearDown() {
- ProxyContext.getInstance().init(contextManagerBefore);
+ ProxyContext.init(contextManagerBefore);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
index 16707bfc833..2c3e215184e 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
@@ -89,8 +89,10 @@ public final class MySQLFrontendEngineTest {
@Mock
private Channel channel;
+ @SuppressWarnings("unchecked")
@Before
public void setUp() {
+ ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
resetConnectionIdGenerator();
when(context.channel()).thenReturn(channel);
when(channel.attr(CommonConstants.CHARSET_ATTRIBUTE_KEY)).thenReturn(mock(Attribute.class));
@@ -163,14 +165,11 @@ public final class MySQLFrontendEngineTest {
field.set(mysqlFrontendEngine.getAuthenticationEngine(), connectionPhase);
}
- @SneakyThrows(ReflectiveOperationException.class)
private void initProxyContext(final ShardingSphereUser user) {
- Field contextManagerField = ProxyContext.getInstance().getClass().getDeclaredField("contextManager");
- contextManagerField.setAccessible(true);
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
MetaDataContexts metaDataContexts = getMetaDataContexts(user);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- contextManagerField.set(ProxyContext.getInstance(), contextManager);
+ ProxyContext.init(contextManager);
}
private MetaDataContexts getMetaDataContexts(final ShardingSphereUser user) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngineTest.java
index 4bd02fb50a2..ac8d8851745 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/authentication/OpenGaussAuthenticationEngineTest.java
@@ -156,7 +156,7 @@ public final class OpenGaussAuthenticationEngineTest {
MetaDataContexts metaDataContexts = getMetaDataContexts(new ShardingSphereUser(username, password, ""));
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
actual = engine.authenticate(channelHandlerContext, payload);
assertThat(actual.isFinished(), is(password.equals(inputPassword)));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
index 0e3f15027dd..d8eb309e89b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
@@ -70,7 +70,7 @@ public final class OpenGaussComBatchBindExecutorTest {
@Before
public void setup() {
contextManagerBefore = ProxyContext.getInstance().getContextManager();
- ProxyContext.getInstance().init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
+ ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
}
@Test
@@ -109,6 +109,6 @@ public final class OpenGaussComBatchBindExecutorTest {
@After
public void tearDown() {
- ProxyContext.getInstance().init(contextManagerBefore);
+ ProxyContext.init(contextManagerBefore);
}
}
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 bd393a2cde3..e6add4eb0b4 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
@@ -166,7 +166,7 @@ public final class PostgreSQLAuthenticationEngineTest {
MetaDataContexts metaDataContexts = getMetaDataContexts(new ShardingSphereUser(username, password, ""));
ContextManager contextManager = mock(ContextManager.class, RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
actual = engine.authenticate(channelHandlerContext, payload);
assertThat(actual.isFinished(), is(password.equals(inputPassword)));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
index 1934f3f05b7..3a16e1b31d6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngineTest.java
@@ -22,12 +22,18 @@ import io.netty.channel.ChannelHandlerContext;
import org.apache.shardingsphere.db.protocol.postgresql.packet.PostgreSQLPacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLCommandCompletePacket;
import org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
+import org.apache.shardingsphere.infra.instance.InstanceContext;
+import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
+import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDBCBackendConnection;
import org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.ResourceLock;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.session.transaction.TransactionStatus;
import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
import org.apache.shardingsphere.proxy.frontend.postgresql.command.query.simple.PostgreSQLComQueryExecutor;
+import org.apache.shardingsphere.transaction.context.TransactionContexts;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.junit.Before;
import org.junit.Test;
@@ -61,6 +67,10 @@ public final class PostgreSQLCommandExecuteEngineTest {
@Before
public void setUp() {
+ MetaDataContexts metaDataContexts = new MetaDataContexts(mock(MetaDataPersistService.class));
+ ContextManager contextManager = new ContextManager();
+ contextManager.init(metaDataContexts, mock(TransactionContexts.class), mock(InstanceContext.class));
+ ProxyContext.init(contextManager);
when(channelHandlerContext.channel()).thenReturn(channel);
when(connectionSession.getTransactionStatus()).thenReturn(new TransactionStatus(TransactionType.LOCAL));
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java
index 1ce50853c6c..8e15b1e1222 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/JDBCPortalTest.java
@@ -92,7 +92,7 @@ public final class JDBCPortalTest {
@Before
public void setup() throws SQLException {
contextManagerBefore = ProxyContext.getInstance().getContextManager();
- ProxyContext.getInstance().init(mockContextManager);
+ ProxyContext.init(mockContextManager);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.SQL_SHOW)).thenReturn(false);
when(backendConnection.getConnectionSession()).thenReturn(connectionSession);
prepareJDBCPortal();
@@ -208,6 +208,6 @@ public final class JDBCPortalTest {
@After
public void tearDown() {
- ProxyContext.getInstance().init(contextManagerBefore);
+ ProxyContext.init(contextManagerBefore);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
index 51084fa508c..45de1aee237 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
@@ -81,7 +81,7 @@ public final class PostgreSQLAggregatedBatchedStatementsCommandExecutorTest {
@Before
public void setup() {
contextManagerBefore = ProxyContext.getInstance().getContextManager();
- ProxyContext.getInstance().init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
+ ProxyContext.init(mock(ContextManager.class, RETURNS_DEEP_STUBS));
}
@Test
@@ -133,6 +133,6 @@ public final class PostgreSQLAggregatedBatchedStatementsCommandExecutorTest {
@After
public void tearDown() {
- ProxyContext.getInstance().init(contextManagerBefore);
+ ProxyContext.init(contextManagerBefore);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
index 68b7fed4472..40fc796b070 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
@@ -85,7 +85,7 @@ public final class PostgreSQLBatchedStatementsExecutorTest {
when(connectionSession.getBackendConnection()).thenReturn(backendConnection);
when(connectionSession.getStatementManager()).thenReturn(backendStatement);
previousContextManager = ProxyContext.getInstance().getContextManager();
- ProxyContext.getInstance().init(contextManager);
+ ProxyContext.init(contextManager);
when(contextManager.getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE)).thenReturn(1);
when(contextManager.getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY)).thenReturn(1);
when(contextManager.getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.SQL_SHOW)).thenReturn(false);
@@ -131,6 +131,6 @@ public final class PostgreSQLBatchedStatementsExecutorTest {
@After
public void tearDown() {
- ProxyContext.getInstance().init(previousContextManager);
+ ProxyContext.init(previousContextManager);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
index b75348d12d2..a293b434623 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
@@ -110,7 +110,7 @@ public final class PostgreSQLComDescribeExecutorTest {
@Before
public void setup() {
contextManagerBefore = ProxyContext.getInstance().getContextManager();
- ProxyContext.getInstance().init(mockContextManager);
+ ProxyContext.init(mockContextManager);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps().getValue(ConfigurationPropertyKey.SQL_SHOW)).thenReturn(false);
when(connectionSession.getDatabaseName()).thenReturn(DATABASE_NAME);
when(mockContextManager.getMetaDataContexts().getAllDatabaseNames().contains(DATABASE_NAME)).thenReturn(true);
@@ -324,6 +324,6 @@ public final class PostgreSQLComDescribeExecutorTest {
@After
public void tearDown() {
- ProxyContext.getInstance().init(contextManagerBefore);
+ ProxyContext.init(contextManagerBefore);
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
index a195c2dc0db..17453f1f317 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
@@ -74,7 +74,7 @@ public final class PostgreSQLComParseExecutorTest {
@Before
public void setup() {
contextManagerBefore = ProxyContext.getInstance().getContextManager();
- ProxyContext.getInstance().init(mockedContextManager);
+ ProxyContext.init(mockedContextManager);
PostgreSQLPreparedStatementRegistry.getInstance().register(CONNECTION_ID);
when(connectionSession.getConnectionId()).thenReturn(CONNECTION_ID);
}
@@ -117,6 +117,6 @@ public final class PostgreSQLComParseExecutorTest {
@After
public void tearDown() {
- ProxyContext.getInstance().init(contextManagerBefore);
+ ProxyContext.init(contextManagerBefore);
}
}