Bump to latest 2.5 spring boot release

Contains feedback from @Kehrlann

Original commit by @abelsromero - amended to keep compatibility with Spring Boot 2

Add integration tests
* use Maven modules to do so
* spring-cloud-bindings goes one level down
* addition of a spring-cloud-bindings parent

Inspired by @gregturn and spring-data-rest

Integrate PR#94 comments from @Kehrlann

* move bindings to src/test/resources
* get rid of unused / duplicate annotations
* move all dependencies to test scope for test projects

Spring Boot 2 support
* only in branch 1.x, SB3 support is in main branch
This commit is contained in:
Anthony Dahanne
2023-02-13 14:25:29 -05:00
parent 909f3b5e0d
commit 874b54b4b6
117 changed files with 376 additions and 173 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 SpringBoot2Application {
}

View File

@@ -0,0 +1 @@
localhost

View File

@@ -0,0 +1 @@
4242

View File

@@ -0,0 +1 @@
redis