diff --git a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingAlgorithmImplementationsExecutor.java b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingAlgorithmImplementationsExecutor.java index b0ae7f013cebe..6c5fb095e120d 100644 --- a/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingAlgorithmImplementationsExecutor.java +++ b/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/query/ShowShardingAlgorithmImplementationsExecutor.java @@ -42,8 +42,7 @@ public Collection getRows(final ShowShardingAlgorithmIm Collection result = new LinkedList<>(); Collection shardingAlgorithms = ShardingSphereServiceLoader.getServiceInstances(ShardingAlgorithm.class); for (ShardingAlgorithm each : shardingAlgorithms) { - LocalDataQueryResultRow row = new LocalDataQueryResultRow(each.getClass().getSimpleName(), each.getType(), each.getClass().getName()); - result.add(row); + result.add(new LocalDataQueryResultRow(each.getClass().getSimpleName(), each.getType(), each.getClass().getName())); } return result; } diff --git a/proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm b/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor similarity index 88% rename from proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm rename to features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor index 18da880d1937d..79ba98c3e8fd5 100644 --- a/proxy/backend/core/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm +++ b/features/sharding/distsql/handler/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor @@ -15,4 +15,4 @@ # limitations under the License. # -org.apache.shardingsphere.proxy.backend.handler.distsql.fixture.FooDistSQLShardingAlgorithmFixture +org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingAlgorithmImplementationsExecutor diff --git a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmImplementationsExecutorTest.java b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmImplementationsExecutorTest.java index 1fd226947aad4..e810c063d55bd 100644 --- a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmImplementationsExecutorTest.java +++ b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmImplementationsExecutorTest.java @@ -28,7 +28,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.mock; class ShowShardingAlgorithmImplementationsExecutorTest { @@ -37,7 +37,7 @@ class ShowShardingAlgorithmImplementationsExecutorTest { void assertGetRowData() { QueryableRALExecutor executor = new ShowShardingAlgorithmImplementationsExecutor(); Collection actual = executor.getRows(mock(ShowShardingAlgorithmImplementationsStatement.class)); - assertTrue(actual.size() > 0); + assertFalse(actual.isEmpty()); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); assertThat(row.getCell(1), is("FooDistSQLShardingAlgorithmFixture")); diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutor.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutor.java index 8afa1c03f840d..5c9f4ec75201a 100644 --- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutor.java +++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutor.java @@ -49,9 +49,8 @@ public Collection getRows(final ShowServiceProviderImpl } Collection shardingAlgorithms = ShardingSphereServiceLoader.getServiceInstances(clazz); for (Object each : shardingAlgorithms) { - TypedSPI type = (TypedSPI) each; - LocalDataQueryResultRow row = new LocalDataQueryResultRow(type.getClass().getSimpleName(), type.getType(), type.getClass().getName()); - result.add(row); + TypedSPI implementation = (TypedSPI) each; + result.add(new LocalDataQueryResultRow(implementation.getClass().getSimpleName(), implementation.getType(), implementation.getClass().getName())); } return result; } diff --git a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor index 29930a6c12758..97d4f5329cc4a 100644 --- a/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor +++ b/proxy/backend/core/src/main/resources/META-INF/services/org.apache.shardingsphere.distsql.handler.ral.query.QueryableRALExecutor @@ -28,4 +28,3 @@ org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowStatus org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowTableMetaDataExecutor org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowMigrationRuleExecutor org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowServiceProviderImplementationsExecutor -org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingAlgorithmImplementationsExecutor diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/FooDistSQLShardingAlgorithmFixture.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/FooDistSQLShardingAlgorithmFixture.java deleted file mode 100644 index 9c29fc35ad1ee..0000000000000 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/fixture/FooDistSQLShardingAlgorithmFixture.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shardingsphere.proxy.backend.handler.distsql.fixture; - -import org.apache.shardingsphere.sharding.api.sharding.ShardingAutoTableAlgorithm; -import org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue; -import org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue; -import org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm; - -import java.util.Collection; -import java.util.Collections; - -public final class FooDistSQLShardingAlgorithmFixture implements StandardShardingAlgorithm, ShardingAutoTableAlgorithm { - - @Override - public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) { - return ""; - } - - @Override - public Collection doSharding(final Collection availableTargetNames, final RangeShardingValue shardingValue) { - return Collections.emptyList(); - } - - @Override - public String getType() { - return "FOO.DISTSQL.FIXTURE"; - } - - @Override - public int getAutoTablesAmount() { - return 2; - } -} diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutorTest.java index 3afa27f86bf36..e8e10185d8fbd 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ShowServiceProviderImplementationsExecutorTest.java @@ -27,7 +27,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -37,14 +37,14 @@ class ShowServiceProviderImplementationsExecutorTest { void assertGetRowData() { QueryableRALExecutor executor = new ShowServiceProviderImplementationsExecutor(); ShowServiceProviderImplementationsStatement statement = mock(ShowServiceProviderImplementationsStatement.class); - when(statement.getServiceProviderInterface()).thenReturn("org.apache.shardingsphere.sharding.spi.ShardingAlgorithm"); + when(statement.getServiceProviderInterface()).thenReturn("org.apache.shardingsphere.infra.datasource.pool.destroyer.DataSourcePoolActiveDetector"); Collection actual = executor.getRows(statement); - assertTrue(actual.size() > 0); + assertFalse(actual.isEmpty()); Iterator iterator = actual.iterator(); LocalDataQueryResultRow row = iterator.next(); - assertThat(row.getCell(1), is("FooDistSQLShardingAlgorithmFixture")); - assertThat(row.getCell(2), is("FOO.DISTSQL.FIXTURE")); - assertThat(row.getCell(3), is("org.apache.shardingsphere.proxy.backend.handler.distsql.fixture.FooDistSQLShardingAlgorithmFixture")); + assertThat(row.getCell(1), is("HikariDataSourcePoolActiveDetector")); + assertThat(row.getCell(2), is("com.zaxxer.hikari.HikariDataSource")); + assertThat(row.getCell(3), is("org.apache.shardingsphere.infra.datasource.pool.hikari.detector.HikariDataSourcePoolActiveDetector")); } @Test