Files
fizz-gateway-node/src/test/java/we/stats/ratelimit/ResourceRateLimitConfigServiceTests.java

50 lines
1.5 KiB
Java
Raw Normal View History

2021-01-14 17:09:34 +08:00
package we.stats.ratelimit;
import org.junit.jupiter.api.BeforeAll;
2021-01-14 17:09:34 +08:00
import org.junit.jupiter.api.Test;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import redis.embedded.RedisServer;
2021-01-14 17:09:34 +08:00
import we.redis.RedisProperties;
import we.redis.RedisServerConfiguration;
import we.redis.RedisTemplateConfiguration;
2021-01-14 17:09:34 +08:00
import javax.annotation.Resource;
import static org.junit.jupiter.api.Assertions.assertEquals;
2021-01-14 17:09:34 +08:00
/**
* @author hongqiaowei
*/
@TestPropertySource("/application.properties")
@SpringJUnitConfig(classes = {RedisProperties.class, RedisTemplateConfiguration.class, RedisServerConfiguration.class})
// @ActiveProfiles("unittest")
public class ResourceRateLimitConfigServiceTests {
@Resource
private RedisProperties redisProperties;
@Resource
private StringRedisTemplate stringRedisTemplate;
ResourceRateLimitConfigService resourceRateLimitConfigService;
@BeforeAll
void beforeAllTests() {
resourceRateLimitConfigService = new ResourceRateLimitConfigService();
}
2021-01-14 17:09:34 +08:00
@Test
void initTest() throws InterruptedException {
2021-01-14 17:09:34 +08:00
System.err.println(redisProperties);
System.err.println(stringRedisTemplate);
stringRedisTemplate.opsForValue().set("name", "F-22");
Thread.sleep(2000);
String name = stringRedisTemplate.opsForValue().get("name");
assertEquals(name, "F-22");
System.err.println(name);
2021-01-14 17:09:34 +08:00
}
}