diff --git a/pom.xml b/pom.xml index 7d689d1..db55740 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.czcb.scfs scfs-api-sdk - 2.0.2-snapshot + 2.0.2 scfs-api-sdk scfs-api-sdk pom diff --git a/scfs-api-core/pom.xml b/scfs-api-core/pom.xml index b3a574d..c3e89a2 100644 --- a/scfs-api-core/pom.xml +++ b/scfs-api-core/pom.xml @@ -5,11 +5,11 @@ com.czcb.scfs scfs-api-sdk - 2.0.2-snapshot + 2.0.2 scfs-api-core - 2.0.2-snapshot + 2.0.2 scfs-api-core:核心模块 scfs-api-core jar diff --git a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/exception/DecryptExceptionTest.java b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/exception/DecryptExceptionTest.java new file mode 100644 index 0000000..4875864 --- /dev/null +++ b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/exception/DecryptExceptionTest.java @@ -0,0 +1,16 @@ +package com.czcb.scfs.api.core.exception; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class DecryptExceptionTest { + @Test + void test() { + Exception e = Assertions.assertThrows(DecryptException.class, () -> { + throw new DecryptException("error", new ValidationException()); + }); + + Assertions.assertEquals("error", e.getMessage()); + Assertions.assertInstanceOf(ValidationException.class, e.getCause()); + } +} \ No newline at end of file diff --git a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/exception/ZipExceptionTest.java b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/exception/ZipExceptionTest.java index a731091..3ce24c1 100644 --- a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/exception/ZipExceptionTest.java +++ b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/exception/ZipExceptionTest.java @@ -7,12 +7,22 @@ class ZipExceptionTest { @Test void test() { - Assertions.assertThrows(ZipException.class, () -> { + Assertions.assertNull(Assertions.assertThrows(ZipException.class, () -> { throw new ZipException(); - }); + }).getMessage()); - Assertions.assertThrows(ZipException.class, () -> { - throw new ZipException(""); + Assertions.assertEquals("error", Assertions.assertThrows(ZipException.class, () -> { + throw new ZipException("error"); + }).getMessage()); + + Exception e = Assertions.assertThrows(ZipException.class, () -> { + throw new ZipException("error", new ValidationException()); }); + Assertions.assertInstanceOf(ValidationException.class, e.getCause()); + + e = Assertions.assertThrows(ZipException.class, () -> { + throw new ZipException(new ValidationException()); + }); + Assertions.assertInstanceOf(ValidationException.class, e.getCause()); } } \ No newline at end of file diff --git a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/http/HttpLoggerTest.java b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/http/HttpLoggerTest.java new file mode 100644 index 0000000..39d0d9f --- /dev/null +++ b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/http/HttpLoggerTest.java @@ -0,0 +1,21 @@ +package com.czcb.scfs.api.core.http; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class HttpLoggerTest { + + @Test + void httpReasonPhrase() { + OriginalResponse response = new OriginalResponse.Builder() + .request(new HttpRequest.Builder() + .httpMethod(HttpMethod.POST) + .url("http://demo") + .build()) + .body("123") + .statusCode(200) + .build(); + HttpLogger httpLogger = new HttpLogger(LogLevel.basic); + Assertions.assertEquals("OK", httpLogger.httpReasonPhrase(response)); + } +} \ No newline at end of file diff --git a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/util/PemFileTest.java b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/util/PemFileTest.java index 70e5c10..cca561d 100644 --- a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/util/PemFileTest.java +++ b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/util/PemFileTest.java @@ -70,4 +70,9 @@ class PemFileTest { String text = PemFile.getSerialNumber(certificate); Assertions.assertTrue(Pattern.matches("[A-Z0-9]+", text)); } + + @Test + void testLoadPrivateKeyFromStream() { + Assertions.assertThrows(NullPointerException.class, () -> PemFile.loadPrivateKeyFromStream(null)); + } } \ No newline at end of file diff --git a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/util/StringsTest.java b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/util/StringsTest.java index 596f94f..6ab1e72 100644 --- a/scfs-api-core/src/test/java/com/czcb/scfs/api/core/util/StringsTest.java +++ b/scfs-api-core/src/test/java/com/czcb/scfs/api/core/util/StringsTest.java @@ -1,10 +1,13 @@ package com.czcb.scfs.api.core.util; +import com.czcb.scfs.api.core.KeyText; import com.czcb.scfs.api.core.exception.EncodingException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.math.BigInteger; import java.nio.charset.StandardCharsets; +import java.security.cert.X509Certificate; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -70,4 +73,32 @@ class StringsTest { Assertions.assertEquals("123", Strings.removeSuffix("123;", ";")); Assertions.assertEquals("", Strings.removeSuffix("123;", null)); } + + @Test + void isNotEmpty() { + Assertions.assertTrue(Strings.isNotEmpty("11")); + } + + @Test + void fmtEmpty() { + Assertions.assertEquals("11", Strings.fmtEmpty("11")); + Assertions.assertEquals("", Strings.fmtEmpty(null)); + } + + @Test + void toHexUpper() { + BigInteger data = new BigInteger("1234"); + Assertions.assertEquals("4D2", Strings.toHexUpper(data)); + } + + @Test + void toUpper() { + Assertions.assertEquals("ADF", Strings.toUpper("adf")); + } + + @Test + void timeRange() { + X509Certificate certificate = KeyText.loadTestRSA(); + Assertions.assertEquals("2024-02-13 17:52:40,2034-02-10 17:52:40", Strings.timeRange(certificate)); + } } \ No newline at end of file diff --git a/scfs-api-rsa/pom.xml b/scfs-api-rsa/pom.xml index 8631d32..34df985 100644 --- a/scfs-api-rsa/pom.xml +++ b/scfs-api-rsa/pom.xml @@ -5,11 +5,11 @@ com.czcb.scfs scfs-api-sdk - 2.0.2-snapshot + 2.0.2 scfs-api-rsa - 2.0.2-snapshot + 2.0.2 scfs-api-rsa:RSA模块 封装RSA、AES国密算法 @@ -17,7 +17,7 @@ com.czcb.scfs scfs-api-core - 2.0.2-snapshot + 2.0.2 diff --git a/scfs-api-service-cat/pom.xml b/scfs-api-service-cat/pom.xml index 3108ebd..f9c1c29 100644 --- a/scfs-api-service-cat/pom.xml +++ b/scfs-api-service-cat/pom.xml @@ -5,11 +5,11 @@ com.czcb.scfs scfs-api-sdk - 2.0.2-snapshot + 2.0.2 scfs-api-service-cat - 2.0.2-snapshot + 2.0.2 scfs-api-service-cat:肥猫定制化接口 肥猫SDK jar @@ -29,7 +29,7 @@ com.czcb.scfs scfs-api-core - 2.0.2-snapshot + 2.0.2 diff --git a/scfs-api-service/pom.xml b/scfs-api-service/pom.xml index f2f5432..c82870e 100644 --- a/scfs-api-service/pom.xml +++ b/scfs-api-service/pom.xml @@ -5,11 +5,11 @@ com.czcb.scfs scfs-api-sdk - 2.0.2-snapshot + 2.0.2 scfs-api-service - 2.0.2-snapshot + 2.0.2 scfs-api-service:通用类接口 通用类接口 jar @@ -24,7 +24,7 @@ com.czcb.scfs scfs-api-core - 2.0.2-snapshot + 2.0.2 diff --git a/scfs-api-sm/pom.xml b/scfs-api-sm/pom.xml index cfa8481..23e537b 100644 --- a/scfs-api-sm/pom.xml +++ b/scfs-api-sm/pom.xml @@ -5,11 +5,11 @@ com.czcb.scfs scfs-api-sdk - 2.0.2-snapshot + 2.0.2 scfs-api-sm - 2.0.2-snapshot + 2.0.2 scfs-api-sm:国密模块 封装SM2、SM4国密算法 @@ -17,7 +17,7 @@ com.czcb.scfs scfs-api-core - 2.0.2-snapshot + 2.0.2 diff --git a/scfs-api-spring-boot-starter/pom.xml b/scfs-api-spring-boot-starter/pom.xml index b62de9d..552edc4 100644 --- a/scfs-api-spring-boot-starter/pom.xml +++ b/scfs-api-spring-boot-starter/pom.xml @@ -5,11 +5,11 @@ com.czcb.scfs scfs-api-sdk - 2.0.2-snapshot + 2.0.2 scfs-api-spring-boot-starter - 2.0.2-snapshot + 2.0.2 scfs-spring-boot-starter scfs-spring-boot-starter diff --git a/scfs-api-test/pom.xml b/scfs-api-test/pom.xml index 7751881..cf40785 100644 --- a/scfs-api-test/pom.xml +++ b/scfs-api-test/pom.xml @@ -5,11 +5,11 @@ com.czcb.scfs scfs-api-sdk - 2.0.2-snapshot + 2.0.2 scfs-api-test - 2.0.2-snapshot + 2.0.2 scfs-api-test scfs-api-test