test: 消除代码异味
parent
074c711fdd
commit
4df38f04b2
23
readme.md
23
readme.md
|
|
@ -66,3 +66,26 @@ mvn versions:set -DnewVersion=dev-snapshot
|
|||
# 正式版本,版本号加一
|
||||
mvn versions:set -DnewVersion=2.0.0
|
||||
```
|
||||
|
||||
## 代码扫描
|
||||
|
||||
配置maven脚本 \bin\mvn.cmd,添加一行命令 `set JAVA_HOME="C:\Ext\zulu17"`
|
||||
|
||||
```shell
|
||||
## 添加jdk17目录
|
||||
set JAVA_HOME="C:\Ext\zulu17"
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%"=="" goto OkJHome
|
||||
for %%i in (java.exe) do set "JAVACMD=%%~$PATH:i"
|
||||
goto checkJCmd
|
||||
```
|
||||
|
||||
执行 scanner.cmd脚本
|
||||
|
||||
```shell
|
||||
## C:\Ext\mvn17\bin\mvn.cmd 修改maven脚本路径
|
||||
call C:\Ext\mvn17\bin\mvn.cmd clean package verify sonar:sonar -Dsonar.projectKey=scfs-api-sdk -Dsonar.projectName=scfs-api-sdk -Dsonar.host.url=http://10.129.135.192:7100 -Dsonar.login=sqp_90e5fb014f985e2c458e46b9239926cfbbd4fffe
|
||||
```
|
||||
|
|
@ -0,0 +1 @@
|
|||
call C:\Ext\mvn17\bin\mvn.cmd clean package verify sonar:sonar -Dsonar.projectKey=scfs-api-sdk -Dsonar.projectName=scfs-api-sdk -Dsonar.host.url=http://10.129.135.192:7100 -Dsonar.login=sqp_90e5fb014f985e2c458e46b9239926cfbbd4fffe
|
||||
|
|
@ -1 +0,0 @@
|
|||
mvn clean test verify sonar:sonar -Dsonar.projectKey=scfs-api-sdk -Dsonar.projectName=scfs-api-sdk -Dsonar.host.url=http://10.129.135.192:7100 -Dsonar.login=sqp_90e5fb014f985e2c458e46b9239926cfbbd4fffe
|
||||
|
|
@ -32,18 +32,5 @@
|
|||
<artifactId>httpclient5</artifactId>
|
||||
<version>5.2.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.2.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public abstract class AbstractApiClient implements ApiClient {
|
|||
this.privacy = profile.getPrivacy();
|
||||
this.signature = profile.getSignature();
|
||||
this.validator = new DefaultValidator(profile);
|
||||
this.httpLogger = new HttpLogger(profile.getHttpProfile() == null ? LogLevel.basic : profile.getHttpProfile().logLevel());
|
||||
this.httpLogger = new HttpLogger(profile.getHttpProfile() == null ? LogLevel.BASIC : profile.getHttpProfile().logLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class DefaultHttpProfile implements HttpProfile {
|
|||
// 请求代理
|
||||
private Proxy proxy;
|
||||
// 是否启用日志打印
|
||||
private LogLevel logLevel = LogLevel.basic;
|
||||
private LogLevel logLevel = LogLevel.BASIC;
|
||||
// 是否启用压缩
|
||||
private boolean compressionEnabled = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import static com.czcb.scfs.api.core.http.LogLevel.isFull;
|
|||
public class HttpLogger {
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private final LogLevel logLevel;
|
||||
private final boolean logPrefix = false;
|
||||
private static final boolean LOG_PREFIX = false;
|
||||
|
||||
public HttpLogger(LogLevel logLevel) {
|
||||
this.logLevel = logLevel;
|
||||
|
|
@ -90,7 +90,7 @@ public class HttpLogger {
|
|||
}
|
||||
|
||||
private String logPrefix(HttpRequest request) {
|
||||
if (logPrefix) {
|
||||
if (LOG_PREFIX) {
|
||||
return String.format("[%s] ", request.getId());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -617,18 +617,6 @@ public enum HttpStatus {
|
|||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code Series} enum constant for the supplied {@code HttpStatus}.
|
||||
*
|
||||
* @param status a standard HTTP status enum constant
|
||||
* @return the {@code Series} enum constant for the supplied {@code HttpStatus}
|
||||
* @deprecated as of 5.3, in favor of invoking {@link HttpStatus#series()} directly
|
||||
*/
|
||||
@Deprecated
|
||||
public static Series valueOf(HttpStatus status) {
|
||||
return status.series;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code Series} enum constant for the supplied status code.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ package com.czcb.scfs.api.core.http;
|
|||
import java.util.Objects;
|
||||
|
||||
public enum LogLevel {
|
||||
basic, full;
|
||||
BASIC, FULL;
|
||||
|
||||
public static boolean isFull(LogLevel logLevel) {
|
||||
return Objects.equals(full, logLevel);
|
||||
return Objects.equals(FULL, logLevel);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ import java.util.zip.ZipOutputStream;
|
|||
* 压缩文件
|
||||
*/
|
||||
public final class Compression {
|
||||
private static final String ZIP_ERROR_TEXT = "待压缩数据不能为空";
|
||||
private static final String ZIP_EXCEPTION_TEXT_FMT = "压缩文件异常: %s";
|
||||
|
||||
private Compression() {
|
||||
}
|
||||
|
||||
|
|
@ -19,7 +22,7 @@ public final class Compression {
|
|||
*/
|
||||
public static byte[] zip(byte[] data, String filename) {
|
||||
if (data == null || data.length == 0) {
|
||||
throw new IllegalArgumentException("待压缩数据不能为空");
|
||||
throw new IllegalArgumentException(ZIP_ERROR_TEXT);
|
||||
}
|
||||
|
||||
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
|
|
@ -31,7 +34,7 @@ public final class Compression {
|
|||
zipOutputStream.closeEntry();
|
||||
return byteArrayOutputStream.toByteArray();
|
||||
} catch (Exception ex) {
|
||||
throw new ZipException(String.format("压缩文件异常: %s", filename));
|
||||
throw new ZipException(String.format(ZIP_EXCEPTION_TEXT_FMT, filename));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +43,7 @@ public final class Compression {
|
|||
*/
|
||||
public static byte[] unzip(byte[] data) {
|
||||
if (data == null || data.length == 0) {
|
||||
throw new IllegalArgumentException("待压缩数据不能为空");
|
||||
throw new IllegalArgumentException(ZIP_ERROR_TEXT);
|
||||
}
|
||||
|
||||
try (ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(data));
|
||||
|
|
@ -66,7 +69,7 @@ public final class Compression {
|
|||
*/
|
||||
public static String zipAndEncode(byte[] data, String fileName) {
|
||||
if (data == null || data.length == 0) {
|
||||
throw new IllegalArgumentException("待压缩数据不能为空");
|
||||
throw new IllegalArgumentException(ZIP_ERROR_TEXT);
|
||||
}
|
||||
|
||||
return Base64.encodeStr(zip(data, fileName));
|
||||
|
|
@ -100,7 +103,7 @@ public final class Compression {
|
|||
|
||||
return zipAndEncode(data, filename);
|
||||
} catch (IOException e) {
|
||||
throw new ZipException(String.format("压缩文件异常: %s", filename));
|
||||
throw new ZipException(String.format(ZIP_EXCEPTION_TEXT_FMT, filename));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +116,7 @@ public final class Compression {
|
|||
try (FileInputStream inputStream = new FileInputStream(tmpFile)) {
|
||||
return zipAndEncodeFromStream(inputStream, tmpFile.getName());
|
||||
} catch (IOException e) {
|
||||
throw new ZipException(String.format("压缩文件异常: %s", filepath), e);
|
||||
throw new ZipException(String.format(ZIP_EXCEPTION_TEXT_FMT, filepath), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ import com.czcb.scfs.api.core.http.client.TestVerifier;
|
|||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
import java.security.Provider;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -35,18 +33,4 @@ class AbstractSignerTest {
|
|||
Assertions.assertThrows(UnsupportedOperationException.class, () -> signer.sign(message));
|
||||
}
|
||||
|
||||
private static class TestSigner extends AbstractSigner {
|
||||
|
||||
/**
|
||||
* @param privateKey API私钥
|
||||
*/
|
||||
public TestSigner(PrivateKey privateKey, Provider provider) {
|
||||
super("SHA256withRSA", "SHA256withRSA", privateKey, provider, "");
|
||||
}
|
||||
|
||||
public TestSigner(PrivateKey privateKey) {
|
||||
// 错误的签名算法
|
||||
super("SHA256withRSA1", "SHA256withRSA1", privateKey, null, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ class DefaultValidatorTest {
|
|||
.build(),
|
||||
new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
@ -73,7 +73,7 @@ class DefaultValidatorTest {
|
|||
.build(),
|
||||
new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
@ -96,9 +96,7 @@ class DefaultValidatorTest {
|
|||
.statusCode(200)
|
||||
.build();
|
||||
|
||||
Assertions.assertDoesNotThrow(() -> {
|
||||
defaultValidator.isInvalidHttpCode(response);
|
||||
});
|
||||
Assertions.assertDoesNotThrow(() -> defaultValidator.isInvalidHttpCode(response));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.czcb.scfs.api.core.cipher;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
import java.security.Provider;
|
||||
|
||||
public class TestSigner extends AbstractSigner {
|
||||
|
||||
/**
|
||||
* @param privateKey API私钥
|
||||
*/
|
||||
public TestSigner(PrivateKey privateKey, Provider provider) {
|
||||
super("SHA256withRSA", "SHA256withRSA", privateKey, provider, "");
|
||||
}
|
||||
|
||||
public TestSigner(PrivateKey privateKey) {
|
||||
// 错误的签名算法
|
||||
super("SHA256withRSA1", "SHA256withRSA1", privateKey, null, "");
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,9 @@ import org.junit.jupiter.api.Test;
|
|||
class DecryptExceptionTest {
|
||||
@Test
|
||||
void test() {
|
||||
ValidationException validationException = new ValidationException();
|
||||
Exception e = Assertions.assertThrows(DecryptException.class, () -> {
|
||||
throw new DecryptException("error", new ValidationException());
|
||||
throw new DecryptException("error", validationException);
|
||||
});
|
||||
|
||||
Assertions.assertEquals("error", e.getMessage());
|
||||
|
|
|
|||
|
|
@ -15,13 +15,14 @@ class ZipExceptionTest {
|
|||
throw new ZipException("error");
|
||||
}).getMessage());
|
||||
|
||||
ValidationException validationException = new ValidationException();
|
||||
Exception e = Assertions.assertThrows(ZipException.class, () -> {
|
||||
throw new ZipException("error", new ValidationException());
|
||||
throw new ZipException("error", validationException);
|
||||
});
|
||||
Assertions.assertInstanceOf(ValidationException.class, e.getCause());
|
||||
|
||||
e = Assertions.assertThrows(ZipException.class, () -> {
|
||||
throw new ZipException(new ValidationException());
|
||||
throw new ZipException(validationException);
|
||||
});
|
||||
Assertions.assertInstanceOf(ValidationException.class, e.getCause());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class ApiClientBuilderTest {
|
|||
.build(),
|
||||
new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
@ -142,7 +142,7 @@ class ApiClientBuilderTest {
|
|||
.port("1000")
|
||||
.build())
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class DefaultHttpProfileTest {
|
|||
.headers(data)
|
||||
.compressionEnabled(true)
|
||||
.online(true)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.host("http://10.133.129.74:8761/")
|
||||
.build();
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ class DefaultHttpProfileTest {
|
|||
|
||||
Assertions.assertTrue(httpProfile.compressionEnabled());
|
||||
Assertions.assertTrue(httpProfile.online());
|
||||
Assertions.assertEquals(LogLevel.basic, httpProfile.logLevel());
|
||||
Assertions.assertEquals(LogLevel.BASIC, httpProfile.logLevel());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class HttpLoggerTest {
|
|||
.body("123")
|
||||
.statusCode(200)
|
||||
.build();
|
||||
HttpLogger httpLogger = new HttpLogger(LogLevel.basic);
|
||||
HttpLogger httpLogger = new HttpLogger(LogLevel.BASIC);
|
||||
Assertions.assertEquals("OK", httpLogger.httpReasonPhrase(response));
|
||||
}
|
||||
}
|
||||
|
|
@ -16,12 +16,6 @@ class HttpStatusTest {
|
|||
Assertions.assertEquals(101, status.value());
|
||||
}
|
||||
|
||||
@Test
|
||||
void series() {
|
||||
HttpStatus.Series series = HttpStatus.Series.valueOf(HttpStatus.ACCEPTED);
|
||||
Assertions.assertEquals(HttpStatus.Series.SUCCESSFUL, series);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getReasonPhrase() {
|
||||
HttpStatus status = HttpStatus.valueOf(101);
|
||||
|
|
@ -72,9 +66,7 @@ class HttpStatusTest {
|
|||
HttpStatus.Series series = HttpStatus.Series.valueOf(300);
|
||||
Assertions.assertNotNull(series);
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
HttpStatus.Series.valueOf(0);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> HttpStatus.Series.valueOf(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -97,8 +89,6 @@ class HttpStatusTest {
|
|||
Assertions.assertNotNull(status);
|
||||
Assertions.assertEquals("OK", status.getReasonPhrase());
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
HttpStatus.valueOf(0);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> HttpStatus.valueOf(0));
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ class ApacheHttpclientProxyTest {
|
|||
.appNo("100000")
|
||||
.build(), new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class ApacheHttpclientTest {
|
|||
.appNo("100000")
|
||||
.build(), new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(compressionEnabled)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class ApacheHttpclientTestProxyTest {
|
|||
.appNo("100000")
|
||||
.build(), new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class ApacheHttpclientV2Test {
|
|||
.appNo("100000")
|
||||
.build(), new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class ApacheHttpclientV3Test {
|
|||
.appNo("100000")
|
||||
.build(), new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class ApacheHttpclientValidTest {
|
|||
.appNo("100000")
|
||||
.build(), new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -14,25 +14,16 @@ import java.nio.file.Files;
|
|||
class CompressionTest {
|
||||
@Test
|
||||
void zip() {
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.zip(null, null);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.zip(null, null));
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.zip(new byte[0], null);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.zip(new byte[0], null));
|
||||
|
||||
Assertions.assertThrows(ZipException.class, () -> {
|
||||
Compression.zip("test".getBytes(StandardCharsets.UTF_8), null);
|
||||
});
|
||||
byte[] bytes = "test".getBytes(StandardCharsets.UTF_8);
|
||||
Assertions.assertThrows(ZipException.class, () -> Compression.zip(bytes, null));
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.unzip(null);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.unzip(null));
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.unzip(new byte[0]);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.unzip(new byte[0]));
|
||||
|
||||
String text = "l1231344";
|
||||
String filename = "a.txt";
|
||||
|
|
@ -45,13 +36,9 @@ class CompressionTest {
|
|||
|
||||
@Test
|
||||
void decode() {
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.zipAndEncode(null, null);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.zipAndEncode(null, null));
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.zipAndEncode(new byte[]{}, null);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.zipAndEncode(new byte[]{}, null));
|
||||
|
||||
String text = "l1231344";
|
||||
String filename = "a.txt";
|
||||
|
|
@ -64,13 +51,9 @@ class CompressionTest {
|
|||
|
||||
@Test
|
||||
void decodeStream() {
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.decodeAndUnzip(null);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.decodeAndUnzip(null));
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.decodeAndUnzip("");
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.decodeAndUnzip(""));
|
||||
|
||||
String text = "l1231344";
|
||||
String filename = "a.txt";
|
||||
|
|
@ -83,17 +66,11 @@ class CompressionTest {
|
|||
|
||||
@Test
|
||||
void decodeFile() throws IOException {
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.zipAndEncodeFromFile("");
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.zipAndEncodeFromFile(""));
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.zipAndEncodeFromFile((String) null);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.zipAndEncodeFromFile((String) null));
|
||||
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
Compression.zipAndEncodeFromFile((File) null);
|
||||
});
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> Compression.zipAndEncodeFromFile((File) null));
|
||||
|
||||
String text = "l1231344";
|
||||
File file = Files.createTempFile("decodeFile-", "").toFile();
|
||||
|
|
@ -106,7 +83,7 @@ class CompressionTest {
|
|||
String unzipText = new String(Compression.decodeAndUnzip(data), StandardCharsets.UTF_8);
|
||||
Assertions.assertEquals(text, unzipText);
|
||||
} finally {
|
||||
file.delete();
|
||||
Assertions.assertTrue(file.delete());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<version>2.7.16</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -8,24 +8,19 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("com.czcb.scfs.service.cat")
|
||||
public class ScfsApiServiceCatAutoConfiguration {
|
||||
|
||||
@Resource
|
||||
private ApiClient apiClient;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ProjectService projectService() {
|
||||
public ProjectService projectService(ApiClient apiClient) {
|
||||
return new ProjectService(apiClient);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OrderService orderService() {
|
||||
public OrderService orderService(ApiClient apiClient) {
|
||||
return new OrderService(apiClient);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
package com.czcb.scfs.service.cat.configuration;
|
||||
|
||||
import com.czcb.scfs.api.core.util.PemFile;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
* @author wangwei
|
||||
* @date 2024/2/20
|
||||
*/
|
||||
public final class KeyText {
|
||||
|
||||
|
||||
// 失效的
|
||||
public static final String PRIVATE_RSA_INVALID = "-----BEGIN PRIVATE KEY-----\n" +
|
||||
"MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCfHOgnUYbFi780EX9xQTdWPvCy\n" +
|
||||
"BhaEnU5Y2p1bW4dHoumgEtjQOkLlRe3Ug1lu6TfhuE9YOQ9+V+Dsnzt7MXIRI7KlOuwpfwXn3e/M\n" +
|
||||
"YP5ZtDBUiuSGNNVSP39wgb6aYXhvFY/Lm9gaO8Q4rauzK94Clw4sH3a7J6ST50xHss8VjSVFUkcP\n" +
|
||||
"hpH+OJBTUrXWiccZCn01XDz0vmq6J3AujM55WBEmoz2r9iiVdCjZsgB4veQIpCKuMvJsEXVgRzUL\n" +
|
||||
"UnaqdX+7BTDBs30kCGyyBarR+wXLAKNQ1nENFs1IGM99I+O8UsD6CvUnt2t7l3B8/qIlOSfds8x+\n" +
|
||||
"BoUxQwhmUaMjAgMBAAECggEAQ+meKz4QdJvnse0wBKKN4Hl/2bRggxzzVliFJnvEG27tIb45nXLo\n" +
|
||||
"n5x/3R9tGjpf+C9namP8eXQ/1C9Iv5XEto0SkJS8PR/y4NspIYZaueX/ZO5diOzfCjqBBf/S32jv\n" +
|
||||
"8xX0aLbtf5D3+SsjaJe2LEvWKD4Luuk6RUjJlaa73dnSuGFSuvYV8MvFdHtfU8L8ZRoqZwmM9QTg\n" +
|
||||
"+Gpix4z6Hy/Mmi1xRl0EhIITq+mV9wR9Ock/0o12nvsNDyDSyrrt3niXTTkVCbct+t4UFwtnrZyH\n" +
|
||||
"dwl1OQ+WleTkUQY+wNgpq4jLjwGowXnqXlKff3tvXEt+3tpdOS8i+kXYwIrvIQKBgQDVnldDo2iq\n" +
|
||||
"TwLcZjXbreHskn/4hvWYUPqucEZ93jmyYNKUKPlXkVnc+kXnS0uuM5JZpi/7+FDkTqwHK83ET4/n\n" +
|
||||
"kTC9zM+K7KyIBbljclPjzXYJAW7nwD8A/vKx6CWi++f4buYc+lttsTprdAZ4/kWPTnvNJSjhSTAR\n" +
|
||||
"SQ32HxkiIQKBgQC+rjujW31WN4d2j48+K0B+7bIQON+VtmBZ48u2ZIQOi4PdoBvHv8HqQyhJlR+6\n" +
|
||||
"z49k5WczSqAXdG2+nIgs8fpjj0lc7YiMIYs0VsLodOToH9J2MfXjWi+A4Y2vbfcjfUuCWhKSZs6B\n" +
|
||||
"eMLNe1LPIBDmlT3A1X83qkCpvAYYQWAkwwKBgFVtslZRZk0dtfYwRf+phT1XxSe9yT/1uprCOd6i\n" +
|
||||
"XY6RnAU2cajsbvSpfgUmnoh3BWMmy+/HeYokUDW59ds5OkKQVN7CpolXZxQqvd4gXZ4vj7HASfsS\n" +
|
||||
"bd/XFXXCcjLA7R70MsCJ+sBebQ+F4gTHI0hRSb9bygJ2g2uWPKgd/a4hAoGABCtZIHxKpEz4iE4h\n" +
|
||||
"SrG1alEWOKaVtPdU6gJCHQ3bmVnRm1H56Yc23UF0qw84r2QEdadSd1ulXn3sPGO90oXD/NNQPljv\n" +
|
||||
"SGkfWxiekGil7LFtb6ot/zeknEPSTkiwQ7VkpkgD6fGXiFs0nzuYFvFTjUcsH4BLlNMDMPLsizE6\n" +
|
||||
"wfMCgYANvw4Lq1cVfHAl3f6IZlpWHPFEEJbPcBLu9+qtUlZjleCaWA8WXuiBxkqaIkeVi3JMst34\n" +
|
||||
"adfIfBsAk4FeyLpkiTYNjOckZvXFXYKA3a05l/RJ5rsnnI9GRh+3Gk3V+87OU7HwMU6jNZmQiPIO\n" +
|
||||
"/jerEvZ9A5tbuzKkfJj2F0ZXfw==\n" +
|
||||
"-----END PRIVATE KEY-----";
|
||||
|
||||
// 失效的证书 823CF3E310F2E2ED1AF85506E74A95DC4301006FDEF2FD019953FAF4DE12A8BF
|
||||
public static final String CERTIFICATE_RSA_INVALID = "-----BEGIN CERTIFICATE-----\n" +
|
||||
"MIIDeTCCAmGgAwIBAgIhAII88+MQ8uLtGvhVBudKldxDAQBv3vL9AZlT+vTeEqi/MA0GCSqGSIb3\n" +
|
||||
"DQEBCwUAMIGNMQswCQYDVQQGEwJDTjESMBAGA1UECAwJ5rWZ5rGf55yBMRIwEAYDVQQHDAnmna3l\n" +
|
||||
"t57luIIxITAfBgNVBAoMGOa1meaxn+eooOW3nuWVhuS4mumTtuihjDEYMBYGA1UECwwP5pWw5a2X\n" +
|
||||
"6YeR6J6N6YOoMRkwFwYDVQQDDBBzY2ZzLmN6Y2IuY29tLmNuMB4XDTIzMDYxODA5MDczMVoXDTI0\n" +
|
||||
"MDYxODA5MDczMVowUjELMAkGA1UEBhMCQ04xEjAQBgNVBAgMCea1meaxn+ecgTESMBAGA1UEBwwJ\n" +
|
||||
"5p2t5bee5biCMRswGQYDVQQKDBLnqKDlt57llYbkuJrpk7booYwwggEiMA0GCSqGSIb3DQEBAQUA\n" +
|
||||
"A4IBDwAwggEKAoIBAQCfHOgnUYbFi780EX9xQTdWPvCyBhaEnU5Y2p1bW4dHoumgEtjQOkLlRe3U\n" +
|
||||
"g1lu6TfhuE9YOQ9+V+Dsnzt7MXIRI7KlOuwpfwXn3e/MYP5ZtDBUiuSGNNVSP39wgb6aYXhvFY/L\n" +
|
||||
"m9gaO8Q4rauzK94Clw4sH3a7J6ST50xHss8VjSVFUkcPhpH+OJBTUrXWiccZCn01XDz0vmq6J3Au\n" +
|
||||
"jM55WBEmoz2r9iiVdCjZsgB4veQIpCKuMvJsEXVgRzULUnaqdX+7BTDBs30kCGyyBarR+wXLAKNQ\n" +
|
||||
"1nENFs1IGM99I+O8UsD6CvUnt2t7l3B8/qIlOSfds8x+BoUxQwhmUaMjAgMBAAEwDQYJKoZIhvcN\n" +
|
||||
"AQELBQADggEBACRCHOYH8ncOiYjMm3As7OFdnVDuGByMoZsDucqwrs0mJZVdp3OMgvGhC9zkzdZX\n" +
|
||||
"sJFKQeIRp/13cD1SKxtwfU7w4J+/FWpWPEG9Jf2bLqurYivu0tTa1xe5SDL4unNaj/o7BA0vaKJe\n" +
|
||||
"gagyULAilNCGBCfy59BSR/GQbgAC6pdl3soMx/s1c9BcZVplbq12/rmStGce6h3QqNjwpRMowbVW\n" +
|
||||
"XswXhr08AUevF7UriDjHkCsa6MqQ5x+ShV9qO1f2LDYBQRnM2Ty44EV5eUbHyKOJAYF+WqT6IRiA\n" +
|
||||
"2sMZrKRTHaNZB4j0Vc87HuxDtTNh/EEXU2sO31WZHs3ymAChbC4=\n" +
|
||||
"-----END CERTIFICATE-----";
|
||||
|
||||
public static PrivateKey loadPrivateKeyInvalid() {
|
||||
return PemFile.loadPrivateKeyFromString(PRIVATE_RSA_INVALID);
|
||||
}
|
||||
|
||||
public static X509Certificate loadCertificateInvalid() {
|
||||
return PemFile.loadX509FromString(CERTIFICATE_RSA_INVALID);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,59 @@
|
|||
package com.czcb.scfs.service.cat.configuration;
|
||||
|
||||
class ScfsApiServiceCatAutoConfigurationTest {
|
||||
import com.czcb.scfs.api.core.ApiClient;
|
||||
import com.czcb.scfs.api.core.DefaultChannel;
|
||||
import com.czcb.scfs.api.core.Profile;
|
||||
import com.czcb.scfs.api.core.cipher.*;
|
||||
import com.czcb.scfs.api.core.http.DefaultHttpProfile;
|
||||
import com.czcb.scfs.api.core.http.LogLevel;
|
||||
import com.czcb.scfs.api.core.http.client.ApacheHttpclient;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClients;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class ScfsApiServiceCatAutoConfigurationTest {
|
||||
private Profile profile() {
|
||||
PrivateKey privateKey = KeyText.loadPrivateKeyInvalid();
|
||||
X509Certificate certificate = KeyText.loadCertificateInvalid();
|
||||
List<X509Certificate> list = new ArrayList<>();
|
||||
list.add(certificate);
|
||||
CertificateProvider certificateProvider = new LocalCertificateProvider(list);
|
||||
Privacy privacy = new TestPrivacy(privateKey, certificateProvider);
|
||||
Signature signature = new DefaultSignature(certificateProvider,
|
||||
new TestSigner(privateKey, "823CF3E310F2E2ED1AF85506E74A95DC4301006FDEF2FD019953FAF4DE12A8BF"),
|
||||
new TestVerifier(certificateProvider));
|
||||
|
||||
return new TestProfile(
|
||||
privacy, signature, new DefaultChannel.Builder()
|
||||
.channelNo("0000")
|
||||
.appNo("100000")
|
||||
.build(), new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
protected ApiClient apiClient() {
|
||||
return new ApacheHttpclient(HttpClients.custom().build(), profile());
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectService() {
|
||||
ScfsApiServiceCatAutoConfiguration configuration = new ScfsApiServiceCatAutoConfiguration();
|
||||
Assertions.assertNotNull(configuration.projectService(apiClient()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void orderService() {
|
||||
ScfsApiServiceCatAutoConfiguration configuration = new ScfsApiServiceCatAutoConfiguration();
|
||||
Assertions.assertNotNull(configuration.orderService(apiClient()));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.czcb.scfs.service.cat.configuration;
|
||||
|
||||
import com.czcb.scfs.api.core.cipher.*;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
|
||||
public class TestPrivacy implements Privacy {
|
||||
// 对称加密/解密器
|
||||
private final SecretCipher secretCipher;
|
||||
// 非对称加密器
|
||||
private final PrivacyEncryptor privacyEncryptor;
|
||||
// 非对称解密器
|
||||
private final PrivacyDecryptor privacyDecryptor;
|
||||
|
||||
public TestPrivacy(PrivateKey privateKey, CertificateProvider certificateProvider) {
|
||||
this.secretCipher = new TestSecretCipher();
|
||||
this.privacyEncryptor = new TestPrivacyEncryptor(certificateProvider.getAvailableCertificate().getPublicKey());
|
||||
this.privacyDecryptor = new TestPrivacyDecryptor(privateKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecretCipher getSecretCipher() {
|
||||
return secretCipher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrivacyEncryptor getEncryptor() {
|
||||
return privacyEncryptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrivacyDecryptor getDecryptor() {
|
||||
return privacyDecryptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.czcb.scfs.service.cat.configuration;
|
||||
|
||||
import com.czcb.scfs.api.core.cipher.AbstractPrivacyDecryptor;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
|
||||
public class TestPrivacyDecryptor extends AbstractPrivacyDecryptor {
|
||||
/**
|
||||
* 构造敏感信息解密的抽象类
|
||||
*
|
||||
* @param privateKey 加密使用的私钥
|
||||
*/
|
||||
public TestPrivacyDecryptor(PrivateKey privateKey) {
|
||||
super("RSA/ECB/OAEPWithSHA-1AndMGF1Padding", privateKey, null);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.czcb.scfs.service.cat.configuration;
|
||||
|
||||
import com.czcb.scfs.api.core.cipher.AbstractPrivacyEncryptor;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
public class TestPrivacyEncryptor extends AbstractPrivacyEncryptor {
|
||||
/**
|
||||
* 构造敏感信息加密的抽象类
|
||||
*
|
||||
* @param publicKey 加密使用的公钥
|
||||
*/
|
||||
public TestPrivacyEncryptor(PublicKey publicKey) {
|
||||
super("RSA/ECB/OAEPWithSHA-1AndMGF1Padding", publicKey, null, "");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.czcb.scfs.service.cat.configuration;
|
||||
|
||||
import com.czcb.scfs.api.core.AbstractProfile;
|
||||
import com.czcb.scfs.api.core.Channel;
|
||||
import com.czcb.scfs.api.core.cipher.Privacy;
|
||||
import com.czcb.scfs.api.core.cipher.Signature;
|
||||
import com.czcb.scfs.api.core.http.HttpProfile;
|
||||
|
||||
public class TestProfile extends AbstractProfile {
|
||||
public TestProfile(Privacy privacy, Signature signature, Channel channel, HttpProfile httpProfile) {
|
||||
super(privacy, signature, channel, httpProfile);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.czcb.scfs.service.cat.configuration;
|
||||
|
||||
import com.czcb.scfs.api.core.cipher.AbstractSecretCipher;
|
||||
|
||||
public class TestSecretCipher extends AbstractSecretCipher {
|
||||
|
||||
protected TestSecretCipher() {
|
||||
super("AES", "AES/GCM/NoPadding", null, 128);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.czcb.scfs.service.cat.configuration;
|
||||
|
||||
import com.czcb.scfs.api.core.cipher.AbstractSigner;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
|
||||
/**
|
||||
* @author wangwei
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class TestSigner extends AbstractSigner {
|
||||
|
||||
/**
|
||||
* @param privateKey API私钥
|
||||
*/
|
||||
public TestSigner(PrivateKey privateKey, String certificateSerialNumber) {
|
||||
super("SHA256withRSA", "SHA256withRSA", privateKey, null, certificateSerialNumber);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.czcb.scfs.service.cat.configuration;
|
||||
|
||||
import com.czcb.scfs.api.core.cipher.AbstractVerifier;
|
||||
import com.czcb.scfs.api.core.cipher.CertificateProvider;
|
||||
|
||||
/**
|
||||
* @author wangwei
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class TestVerifier extends AbstractVerifier {
|
||||
/**
|
||||
* @param certificateProvider 验签使用的证书管理器,非空
|
||||
*/
|
||||
public TestVerifier(CertificateProvider certificateProvider) {
|
||||
super("SHA256withRSA", certificateProvider, null);
|
||||
}
|
||||
}
|
||||
|
|
@ -48,11 +48,11 @@ public class FiveCascadeQueryResponse implements ApiResponse {
|
|||
* 下级区划代码信息
|
||||
*/
|
||||
@SerializedName("zoning_code_children_list")
|
||||
private List<zoning_code_children> zoningCodeChildrenList;
|
||||
private List<ZoningCodeChildren> zoningCodeChildrenList;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class zoning_code_children implements Serializable {
|
||||
public static class ZoningCodeChildren implements Serializable {
|
||||
|
||||
/**
|
||||
* 省码
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class MockResponse {
|
|||
.appNo("100000")
|
||||
.build(), new DefaultHttpProfile.Builder()
|
||||
.online(false)
|
||||
.logLevel(LogLevel.basic)
|
||||
.logLevel(LogLevel.BASIC)
|
||||
.compressionEnabled(false)
|
||||
.host("http://127.0.0.1:8888")
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
package com.czcb.scfs.api.service.v1.account;
|
||||
|
||||
import com.czcb.scfs.api.core.util.Json;
|
||||
import com.czcb.scfs.api.service.v1.account.model.OpenAccAllCompanyRequest;
|
||||
import com.czcb.scfs.api.service.v1.account.model.OpenAccAllPersonRequest.FileList;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
class AccountServiceTest {
|
||||
|
||||
@Test
|
||||
void openAccAllCompany() {
|
||||
OpenAccAllCompanyRequest request = new OpenAccAllCompanyRequest();
|
||||
request.setChannelNo("");
|
||||
request.setAppNo("");
|
||||
request.setSerialNo("");
|
||||
request.setAccountName("");
|
||||
request.setAccountClass("");
|
||||
request.setAccountProperty("");
|
||||
request.setIdType("");
|
||||
request.setIdNo("");
|
||||
request.setIdStartDate("");
|
||||
request.setIdEndDate("");
|
||||
request.setSignNo("");
|
||||
request.setSignName("");
|
||||
request.setIdAddress("");
|
||||
request.setMobile("");
|
||||
request.setOrgcodes("");
|
||||
request.setRatcodes("");
|
||||
request.setZsopscope("");
|
||||
request.setPrimaryAccount("");
|
||||
request.setBankNo("");
|
||||
request.setBankName("");
|
||||
request.setIndustry("");
|
||||
request.setTradeNo("");
|
||||
request.setVerifyCode("");
|
||||
request.setCompanyIdType("");
|
||||
request.setCompanyIdNo("");
|
||||
request.setCompanyIdName("");
|
||||
request.setCompanyOpto("");
|
||||
request.setControllerIdType("");
|
||||
request.setControllerIdNo("");
|
||||
request.setControllerIdName("");
|
||||
request.setControllerOpto("");
|
||||
request.setLeaderIdType("");
|
||||
request.setLeaderIdNo("");
|
||||
request.setLeaderIdName("");
|
||||
request.setLeaderMobile("");
|
||||
request.setLeaderOpto("");
|
||||
request.setOperatorIdType("");
|
||||
request.setOperatorIdNo("");
|
||||
request.setOperatorIdName("");
|
||||
request.setOperatorMobile("");
|
||||
request.setOperatorOpto("");
|
||||
request.setBeneName("");
|
||||
request.setBeneSex("");
|
||||
request.setBeneNationality("");
|
||||
request.setBeneIsShareholider("");
|
||||
request.setBeneRatio("");
|
||||
request.setBeneAddr("");
|
||||
request.setBeneIdType("");
|
||||
request.setBeneIdNo("");
|
||||
request.setBeneOpto("");
|
||||
request.setBeneOwner("");
|
||||
request.setFileList(new ArrayList<FileList>());
|
||||
request.setOpenLongitude("");
|
||||
request.setOpenDimensions("");
|
||||
request.setOpenIp("");
|
||||
request.setOpenDate("");
|
||||
request.setOpenTradeTime("");
|
||||
Json.toJson(request);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ public class ScfsApiGatewayProperties {
|
|||
/**
|
||||
* 请求日志打印级别 默认 basic
|
||||
*/
|
||||
private LogLevel logLevel = LogLevel.basic;
|
||||
private LogLevel logLevel = LogLevel.BASIC;
|
||||
/**
|
||||
* 请求压缩 默认 false
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class RsaConfigurationTest {
|
|||
connPool.setSocketTimeout(100);
|
||||
httpclient.setConnPool(connPool);
|
||||
httpclient.setCompressionEnabled(false);
|
||||
httpclient.setLogLevel(LogLevel.basic);
|
||||
httpclient.setLogLevel(LogLevel.BASIC);
|
||||
properties.setHttpclient(httpclient);
|
||||
|
||||
ScfsApiGatewayProperties.Channel channel = new ScfsApiGatewayProperties.Channel();
|
||||
|
|
|
|||
|
|
@ -66,15 +66,15 @@ class ScfsApiGatewayPropertiesTest {
|
|||
httpclient.setConnPool(connPool);
|
||||
|
||||
httpclient.setCompressionEnabled(false);
|
||||
httpclient.setLogLevel(LogLevel.full);
|
||||
httpclient.setLogLevel(LogLevel.FULL);
|
||||
ScfsApiGatewayProperties properties = new ScfsApiGatewayProperties();
|
||||
properties.setHttpclient(httpclient);
|
||||
|
||||
Assertions.assertNotNull(properties.getHttpclient());
|
||||
Assertions.assertFalse(properties.getHttpclient().getCompressionEnabled());
|
||||
Assertions.assertEquals(LogLevel.full, properties.getHttpclient().getLogLevel());
|
||||
Assertions.assertEquals(LogLevel.FULL, properties.getHttpclient().getLogLevel());
|
||||
|
||||
assertThatJson("{\"logLevel\":\"full\",\"compressionEnabled\":false," +
|
||||
assertThatJson("{\"logLevel\":\"FULL\",\"compressionEnabled\":false," +
|
||||
"\"connPool\":{\"maxRequests\":100,\"maxRequestPerHost\":100,\"connectTimeout\":100,\"socketTimeout\":100}," +
|
||||
"\"proxy\":{\"enabled\":true,\"host\":\"128.0.0.1\",\"port\":\"1000\",\"username\":\"name\",\"password\":\"123456\",\"scheme\":\"https\"}," +
|
||||
"\"headers\":{\"aa\":\"123456\"}}")
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class ScfsAutoConfigurationTest {
|
|||
connPool.setSocketTimeout(100);
|
||||
httpclient.setConnPool(connPool);
|
||||
httpclient.setCompressionEnabled(false);
|
||||
httpclient.setLogLevel(LogLevel.basic);
|
||||
httpclient.setLogLevel(LogLevel.BASIC);
|
||||
properties.setHttpclient(httpclient);
|
||||
|
||||
ScfsApiGatewayProperties.Channel channel = new ScfsApiGatewayProperties.Channel();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class SmConfigurationTest {
|
|||
connPool.setSocketTimeout(100);
|
||||
httpclient.setConnPool(connPool);
|
||||
httpclient.setCompressionEnabled(false);
|
||||
httpclient.setLogLevel(LogLevel.basic);
|
||||
httpclient.setLogLevel(LogLevel.BASIC);
|
||||
properties.setHttpclient(httpclient);
|
||||
|
||||
ScfsApiGatewayProperties.Channel channel = new ScfsApiGatewayProperties.Channel();
|
||||
|
|
|
|||
Loading…
Reference in New Issue