parent
df193ea774
commit
31c5d0507b
|
@ -30,7 +30,8 @@ public class PhoenixBootApplication {
|
||||||
SpringApplication.run(PhoenixBootApplication.class, args);
|
SpringApplication.run(PhoenixBootApplication.class, args);
|
||||||
log.info("\n----------------------------------------------------------\n\t"
|
log.info("\n----------------------------------------------------------\n\t"
|
||||||
+ "Phoenix Application is running! Access URLs:\n\t"
|
+ "Phoenix Application is running! Access URLs:\n\t"
|
||||||
+ "swagger-ui: \thttp://ip:port/${context-path}/swagger-ui.html\n\t" + "If you set the api switch true! \n\t"
|
+ "swagger-ui: \thttp://ip:port/${context-path}/swagger-ui.html\n\t" + "If you set the api switch " +
|
||||||
|
"true! \n\t"
|
||||||
+ "----------------------------------------------------------");
|
+ "----------------------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import javax.validation.ConstraintValidatorContext;
|
||||||
*/
|
*/
|
||||||
public class UserIdValidator implements ConstraintValidator<UserId, Long> {
|
public class UserIdValidator implements ConstraintValidator<UserId, Long> {
|
||||||
|
|
||||||
|
private final Set<Long> idSet = Sets.newHashSet(1L, 2L);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 快速失败模式下,这里无法注入依赖 参数校验的数据源相关校验放到controller里 方法抽象到下层service中
|
* 快速失败模式下,这里无法注入依赖 参数校验的数据源相关校验放到controller里 方法抽象到下层service中
|
||||||
*/
|
*/
|
||||||
|
@ -24,8 +26,6 @@ public class UserIdValidator implements ConstraintValidator<UserId, Long> {
|
||||||
return existsById(aLong);
|
return existsById(aLong);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Set<Long> idSet = Sets.newHashSet(1L, 2L);
|
|
||||||
|
|
||||||
private boolean existsById(long aId) {
|
private boolean existsById(long aId) {
|
||||||
return idSet.contains(aId);
|
return idSet.contains(aId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,9 @@ public class MyCacheInterceptor {
|
||||||
* 系统统一缓存key前缀
|
* 系统统一缓存key前缀
|
||||||
*/
|
*/
|
||||||
public static final String CACHE_PREFIX = "PHOENIX_IC" + SPILIT;
|
public static final String CACHE_PREFIX = "PHOENIX_IC" + SPILIT;
|
||||||
private static final ExpressionParser parser = new SpelExpressionParser();
|
|
||||||
// SpelExpressionParser spelExpressionParser = new SpelExpressionParser();
|
// SpelExpressionParser spelExpressionParser = new SpelExpressionParser();
|
||||||
public static final String CACHE_NULL = "NULL";
|
public static final String CACHE_NULL = "NULL";
|
||||||
|
private static final ExpressionParser parser = new SpelExpressionParser();
|
||||||
@Resource
|
@Resource
|
||||||
private RedisClient redisClient;
|
private RedisClient redisClient;
|
||||||
|
|
||||||
|
|
|
@ -4,77 +4,6 @@ package com.dispose.common;
|
||||||
* The type Const value.
|
* The type Const value.
|
||||||
*/
|
*/
|
||||||
public class ConstValue {
|
public class ConstValue {
|
||||||
/**
|
|
||||||
* The type Global configure.
|
|
||||||
*/
|
|
||||||
public static class GlobalConfigure {
|
|
||||||
/**
|
|
||||||
* The constant TOKEN_TIMEOUT_MS.
|
|
||||||
*/
|
|
||||||
public static final int TOKEN_TIMEOUT_MS = 30 * 60 * 1000;
|
|
||||||
/**
|
|
||||||
* The constant ALLOW_PWD_ERR_TIMES.
|
|
||||||
*/
|
|
||||||
public static final int ALLOW_PWD_ERR_TIMES = 5;
|
|
||||||
/**
|
|
||||||
* The constant IS_SKIP_TIMEOUT_CHECK.
|
|
||||||
*/
|
|
||||||
public static final boolean IS_SKIP_TIMEOUT_CHECK = true;
|
|
||||||
/**
|
|
||||||
* The constant IS_VERIFY_TOKEN.
|
|
||||||
*/
|
|
||||||
public static final boolean IS_VERIFY_TOKEN = false;
|
|
||||||
/**
|
|
||||||
* The constant TOKEN_EXPIRED_TIME_MS.
|
|
||||||
*/
|
|
||||||
public static final long TOKEN_EXPIRED_TIME_MS = 1000 * 60 * 60;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type Soap wrapper const.
|
|
||||||
*/
|
|
||||||
public static class SOAPWrapperConst {
|
|
||||||
/**
|
|
||||||
* The constant NAMESPACE_URI.
|
|
||||||
*/
|
|
||||||
public static final String NAMESPACE_URI = "http://%s/UMC/service/AbnormalFlowCleaningService";
|
|
||||||
/**
|
|
||||||
* The constant USER_NAME.
|
|
||||||
*/
|
|
||||||
//public static final String SERVICE_ADDRESS = "http://10.88.77.15/UMC/service/AbnormalFlowCleaningService?wsdl";
|
|
||||||
public static final String USER_NAME = "admin";
|
|
||||||
/**
|
|
||||||
* The constant PASSWORD.
|
|
||||||
*/
|
|
||||||
public static final String PASSWORD = "UMCAdministrator";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type Protocol.
|
|
||||||
*/
|
|
||||||
public static class Protocol {
|
|
||||||
/**
|
|
||||||
* The constant RESP_CMD_BASE.
|
|
||||||
*/
|
|
||||||
public static final int RESP_CMD_BASE = 10000;
|
|
||||||
/**
|
|
||||||
* The constant VERSION.
|
|
||||||
*/
|
|
||||||
public static final int VERSION = 2;
|
|
||||||
/**
|
|
||||||
* The constant CRYPTO_NONE.
|
|
||||||
*/
|
|
||||||
public static final int CRYPTO_NONE = 0;
|
|
||||||
/**
|
|
||||||
* The constant CRYPTO_BASE64.
|
|
||||||
*/
|
|
||||||
public static final int CRYPTO_BASE64 = 1;
|
|
||||||
/**
|
|
||||||
* The constant CRYPTO_AES256.
|
|
||||||
*/
|
|
||||||
public static final int CRYPTO_AES256 = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The enum Dispose device type.
|
* The enum Dispose device type.
|
||||||
*/
|
*/
|
||||||
|
@ -120,20 +49,6 @@ public class ConstValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The type User account status.
|
|
||||||
*/
|
|
||||||
public static class UserAccountStatus {
|
|
||||||
/**
|
|
||||||
* The constant NORMAL.
|
|
||||||
*/
|
|
||||||
public static final int NORMAL = 0;
|
|
||||||
/**
|
|
||||||
* The constant LOCKED.
|
|
||||||
*/
|
|
||||||
public static final int LOCKED = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The enum Device capacity.
|
* The enum Device capacity.
|
||||||
*/
|
*/
|
||||||
|
@ -209,4 +124,89 @@ public class ConstValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Global configure.
|
||||||
|
*/
|
||||||
|
public static class GlobalConfigure {
|
||||||
|
/**
|
||||||
|
* The constant TOKEN_TIMEOUT_MS.
|
||||||
|
*/
|
||||||
|
public static final int TOKEN_TIMEOUT_MS = 30 * 60 * 1000;
|
||||||
|
/**
|
||||||
|
* The constant ALLOW_PWD_ERR_TIMES.
|
||||||
|
*/
|
||||||
|
public static final int ALLOW_PWD_ERR_TIMES = 5;
|
||||||
|
/**
|
||||||
|
* The constant IS_SKIP_TIMEOUT_CHECK.
|
||||||
|
*/
|
||||||
|
public static final boolean IS_SKIP_TIMEOUT_CHECK = true;
|
||||||
|
/**
|
||||||
|
* The constant IS_VERIFY_TOKEN.
|
||||||
|
*/
|
||||||
|
public static final boolean IS_VERIFY_TOKEN = false;
|
||||||
|
/**
|
||||||
|
* The constant TOKEN_EXPIRED_TIME_MS.
|
||||||
|
*/
|
||||||
|
public static final long TOKEN_EXPIRED_TIME_MS = 1000 * 60 * 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Soap wrapper const.
|
||||||
|
*/
|
||||||
|
public static class SOAPWrapperConst {
|
||||||
|
/**
|
||||||
|
* The constant NAMESPACE_URI.
|
||||||
|
*/
|
||||||
|
public static final String NAMESPACE_URI = "http://%s/UMC/service/AbnormalFlowCleaningService";
|
||||||
|
/**
|
||||||
|
* The constant USER_NAME.
|
||||||
|
*/
|
||||||
|
//public static final String SERVICE_ADDRESS = "http://10.88.77.15/UMC/service/AbnormalFlowCleaningService?wsdl";
|
||||||
|
public static final String USER_NAME = "admin";
|
||||||
|
/**
|
||||||
|
* The constant PASSWORD.
|
||||||
|
*/
|
||||||
|
public static final String PASSWORD = "UMCAdministrator";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Protocol.
|
||||||
|
*/
|
||||||
|
public static class Protocol {
|
||||||
|
/**
|
||||||
|
* The constant RESP_CMD_BASE.
|
||||||
|
*/
|
||||||
|
public static final int RESP_CMD_BASE = 10000;
|
||||||
|
/**
|
||||||
|
* The constant VERSION.
|
||||||
|
*/
|
||||||
|
public static final int VERSION = 2;
|
||||||
|
/**
|
||||||
|
* The constant CRYPTO_NONE.
|
||||||
|
*/
|
||||||
|
public static final int CRYPTO_NONE = 0;
|
||||||
|
/**
|
||||||
|
* The constant CRYPTO_BASE64.
|
||||||
|
*/
|
||||||
|
public static final int CRYPTO_BASE64 = 1;
|
||||||
|
/**
|
||||||
|
* The constant CRYPTO_AES256.
|
||||||
|
*/
|
||||||
|
public static final int CRYPTO_AES256 = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type User account status.
|
||||||
|
*/
|
||||||
|
public static class UserAccountStatus {
|
||||||
|
/**
|
||||||
|
* The constant NORMAL.
|
||||||
|
*/
|
||||||
|
public static final int NORMAL = 0;
|
||||||
|
/**
|
||||||
|
* The constant LOCKED.
|
||||||
|
*/
|
||||||
|
public static final int LOCKED = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,11 +64,14 @@ public class PatternUtil {
|
||||||
|
|
||||||
// ip
|
// ip
|
||||||
ipPattern = compiler.compile(
|
ipPattern = compiler.compile(
|
||||||
"^(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
"^(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1," +
|
||||||
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)$");
|
"2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
||||||
|
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\." +
|
||||||
|
"(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)$");
|
||||||
// 内网IP
|
// 内网IP
|
||||||
internalIpPattern = compiler.compile(
|
internalIpPattern = compiler.compile(
|
||||||
"((10\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
"((10\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\." +
|
||||||
|
"(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
||||||
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0))|(172"
|
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0))|(172"
|
||||||
+ "\\.(1[6-9]|2[0-9]|3[0-1])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
+ "\\.(1[6-9]|2[0-9]|3[0-1])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
||||||
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0))|(192"
|
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0))|(192"
|
||||||
|
@ -76,15 +79,19 @@ public class PatternUtil {
|
||||||
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)))");
|
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)))");
|
||||||
// 端口 port 1024-65535
|
// 端口 port 1024-65535
|
||||||
portPattern = compiler.compile(
|
portPattern = compiler.compile(
|
||||||
"^(102[4-9]|10[3-9][0-9]|1[1-9][0-9]{2}|[2-9][0-9]{3}|[1-5][0-9]{4}|6[0-4]{4}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$");
|
"^(102[4-9]|10[3-9][0-9]|1[1-9][0-9]{2}|[2-9][0-9]{3}|[1-5][0-9]{4}|6[0-4]{4}|65[0-4][0-9]{2}|655" +
|
||||||
|
"[0-2][0-9]|6553[0-5])$");
|
||||||
// ip port
|
// ip port
|
||||||
ipPortPattern = compiler.compile(
|
ipPortPattern = compiler.compile(
|
||||||
"^(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
"^(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1," +
|
||||||
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
"2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
||||||
|
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\." +
|
||||||
|
"(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
||||||
+ ":([0-9]{1,4}|[1-5][0-9]{4}|6[0-4]{4}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$");
|
+ ":([0-9]{1,4}|[1-5][0-9]{4}|6[0-4]{4}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$");
|
||||||
// 内网 ip port
|
// 内网 ip port
|
||||||
internalIpPortPattern = compiler.compile(
|
internalIpPortPattern = compiler.compile(
|
||||||
"^((10\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
"^((10\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)\\." +
|
||||||
|
"(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
||||||
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0))|(172"
|
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0))|(172"
|
||||||
+ "\\.(1[6-9]|2[0-9]|3[0-1])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
+ "\\.(1[6-9]|2[0-9]|3[0-1])\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0)"
|
||||||
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0))|(192"
|
+ "\\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[1-9]{1,2}|[1-9][0-9]|0))|(192"
|
||||||
|
|
|
@ -62,7 +62,8 @@ public class AuthController {
|
||||||
LoginReq reqInfo = mr.getRequestObject(LoginReq.class);
|
LoginReq reqInfo = mr.getRequestObject(LoginReq.class);
|
||||||
|
|
||||||
|
|
||||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService(reqInfo.getUserName(), reqInfo.getPassword());
|
MReturnType<ErrorCode, String> ret = userAccountService.loginService(reqInfo.getUserName(),
|
||||||
|
reqInfo.getPassword());
|
||||||
|
|
||||||
if (ret.getFirstParam() != ErrorCode.ERR_OK) {
|
if (ret.getFirstParam() != ErrorCode.ERR_OK) {
|
||||||
return ProtocolRespDTO.result(ret.getFirstParam());
|
return ProtocolRespDTO.result(ret.getFirstParam());
|
||||||
|
|
|
@ -303,7 +303,8 @@ public class DisposeNodeInfoController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String rspMessage = new ObjectMapper().writerWithView(DisposeCapacity.CapacityView.class).writeValueAsString(rspInfo);
|
String rspMessage =
|
||||||
|
new ObjectMapper().writerWithView(DisposeCapacity.CapacityView.class).writeValueAsString(rspInfo);
|
||||||
|
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
|
||||||
}
|
}
|
||||||
|
@ -365,7 +366,8 @@ public class DisposeNodeInfoController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String rspMessage = new ObjectMapper().writerWithView(DisposeCapacity.DependIpView.class).writeValueAsString(rspInfo);
|
String rspMessage =
|
||||||
|
new ObjectMapper().writerWithView(DisposeCapacity.DependIpView.class).writeValueAsString(rspInfo);
|
||||||
|
|
||||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
|
return ProtocolRespDTO.result(ErrorCode.ERR_OK, rspMessage, ConstValue.Protocol.CRYPTO_NONE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import com.dispose.pojo.vo.common.IDArrayReq;
|
||||||
import com.dispose.pojo.vo.task.StartTaskReq;
|
import com.dispose.pojo.vo.task.StartTaskReq;
|
||||||
import com.dispose.pojo.vo.task.StartTaskRsp;
|
import com.dispose.pojo.vo.task.StartTaskRsp;
|
||||||
import com.dispose.pojo.vo.task.StopTaskReq;
|
import com.dispose.pojo.vo.task.StopTaskReq;
|
||||||
import com.dispose.pojo.vo.task.TaskInfoRsp;
|
|
||||||
import com.dispose.pojo.vo.task.TaskInfoData;
|
import com.dispose.pojo.vo.task.TaskInfoData;
|
||||||
|
import com.dispose.pojo.vo.task.TaskInfoRsp;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
|
@ -26,6 +26,58 @@ import org.apache.wss4j.dom.handler.WSHandlerConstants;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DPTechImpl implements DisposeEntryManager {
|
public class DPTechImpl implements DisposeEntryManager {
|
||||||
|
/**
|
||||||
|
* The Clean type port.
|
||||||
|
*/
|
||||||
|
AbnormalFlowCleaningServicePortType cleanTypePort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new Dp tech.
|
||||||
|
*
|
||||||
|
* @param ipAddr the ip addr
|
||||||
|
*/
|
||||||
|
public DPTechImpl(String ipAddr) {
|
||||||
|
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
|
||||||
|
jaxWsProxyFactoryBean.setServiceClass(AbnormalFlowCleaningServicePortType.class);
|
||||||
|
jaxWsProxyFactoryBean.setAddress(String.format(ConstValue.SOAPWrapperConst.NAMESPACE_URI, ipAddr));
|
||||||
|
|
||||||
|
//WS-Security Head
|
||||||
|
Map<String, Object> outProps = new HashMap<>();
|
||||||
|
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
|
||||||
|
|
||||||
|
outProps.put(WSHandlerConstants.USER, "admin");
|
||||||
|
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
|
||||||
|
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, SoapPasswordCallbackHandler.class.getName());
|
||||||
|
|
||||||
|
jaxWsProxyFactoryBean.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));
|
||||||
|
|
||||||
|
this.cleanTypePort = (AbnormalFlowCleaningServicePortType) jaxWsProxyFactoryBean.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new Dp tech.
|
||||||
|
*
|
||||||
|
* @param ipAddr the ip addr
|
||||||
|
* @param type the type
|
||||||
|
*/
|
||||||
|
public DPTechImpl(String ipAddr, ConstValue.IPAddrType type) {
|
||||||
|
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
|
||||||
|
jaxWsProxyFactoryBean.setServiceClass(AbnormalFlowCleaningServicePortType.class);
|
||||||
|
jaxWsProxyFactoryBean.setAddress(String.format(ConstValue.SOAPWrapperConst.NAMESPACE_URI, ipAddr));
|
||||||
|
|
||||||
|
//WS-Security Head
|
||||||
|
Map<String, Object> outProps = new HashMap<>();
|
||||||
|
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
|
||||||
|
|
||||||
|
outProps.put(WSHandlerConstants.USER, "admin");
|
||||||
|
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
|
||||||
|
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, SoapPasswordCallbackHandler.class.getName());
|
||||||
|
|
||||||
|
jaxWsProxyFactoryBean.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));
|
||||||
|
|
||||||
|
this.cleanTypePort = (AbnormalFlowCleaningServicePortType) jaxWsProxyFactoryBean.create();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets version.
|
* Gets version.
|
||||||
*
|
*
|
||||||
|
@ -222,57 +274,5 @@ public class DPTechImpl implements DisposeEntryManager {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The Clean type port.
|
|
||||||
*/
|
|
||||||
AbnormalFlowCleaningServicePortType cleanTypePort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new Dp tech.
|
|
||||||
*
|
|
||||||
* @param ipAddr the ip addr
|
|
||||||
*/
|
|
||||||
public DPTechImpl(String ipAddr) {
|
|
||||||
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
|
|
||||||
jaxWsProxyFactoryBean.setServiceClass(AbnormalFlowCleaningServicePortType.class);
|
|
||||||
jaxWsProxyFactoryBean.setAddress(String.format(ConstValue.SOAPWrapperConst.NAMESPACE_URI, ipAddr));
|
|
||||||
|
|
||||||
//WS-Security Head
|
|
||||||
Map<String, Object> outProps = new HashMap<>();
|
|
||||||
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
|
|
||||||
|
|
||||||
outProps.put(WSHandlerConstants.USER, "admin");
|
|
||||||
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
|
|
||||||
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, SoapPasswordCallbackHandler.class.getName());
|
|
||||||
|
|
||||||
jaxWsProxyFactoryBean.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));
|
|
||||||
|
|
||||||
this.cleanTypePort = (AbnormalFlowCleaningServicePortType) jaxWsProxyFactoryBean.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new Dp tech.
|
|
||||||
*
|
|
||||||
* @param ipAddr the ip addr
|
|
||||||
* @param type the type
|
|
||||||
*/
|
|
||||||
public DPTechImpl(String ipAddr, ConstValue.IPAddrType type) {
|
|
||||||
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
|
|
||||||
jaxWsProxyFactoryBean.setServiceClass(AbnormalFlowCleaningServicePortType.class);
|
|
||||||
jaxWsProxyFactoryBean.setAddress(String.format(ConstValue.SOAPWrapperConst.NAMESPACE_URI, ipAddr));
|
|
||||||
|
|
||||||
//WS-Security Head
|
|
||||||
Map<String, Object> outProps = new HashMap<>();
|
|
||||||
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
|
|
||||||
|
|
||||||
outProps.put(WSHandlerConstants.USER, "admin");
|
|
||||||
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
|
|
||||||
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, SoapPasswordCallbackHandler.class.getName());
|
|
||||||
|
|
||||||
jaxWsProxyFactoryBean.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));
|
|
||||||
|
|
||||||
this.cleanTypePort = (AbnormalFlowCleaningServicePortType) jaxWsProxyFactoryBean.create();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,14 @@ import java.util.List;
|
||||||
* The type Virtual device.
|
* The type Virtual device.
|
||||||
*/
|
*/
|
||||||
public class VirtualDeviceImpl implements DisposeEntryManager {
|
public class VirtualDeviceImpl implements DisposeEntryManager {
|
||||||
|
public VirtualDeviceImpl(String ipAddr) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public VirtualDeviceImpl(String ipAddr, ConstValue.IPAddrType type) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run dispose int.
|
* Run dispose int.
|
||||||
*
|
*
|
||||||
|
@ -136,12 +144,4 @@ public class VirtualDeviceImpl implements DisposeEntryManager {
|
||||||
public String getProtectDevices() {
|
public String getProtectDevices() {
|
||||||
return "192.168.10.10";
|
return "192.168.10.10";
|
||||||
}
|
}
|
||||||
|
|
||||||
public VirtualDeviceImpl(String ipAddr) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualDeviceImpl(String ipAddr, ConstValue.IPAddrType type) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,16 +24,13 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
public class UserAccountCacheManagerImpl implements UserAccountCacheManager {
|
||||||
|
private static final Random randomGen = new Random(System.currentTimeMillis());
|
||||||
|
private final ConcurrentHashMap<String, UserAccountCache> userAccountCache = new ConcurrentHashMap<>();
|
||||||
@Resource
|
@Resource
|
||||||
private DisposeConfigure disposeConfigure;
|
private DisposeConfigure disposeConfigure;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
private static final Random randomGen = new Random(System.currentTimeMillis());
|
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, UserAccountCache> userAccountCache = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify permission error code.
|
* Verify permission error code.
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,24 +18,6 @@ import lombok.Setter;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class DisposeCapacity {
|
public class DisposeCapacity {
|
||||||
/**
|
|
||||||
* The interface Base view.
|
|
||||||
*/
|
|
||||||
public interface BaseView {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The interface Capacity view.
|
|
||||||
*/
|
|
||||||
public interface CapacityView extends BaseView {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The interface Depend ip view.
|
|
||||||
*/
|
|
||||||
public interface DependIpView extends BaseView {
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonView(BaseView.class)
|
@JsonView(BaseView.class)
|
||||||
private int type;
|
private int type;
|
||||||
@JsonView(DependIpView.class)
|
@JsonView(DependIpView.class)
|
||||||
|
@ -44,4 +26,19 @@ public class DisposeCapacity {
|
||||||
private int tolCapacity;
|
private int tolCapacity;
|
||||||
@JsonView(CapacityView.class)
|
@JsonView(CapacityView.class)
|
||||||
private int usedCapacity;
|
private int usedCapacity;
|
||||||
|
/**
|
||||||
|
* The interface Base view.
|
||||||
|
*/
|
||||||
|
public interface BaseView {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The interface Capacity view.
|
||||||
|
*/
|
||||||
|
public interface CapacityView extends BaseView {
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The interface Depend ip view.
|
||||||
|
*/
|
||||||
|
public interface DependIpView extends BaseView {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,8 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
@JsonPropertyOrder({"id", "type", "name", "ip", "areaCode", "manufacturer", "model", "version", "readme", "status", "message"})
|
@JsonPropertyOrder({"id", "type", "name", "ip", "areaCode", "manufacturer", "model", "version", "readme", "status",
|
||||||
|
"message"})
|
||||||
public class DisposeNodeData extends DeviceCapacityData {
|
public class DisposeNodeData extends DeviceCapacityData {
|
||||||
private int type;
|
private int type;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
package com.dispose.pojo.vo.task;
|
package com.dispose.pojo.vo.task;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Stop task data.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@JsonPropertyOrder({"id", "type", "disposeIp"})
|
||||||
public class StopTaskData {
|
public class StopTaskData {
|
||||||
private String id;
|
private String id;
|
||||||
private int type;
|
private int type;
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class MyRedisConfiguration {
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
* @Description: Redisson哨兵模式实例 具体API操作参照Redisson Github对照表
|
* @Description: Redisson哨兵模式实例 具体API操作参照Redisson Github对照表
|
||||||
* https://github.com/redisson/redisson/wiki/11.-Redis%E5%91%BD%E4%BB%A4%E5%92%8CRedisson%E5%AF%B9%E8%B1%A1%E5%8C%B9%E9%85%8D%E5%88%97%E8%A1%A8
|
* https://github.com/redisson/redisson/wiki/11
|
||||||
|
* .-Redis%E5%91%BD%E4%BB%A4%E5%92%8CRedisson%E5%AF%B9%E8%B1%A1%E5%8C%B9%E9%85%8D%E5%88%97%E8%A1%A8
|
||||||
* @blog https://blog.csdn.net/unclecoco/article/details/99412915
|
* @blog https://blog.csdn.net/unclecoco/article/details/99412915
|
||||||
*/
|
*/
|
||||||
@ConditionalOnProperty(prefix = "phoenix", name = "redis.type", havingValue = "redisson-sentinel")
|
@ConditionalOnProperty(prefix = "phoenix", name = "redis.type", havingValue = "redisson-sentinel")
|
||||||
|
|
|
@ -21,14 +21,12 @@ import org.springframework.stereotype.Service;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class DisposeNodeManagerImpl implements DisposeNodeManager {
|
public class DisposeNodeManagerImpl implements DisposeNodeManager {
|
||||||
|
private final ConcurrentHashMap<String, DisposeDevice> disposeDevMap = new ConcurrentHashMap<>();
|
||||||
@Resource
|
@Resource
|
||||||
private DisposeDeviceMapper disposeDeviceMapper;
|
private DisposeDeviceMapper disposeDeviceMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserAccountService userAccountService;
|
private UserAccountService userAccountService;
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, DisposeDevice> disposeDevMap = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load dispose node from db.
|
* Load dispose node from db.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,12 +5,18 @@ import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Init test environment.
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Getter
|
@Getter
|
||||||
public class InitTestEnvironment {
|
public class InitTestEnvironment {
|
||||||
private final String USER_NAME = "admin";
|
private final String USER_NAME = "admin";
|
||||||
private final String PASSWORD = "c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58";
|
private final String PASSWORD = "c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init virtual device.
|
||||||
|
*/
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initVirtualDevice() {
|
public static void initVirtualDevice() {
|
||||||
GlobalVar.USED_VIRTUAL_DISPOSE_MODE = true;
|
GlobalVar.USED_VIRTUAL_DISPOSE_MODE = true;
|
||||||
|
|
|
@ -4,6 +4,7 @@ package com.dispose.TestSuit;
|
||||||
import com.dispose.controller.AuthControllerTest;
|
import com.dispose.controller.AuthControllerTest;
|
||||||
import com.dispose.controller.DeviceNodeInfoControllerTest;
|
import com.dispose.controller.DeviceNodeInfoControllerTest;
|
||||||
import com.dispose.controller.DeviceNodeManagerControllerTest;
|
import com.dispose.controller.DeviceNodeManagerControllerTest;
|
||||||
|
import com.dispose.controller.TaskControllerTest;
|
||||||
import com.dispose.dptech.DPTechInterfaceTestCase;
|
import com.dispose.dptech.DPTechInterfaceTestCase;
|
||||||
import com.dispose.manager.UserAccountManagerTest;
|
import com.dispose.manager.UserAccountManagerTest;
|
||||||
import com.dispose.mapper.DisposeDeviceMapperTest;
|
import com.dispose.mapper.DisposeDeviceMapperTest;
|
||||||
|
@ -24,7 +25,8 @@ import org.junit.runners.Suite;
|
||||||
AuthControllerTest.class,
|
AuthControllerTest.class,
|
||||||
DeviceNodeManagerControllerTest.class,
|
DeviceNodeManagerControllerTest.class,
|
||||||
DeviceNodeInfoControllerTest.class,
|
DeviceNodeInfoControllerTest.class,
|
||||||
UserAccountServiceTest.class
|
UserAccountServiceTest.class,
|
||||||
|
TaskControllerTest.class
|
||||||
})
|
})
|
||||||
public class AllDisposePlatformTest {
|
public class AllDisposePlatformTest {
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ import com.dispose.pojo.po.MReturnType;
|
||||||
import com.dispose.pojo.vo.auth.LoginReq;
|
import com.dispose.pojo.vo.auth.LoginReq;
|
||||||
import com.dispose.pojo.vo.auth.LoginRsp;
|
import com.dispose.pojo.vo.auth.LoginRsp;
|
||||||
import com.dispose.service.UserAccountService;
|
import com.dispose.service.UserAccountService;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import javax.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -23,9 +23,6 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
@ -39,17 +36,14 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AuthControllerTest extends InitTestEnvironment {
|
public class AuthControllerTest extends InitTestEnvironment {
|
||||||
|
private static String logToken = "";
|
||||||
@Resource
|
@Resource
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserAccountService userAccountService;
|
private UserAccountService userAccountService;
|
||||||
|
|
||||||
private static String logToken = "";
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void userLogin() throws Exception {
|
public void userLogin() throws Exception {
|
||||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.dispose.pojo.vo.common.IDArrayReq;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -32,7 +31,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||||
@Slf4j
|
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -72,7 +70,51 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
log.info("Request Json:" + objectMapper.writeValueAsString(reqInfo));
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/information/version")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
|
||||||
|
reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/information/version")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 1 get version all.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t1_getVersionAll() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/version")
|
.post("/information/version")
|
||||||
|
@ -103,7 +145,34 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
log.info("Request Json:" + objectMapper.writeValueAsString(reqInfo));
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/information/deviceinfo")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 2 get device info all.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t2_getDeviceInfoAll() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/deviceinfo")
|
.post("/information/deviceinfo")
|
||||||
|
@ -134,7 +203,34 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
log.info("Request Json:" + objectMapper.writeValueAsString(reqInfo));
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/information/capacity")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 3 get device capacity all.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t3_getDeviceCapacityAll() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/capacity")
|
.post("/information/capacity")
|
||||||
|
@ -165,7 +261,34 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
log.info("Request Json:" + objectMapper.writeValueAsString(reqInfo));
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/information/protected_ip")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 3 get device protected ip all.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t3_getDeviceProtectedIpAll() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/protected_ip")
|
.post("/information/protected_ip")
|
||||||
|
@ -196,7 +319,34 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
log.info("Request Json:" + objectMapper.writeValueAsString(reqInfo));
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/information/node_list")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 3 get dispose node list all.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t3_getDisposeNodeListAll() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/node_list")
|
.post("/information/node_list")
|
||||||
|
@ -227,7 +377,34 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment {
|
||||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
log.info("Request Json:" + objectMapper.writeValueAsString(reqInfo));
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/information/node_details")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 3 get dispose node details all.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t3_getDisposeNodeDetailsAll() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.id(new String[]{})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/information/node_details")
|
.post("/information/node_details")
|
||||||
|
|
|
@ -7,6 +7,8 @@ import com.dispose.pojo.po.NewNodeInfo;
|
||||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||||
import com.dispose.pojo.vo.device.AddNodeReq;
|
import com.dispose.pojo.vo.device.AddNodeReq;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import javax.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
@ -17,11 +19,6 @@ import org.springframework.test.annotation.DirtiesContext;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
|
@ -5,9 +5,11 @@ import com.dispose.common.ConstValue;
|
||||||
import com.dispose.pojo.dto.ProtocolReqDTO;
|
import com.dispose.pojo.dto.ProtocolReqDTO;
|
||||||
import com.dispose.pojo.vo.common.IDArrayReq;
|
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||||
import com.dispose.pojo.vo.task.StartTaskReq;
|
import com.dispose.pojo.vo.task.StartTaskReq;
|
||||||
|
import com.dispose.pojo.vo.task.StopTaskData;
|
||||||
|
import com.dispose.pojo.vo.task.StopTaskReq;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import java.util.ArrayList;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
|
@ -28,7 +30,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||||
@Slf4j
|
|
||||||
public class TaskControllerTest extends InitTestEnvironment {
|
public class TaskControllerTest extends InitTestEnvironment {
|
||||||
@Resource
|
@Resource
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
@ -55,8 +56,6 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
reqInfo.setTimeStamp(System.currentTimeMillis());
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
log.info("Request Json:" + objectMapper.writeValueAsString(reqInfo));
|
|
||||||
|
|
||||||
mockMvc.perform(MockMvcRequestBuilders
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
.post("/task/start")
|
.post("/task/start")
|
||||||
.contentType(MediaType.APPLICATION_JSON)
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
@ -68,4 +67,196 @@ public class TaskControllerTest extends InitTestEnvironment {
|
||||||
.getResponse()
|
.getResponse()
|
||||||
.getContentAsString();
|
.getContentAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 2 stop task.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t2_stopTask() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.taskId(new String[]{"1", "2"})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/task/stop")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 3 stop node ip task.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t3_stopNodeIpTask() throws Exception {
|
||||||
|
StopTaskData itemData = StopTaskData.builder()
|
||||||
|
.disposeIp("192.168.1.1")
|
||||||
|
.type(ConstValue.DeviceCapacity.CLEANUP.getCode())
|
||||||
|
.id("210")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
StopTaskReq reqData = new StopTaskReq();
|
||||||
|
|
||||||
|
reqData.setItems(new ArrayList<>());
|
||||||
|
reqData.getItems().add(itemData);
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/task/stop_ip")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 4 stop node task.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t4_stopNodeTask() throws Exception {
|
||||||
|
StopTaskData itemData = StopTaskData.builder()
|
||||||
|
.type(ConstValue.DeviceCapacity.CLEANUP.getCode())
|
||||||
|
.id("210")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
StopTaskReq reqData = new StopTaskReq();
|
||||||
|
|
||||||
|
reqData.setItems(new ArrayList<>());
|
||||||
|
reqData.getItems().add(itemData);
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/task/stop_node")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 5 stop all task.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t5_stopAllTask() throws Exception {
|
||||||
|
StopTaskData itemData = StopTaskData.builder()
|
||||||
|
.type(ConstValue.DeviceCapacity.CLEANUP.getCode())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
StopTaskReq reqData = new StopTaskReq();
|
||||||
|
|
||||||
|
reqData.setItems(new ArrayList<>());
|
||||||
|
reqData.getItems().add(itemData);
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/task/stop_all")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 6 get node task.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t6_getNodeTask() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.taskId(new String[]{"1", "2"})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/task/get_node")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 6 get all task.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void t6_getAllTask() throws Exception {
|
||||||
|
IDArrayReq reqData = IDArrayReq.builder()
|
||||||
|
.taskId(new String[]{"1", "2"})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProtocolReqDTO reqInfo = new ProtocolReqDTO();
|
||||||
|
reqInfo.setVer(ConstValue.Protocol.VERSION);
|
||||||
|
reqInfo.setCryptoType(ConstValue.Protocol.CRYPTO_NONE);
|
||||||
|
reqInfo.setTimeStamp(System.currentTimeMillis());
|
||||||
|
reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders
|
||||||
|
.post("/task/get")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON)
|
||||||
|
.header("Authorization", "Bearer 45509b805d955cfd5ef7093e27a8bb99b3733d9a7bf90e88ba528bcbd29c6122")
|
||||||
|
.content(objectMapper.writeValueAsString(reqInfo)))
|
||||||
|
.andDo(print()).andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$.code").value(200))
|
||||||
|
.andReturn()
|
||||||
|
.getResponse()
|
||||||
|
.getContentAsString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,84 +4,38 @@ import com.dispose.Global.InitTestEnvironment;
|
||||||
import com.dispose.common.ConstValue;
|
import com.dispose.common.ConstValue;
|
||||||
import com.dispose.dispose.DeviceRouter;
|
import com.dispose.dispose.DeviceRouter;
|
||||||
import com.dispose.dispose.DisposeEntryManager;
|
import com.dispose.dispose.DisposeEntryManager;
|
||||||
import com.dispose.dispose.po.DeviceInfo;
|
|
||||||
import com.dispose.pojo.po.DisposeDeviceCapacity;
|
import com.dispose.pojo.po.DisposeDeviceCapacity;
|
||||||
import com.dptech.dispose.DetectionObjectDataForService;
|
import com.dptech.dispose.DetectionObjectDataForService;
|
||||||
import com.dptech.dispose.ProtectionObjectDataForService;
|
import com.dptech.dispose.ProtectionObjectDataForService;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.cxf.databinding.AbstractDataBinding;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
import org.mockito.BDDMockito;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
|
||||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
/**
|
||||||
import java.util.List;
|
* The type Dp tech interface test case.
|
||||||
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
// @Before
|
/**
|
||||||
// public void initVirtualDevice() {
|
* T 1 get all detection object from umc.
|
||||||
// List<ProtectionObjectDataForService> protectList = new ArrayList<>();
|
*/
|
||||||
// List<DetectionObjectDataForService> detectionList = new ArrayList<>();
|
|
||||||
// detectionList.add(new DetectionObjectDataForService());
|
|
||||||
// detectionList.add(new DetectionObjectDataForService());
|
|
||||||
// detectionList.add(new DetectionObjectDataForService());
|
|
||||||
//
|
|
||||||
// protectList.add(new ProtectionObjectDataForService());
|
|
||||||
// protectList.add(new ProtectionObjectDataForService());
|
|
||||||
// protectList.add(new ProtectionObjectDataForService());
|
|
||||||
//
|
|
||||||
// List<DisposeDeviceCapacity> capList = new ArrayList<>();
|
|
||||||
// capList.add(DisposeDeviceCapacity.builder()
|
|
||||||
// .capacity(0)
|
|
||||||
// .tolFlowCapacity(1024)
|
|
||||||
// .build());
|
|
||||||
// capList.add(DisposeDeviceCapacity.builder()
|
|
||||||
// .capacity(1)
|
|
||||||
// .build());
|
|
||||||
//
|
|
||||||
// DisposeEntryManager disposeEntryManager = PowerMockito.mock(DisposeEntryManager.class);
|
|
||||||
//
|
|
||||||
// PowerMockito.when(disposeEntryManager.getAllDetectionObject()).thenReturn(detectionList);
|
|
||||||
// PowerMockito.when(disposeEntryManager.getAllProtectionObject()).thenReturn(protectList);
|
|
||||||
// PowerMockito.when(disposeEntryManager.getProtectDevices()).thenReturn("10.88.76.41");
|
|
||||||
// PowerMockito.when(disposeEntryManager.getDeviceLinkStatus()).thenReturn(true);
|
|
||||||
// PowerMockito.when(disposeEntryManager.getDeviceCapacity()).thenReturn(capList);
|
|
||||||
// PowerMockito.when(disposeEntryManager.getVersion()).thenReturn("1.0.0");
|
|
||||||
// PowerMockito.when(disposeEntryManager.getDeviceInfo()).thenReturn(new DeviceInfo());
|
|
||||||
//
|
|
||||||
// PowerMockito.mockStatic(DeviceRouter.class);
|
|
||||||
// PowerMockito.when(DeviceRouter.deviceRouterFactory(BDDMockito.anyInt(), BDDMockito.anyString())).thenReturn(disposeEntryManager);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void t1_getAllDetectionObjectFromUMC() {
|
public void t1_getAllDetectionObjectFromUMC() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DisposeEntryManager dp = DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15");
|
DisposeEntryManager dp =
|
||||||
|
DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15");
|
||||||
|
|
||||||
List<DetectionObjectDataForService> detDevs = dp.getAllDetectionObject();
|
List<DetectionObjectDataForService> detDevs = dp.getAllDetectionObject();
|
||||||
|
|
||||||
|
@ -92,11 +46,15 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 2 get all protect devices.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t2_getAllProtectDevices() {
|
public void t2_getAllProtectDevices() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DisposeEntryManager dp = DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15");
|
DisposeEntryManager dp =
|
||||||
|
DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15");
|
||||||
|
|
||||||
String proDevs = dp.getProtectDevices();
|
String proDevs = dp.getProtectDevices();
|
||||||
|
|
||||||
|
@ -107,11 +65,15 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 3 get all protect objects.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_getAllProtectObjects() {
|
public void t3_getAllProtectObjects() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DisposeEntryManager dp = DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15");
|
DisposeEntryManager dp =
|
||||||
|
DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15");
|
||||||
|
|
||||||
List<ProtectionObjectDataForService> proObjs = dp.getAllProtectionObject();
|
List<ProtectionObjectDataForService> proObjs = dp.getAllProtectionObject();
|
||||||
|
|
||||||
|
@ -122,6 +84,9 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 4 get link status.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t4_getLinkStatus() {
|
public void t4_getLinkStatus() {
|
||||||
|
|
||||||
|
@ -131,6 +96,11 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment {
|
||||||
Assert.assertTrue(dp.getDeviceLinkStatus());
|
Assert.assertTrue(dp.getDeviceLinkStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 5 get device capacity.
|
||||||
|
*
|
||||||
|
* @throws JsonProcessingException the json processing exception
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t5_getDeviceCapacity() throws JsonProcessingException {
|
public void t5_getDeviceCapacity() throws JsonProcessingException {
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,15 @@
|
||||||
package com.dispose.exception;
|
package com.dispose.exception;
|
||||||
|
|
||||||
import com.dispose.Global.InitTestEnvironment;
|
|
||||||
import com.dispose.common.ConstValue;
|
import com.dispose.common.ConstValue;
|
||||||
import com.dispose.mapper.DisposeDeviceMapper;
|
|
||||||
import com.dispose.pojo.dto.ProtocolReqDTO;
|
import com.dispose.pojo.dto.ProtocolReqDTO;
|
||||||
import com.dispose.pojo.dto.ProtocolRespDTO;
|
|
||||||
import com.dispose.pojo.vo.auth.LoginReq;
|
import com.dispose.pojo.vo.auth.LoginReq;
|
||||||
import com.dispose.pojo.vo.auth.LoginRsp;
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.FixMethodOrder;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.MethodSorters;
|
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -28,21 +21,30 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Exception test.
|
||||||
|
*/
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ExceptionTest {
|
public class ExceptionTest {
|
||||||
|
/**
|
||||||
|
* The Expected ex.
|
||||||
|
*/
|
||||||
|
@Rule
|
||||||
|
public ExpectedException expectedEx = ExpectedException.none();
|
||||||
@Resource
|
@Resource
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Rule
|
/**
|
||||||
public ExpectedException expectedEx = ExpectedException.none();
|
* T 1 input exception.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
@Test(expected = Throwable.class)
|
@Test(expected = Throwable.class)
|
||||||
public void t1_inputException() throws Exception {
|
public void t1_inputException() throws Exception {
|
||||||
expectedEx.expect(Throwable.class);
|
expectedEx.expect(Throwable.class);
|
||||||
|
@ -67,6 +69,11 @@ public class ExceptionTest{
|
||||||
.getContentAsString();
|
.getContentAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 2 global exception.
|
||||||
|
*
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
@Test(expected = Exception.class)
|
@Test(expected = Exception.class)
|
||||||
public void t2_globalException() throws Exception {
|
public void t2_globalException() throws Exception {
|
||||||
expectedEx.expect(Exception.class);
|
expectedEx.expect(Exception.class);
|
||||||
|
|
|
@ -17,19 +17,25 @@ import org.junit.runners.MethodSorters;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type User account manager test.
|
||||||
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class UserAccountManagerTest extends InitTestEnvironment {
|
public class UserAccountManagerTest extends InitTestEnvironment {
|
||||||
|
private static String userToken;
|
||||||
@Resource
|
@Resource
|
||||||
private UserAccountCacheManager userAccountCacheManager;
|
private UserAccountCacheManager userAccountCacheManager;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserAccountService userAccountService;
|
private UserAccountService userAccountService;
|
||||||
|
|
||||||
private static String userToken;
|
/**
|
||||||
|
* User login.
|
||||||
|
*
|
||||||
|
* @throws NoSuchAlgorithmException the no such algorithm exception
|
||||||
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void userLogin() throws NoSuchAlgorithmException {
|
public void userLogin() throws NoSuchAlgorithmException {
|
||||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
MReturnType<ErrorCode, String> ret = userAccountService.loginService(getUSER_NAME(), getPASSWORD());
|
||||||
|
@ -41,27 +47,44 @@ public class UserAccountManagerTest extends InitTestEnvironment {
|
||||||
Assert.assertNotEquals(userToken.length(), 0);
|
Assert.assertNotEquals(userToken.length(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 1 permission test.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t1_permissionTest() {
|
public void t1_permissionTest() {
|
||||||
Assert.assertEquals(userAccountCacheManager.verifyPermission(userToken), ErrorCode.ERR_OK);
|
Assert.assertEquals(userAccountCacheManager.verifyPermission(userToken), ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 2 get username by token test.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t2_getUsernameByTokenTest() {
|
public void t2_getUsernameByTokenTest() {
|
||||||
Assert.assertEquals(userAccountCacheManager.getUsernameByToken(userToken), getUSER_NAME());
|
Assert.assertEquals(userAccountCacheManager.getUsernameByToken(userToken), getUSER_NAME());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 3 verify token test.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t3_verifyTokenTest() {
|
public void t3_verifyTokenTest() {
|
||||||
Assert.assertEquals(userAccountCacheManager.verifyToken(userToken), ErrorCode.ERR_OK);
|
Assert.assertEquals(userAccountCacheManager.verifyToken(userToken), ErrorCode.ERR_OK);
|
||||||
Assert.assertEquals(userAccountCacheManager.verifyToken(userToken + "123"), ErrorCode.ERR_LOGOUT);
|
Assert.assertEquals(userAccountCacheManager.verifyToken(userToken + "123"), ErrorCode.ERR_LOGOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 4 verify user login test.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t4_verifyUserLoginTest() {
|
public void t4_verifyUserLoginTest() {
|
||||||
Assert.assertEquals(userAccountCacheManager.verifyUserLogin(getUSER_NAME(), userToken), ErrorCode.ERR_OK);
|
Assert.assertEquals(userAccountCacheManager.verifyUserLogin(getUSER_NAME(), userToken), ErrorCode.ERR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 5 get cache user.
|
||||||
|
*
|
||||||
|
* @throws JsonProcessingException the json processing exception
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t5_getCacheUser() throws JsonProcessingException {
|
public void t5_getCacheUser() throws JsonProcessingException {
|
||||||
String userInfo = userAccountCacheManager.getCacheUser();
|
String userInfo = userAccountCacheManager.getCacheUser();
|
||||||
|
@ -70,11 +93,17 @@ public class UserAccountManagerTest extends InitTestEnvironment {
|
||||||
Assert.assertNotEquals(userInfo.length(), 0);
|
Assert.assertNotEquals(userInfo.length(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 6 get usr pwd err times test.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t6_getUsrPwdErrTimesTest() {
|
public void t6_getUsrPwdErrTimesTest() {
|
||||||
Assert.assertEquals(userAccountCacheManager.getUsrPwdErrTimes(getUSER_NAME()), 0);
|
Assert.assertEquals(userAccountCacheManager.getUsrPwdErrTimes(getUSER_NAME()), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 6 set usr pwd err times test.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t6_setUsrPwdErrTimesTest() {
|
public void t6_setUsrPwdErrTimesTest() {
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
|
@ -86,11 +115,19 @@ public class UserAccountManagerTest extends InitTestEnvironment {
|
||||||
Assert.assertEquals(userAccountCacheManager.getUsrPwdErrTimes(getUSER_NAME()), 0);
|
Assert.assertEquals(userAccountCacheManager.getUsrPwdErrTimes(getUSER_NAME()), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 7 get user token test.
|
||||||
|
*
|
||||||
|
* @throws NoSuchAlgorithmException the no such algorithm exception
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t7_getUserTokenTest() throws NoSuchAlgorithmException {
|
public void t7_getUserTokenTest() throws NoSuchAlgorithmException {
|
||||||
Assert.assertEquals(userAccountCacheManager.getUserToken(getUSER_NAME()), userToken);
|
Assert.assertEquals(userAccountCacheManager.getUserToken(getUSER_NAME()), userToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T 99 clean user token test.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void t99_cleanUserTokenTest() {
|
public void t99_cleanUserTokenTest() {
|
||||||
userAccountCacheManager.cleanUserToken(getUSER_NAME());
|
userAccountCacheManager.cleanUserToken(getUSER_NAME());
|
||||||
|
|
|
@ -7,6 +7,9 @@ import com.dispose.pojo.po.DisposeDeviceCapacity;
|
||||||
import com.dispose.service.DisposeNodeManager;
|
import com.dispose.service.DisposeNodeManager;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
|
@ -16,10 +19,6 @@ import org.junit.runners.MethodSorters;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Dispose device mapper test.
|
* The type Dispose device mapper test.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.dispose.common.ConstValue;
|
||||||
import com.dispose.pojo.entity.UserAccount;
|
import com.dispose.pojo.entity.UserAccount;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import javax.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
|
@ -15,8 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type User account mapper test.
|
* The type User account mapper test.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,11 +21,10 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||||
public class UserAccountServiceTest extends InitTestEnvironment {
|
public class UserAccountServiceTest extends InitTestEnvironment {
|
||||||
|
private static String token = "";
|
||||||
@Resource
|
@Resource
|
||||||
private UserAccountService userAccountService;
|
private UserAccountService userAccountService;
|
||||||
|
|
||||||
private static String token = "";
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void userLogin() throws NoSuchAlgorithmException {
|
public void userLogin() throws NoSuchAlgorithmException {
|
||||||
MReturnType<ErrorCode, String> ret = userAccountService.loginService("admin",
|
MReturnType<ErrorCode, String> ret = userAccountService.loginService("admin",
|
||||||
|
|
Loading…
Reference in New Issue