提交 14048434 编写于 作者: W wangliang

junit test

上级 b0895f5f
package com.codingapi.txlcn.tm.exception;
/**
* @author lorne
* @date 2020/9/14
* @description
*/
public class UtilException extends RuntimeException {
public UtilException() {
}
public UtilException(String message) {
super(message);
}
public UtilException(String message, Throwable cause) {
super(message, cause);
}
public UtilException(Throwable cause) {
super(cause);
}
public UtilException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
package com.codingapi.txlcn.tm.util;
import com.sun.xml.internal.ws.util.UtilException;
import com.codingapi.txlcn.tm.exception.UtilException;
import java.net.*;
import java.util.Enumeration;
......
package com.codingapi.txlcn.tm;
import com.codingapi.txlcn.tm.repository.TmNodeRepository;
import com.codingapi.txlcn.tm.repository.redis.RedisTmNodeRepository;
import org.mockito.Mockito;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -25,4 +28,10 @@ public class MockRedisTemplateConfiguration {
return redisTemplate;
}
@Bean
@ConditionalOnMissingBean
public TmNodeRepository tmNodeRepository(RedisTemplate<String, Object> tmRedisTemplate) {
return new RedisTmNodeRepository(tmRedisTemplate);
}
}
package com.codingapi.txlcn.tm.id;
import com.codingapi.txlcn.tm.MockRedisTemplateConfiguration;
import com.codingapi.txlcn.tm.node.TmNodeInitiator;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
......@@ -16,7 +17,7 @@ import static com.codingapi.txlcn.tm.id.SnowflakeHandler.generateLogId;
* @author WhomHim
* @date Create in 2020-8-10 22:09:30
*/
@SpringBootTest(classes = {MockRedisTemplateConfiguration.class,SnowflakeInitiator.class})
@SpringBootTest(classes = {MockRedisTemplateConfiguration.class, TmNodeInitiator.class})
public class SnowflakeHandlerTest {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册