-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some unit test cases for WeOpen-Star .
- Loading branch information
1 parent
4332e31
commit 06f9381
Showing
43 changed files
with
1,345 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...che/shardingsphere/readwritesplitting/factory/ReplicaLoadBalanceAlgorithmFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...ardingsphere/readwritesplitting/factory/fixture/ReadQueryLoadBalanceAlgorithmFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> readDataSourceNames) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Properties getProps() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void init(final Properties props) { | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return TYPE; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...F/services/org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
47 changes: 47 additions & 0 deletions
47
...test/java/org/apache/shardingsphere/sharding/factory/KeyGenerateAlgorithmFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...rc/test/java/org/apache/shardingsphere/sharding/factory/ShardingAlgorithmFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...src/test/java/org/apache/shardingsphere/sharding/fixture/KeyGenerateAlgorithmFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...pi/src/test/java/org/apache/shardingsphere/sharding/fixture/ShardingAlgorithmFixture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...t/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
18 changes: 18 additions & 0 deletions
18
...test/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
39 changes: 39 additions & 0 deletions
39
...e/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessorFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<RuleDefinitionAlterPreprocessor> actual = RuleDefinitionAlterPreprocessorFactory.findInstance(new FixtureRuleStatement()); | ||
assertTrue(actual.isPresent()); | ||
assertThat(actual.get(), instanceOf(FixtureRuleDefinitionAlterPreprocessor.class)); | ||
} | ||
} |
Oops, something went wrong.