test: 单元测试
parent
33baa0436d
commit
b6ac5b0db5
2
pom.xml
2
pom.xml
|
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-sdk</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
<name>scfs-api-sdk</name>
|
||||
<description>scfs-api-sdk</description>
|
||||
<packaging>pom</packaging>
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
<parent>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-sdk</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>scfs-api-core</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
<name>scfs-api-core:核心模块</name>
|
||||
<description>scfs-api-core</description>
|
||||
<packaging>jar</packaging>
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
@ -5,11 +5,11 @@
|
|||
<parent>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-sdk</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>scfs-api-rsa</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
<name>scfs-api-rsa:RSA模块</name>
|
||||
<description>封装RSA、AES国密算法</description>
|
||||
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<dependency>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-core</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
<parent>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-sdk</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>scfs-api-service-cat</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
<name>scfs-api-service-cat:肥猫定制化接口</name>
|
||||
<description>肥猫SDK</description>
|
||||
<packaging>jar</packaging>
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
<dependency>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-core</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
<parent>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-sdk</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>scfs-api-service</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
<name>scfs-api-service:通用类接口</name>
|
||||
<description>通用类接口</description>
|
||||
<packaging>jar</packaging>
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
<dependency>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-core</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
<parent>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-sdk</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>scfs-api-sm</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
<name>scfs-api-sm:国密模块</name>
|
||||
<description>封装SM2、SM4国密算法</description>
|
||||
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<dependency>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-core</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.tencent.kona/kona-crypto -->
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
<parent>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-sdk</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>scfs-api-spring-boot-starter</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
<name>scfs-spring-boot-starter</name>
|
||||
<description>scfs-spring-boot-starter</description>
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
<parent>
|
||||
<groupId>com.czcb.scfs</groupId>
|
||||
<artifactId>scfs-api-sdk</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>scfs-api-test</artifactId>
|
||||
<version>2.0.2-snapshot</version>
|
||||
<version>2.0.2</version>
|
||||
<name>scfs-api-test</name>
|
||||
<description>scfs-api-test</description>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue