diff --git a/src/main/java/we/plugin/auth/GatewayGroupService.java b/src/main/java/we/plugin/auth/GatewayGroupService.java index 91d0002..2fb2034 100644 --- a/src/main/java/we/plugin/auth/GatewayGroupService.java +++ b/src/main/java/we/plugin/auth/GatewayGroupService.java @@ -34,6 +34,8 @@ import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author hongqiaowei @@ -52,7 +54,7 @@ public class GatewayGroupService { private Map oldGatewayGroupMap = new HashMap<>(6); - public Set currentGatewayGroupSet = new HashSet<>(6); + public Set currentGatewayGroupSet = Stream.of(GatewayGroup.DEFAULT).collect(Collectors.toSet()); @Resource(name = AggregateRedisConfig.AGGREGATE_REACTIVE_REDIS_TEMPLATE) private ReactiveStringRedisTemplate rt; diff --git a/src/test/java/we/stats/ratelimit/ResourceRateLimitConfigServiceTests.java b/src/test/java/we/stats/ratelimit/ResourceRateLimitConfigServiceTests.java index fb83967..dd4fbc9 100644 --- a/src/test/java/we/stats/ratelimit/ResourceRateLimitConfigServiceTests.java +++ b/src/test/java/we/stats/ratelimit/ResourceRateLimitConfigServiceTests.java @@ -4,12 +4,14 @@ 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 we.redis.RedisTemplateConfiguration; import we.redis.RedisProperties; import we.redis.RedisServerConfiguration; +import we.redis.RedisTemplateConfiguration; import javax.annotation.Resource; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * @author hongqiaowei */ @@ -19,22 +21,6 @@ import javax.annotation.Resource; // @ActiveProfiles("unittest") public class ResourceRateLimitConfigServiceTests { - // private static RedisServer redisServer; - // - // @BeforeAll - // static void startRedis() { - // redisServer = RedisServer.builder() - // .port(6379) - // .setting("maxmemory 32M") - // .build(); - // redisServer.start(); - // } - // - // @AfterAll - // static void stopRedis() { - // redisServer.stop(); - // } - @Resource private RedisProperties redisProperties; @@ -42,8 +28,13 @@ public class ResourceRateLimitConfigServiceTests { private StringRedisTemplate stringRedisTemplate; @Test - void initTest() { + void initTest() throws InterruptedException { 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); } }