Spring Boot 3 support
* only in main branch, SB2 support will be continued in 1.x branch
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package org.springframework.cloud;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@SpringBootTest(classes = RedisServerTestConfiguration.class)
|
||||
public class IntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Test
|
||||
public void shouldSaveUser_toRedis() {
|
||||
redisTemplate.opsForValue().set("hello", "world");
|
||||
assertTrue(redisTemplate.hasKey("hello"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.springframework.cloud;
|
||||
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import redis.embedded.RedisServer;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
|
||||
@TestConfiguration
|
||||
public class RedisServerTestConfiguration {
|
||||
|
||||
private final RedisServer redisServer;
|
||||
|
||||
public RedisServerTestConfiguration() throws IOException {
|
||||
try (Scanner scanner = new Scanner(new ClassPathResource("bindings/redis/port").getInputStream())) {
|
||||
int port = scanner.nextInt();
|
||||
this.redisServer = new RedisServer(port);
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
redisServer.start();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void preDestroy() {
|
||||
redisServer.stop();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.springframework.cloud;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringBoot3Application {
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
localhost
|
||||
@@ -0,0 +1 @@
|
||||
4343
|
||||
@@ -0,0 +1 @@
|
||||
redis
|
||||
Reference in New Issue
Block a user