Spring Boot 3 support

* only in main branch, SB2 support will be continued in 1.x branch
This commit is contained in:
Anthony Dahanne
2023-06-05 17:23:22 -04:00
parent be780f7a4b
commit 3b43462fc4
47 changed files with 252 additions and 1231 deletions

View File

@@ -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"));
}
}

View File

@@ -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();
}
}

View File

@@ -0,0 +1,7 @@
package org.springframework.cloud;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBoot3Application {
}

View File

@@ -0,0 +1 @@
localhost

View File

@@ -0,0 +1 @@
4343

View File

@@ -0,0 +1 @@
redis