You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by to...@apache.org on 2022/06/21 05:05:34 UTC
[shardingsphere] branch master updated: Refactor OptimizerSQLDialectBuilderFactoryTest (#18483)
This is an automated email from the ASF dual-hosted git repository.
totalo 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 db210de5b14 Refactor OptimizerSQLDialectBuilderFactoryTest (#18483)
db210de5b14 is described below
commit db210de5b14e58a25808cab1d7587b090f503584
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Jun 21 13:05:26 2022 +0800
Refactor OptimizerSQLDialectBuilderFactoryTest (#18483)
---
.../OptimizerSQLDialectBuilderFactoryTest.java | 23 ++++----
.../parser/fixture/FixtureDatabaseType.java | 62 ----------------------
.../fixture/OptimizerSQLDialectBuilderFixture.java | 36 -------------
...shardingsphere.infra.database.type.DatabaseType | 18 -------
...ntext.parser.dialect.OptimizerSQLDialectBuilder | 18 -------
5 files changed, 13 insertions(+), 144 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/dialect/OptimizerSQLDialectBuilderFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/dialect/OptimizerSQLDialectBuilderFactoryTest.java
index d9b07ae81db..c3ed13c8872 100644
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/dialect/OptimizerSQLDialectBuilderFactoryTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/dialect/OptimizerSQLDialectBuilderFactoryTest.java
@@ -17,22 +17,25 @@
package org.apache.shardingsphere.infra.federation.optimizer.context.parser.dialect;
-import java.util.Properties;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeFactory;
-import org.apache.shardingsphere.infra.federation.optimizer.context.parser.fixture.OptimizerSQLDialectBuilderFixture;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertThat;
+import org.apache.shardingsphere.infra.federation.optimizer.context.parser.dialect.impl.H2OptimizerBuilder;
+import org.apache.shardingsphere.infra.federation.optimizer.context.parser.dialect.impl.MySQLOptimizerBuilder;
import org.junit.Test;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
public final class OptimizerSQLDialectBuilderFactoryTest {
@Test
- public void assertCreateOptimizerSQLDialectBuilder() {
- DatabaseType type = DatabaseTypeFactory.getInstance("FIXTURE");
- Properties actual = OptimizerSQLDialectBuilderFactory.build(type);
- OptimizerSQLDialectBuilder builder = new OptimizerSQLDialectBuilderFixture();
- Properties excepted = builder.build();
- assertThat(actual, equalTo(excepted));
+ public void assertBuildWithDatabaseType() {
+ DatabaseType databaseType = DatabaseTypeFactory.getInstance("H2");
+ assertThat(OptimizerSQLDialectBuilderFactory.build(databaseType), is(new H2OptimizerBuilder().build()));
+ }
+
+ @Test
+ public void assertBuildWithoutDatabaseType() {
+ assertThat(OptimizerSQLDialectBuilderFactory.build(null), is(new MySQLOptimizerBuilder().build()));
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/fixture/FixtureDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/fixture/FixtureDatabaseType.java
deleted file mode 100644
index b0155b90e4a..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/fixture/FixtureDatabaseType.java
+++ /dev/null
@@ -1,62 +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.infra.federation.optimizer.context.parser.fixture;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Optional;
-import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.sql.parser.sql.common.constant.QuoteCharacter;
-
-public class FixtureDatabaseType implements DatabaseType {
- @Override
- public QuoteCharacter getQuoteCharacter() {
- return null;
- }
-
- @Override
- public Collection<String> getJdbcUrlPrefixes() {
- return null;
- }
-
- @Override
- public DataSourceMetaData getDataSourceMetaData(final String url, final String username) {
- return null;
- }
-
- @Override
- public Optional<String> getDataSourceClassName() {
- return Optional.empty();
- }
-
- @Override
- public Map<String, Collection<String>> getSystemDatabaseSchemaMap() {
- return null;
- }
-
- @Override
- public Collection<String> getSystemSchemas() {
- return null;
- }
-
- @Override
- public String getType() {
- return "FIXTURE";
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/fixture/OptimizerSQLDialectBuilderFixture.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/fixture/OptimizerSQLDialectBuilderFixture.java
deleted file mode 100644
index 7de11d11532..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/fixture/OptimizerSQLDialectBuilderFixture.java
+++ /dev/null
@@ -1,36 +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.infra.federation.optimizer.context.parser.fixture;
-
-import java.util.Properties;
-import org.apache.shardingsphere.infra.federation.optimizer.context.parser.dialect.OptimizerSQLDialectBuilder;
-
-public final class OptimizerSQLDialectBuilderFixture implements OptimizerSQLDialectBuilder {
-
- @Override
- public Properties build() {
- Properties properties = new Properties();
- properties.setProperty("fixture", "fixture");
- return properties;
- }
-
- @Override
- public String getType() {
- return "FIXTURE";
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType
deleted file mode 100644
index 36adc826199..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType
+++ /dev/null
@@ -1,18 +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.
-#
-
-org.apache.shardingsphere.infra.federation.optimizer.context.parser.fixture.FixtureDatabaseType
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.federation.optimizer.context.parser.dialect.OptimizerSQLDialectBuilder b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.federation.optimizer.context.parser.dialect.OptimizerSQLDialectBuilder
deleted file mode 100644
index 31af89156d4..00000000000
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.federation.optimizer.context.parser.dialect.OptimizerSQLDialectBuilder
+++ /dev/null
@@ -1,18 +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.
-#
-
-org.apache.shardingsphere.infra.federation.optimizer.context.parser.fixture.OptimizerSQLDialectBuilderFixture