feat: lombok.config

main
13009 2024-06-21 17:02:41 +08:00
parent 68ce560a07
commit aaa03a4ea0
3 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,13 @@
package com.czcb.scfs.api.core.cipher;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
class CipherTypeTest {
@Test
void getValue() {
Assertions.assertEquals("sm", CipherType.SM.getValue());
Assertions.assertEquals("rsa", CipherType.RSA.getValue());
}
}

View File

@ -54,7 +54,7 @@ class PemFileTest {
String privateKey = PemFile.readPrivateKeyStringFromPath(file.getPath());
Assertions.assertNotNull(PemFile.loadPrivateKeyFromString(privateKey));
} finally {
file.delete();
Assertions.assertTrue(file.delete());
}
}
@ -75,4 +75,32 @@ class PemFileTest {
void testLoadPrivateKeyFromStream() {
Assertions.assertThrows(NullPointerException.class, () -> PemFile.loadPrivateKeyFromStream(null));
}
@Test
void loadPrivateKeyFromAbsolutePathTest() throws IOException {
File file = File.createTempFile("Test.", "rsa_channel_private_key.pem");
try (FileOutputStream outputStream = new FileOutputStream(file)) {
outputStream.write(KeyText.PRIVATE_TEXT_RSA.getBytes(StandardCharsets.UTF_8));
outputStream.flush();
PrivateKey privateKey = PemFile.loadPrivateKeyFromAbsolutePath(file.getPath());
Assertions.assertNotNull(privateKey);
} finally {
Assertions.assertTrue(file.delete());
}
}
@Test
void loadX509FromAbsolutePath() throws IOException {
File file = File.createTempFile("Test.", "rsa.pem");
try (FileOutputStream outputStream = new FileOutputStream(file)) {
outputStream.write(KeyText.CERTIFICATE_TEXT_RSA.getBytes(StandardCharsets.UTF_8));
outputStream.flush();
X509Certificate certificate = PemFile.loadX509FromAbsolutePath(file.getPath());
Assertions.assertNotNull(certificate);
} finally {
Assertions.assertTrue(file.delete());
}
}
}

View File

@ -66,4 +66,22 @@ class StopWatchTest {
Assertions.assertEquals(1, stopWatch.getTaskInfo().length);
Assertions.assertNotEquals(0, stopWatch.getTaskInfo()[0].getTimeSeconds());
}
@Test
void start4() {
StopWatch stopWatch = new StopWatch("11", false).start();
Assertions.assertThrows(UnsupportedOperationException.class, stopWatch::getTaskInfo);
Assertions.assertThrows(IllegalStateException.class, stopWatch::getLastTaskInfo);
Assertions.assertThrows(IllegalStateException.class, stopWatch::getLastTaskTimeNanos);
Assertions.assertThrows(IllegalStateException.class, stopWatch::getLastTaskTimeMillis);
Assertions.assertThrows(IllegalStateException.class, stopWatch::getLastTaskName);
Assertions.assertTrue(stopWatch.isRunning());
Assertions.assertThrows(IllegalStateException.class, stopWatch::start);
}
@Test
void start5() {
StopWatch stopWatch = new StopWatch("11", false);
Assertions.assertThrows(IllegalStateException.class, stopWatch::stop);
}
}