diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/test/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactoryTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/test/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactoryTest.java new file mode 100644 index 0000000000000..43fd555c465e5 --- /dev/null +++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/test/java/org/apache/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactoryTest.java @@ -0,0 +1,47 @@ +/* + * 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.readwritesplitting.factory; + +import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration; +import org.apache.shardingsphere.readwritesplitting.factory.fixture.ReadQueryLoadBalanceAlgorithmFixture; +import org.junit.Test; + +import java.util.Properties; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public final class ReplicaLoadBalanceAlgorithmFactoryTest { + + @Test + public void assertNewInstance() { + assertThat(ReplicaLoadBalanceAlgorithmFactory.newInstance(), instanceOf(ReadQueryLoadBalanceAlgorithmFixture.class)); + } + + @Test + public void assertNewInstanceWithShardingSphereAlgorithmConfiguration() { + ShardingSphereAlgorithmConfiguration configuration = new ShardingSphereAlgorithmConfiguration("FIXTURE", new Properties()); + assertThat(ReplicaLoadBalanceAlgorithmFactory.newInstance(configuration), instanceOf(ReadQueryLoadBalanceAlgorithmFixture.class)); + } + + @Test + public void assertContains() { + assertTrue(ReplicaLoadBalanceAlgorithmFactory.contains("FIXTURE")); + } +} diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/test/java/org/apache/shardingsphere/readwritesplitting/factory/fixture/ReadQueryLoadBalanceAlgorithmFixture.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/test/java/org/apache/shardingsphere/readwritesplitting/factory/fixture/ReadQueryLoadBalanceAlgorithmFixture.java new file mode 100644 index 0000000000000..9c4e997499e54 --- /dev/null +++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/test/java/org/apache/shardingsphere/readwritesplitting/factory/fixture/ReadQueryLoadBalanceAlgorithmFixture.java @@ -0,0 +1,47 @@ +/* + * 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.readwritesplitting.factory.fixture; + +import org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm; + +import java.util.List; +import java.util.Properties; + +public final class ReadQueryLoadBalanceAlgorithmFixture implements ReadQueryLoadBalanceAlgorithm { + + public static final String TYPE = "FIXTURE"; + + @Override + public String getDataSource(final String name, final String writeDataSourceName, final List readDataSourceNames) { + return null; + } + + @Override + public Properties getProps() { + return null; + } + + @Override + public void init(final Properties props) { + } + + @Override + public String getType() { + return TYPE; + } +} diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/test/resources/META-INF/services/org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/test/resources/META-INF/services/org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm new file mode 100644 index 0000000000000..5e354ef41d8b8 --- /dev/null +++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-api/src/test/resources/META-INF/services/org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm @@ -0,0 +1,18 @@ +# +# 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.readwritesplitting.factory.fixture.ReadQueryLoadBalanceAlgorithmFixture diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactoryTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactoryTest.java new file mode 100644 index 0000000000000..79c65fcb51c9f --- /dev/null +++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactoryTest.java @@ -0,0 +1,47 @@ +/* + * 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.sharding.factory; + +import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration; +import org.apache.shardingsphere.sharding.fixture.KeyGenerateAlgorithmFixture; +import org.junit.Test; + +import java.util.Properties; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public final class KeyGenerateAlgorithmFactoryTest { + + @Test + public void assertNewInstance() { + assertThat(KeyGenerateAlgorithmFactory.newInstance(), instanceOf(KeyGenerateAlgorithmFixture.class)); + } + + @Test + public void assertNewInstanceWithShardingSphereAlgorithmConfiguration() { + ShardingSphereAlgorithmConfiguration configuration = new ShardingSphereAlgorithmConfiguration("FIXTURE", new Properties()); + assertThat(KeyGenerateAlgorithmFactory.newInstance(configuration), instanceOf(KeyGenerateAlgorithmFixture.class)); + } + + @Test + public void assertContains() { + assertTrue(KeyGenerateAlgorithmFactory.contains("FIXTURE")); + } +} diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactoryTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactoryTest.java new file mode 100644 index 0000000000000..d4e6b8024216c --- /dev/null +++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactoryTest.java @@ -0,0 +1,42 @@ +/* + * 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.sharding.factory; + +import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration; +import org.apache.shardingsphere.sharding.fixture.ShardingAlgorithmFixture; +import org.junit.Test; + +import java.util.Properties; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public final class ShardingAlgorithmFactoryTest { + + @Test + public void assertNewInstance() { + ShardingSphereAlgorithmConfiguration configuration = new ShardingSphereAlgorithmConfiguration("FIXTURE", new Properties()); + assertThat(ShardingAlgorithmFactory.newInstance(configuration), instanceOf(ShardingAlgorithmFixture.class)); + } + + @Test + public void assertContains() { + assertTrue(ShardingAlgorithmFactory.contains("FIXTURE")); + } +} diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/fixture/KeyGenerateAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/fixture/KeyGenerateAlgorithmFixture.java new file mode 100644 index 0000000000000..0bff4f883da42 --- /dev/null +++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/fixture/KeyGenerateAlgorithmFixture.java @@ -0,0 +1,46 @@ +/* + * 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.sharding.fixture; + +import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm; + +import java.util.Properties; + +public final class KeyGenerateAlgorithmFixture implements KeyGenerateAlgorithm { + + public static final String TYPE = "FIXTURE"; + + @Override + public Comparable generateKey() { + return null; + } + + @Override + public Properties getProps() { + return new Properties(); + } + + @Override + public void init(final Properties props) { + } + + @Override + public String getType() { + return TYPE; + } +} diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/fixture/ShardingAlgorithmFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/fixture/ShardingAlgorithmFixture.java new file mode 100644 index 0000000000000..2d6f6286a060a --- /dev/null +++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/java/org/apache/shardingsphere/sharding/fixture/ShardingAlgorithmFixture.java @@ -0,0 +1,41 @@ +/* + * 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.sharding.fixture; + +import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm; + +import java.util.Properties; + +public final class ShardingAlgorithmFixture implements ShardingAlgorithm { + + public static final String TYPE = "FIXTURE"; + + @Override + public Properties getProps() { + return new Properties(); + } + + @Override + public void init(final Properties props) { + } + + @Override + public String getType() { + return TYPE; + } +} diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm new file mode 100644 index 0000000000000..da7b2a000f64d --- /dev/null +++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm @@ -0,0 +1,18 @@ +# +# 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.sharding.fixture.KeyGenerateAlgorithmFixture diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm new file mode 100644 index 0000000000000..cf5d2a563716f --- /dev/null +++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-api/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm @@ -0,0 +1,18 @@ +# +# 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.sharding.fixture.ShardingAlgorithmFixture diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeFactoryTest.java new file mode 100644 index 0000000000000..0a9c08ea8162c --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeFactoryTest.java @@ -0,0 +1,60 @@ +/* + * 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.database.type; + +import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType; +import org.apache.shardingsphere.infra.database.type.dialect.MariaDBDatabaseType; +import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType; +import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType; +import org.apache.shardingsphere.infra.database.type.dialect.OracleDatabaseType; +import org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType; +import org.apache.shardingsphere.infra.database.type.dialect.SQL92DatabaseType; +import org.apache.shardingsphere.infra.database.type.dialect.SQLServerDatabaseType; +import org.apache.shardingsphere.infra.fixture.FixtureDatabaseType; +import org.junit.Test; + +import java.util.Collection; +import java.util.Iterator; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public final class DatabaseTypeFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(DatabaseTypeFactory.getInstance("FIXTURE"), instanceOf(FixtureDatabaseType.class)); + } + + @Test + public void assertGetInstances() { + Collection actual = DatabaseTypeFactory.getInstances(); + assertThat(actual.size(), is(9)); + Iterator iterator = actual.iterator(); + assertThat(iterator.next(), instanceOf(FixtureDatabaseType.class)); + assertThat(iterator.next(), instanceOf(SQL92DatabaseType.class)); + assertThat(iterator.next(), instanceOf(MySQLDatabaseType.class)); + assertThat(iterator.next(), instanceOf(MariaDBDatabaseType.class)); + assertThat(iterator.next(), instanceOf(PostgreSQLDatabaseType.class)); + assertThat(iterator.next(), instanceOf(OpenGaussDatabaseType.class)); + assertThat(iterator.next(), instanceOf(OracleDatabaseType.class)); + assertThat(iterator.next(), instanceOf(SQLServerDatabaseType.class)); + assertThat(iterator.next(), instanceOf(H2DatabaseType.class)); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactoryTest.java new file mode 100644 index 0000000000000..4533ba5dccd88 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactoryTest.java @@ -0,0 +1,39 @@ +/* + * 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.distsql.preprocess; + +import org.apache.shardingsphere.infra.fixture.FixtureRuleDefinitionAlterPreprocessor; +import org.apache.shardingsphere.infra.fixture.FixtureRuleStatement; +import org.junit.Test; + +import java.util.Optional; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public final class RuleDefinitionAlterPreprocessorFactoryTest { + + @SuppressWarnings("rawtypes") + @Test + public void assertFindInstance() { + Optional actual = RuleDefinitionAlterPreprocessorFactory.findInstance(new FixtureRuleStatement()); + assertTrue(actual.isPresent()); + assertThat(actual.get(), instanceOf(FixtureRuleDefinitionAlterPreprocessor.class)); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/update/RALUpdaterFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/update/RALUpdaterFactoryTest.java new file mode 100644 index 0000000000000..243d2fb62897b --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/update/RALUpdaterFactoryTest.java @@ -0,0 +1,33 @@ +/* + * 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.distsql.update; + +import org.apache.shardingsphere.infra.fixture.FixtureRALStatement; +import org.apache.shardingsphere.infra.fixture.FixtureRALUpdater; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class RALUpdaterFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(RALUpdaterFactory.getInstance(FixtureRALStatement.class), instanceOf(FixtureRALUpdater.class)); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/update/RuleDefinitionUpdaterFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/update/RuleDefinitionUpdaterFactoryTest.java new file mode 100644 index 0000000000000..43fba6479f729 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/distsql/update/RuleDefinitionUpdaterFactoryTest.java @@ -0,0 +1,34 @@ +/* + * 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.distsql.update; + +import org.apache.shardingsphere.infra.fixture.FixtureRuleDefinitionUpdater; +import org.apache.shardingsphere.infra.fixture.FixtureRuleStatement; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.mock; + +public final class RuleDefinitionUpdaterFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(RuleDefinitionUpdaterFactory.getInstance(mock(FixtureRuleStatement.class)), instanceOf(FixtureRuleDefinitionUpdater.class)); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureDatabaseType.java new file mode 100644 index 0000000000000..f78b70e1e3a0c --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureDatabaseType.java @@ -0,0 +1,66 @@ +/* + * 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.fixture; + +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; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +public final class FixtureDatabaseType implements DatabaseType { + + @Override + public QuoteCharacter getQuoteCharacter() { + return QuoteCharacter.BACK_QUOTE; + } + + @Override + public Collection getJdbcUrlPrefixes() { + return Collections.singleton(String.format("jdbc:%s:", getType().toLowerCase())); + } + + @Override + public DataSourceMetaData getDataSourceMetaData(final String url, final String username) { + return null; + } + + @Override + public Optional getDataSourceClassName() { + return Optional.empty(); + } + + @Override + public Map> getSystemDatabaseSchemaMap() { + return new HashMap<>(); + } + + @Override + public Collection getSystemSchemas() { + return Collections.emptyList(); + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRALStatement.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRALStatement.java new file mode 100644 index 0000000000000..70db52048cc11 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRALStatement.java @@ -0,0 +1,23 @@ +/* + * 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.fixture; + +import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement; + +public final class FixtureRALStatement extends AbstractSQLStatement { +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRALUpdater.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRALUpdater.java new file mode 100644 index 0000000000000..b068111a17c5a --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRALUpdater.java @@ -0,0 +1,32 @@ +/* + * 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.fixture; + +import org.apache.shardingsphere.infra.distsql.update.RALUpdater; + +public final class FixtureRALUpdater implements RALUpdater { + + @Override + public void executeUpdate(final FixtureRALStatement sqlStatement) { + } + + @Override + public String getType() { + return FixtureRALStatement.class.getName(); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleConfiguration.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleConfiguration.java new file mode 100644 index 0000000000000..bc4282706e9ea --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleConfiguration.java @@ -0,0 +1,23 @@ +/* + * 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.fixture; + +import org.apache.shardingsphere.infra.config.RuleConfiguration; + +public final class FixtureRuleConfiguration implements RuleConfiguration { +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleDefinitionAlterPreprocessor.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleDefinitionAlterPreprocessor.java new file mode 100644 index 0000000000000..05f18ec3c19c7 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleDefinitionAlterPreprocessor.java @@ -0,0 +1,33 @@ +/* + * 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.fixture; + +import org.apache.shardingsphere.infra.distsql.preprocess.RuleDefinitionAlterPreprocessor; + +public final class FixtureRuleDefinitionAlterPreprocessor implements RuleDefinitionAlterPreprocessor { + + @Override + public FixtureRuleConfiguration preprocess(final FixtureRuleConfiguration currentRuleConfig, final FixtureRuleConfiguration toBeAlteredRuleConfig) { + return null; + } + + @Override + public String getType() { + return FixtureRuleStatement.class.getName(); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleDefinitionUpdater.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleDefinitionUpdater.java new file mode 100644 index 0000000000000..3fb0a9774e38a --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleDefinitionUpdater.java @@ -0,0 +1,39 @@ +/* + * 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.fixture; + +import org.apache.shardingsphere.infra.distsql.exception.DistSQLException; +import org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater; +import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; + +public final class FixtureRuleDefinitionUpdater implements RuleDefinitionUpdater { + + @Override + public void checkSQLStatement(final ShardingSphereDatabase database, final FixtureRuleStatement sqlStatement, final FixtureRuleConfiguration currentRuleConfig) throws DistSQLException { + } + + @Override + public Class getRuleConfigurationClass() { + return FixtureRuleConfiguration.class; + } + + @Override + public String getType() { + return FixtureRuleStatement.class.getName(); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleStatement.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleStatement.java new file mode 100644 index 0000000000000..f5fc6242fb1b5 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/fixture/FixtureRuleStatement.java @@ -0,0 +1,28 @@ +/* + * 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.fixture; + +import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; + +public final class FixtureRuleStatement implements SQLStatement { + + @Override + public int getParameterCount() { + return 0; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType new file mode 100644 index 0000000000000..882eb57af6473 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType @@ -0,0 +1,18 @@ +# +# 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.fixture.FixtureDatabaseType diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.preprocess.RuleDefinitionAlterPreprocessor b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.preprocess.RuleDefinitionAlterPreprocessor new file mode 100644 index 0000000000000..6c2b69386c1c8 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.preprocess.RuleDefinitionAlterPreprocessor @@ -0,0 +1,18 @@ +# +# 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.fixture.FixtureRuleDefinitionAlterPreprocessor diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RALUpdater b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RALUpdater new file mode 100644 index 0000000000000..630770badccb9 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RALUpdater @@ -0,0 +1,18 @@ +# +# 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.fixture.FixtureRALUpdater diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater new file mode 100644 index 0000000000000..571086a6b4333 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.distsql.update.RuleDefinitionUpdater @@ -0,0 +1,18 @@ +# +# 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.fixture.FixtureRuleDefinitionUpdater diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresherFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresherFactoryTest.java new file mode 100644 index 0000000000000..991125a261ea0 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresherFactoryTest.java @@ -0,0 +1,39 @@ +/* + * 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.context.refresher; + +import org.apache.shardingsphere.infra.context.refresher.fixture.FixtureSQLStatement; +import org.apache.shardingsphere.infra.context.refresher.fixture.MetaDataRefresherFixture; +import org.junit.Test; + +import java.util.Optional; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public final class MetaDataRefresherFactoryTest { + + @SuppressWarnings("rawtypes") + @Test + public void assertFindInstance() { + Optional actual = MetaDataRefresherFactory.findInstance(FixtureSQLStatement.class); + assertTrue(actual.isPresent()); + assertThat(actual.get(), instanceOf(MetaDataRefresherFixture.class)); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/refresher/fixture/FixtureSQLStatement.java b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/refresher/fixture/FixtureSQLStatement.java new file mode 100644 index 0000000000000..056230553215d --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/refresher/fixture/FixtureSQLStatement.java @@ -0,0 +1,28 @@ +/* + * 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.context.refresher.fixture; + +import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement; + +public final class FixtureSQLStatement extends AbstractSQLStatement { + + @Override + public int getParameterCount() { + return 0; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/refresher/fixture/MetaDataRefresherFixture.java b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/refresher/fixture/MetaDataRefresherFixture.java new file mode 100644 index 0000000000000..30af0ed347e21 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/refresher/fixture/MetaDataRefresherFixture.java @@ -0,0 +1,42 @@ +/* + * 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.context.refresher.fixture; + +import org.apache.shardingsphere.infra.config.props.ConfigurationProperties; +import org.apache.shardingsphere.infra.context.refresher.MetaDataRefresher; +import org.apache.shardingsphere.infra.federation.optimizer.context.planner.OptimizerPlannerContext; +import org.apache.shardingsphere.infra.federation.optimizer.metadata.FederationDatabaseMetaData; +import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; +import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement; + +import java.sql.SQLException; +import java.util.Collection; +import java.util.Map; + +public final class MetaDataRefresherFixture implements MetaDataRefresher { + + @Override + public void refresh(final ShardingSphereDatabase database, final FederationDatabaseMetaData federationDatabaseMetaData, final Map optimizerPlanners, + final Collection logicDataSourceNames, final String schemaName, final AbstractSQLStatement sqlStatement, final ConfigurationProperties props) throws SQLException { + } + + @Override + public String getType() { + return AbstractSQLStatement.class.getName(); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.context.refresher.MetaDataRefresher b/shardingsphere-infra/shardingsphere-infra-context/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.context.refresher.MetaDataRefresher index f21724a890607..ed25ef149d1b3 100644 --- a/shardingsphere-infra/shardingsphere-infra-context/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.context.refresher.MetaDataRefresher +++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.context.refresher.MetaDataRefresher @@ -16,3 +16,4 @@ # org.apache.shardingsphere.infra.context.refresher.type.DummyDropDatabaseMetaDataRefresher +org.apache.shardingsphere.infra.context.refresher.fixture.MetaDataRefresherFixture diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/test/java/org/apache/shardingsphere/infra/datetime/DatetimeServiceFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/test/java/org/apache/shardingsphere/infra/datetime/DatetimeServiceFactoryTest.java new file mode 100644 index 0000000000000..85ccef653a510 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/test/java/org/apache/shardingsphere/infra/datetime/DatetimeServiceFactoryTest.java @@ -0,0 +1,32 @@ +/* + * 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.datetime; + +import org.apache.shardingsphere.infra.datetime.fixture.DatetimeServiceFixture; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class DatetimeServiceFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(DatetimeServiceFactory.getInstance(), instanceOf(DatetimeServiceFixture.class)); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/test/java/org/apache/shardingsphere/infra/datetime/fixture/DatetimeServiceFixture.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/test/java/org/apache/shardingsphere/infra/datetime/fixture/DatetimeServiceFixture.java new file mode 100644 index 0000000000000..635bb354c05aa --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/test/java/org/apache/shardingsphere/infra/datetime/fixture/DatetimeServiceFixture.java @@ -0,0 +1,30 @@ +/* + * 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.datetime.fixture; + +import org.apache.shardingsphere.infra.datetime.DatetimeService; + +import java.util.Date; + +public final class DatetimeServiceFixture implements DatetimeService { + + @Override + public Date getDatetime() { + return new Date(); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService new file mode 100644 index 0000000000000..21cd41fe973d2 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService @@ -0,0 +1,18 @@ +# +# 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.datetime.fixture.DatetimeServiceFixture diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatabaseType.java new file mode 100644 index 0000000000000..f5a981857c6a6 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatabaseType.java @@ -0,0 +1,66 @@ +/* + * 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.datetime.database.fixture; + +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; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +public final class FixtureDatabaseType implements DatabaseType { + + @Override + public QuoteCharacter getQuoteCharacter() { + return QuoteCharacter.BACK_QUOTE; + } + + @Override + public Collection getJdbcUrlPrefixes() { + return Collections.singleton(String.format("jdbc:%s:", getType().toLowerCase())); + } + + @Override + public DataSourceMetaData getDataSourceMetaData(final String url, final String username) { + return null; + } + + @Override + public Optional getDataSourceClassName() { + return Optional.empty(); + } + + @Override + public Map> getSystemDatabaseSchemaMap() { + return new HashMap<>(); + } + + @Override + public Collection getSystemSchemas() { + return Collections.emptyList(); + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatetimeLoadingSQLProvider.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatetimeLoadingSQLProvider.java new file mode 100644 index 0000000000000..37e4e8d3802e8 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatetimeLoadingSQLProvider.java @@ -0,0 +1,33 @@ +/* + * 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.datetime.database.fixture; + +import org.apache.shardingsphere.datetime.database.provider.DatetimeLoadingSQLProvider; + +public final class FixtureDatetimeLoadingSQLProvider implements DatetimeLoadingSQLProvider { + + @Override + public String getDatetimeLoadingSQL() { + return null; + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/provider/DatetimeLoadingSQLProviderFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/provider/DatetimeLoadingSQLProviderFactoryTest.java new file mode 100644 index 0000000000000..2663b2d24cf95 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/provider/DatetimeLoadingSQLProviderFactoryTest.java @@ -0,0 +1,33 @@ +/* + * 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.datetime.database.provider; + +import org.apache.shardingsphere.datetime.database.fixture.FixtureDatabaseType; +import org.apache.shardingsphere.datetime.database.fixture.FixtureDatetimeLoadingSQLProvider; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class DatetimeLoadingSQLProviderFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(DatetimeLoadingSQLProviderFactory.getInstance(new FixtureDatabaseType()), instanceOf(FixtureDatetimeLoadingSQLProvider.class)); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/META-INF/services/org.apache.shardingsphere.datetime.database.provider.DatetimeLoadingSQLProvider b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/META-INF/services/org.apache.shardingsphere.datetime.database.provider.DatetimeLoadingSQLProvider new file mode 100644 index 0000000000000..13bcb2c941331 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/META-INF/services/org.apache.shardingsphere.datetime.database.provider.DatetimeLoadingSQLProvider @@ -0,0 +1,18 @@ +# +# 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.datetime.database.fixture.FixtureDatetimeLoadingSQLProvider diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType new file mode 100644 index 0000000000000..18d980da547ea --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.database.type.DatabaseType @@ -0,0 +1,18 @@ +# +# 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.datetime.database.fixture.FixtureDatabaseType diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/jdbc/sane/SaneQueryResultEngineFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/jdbc/sane/SaneQueryResultEngineFactoryTest.java new file mode 100644 index 0000000000000..ea3720d10f297 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/jdbc/sane/SaneQueryResultEngineFactoryTest.java @@ -0,0 +1,34 @@ +/* + * 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.executor.sql.execute.engine.jdbc.sane; + +import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.sane.SaneQueryResultEngineFactory; +import org.apache.shardingsphere.infra.executor.sql.fixture.FixtureDatabaseType; +import org.apache.shardingsphere.infra.executor.sql.fixture.FixtureSaneQueryResultEngine; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class SaneQueryResultEngineFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(SaneQueryResultEngineFactory.getInstance(new FixtureDatabaseType()), instanceOf(FixtureSaneQueryResultEngine.class)); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureDatabaseType.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureDatabaseType.java new file mode 100644 index 0000000000000..6b93178b87f32 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureDatabaseType.java @@ -0,0 +1,64 @@ +/* + * 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.executor.sql.fixture; + +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; + +import java.util.Collection; +import java.util.Map; +import java.util.Optional; + +public final class FixtureDatabaseType implements DatabaseType { + + @Override + public QuoteCharacter getQuoteCharacter() { + return null; + } + + @Override + public Collection getJdbcUrlPrefixes() { + return null; + } + + @Override + public DataSourceMetaData getDataSourceMetaData(final String url, final String username) { + return null; + } + + @Override + public Optional getDataSourceClassName() { + return Optional.empty(); + } + + @Override + public Map> getSystemDatabaseSchemaMap() { + return null; + } + + @Override + public Collection getSystemSchemas() { + return null; + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureSaneQueryResultEngine.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureSaneQueryResultEngine.java new file mode 100644 index 0000000000000..2af43bd6b7b47 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/fixture/FixtureSaneQueryResultEngine.java @@ -0,0 +1,37 @@ +/* + * 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.executor.sql.fixture; + +import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.sane.SaneQueryResultEngine; +import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult; +import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement; + +import java.util.Optional; + +public final class FixtureSaneQueryResultEngine implements SaneQueryResultEngine { + + @Override + public Optional getSaneQueryResult(final SQLStatement sqlStatement) { + return Optional.empty(); + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/SQLExecutionUnitBuilderFactoryTest.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/SQLExecutionUnitBuilderFactoryTest.java new file mode 100644 index 0000000000000..b660edb69bceb --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/SQLExecutionUnitBuilderFactoryTest.java @@ -0,0 +1,32 @@ +/* + * 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.executor.sql.prepare.driver; + +import org.apache.shardingsphere.infra.executor.sql.prepare.driver.fixture.FixtureSQLExecutionUnitBuilder; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class SQLExecutionUnitBuilderFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(SQLExecutionUnitBuilderFactory.getInstance("FIXTURE"), instanceOf(FixtureSQLExecutionUnitBuilder.class)); + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureDriverExecutionUnit.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureDriverExecutionUnit.java new file mode 100644 index 0000000000000..41752594c09d2 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureDriverExecutionUnit.java @@ -0,0 +1,40 @@ +/* + * 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.executor.sql.prepare.driver.fixture; + +import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit; +import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode; +import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.DriverExecutionUnit; + +public final class FixtureDriverExecutionUnit implements DriverExecutionUnit { + + @Override + public ExecutionUnit getExecutionUnit() { + return null; + } + + @Override + public ConnectionMode getConnectionMode() { + return null; + } + + @Override + public Object getStorageResource() { + return null; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureExecutorStatementManager.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureExecutorStatementManager.java new file mode 100644 index 0000000000000..fc52ced2dc9bd --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureExecutorStatementManager.java @@ -0,0 +1,38 @@ +/* + * 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.executor.sql.prepare.driver.fixture; + +import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit; +import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode; +import org.apache.shardingsphere.infra.executor.sql.prepare.driver.ExecutorStatementManager; + +import java.sql.SQLException; + +public final class FixtureExecutorStatementManager implements ExecutorStatementManager { + + @Override + public Object createStorageResource(final Object connection, final ConnectionMode connectionMode, final FixtureStorageResourceOption option) throws SQLException { + return null; + } + + @Override + public Object createStorageResource(final ExecutionUnit executionUnit, final Object connection, final ConnectionMode connectionMode, + final FixtureStorageResourceOption option) throws SQLException { + return null; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureSQLExecutionUnitBuilder.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureSQLExecutionUnitBuilder.java new file mode 100644 index 0000000000000..88b99964d5d00 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureSQLExecutionUnitBuilder.java @@ -0,0 +1,38 @@ +/* + * 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.executor.sql.prepare.driver.fixture; + +import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit; +import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode; +import org.apache.shardingsphere.infra.executor.sql.prepare.driver.SQLExecutionUnitBuilder; + +import java.sql.SQLException; + +public final class FixtureSQLExecutionUnitBuilder implements SQLExecutionUnitBuilder { + + @Override + public FixtureDriverExecutionUnit build(final ExecutionUnit executionUnit, final FixtureExecutorStatementManager executorManager, final Object connection, final ConnectionMode connectionMode, + final FixtureStorageResourceOption option) throws SQLException { + return new FixtureDriverExecutionUnit(); + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureStorageResourceOption.java b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureStorageResourceOption.java new file mode 100644 index 0000000000000..0763f447f3ab9 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/fixture/FixtureStorageResourceOption.java @@ -0,0 +1,23 @@ +/* + * 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.executor.sql.prepare.driver.fixture; + +import org.apache.shardingsphere.infra.executor.sql.prepare.driver.StorageResourceOption; + +public final class FixtureStorageResourceOption implements StorageResourceOption { +} diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.sane.SaneQueryResultEngine b/shardingsphere-infra/shardingsphere-infra-executor/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.sane.SaneQueryResultEngine new file mode 100644 index 0000000000000..3a7b4f127dbe6 --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.sane.SaneQueryResultEngine @@ -0,0 +1,18 @@ +# +# 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.executor.sql.fixture.FixtureSaneQueryResultEngine diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.prepare.driver.SQLExecutionUnitBuilder b/shardingsphere-infra/shardingsphere-infra-executor/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.prepare.driver.SQLExecutionUnitBuilder new file mode 100644 index 0000000000000..10f38e9eb550d --- /dev/null +++ b/shardingsphere-infra/shardingsphere-infra-executor/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.executor.sql.prepare.driver.SQLExecutionUnitBuilder @@ -0,0 +1,18 @@ +# +# 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.executor.sql.prepare.driver.fixture.FixtureSQLExecutionUnitBuilder diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/test/java/org/apache/shardingsphere/authority/provider/fixture/FixtureStoragePrivilegeHandler.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/test/java/org/apache/shardingsphere/authority/provider/fixture/FixtureStoragePrivilegeHandler.java new file mode 100644 index 0000000000000..71f5926088d7c --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/test/java/org/apache/shardingsphere/authority/provider/fixture/FixtureStoragePrivilegeHandler.java @@ -0,0 +1,53 @@ +/* + * 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.authority.provider.fixture; + +import org.apache.shardingsphere.authority.provider.natived.builder.StoragePrivilegeHandler; +import org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges; +import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser; + +import javax.sql.DataSource; +import java.sql.SQLException; +import java.util.Collection; +import java.util.Map; + +public final class FixtureStoragePrivilegeHandler implements StoragePrivilegeHandler { + + @Override + public Collection diff(final Collection users, final DataSource dataSource) throws SQLException { + return null; + } + + @Override + public void create(final Collection users, final DataSource dataSource) throws SQLException { + } + + @Override + public void grantAll(final Collection users, final DataSource dataSource) throws SQLException { + } + + @Override + public Map load(final Collection users, final DataSource dataSource) throws SQLException { + return null; + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeHandlerFactoryTest.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeHandlerFactoryTest.java new file mode 100644 index 0000000000000..51b0dcaafeaa2 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/test/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeHandlerFactoryTest.java @@ -0,0 +1,37 @@ +/* + * 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.authority.provider.natived.builder; + +import org.apache.shardingsphere.authority.provider.fixture.FixtureStoragePrivilegeHandler; +import org.junit.Test; + +import java.util.Optional; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public final class StoragePrivilegeHandlerFactoryTest { + + @Test + public void assertFindInstance() { + Optional actual = StoragePrivilegeHandlerFactory.findInstance("FIXTURE"); + assertTrue(actual.isPresent()); + assertThat(actual.get(), instanceOf(FixtureStoragePrivilegeHandler.class)); + } +} diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/test/resources/META-INF/services/org.apache.shardingsphere.authority.provider.natived.builder.StoragePrivilegeHandler b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/test/resources/META-INF/services/org.apache.shardingsphere.authority.provider.natived.builder.StoragePrivilegeHandler new file mode 100644 index 0000000000000..08a6d4cbeec05 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/test/resources/META-INF/services/org.apache.shardingsphere.authority.provider.natived.builder.StoragePrivilegeHandler @@ -0,0 +1,18 @@ +# +# 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.authority.provider.fixture.FixtureStoragePrivilegeHandler diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/check/datasource/DataSourceCheckerFactoryTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/check/datasource/DataSourceCheckerFactoryTest.java new file mode 100644 index 0000000000000..cdd0bdcd52e54 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/check/datasource/DataSourceCheckerFactoryTest.java @@ -0,0 +1,32 @@ +/* + * 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.data.pipeline.spi.check.datasource; + +import org.apache.shardingsphere.data.pipeline.spi.fixture.FixtureDataSourceChecker; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class DataSourceCheckerFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(DataSourceCheckerFactory.getInstance("FIXTURE"), instanceOf(FixtureDataSourceChecker.class)); + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/FixtureDataSourceChecker.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/FixtureDataSourceChecker.java new file mode 100644 index 0000000000000..4bd357159cfe5 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/FixtureDataSourceChecker.java @@ -0,0 +1,48 @@ +/* + * 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.data.pipeline.spi.fixture; + +import org.apache.shardingsphere.data.pipeline.api.config.TableNameSchemaNameMapping; +import org.apache.shardingsphere.data.pipeline.spi.check.datasource.DataSourceChecker; + +import javax.sql.DataSource; +import java.util.Collection; + +public final class FixtureDataSourceChecker implements DataSourceChecker { + + @Override + public void checkConnection(final Collection dataSources) { + } + + @Override + public void checkPrivilege(final Collection dataSources) { + } + + @Override + public void checkVariable(final Collection dataSources) { + } + + @Override + public void checkTargetTable(final Collection dataSources, final TableNameSchemaNameMapping tableNameSchemaNameMapping, final Collection logicTableNames) { + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/RowBasedJobLockFixture.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/RowBasedJobLockFixture.java new file mode 100644 index 0000000000000..0b4c30e419d78 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/RowBasedJobLockFixture.java @@ -0,0 +1,31 @@ +/* + * 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.data.pipeline.spi.fixture; + +import org.apache.shardingsphere.data.pipeline.spi.lock.RowBasedJobLock; + +public final class RowBasedJobLockFixture implements RowBasedJobLock { + + @Override + public void lock(final String databaseName, final String jobId) { + } + + @Override + public void releaseLock(final String databaseName, final String jobId) { + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/RuleAlteredJobConfigurationPreparerFixture.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/RuleAlteredJobConfigurationPreparerFixture.java new file mode 100644 index 0000000000000..5a71f2fbeeb01 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/RuleAlteredJobConfigurationPreparerFixture.java @@ -0,0 +1,36 @@ +/* + * 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.data.pipeline.spi.fixture; + +import org.apache.shardingsphere.data.pipeline.api.config.rulealtered.RuleAlteredJobConfiguration; +import org.apache.shardingsphere.data.pipeline.api.config.rulealtered.TaskConfiguration; +import org.apache.shardingsphere.data.pipeline.api.config.rulealtered.yaml.YamlRuleAlteredJobConfiguration; +import org.apache.shardingsphere.data.pipeline.spi.rulealtered.RuleAlteredJobConfigurationPreparer; +import org.apache.shardingsphere.infra.config.rulealtered.OnRuleAlteredActionConfiguration; + +public final class RuleAlteredJobConfigurationPreparerFixture implements RuleAlteredJobConfigurationPreparer { + + @Override + public void extendJobConfiguration(final YamlRuleAlteredJobConfiguration yamlJobConfig) { + } + + @Override + public TaskConfiguration createTaskConfiguration(final RuleAlteredJobConfiguration jobConfig, final int jobShardingItem, final OnRuleAlteredActionConfiguration onRuleAlteredActionConfig) { + return null; + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/RuleBasedJobLockFixture.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/RuleBasedJobLockFixture.java new file mode 100644 index 0000000000000..2921ca1dec350 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/fixture/RuleBasedJobLockFixture.java @@ -0,0 +1,31 @@ +/* + * 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.data.pipeline.spi.fixture; + +import org.apache.shardingsphere.data.pipeline.spi.lock.RuleBasedJobLock; + +public final class RuleBasedJobLockFixture implements RuleBasedJobLock { + + @Override + public void lock(final String databaseName, final String jobId) { + } + + @Override + public void releaseLock(final String databaseName, final String jobId) { + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/lock/RowBasedJobLockFactoryTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/lock/RowBasedJobLockFactoryTest.java new file mode 100644 index 0000000000000..abfd2df863275 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/lock/RowBasedJobLockFactoryTest.java @@ -0,0 +1,32 @@ +/* + * 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.data.pipeline.spi.lock; + +import org.apache.shardingsphere.data.pipeline.spi.fixture.RowBasedJobLockFixture; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class RowBasedJobLockFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(RowBasedJobLockFactory.getInstance(), instanceOf(RowBasedJobLockFixture.class)); + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/lock/RuleBasedJobLockFactoryTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/lock/RuleBasedJobLockFactoryTest.java new file mode 100644 index 0000000000000..77f3ca052223f --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/lock/RuleBasedJobLockFactoryTest.java @@ -0,0 +1,32 @@ +/* + * 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.data.pipeline.spi.lock; + +import org.apache.shardingsphere.data.pipeline.spi.fixture.RuleBasedJobLockFixture; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class RuleBasedJobLockFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(RuleBasedJobLockFactory.getInstance(), instanceOf(RuleBasedJobLockFixture.class)); + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/rulealtered/RuleAlteredJobConfigurationPreparerFactoryTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/rulealtered/RuleAlteredJobConfigurationPreparerFactoryTest.java new file mode 100644 index 0000000000000..5fdccecd52442 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/java/org/apache/shardingsphere/data/pipeline/spi/rulealtered/RuleAlteredJobConfigurationPreparerFactoryTest.java @@ -0,0 +1,32 @@ +/* + * 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.data.pipeline.spi.rulealtered; + +import org.apache.shardingsphere.data.pipeline.spi.fixture.RuleAlteredJobConfigurationPreparerFixture; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class RuleAlteredJobConfigurationPreparerFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(RuleAlteredJobConfigurationPreparerFactory.getInstance(), instanceOf(RuleAlteredJobConfigurationPreparerFixture.class)); + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.check.datasource.DataSourceChecker b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.check.datasource.DataSourceChecker new file mode 100644 index 0000000000000..e7e4b75cdd22f --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.check.datasource.DataSourceChecker @@ -0,0 +1,18 @@ +# +# 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.data.pipeline.spi.fixture.FixtureDataSourceChecker diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.lock.RowBasedJobLock b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.lock.RowBasedJobLock new file mode 100644 index 0000000000000..293ac3c26fa6d --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.lock.RowBasedJobLock @@ -0,0 +1,18 @@ +# +# 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.data.pipeline.spi.fixture.RowBasedJobLockFixture diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.lock.RuleBasedJobLock b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.lock.RuleBasedJobLock new file mode 100644 index 0000000000000..c07852c1565be --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.lock.RuleBasedJobLock @@ -0,0 +1,18 @@ +# +# 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.data.pipeline.spi.fixture.RuleBasedJobLockFixture diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.rulealtered.RuleAlteredJobConfigurationPreparer b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.rulealtered.RuleAlteredJobConfigurationPreparer new file mode 100644 index 0000000000000..676fd8e8e0805 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.rulealtered.RuleAlteredJobConfigurationPreparer @@ -0,0 +1,18 @@ +# +# 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.data.pipeline.spi.fixture.RuleAlteredJobConfigurationPreparerFixture diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreatorFactoryTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreatorFactoryTest.java new file mode 100644 index 0000000000000..b62f797f43234 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreatorFactoryTest.java @@ -0,0 +1,32 @@ +/* + * 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.data.pipeline.core.datasource.creator; + +import org.apache.shardingsphere.data.pipeline.core.datasource.creator.fixture.FixturePipelineDataSourceCreator; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class PipelineDataSourceCreatorFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(PipelineDataSourceCreatorFactory.getInstance("FIXTURE"), instanceOf(FixturePipelineDataSourceCreator.class)); + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/fixture/FixturePipelineDataSourceCreator.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/fixture/FixturePipelineDataSourceCreator.java new file mode 100644 index 0000000000000..19eafd5a5c6ea --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/fixture/FixturePipelineDataSourceCreator.java @@ -0,0 +1,36 @@ +/* + * 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.data.pipeline.core.datasource.creator.fixture; + +import org.apache.shardingsphere.data.pipeline.core.datasource.creator.PipelineDataSourceCreator; + +import javax.sql.DataSource; +import java.sql.SQLException; + +public final class FixturePipelineDataSourceCreator implements PipelineDataSourceCreator { + + @Override + public DataSource createPipelineDataSource(final Object pipelineDataSourceConfig) throws SQLException { + return null; + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PositionInitializerFactoryTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PositionInitializerFactoryTest.java new file mode 100644 index 0000000000000..ff70bc5e64131 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/PositionInitializerFactoryTest.java @@ -0,0 +1,32 @@ +/* + * 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.data.pipeline.core.ingest.position; + +import org.apache.shardingsphere.data.pipeline.core.ingest.position.fixture.FixturePositionInitializer; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class PositionInitializerFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(PositionInitializerFactory.getInstance("FIXTURE"), instanceOf(FixturePositionInitializer.class)); + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/fixture/FixturePositionInitializer.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/fixture/FixturePositionInitializer.java new file mode 100644 index 0000000000000..0d57ff5638c78 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/ingest/position/fixture/FixturePositionInitializer.java @@ -0,0 +1,42 @@ +/* + * 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.data.pipeline.core.ingest.position.fixture; + +import org.apache.shardingsphere.data.pipeline.api.ingest.position.IngestPosition; +import org.apache.shardingsphere.data.pipeline.spi.ingest.position.PositionInitializer; + +import javax.sql.DataSource; +import java.sql.SQLException; + +public final class FixturePositionInitializer implements PositionInitializer { + + @Override + public IngestPosition init(final DataSource dataSource) throws SQLException { + return null; + } + + @Override + public IngestPosition init(final String data) { + return null; + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactoryTest.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactoryTest.java new file mode 100644 index 0000000000000..53c18567c863a --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/java/org/apache/shardingsphere/data/pipeline/core/sqlbuilder/PipelineSQLBuilderFactoryTest.java @@ -0,0 +1,32 @@ +/* + * 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.data.pipeline.core.sqlbuilder; + +import org.apache.shardingsphere.data.pipeline.core.check.consistency.algorithm.fixture.FixturePipelineSQLBuilder; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class PipelineSQLBuilderFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(PipelineSQLBuilderFactory.getInstance("FIXTURE"), instanceOf(FixturePipelineSQLBuilder.class)); + } +} diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.datasource.creator.PipelineDataSourceCreator b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.datasource.creator.PipelineDataSourceCreator new file mode 100644 index 0000000000000..a579961f5411e --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.core.datasource.creator.PipelineDataSourceCreator @@ -0,0 +1,18 @@ +# +# 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.data.pipeline.core.datasource.creator.fixture.FixturePipelineDataSourceCreator diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.ingest.position.PositionInitializer b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.ingest.position.PositionInitializer new file mode 100644 index 0000000000000..15029e72b0b8b --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/test/resources/META-INF/services/org.apache.shardingsphere.data.pipeline.spi.ingest.position.PositionInitializer @@ -0,0 +1,18 @@ +# +# 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.data.pipeline.core.ingest.position.fixture.FixturePositionInitializer diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactoryTest.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactoryTest.java new file mode 100644 index 0000000000000..86ea942c05e5f --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/factory/TrafficLoadBalanceAlgorithmFactoryTest.java @@ -0,0 +1,42 @@ +/* + * 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.traffic.factory; + +import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration; +import org.apache.shardingsphere.traffic.fixture.TrafficLoadBalanceAlgorithmFixture; +import org.junit.Test; + +import java.util.Properties; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public final class TrafficLoadBalanceAlgorithmFactoryTest { + + @Test + public void assertNewInstance() { + ShardingSphereAlgorithmConfiguration configuration = new ShardingSphereAlgorithmConfiguration("FIXTURE", new Properties()); + assertThat(TrafficLoadBalanceAlgorithmFactory.newInstance(configuration), instanceOf(TrafficLoadBalanceAlgorithmFixture.class)); + } + + @Test + public void assertContains() { + assertTrue(TrafficLoadBalanceAlgorithmFactory.contains("FIXTURE")); + } +} diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/fixture/TrafficLoadBalanceAlgorithmFixture.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/fixture/TrafficLoadBalanceAlgorithmFixture.java new file mode 100644 index 0000000000000..ce96b99ca50ff --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/java/org/apache/shardingsphere/traffic/fixture/TrafficLoadBalanceAlgorithmFixture.java @@ -0,0 +1,48 @@ +/* + * 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.traffic.fixture; + +import org.apache.shardingsphere.infra.instance.definition.InstanceDefinition; +import org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm; + +import java.util.List; +import java.util.Properties; + +public final class TrafficLoadBalanceAlgorithmFixture implements TrafficLoadBalanceAlgorithm { + + public static final String TYPE = "FIXTURE"; + + @Override + public Properties getProps() { + return null; + } + + @Override + public InstanceDefinition getInstanceId(final String name, final List instances) { + return null; + } + + @Override + public void init(final Properties props) { + } + + @Override + public String getType() { + return TYPE; + } +} diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/resources/META-INF/services/org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/resources/META-INF/services/org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm new file mode 100644 index 0000000000000..0b7450ca69f4e --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-api/src/test/resources/META-INF/services/org.apache.shardingsphere.traffic.spi.TrafficLoadBalanceAlgorithm @@ -0,0 +1,18 @@ +# +# 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.traffic.fixture.TrafficLoadBalanceAlgorithmFixture diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/fixture/FixtureTransactionConfigurationFileGenerator.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/fixture/FixtureTransactionConfigurationFileGenerator.java new file mode 100644 index 0000000000000..f731350ebc9f7 --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/fixture/FixtureTransactionConfigurationFileGenerator.java @@ -0,0 +1,41 @@ +/* + * 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.transaction.fixture; + +import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration; +import org.apache.shardingsphere.infra.instance.InstanceContext; +import org.apache.shardingsphere.transaction.spi.TransactionConfigurationFileGenerator; + +import java.util.Properties; + +public final class FixtureTransactionConfigurationFileGenerator implements TransactionConfigurationFileGenerator { + + @Override + public void generateFile(final Properties transactionProps, final InstanceContext instanceContext) { + } + + @Override + public Properties getTransactionProps(final Properties originTransactionProps, final DatabaseConfiguration databaseConfig, final String modeType) { + return new Properties(); + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGeneratorFactoryTest.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGeneratorFactoryTest.java new file mode 100644 index 0000000000000..1fad85aca5a0b --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGeneratorFactoryTest.java @@ -0,0 +1,44 @@ +/* + * 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.transaction.spi; + +import org.apache.shardingsphere.transaction.fixture.FixtureTransactionConfigurationFileGenerator; +import org.junit.Test; + +import java.util.Optional; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public final class TransactionConfigurationFileGeneratorFactoryTest { + + @Test + public void assertFindInstanceWithoutTransactionProviderType() { + Optional actual = TransactionConfigurationFileGeneratorFactory.findInstance(null); + assertFalse(actual.isPresent()); + } + + @Test + public void assertFindInstance() { + Optional actual = TransactionConfigurationFileGeneratorFactory.findInstance("FIXTURE"); + assertTrue(actual.isPresent()); + assertThat(actual.get(), instanceOf(FixtureTransactionConfigurationFileGenerator.class)); + } +} diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/resources/META-INF/services/org.apache.shardingsphere.transaction.spi.TransactionConfigurationFileGenerator b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/resources/META-INF/services/org.apache.shardingsphere.transaction.spi.TransactionConfigurationFileGenerator new file mode 100644 index 0000000000000..938a92bf3ef8d --- /dev/null +++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/test/resources/META-INF/services/org.apache.shardingsphere.transaction.spi.TransactionConfigurationFileGenerator @@ -0,0 +1,18 @@ +# +# 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.transaction.fixture.FixtureTransactionConfigurationFileGenerator diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/StatementMemoryStrictlyFetchSizeSetterFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/StatementMemoryStrictlyFetchSizeSetterFactoryTest.java new file mode 100644 index 0000000000000..d2f0a441177b9 --- /dev/null +++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/StatementMemoryStrictlyFetchSizeSetterFactoryTest.java @@ -0,0 +1,37 @@ +/* + * 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.communication.jdbc.statement; + +import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.fixture.StatementMemoryStrictlyFetchSizeSetterFixture; +import org.junit.Test; + +import java.util.Optional; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public final class StatementMemoryStrictlyFetchSizeSetterFactoryTest { + + @Test + public void assertFindInstance() { + Optional actual = StatementMemoryStrictlyFetchSizeSetterFactory.findInstance("FIXTURE"); + assertTrue(actual.isPresent()); + assertThat(actual.get(), instanceOf(StatementMemoryStrictlyFetchSizeSetterFixture.class)); + } +} diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fixture/StatementMemoryStrictlyFetchSizeSetterFixture.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fixture/StatementMemoryStrictlyFetchSizeSetterFixture.java new file mode 100644 index 0000000000000..a453ca938a128 --- /dev/null +++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/fixture/StatementMemoryStrictlyFetchSizeSetterFixture.java @@ -0,0 +1,35 @@ +/* + * 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.communication.jdbc.statement.fixture; + +import org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter; + +import java.sql.SQLException; +import java.sql.Statement; + +public final class StatementMemoryStrictlyFetchSizeSetterFixture implements StatementMemoryStrictlyFetchSizeSetter { + + @Override + public void setFetchSize(final Statement statement) throws SQLException { + } + + @Override + public String getType() { + return "FIXTURE"; + } +} diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter new file mode 100644 index 0000000000000..7295924920dec --- /dev/null +++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.communication.jdbc.statement.StatementMemoryStrictlyFetchSizeSetter @@ -0,0 +1,18 @@ +# +# 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.proxy.backend.communication.jdbc.statement.fixture.StatementMemoryStrictlyFetchSizeSetterFixture diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureOKProxyState.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureOKProxyState.java new file mode 100644 index 0000000000000..700b55d3671a2 --- /dev/null +++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/fixture/FixtureOKProxyState.java @@ -0,0 +1,35 @@ +/* + * 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.frontend.fixture; + +import io.netty.channel.ChannelHandlerContext; +import org.apache.shardingsphere.proxy.backend.session.ConnectionSession; +import org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine; +import org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState; + +public final class FixtureOKProxyState implements OKProxyState { + + @Override + public void execute(final ChannelHandlerContext context, final Object message, final DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine, final ConnectionSession connectionSession) { + } + + @Override + public String getType() { + return new FixtureDatabaseType().getType(); + } +} diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateFactoryTest.java new file mode 100644 index 0000000000000..e65b620525017 --- /dev/null +++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyStateFactoryTest.java @@ -0,0 +1,33 @@ +/* + * 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.frontend.state.impl; + +import org.apache.shardingsphere.proxy.frontend.fixture.FixtureDatabaseType; +import org.apache.shardingsphere.proxy.frontend.fixture.FixtureOKProxyState; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +public final class OKProxyStateFactoryTest { + + @Test + public void assertGetInstance() { + assertThat(OKProxyStateFactory.getInstance(new FixtureDatabaseType().getType()), instanceOf(FixtureOKProxyState.class)); + } +} diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState new file mode 100644 index 0000000000000..87b1502f29469 --- /dev/null +++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/test/resources/META-INF/services/org.apache.shardingsphere.proxy.frontend.state.impl.OKProxyState @@ -0,0 +1,18 @@ +# +# 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.proxy.frontend.fixture.FixtureOKProxyState