This is an automated email from the ASF dual-hosted git repository. duanzhengqiang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/shardingsphere-plugin.git
commit 243343b9470ceb6196fe58fb058ed9db7a8f7f11 Author: duanzhengqiang <[email protected]> AuthorDate: Mon Sep 11 11:58:52 2023 +0800 fix unit test (cherry picked from commit d163c68b314b0d43f6928401bab2e8e4fc20530d) --- .../encrypt-plugin => feature/encrypt}/pom.xml | 4 +- .../encrypt-plugin => feature/encrypt}/sm/pom.xml | 31 ++++-- .../encrypt/sm/algorithm/SM3EncryptAlgorithm.java | 0 .../encrypt/sm/algorithm/SM4EncryptAlgorithm.java | 0 ...che.shardingsphere.encrypt.spi.EncryptAlgorithm | 0 .../sm/algorithm/SM3EncryptAlgorithmTest.java | 8 +- .../sm/algorithm/SM4EncryptAlgorithmTest.java | 25 +++-- {feature-plugin => feature}/pom.xml | 6 +- .../sharding}/cosid/pom.xml | 30 ++++-- .../cosid/algorithm/CosIdAlgorithmConstants.java | 0 .../keygen/CosIdKeyGenerateAlgorithm.java | 0 .../keygen/CosIdSnowflakeKeyGenerateAlgorithm.java | 0 .../AbstractCosIdIntervalShardingAlgorithm.java | 0 .../interval/CosIdIntervalShardingAlgorithm.java | 0 .../CosIdSnowflakeIntervalShardingAlgorithm.java | 0 .../sharding/mod/CosIdModShardingAlgorithm.java | 0 ...hardingsphere.sharding.spi.KeyGenerateAlgorithm | 0 ...e.shardingsphere.sharding.spi.ShardingAlgorithm | 0 .../keygen/CosIdKeyGenerateAlgorithmTest.java | 10 +- .../CosIdSnowflakeKeyGenerateAlgorithmTest.java | 11 +- .../keygen/fixture/WorkerIdGeneratorFixture.java | 0 .../sharding}/nanoid/pom.xml | 4 +- .../keygen/NanoIdKeyGenerateAlgorithm.java | 0 ...hardingsphere.sharding.spi.KeyGenerateAlgorithm | 0 .../keygen/NanoIdKeyGenerateAlgorithmTest.java | 0 .../sharding-plugin => feature/sharding}/pom.xml | 4 +- pom.xml | 114 ++++++++++++++++++++- 27 files changed, 197 insertions(+), 50 deletions(-) diff --git a/feature-plugin/encrypt-plugin/pom.xml b/feature/encrypt/pom.xml similarity index 91% rename from feature-plugin/encrypt-plugin/pom.xml rename to feature/encrypt/pom.xml index ea5270e..30066ce 100644 --- a/feature-plugin/encrypt-plugin/pom.xml +++ b/feature/encrypt/pom.xml @@ -20,10 +20,10 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-feature-plugin</artifactId> + <artifactId>shardingsphere-plugin-feature</artifactId> <version>5.4.1-SNAPSHOT</version> </parent> - <artifactId>shardingsphere-feature-encrypt-plugin</artifactId> + <artifactId>shardingsphere-plugin-feature-encrypt</artifactId> <packaging>pom</packaging> <name>${project.artifactId}</name> diff --git a/feature-plugin/encrypt-plugin/sm/pom.xml b/feature/encrypt/sm/pom.xml similarity index 74% rename from feature-plugin/encrypt-plugin/sm/pom.xml rename to feature/encrypt/sm/pom.xml index 00e7ba2..6413797 100644 --- a/feature-plugin/encrypt-plugin/sm/pom.xml +++ b/feature/encrypt/sm/pom.xml @@ -20,10 +20,10 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-feature-encrypt-plugin</artifactId> + <artifactId>shardingsphere-plugin-feature-encrypt</artifactId> <version>5.4.1-SNAPSHOT</version> </parent> - <artifactId>shardingsphere-feature-encrypt-plugin-sm</artifactId> + <artifactId>shardingsphere-plugin-feature-encrypt-sm</artifactId> <name>${project.artifactId}</name> <dependencies> @@ -39,13 +39,6 @@ <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-test-util</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.bouncycastle</groupId> <artifactId>bcprov-jdk15on</artifactId> @@ -57,5 +50,25 @@ <artifactId>commons-codec</artifactId> <version>${commons-codec.version}</version> </dependency> + + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </dependency> </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>${maven-compiler-plugin.version}</version> + <configuration> + <source>${java.version}</source> + <target>${java.version}</target> + <testSource>${java.version}</testSource> + <testTarget>${java.version}</testTarget> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/feature-plugin/encrypt-plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java b/feature/encrypt/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java similarity index 100% rename from feature-plugin/encrypt-plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java rename to feature/encrypt/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithm.java diff --git a/feature-plugin/encrypt-plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java b/feature/encrypt/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java similarity index 100% rename from feature-plugin/encrypt-plugin/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java rename to feature/encrypt/sm/src/main/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithm.java diff --git a/feature-plugin/encrypt-plugin/sm/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm b/feature/encrypt/sm/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm similarity index 100% rename from feature-plugin/encrypt-plugin/sm/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm rename to feature/encrypt/sm/src/main/resources/META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm diff --git a/feature-plugin/encrypt-plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java b/feature/encrypt/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java similarity index 92% rename from feature-plugin/encrypt-plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java rename to feature/encrypt/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java index 56a38c6..f17a43b 100644 --- a/feature-plugin/encrypt-plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java +++ b/feature/encrypt/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM3EncryptAlgorithmTest.java @@ -17,12 +17,10 @@ package org.apache.shardingsphere.encrypt.sm.algorithm; +import org.apache.shardingsphere.encrypt.api.context.EncryptContext; import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm; import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm; -import org.apache.shardingsphere.encrypt.api.context.EncryptContext; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.test.util.PropertiesBuilder; -import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -40,7 +38,9 @@ class SM3EncryptAlgorithmTest { @SuppressWarnings("unchecked") @BeforeEach void setUp() { - encryptAlgorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM3", PropertiesBuilder.build(new Property("sm3-salt", "test1234"))); + Properties props = new Properties(); + props.put("sm3-salt", "test1234"); + encryptAlgorithm = (StandardEncryptAlgorithm<Object, String>) TypedSPILoader.getService(EncryptAlgorithm.class, "SM3", props); } @Test diff --git a/feature-plugin/encrypt-plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java b/feature/encrypt/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java similarity index 84% rename from feature-plugin/encrypt-plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java rename to feature/encrypt/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java index a2de944..b9b815a 100644 --- a/feature-plugin/encrypt-plugin/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java +++ b/feature/encrypt/sm/src/test/java/org/apache/shardingsphere/encrypt/sm/algorithm/SM4EncryptAlgorithmTest.java @@ -17,13 +17,11 @@ package org.apache.shardingsphere.encrypt.sm.algorithm; +import org.apache.shardingsphere.encrypt.api.context.EncryptContext; import org.apache.shardingsphere.encrypt.api.encrypt.standard.StandardEncryptAlgorithm; import org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException; import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm; -import org.apache.shardingsphere.encrypt.api.context.EncryptContext; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; -import org.apache.shardingsphere.test.util.PropertiesBuilder; -import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; import org.junit.jupiter.api.Test; import java.util.Properties; @@ -38,8 +36,10 @@ class SM4EncryptAlgorithmTest { @Test void assertInitWithoutKey() { - assertThrows(EncryptAlgorithmInitializationException.class, - () -> TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", PropertiesBuilder.build(new Property("sm4-mode", "ECB"), new Property("sm4-padding", "PKCS5Padding")))); + Properties props = new Properties(); + props.put("sm4-mode", "ECB"); + props.put("sm4-padding", "PKCS5Padding"); + assertThrows(EncryptAlgorithmInitializationException.class, () -> TypedSPILoader.getService(EncryptAlgorithm.class, "SM4", props)); } @SuppressWarnings("unchecked") @@ -71,7 +71,11 @@ class SM4EncryptAlgorithmTest { } private Properties createECBProperties() { - return PropertiesBuilder.build(new Property("sm4-key", "4D744E003D713D054E7E407C350E447E"), new Property("sm4-mode", "ECB"), new Property("sm4-padding", "PKCS5Padding")); + Properties result = new Properties(); + result.put("sm4-key", "4D744E003D713D054E7E407C350E447E"); + result.put("sm4-mode", "ECB"); + result.put("sm4-padding", "PKCS5Padding"); + return result; } @SuppressWarnings("unchecked") @@ -89,8 +93,11 @@ class SM4EncryptAlgorithmTest { } private Properties createCBCProperties() { - return PropertiesBuilder.build( - new Property("sm4-key", "f201326119911788cFd30575b81059ac"), new Property("sm4-iv", "e166c3391294E69cc4c620f594fe00d7"), - new Property("sm4-mode", "CBC"), new Property("sm4-padding", "PKCS7Padding")); + Properties result = new Properties(); + result.put("sm4-key", "f201326119911788cFd30575b81059ac"); + result.put("sm4-iv", "e166c3391294E69cc4c620f594fe00d7"); + result.put("sm4-mode", "CBC"); + result.put("sm4-padding", "PKCS7Padding"); + return result; } } diff --git a/feature-plugin/pom.xml b/feature/pom.xml similarity index 90% rename from feature-plugin/pom.xml rename to feature/pom.xml index 246f5c4..e9d45e9 100644 --- a/feature-plugin/pom.xml +++ b/feature/pom.xml @@ -23,12 +23,12 @@ <artifactId>shardingsphere-plugin</artifactId> <version>5.4.1-SNAPSHOT</version> </parent> - <artifactId>shardingsphere-feature-plugin</artifactId> + <artifactId>shardingsphere-plugin-feature</artifactId> <packaging>pom</packaging> <name>${project.artifactId}</name> <modules> - <module>sharding-plugin</module> - <module>encrypt-plugin</module> + <module>sharding</module> + <module>encrypt</module> </modules> </project> diff --git a/feature-plugin/sharding-plugin/cosid/pom.xml b/feature/sharding/cosid/pom.xml similarity index 71% rename from feature-plugin/sharding-plugin/cosid/pom.xml rename to feature/sharding/cosid/pom.xml index f6191c9..ebba32d 100644 --- a/feature-plugin/sharding-plugin/cosid/pom.xml +++ b/feature/sharding/cosid/pom.xml @@ -20,10 +20,10 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-feature-sharding-plugin</artifactId> + <artifactId>shardingsphere-plugin-feature-sharding</artifactId> <version>5.4.1-SNAPSHOT</version> </parent> - <artifactId>shardingsphere-feature-sharding-plugin-cosid</artifactId> + <artifactId>shardingsphere-plugin-feature-sharding-cosid</artifactId> <name>${project.artifactId}</name> <properties> @@ -37,17 +37,29 @@ <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-test-util</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>me.ahoo.cosid</groupId> <artifactId>cosid-core</artifactId> <version>${cosid.version}</version> </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </dependency> </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>${maven-compiler-plugin.version}</version> + <configuration> + <source>${java.version}</source> + <target>${java.version}</target> + <testSource>${java.version}</testSource> + <testTarget>${java.version}</testTarget> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/CosIdAlgorithmConstants.java b/feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/CosIdAlgorithmConstants.java similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/CosIdAlgorithmConstants.java rename to feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/CosIdAlgorithmConstants.java diff --git a/feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java b/feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java rename to feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithm.java diff --git a/feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java b/feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java rename to feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithm.java diff --git a/feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java b/feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java rename to feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/AbstractCosIdIntervalShardingAlgorithm.java diff --git a/feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdIntervalShardingAlgorithm.java b/feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdIntervalShardingAlgorithm.java similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdIntervalShardingAlgorithm.java rename to feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdIntervalShardingAlgorithm.java diff --git a/feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java b/feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java rename to feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/interval/CosIdSnowflakeIntervalShardingAlgorithm.java diff --git a/feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java b/feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java rename to feature/sharding/cosid/src/main/java/org/apache/shardingsphere/sharding/cosid/algorithm/sharding/mod/CosIdModShardingAlgorithm.java diff --git a/feature-plugin/sharding-plugin/cosid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm b/feature/sharding/cosid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm rename to feature/sharding/cosid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm diff --git a/feature-plugin/sharding-plugin/cosid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm b/feature/sharding/cosid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm rename to feature/sharding/cosid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm diff --git a/feature-plugin/sharding-plugin/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java b/feature/sharding/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java similarity index 90% rename from feature-plugin/sharding-plugin/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java rename to feature/sharding/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java index 1368261..7ced755 100644 --- a/feature-plugin/sharding-plugin/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java +++ b/feature/sharding/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdKeyGenerateAlgorithmTest.java @@ -29,8 +29,6 @@ import me.ahoo.cosid.snowflake.MillisecondSnowflakeId; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.sharding.cosid.algorithm.CosIdAlgorithmConstants; import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm; -import org.apache.shardingsphere.test.util.PropertiesBuilder; -import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; import org.junit.jupiter.api.Test; import java.util.Properties; @@ -49,7 +47,9 @@ class CosIdKeyGenerateAlgorithmTest { String idName = "test-cosid"; DefaultSegmentId defaultSegmentId = new DefaultSegmentId(new IdSegmentDistributor.Mock()); DefaultIdGeneratorProvider.INSTANCE.set(idName, defaultSegmentId); - KeyGenerateAlgorithm algorithm = TypedSPILoader.getService(KeyGenerateAlgorithm.class, "COSID", PropertiesBuilder.build(new Property(CosIdAlgorithmConstants.ID_NAME_KEY, idName))); + Properties props = new Properties(); + props.put(CosIdAlgorithmConstants.ID_NAME_KEY, idName); + KeyGenerateAlgorithm algorithm = TypedSPILoader.getService(KeyGenerateAlgorithm.class, "COSID", props); assertThat(algorithm.generateKey(), is(1L)); assertThat(algorithm.generateKey(), is(2L)); } @@ -75,7 +75,9 @@ class CosIdKeyGenerateAlgorithmTest { String prefix = "test_"; IdGenerator idGeneratorDecorator = new StringIdGeneratorDecorator(new MillisecondSnowflakeId(1, 0), new PrefixIdConverter(prefix, Radix62IdConverter.INSTANCE)); DefaultIdGeneratorProvider.INSTANCE.set(idName, idGeneratorDecorator); - Properties props = PropertiesBuilder.build(new Property(CosIdAlgorithmConstants.ID_NAME_KEY, idName), new Property("as-string", Boolean.TRUE.toString())); + Properties props = new Properties(); + props.put(CosIdAlgorithmConstants.ID_NAME_KEY, idName); + props.put("as-string", Boolean.TRUE.toString()); KeyGenerateAlgorithm algorithm = TypedSPILoader.getService(KeyGenerateAlgorithm.class, "COSID", props); Comparable<?> actual = algorithm.generateKey(); assertThat(actual, instanceOf(String.class)); diff --git a/feature-plugin/sharding-plugin/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java b/feature/sharding/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java similarity index 96% rename from feature-plugin/sharding-plugin/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java rename to feature/sharding/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java index 4c1b9ab..7f4a177 100644 --- a/feature-plugin/sharding-plugin/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java +++ b/feature/sharding/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/CosIdSnowflakeKeyGenerateAlgorithmTest.java @@ -28,13 +28,11 @@ import org.apache.shardingsphere.infra.instance.InstanceContext; import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData; import org.apache.shardingsphere.infra.instance.mode.ModeContextManager; import org.apache.shardingsphere.infra.lock.LockContext; -import org.apache.shardingsphere.infra.util.eventbus.EventBusContext; import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; +import org.apache.shardingsphere.infra.util.eventbus.EventBusContext; import org.apache.shardingsphere.sharding.cosid.algorithm.keygen.fixture.WorkerIdGeneratorFixture; import org.apache.shardingsphere.sharding.exception.ShardingPluginException; import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm; -import org.apache.shardingsphere.test.util.PropertiesBuilder; -import org.apache.shardingsphere.test.util.PropertiesBuilder.Property; import org.junit.jupiter.api.Test; import java.util.Properties; @@ -119,7 +117,8 @@ class CosIdSnowflakeKeyGenerateAlgorithmTest { @Test void assertGenerateKeyAsString() { - Properties props = PropertiesBuilder.build(new Property(CosIdSnowflakeKeyGenerateAlgorithm.AS_STRING_KEY, Boolean.TRUE.toString())); + Properties props = new Properties(); + props.put(CosIdSnowflakeKeyGenerateAlgorithm.AS_STRING_KEY, Boolean.TRUE.toString()); CosIdSnowflakeKeyGenerateAlgorithm algorithm = (CosIdSnowflakeKeyGenerateAlgorithm) TypedSPILoader.getService(KeyGenerateAlgorithm.class, "COSID_SNOWFLAKE", props); algorithm.setInstanceContext(new InstanceContext(new ComputeNodeInstance(mock(InstanceMetaData.class)), new WorkerIdGeneratorFixture(FIXTURE_WORKER_ID), new ModeConfiguration("Standalone", null), @@ -155,6 +154,8 @@ class CosIdSnowflakeKeyGenerateAlgorithmTest { @Test void assertEpochWhenOutOfRange() { - assertThrows(ShardingPluginException.class, () -> TypedSPILoader.getService(KeyGenerateAlgorithm.class, "COSID_SNOWFLAKE", PropertiesBuilder.build(new Property("epoch", "0"))).generateKey()); + Properties props = new Properties(); + props.put("epoch", "0"); + assertThrows(ShardingPluginException.class, () -> TypedSPILoader.getService(KeyGenerateAlgorithm.class, "COSID_SNOWFLAKE", props).generateKey()); } } diff --git a/feature-plugin/sharding-plugin/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/fixture/WorkerIdGeneratorFixture.java b/feature/sharding/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/fixture/WorkerIdGeneratorFixture.java similarity index 100% rename from feature-plugin/sharding-plugin/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/fixture/WorkerIdGeneratorFixture.java rename to feature/sharding/cosid/src/test/java/org/apache/shardingsphere/sharding/cosid/algorithm/keygen/fixture/WorkerIdGeneratorFixture.java diff --git a/feature-plugin/sharding-plugin/nanoid/pom.xml b/feature/sharding/nanoid/pom.xml similarity index 93% rename from feature-plugin/sharding-plugin/nanoid/pom.xml rename to feature/sharding/nanoid/pom.xml index 4d94cd0..d3e3eec 100644 --- a/feature-plugin/sharding-plugin/nanoid/pom.xml +++ b/feature/sharding/nanoid/pom.xml @@ -20,10 +20,10 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-feature-sharding-plugin</artifactId> + <artifactId>shardingsphere-plugin-feature-sharding</artifactId> <version>5.4.1-SNAPSHOT</version> </parent> - <artifactId>shardingsphere-feature-sharding-plugin-nanoid</artifactId> + <artifactId>shardingsphere-plugin-feature-sharding-nanoid</artifactId> <name>${project.artifactId}</name> <properties> diff --git a/feature-plugin/sharding-plugin/nanoid/src/main/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithm.java b/feature/sharding/nanoid/src/main/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithm.java similarity index 100% rename from feature-plugin/sharding-plugin/nanoid/src/main/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithm.java rename to feature/sharding/nanoid/src/main/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithm.java diff --git a/feature-plugin/sharding-plugin/nanoid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm b/feature/sharding/nanoid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm similarity index 100% rename from feature-plugin/sharding-plugin/nanoid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm rename to feature/sharding/nanoid/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm diff --git a/feature-plugin/sharding-plugin/nanoid/src/test/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithmTest.java b/feature/sharding/nanoid/src/test/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithmTest.java similarity index 100% rename from feature-plugin/sharding-plugin/nanoid/src/test/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithmTest.java rename to feature/sharding/nanoid/src/test/java/org/apache/shardingsphere/sharding/nanoid/algorithm/keygen/NanoIdKeyGenerateAlgorithmTest.java diff --git a/feature-plugin/sharding-plugin/pom.xml b/feature/sharding/pom.xml similarity index 91% rename from feature-plugin/sharding-plugin/pom.xml rename to feature/sharding/pom.xml index f80aa8f..9eb1de1 100644 --- a/feature-plugin/sharding-plugin/pom.xml +++ b/feature/sharding/pom.xml @@ -20,10 +20,10 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.shardingsphere</groupId> - <artifactId>shardingsphere-feature-plugin</artifactId> + <artifactId>shardingsphere-plugin-feature</artifactId> <version>5.4.1-SNAPSHOT</version> </parent> - <artifactId>shardingsphere-feature-sharding-plugin</artifactId> + <artifactId>shardingsphere-plugin-feature-sharding</artifactId> <packaging>pom</packaging> <name>${project.artifactId}</name> diff --git a/pom.xml b/pom.xml index 2d65dfe..00e01ce 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ <description>Provide plugins for ShardingSphere pluggable architecture</description> <modules> - <module>feature-plugin</module> + <module>feature</module> </modules> <properties> @@ -50,6 +50,10 @@ <junit.version>5.9.2</junit.version> <hamcrest.version>2.2</hamcrest.version> <mockito.version>4.11.0</mockito.version> + <bouncycastle.version>1.70</bouncycastle.version> + <commons-codec.version>1.15</commons-codec.version> + <lombok.version>1.18.20</lombok.version> + <junit.version>5.9.2</junit.version> <!-- Compile plugin versions --> <maven-enforcer-plugin.version>3.2.1</maven-enforcer-plugin.version> @@ -61,6 +65,114 @@ <dependencyManagement> <dependencies> + <dependency> + <groupId>commons-codec</groupId> + <artifactId>commons-codec</artifactId> + <version>${commons-codec.version}</version> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <version>${lombok.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest</artifactId> + <version>${hamcrest.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>${mockito.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-inline</artifactId> + <version>${mockito.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-junit-jupiter</artifactId> + <version>${mockito.version}</version> + <scope>test</scope> + </dependency> </dependencies> </dependencyManagement> + + <build> + <pluginManagement> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>${maven-compiler-plugin.version}</version> + <configuration> + <source>${java.version}</source> + <target>${java.version}</target> + <testSource>${java.version}</testSource> + <testTarget>${java.version}</testTarget> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + + <dependencies> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-params</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-inline</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-junit-jupiter</artifactId> + <scope>test</scope> + </dependency> + </dependencies> </project>
