JAVA-31544: migrate spring-boot-testing and spring-boot-testing-2 to sb3 (#16182)
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
</dependency>
|
||||
<!-- Embedded Redis Server -->
|
||||
<dependency>
|
||||
<groupId>it.ozimov</groupId>
|
||||
<groupId>com.github.codemonstur</groupId>
|
||||
<artifactId>embedded-redis</artifactId>
|
||||
<version>${embedded-redis.version}</version>
|
||||
<scope>test</scope>
|
||||
@@ -114,7 +114,7 @@
|
||||
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
|
||||
<spock.version>2.4-M1-groovy-4.0</spock.version>
|
||||
<gmavenplus-plugin.version>3.0.0</gmavenplus-plugin.version>
|
||||
<embedded-redis.version>0.7.2</embedded-redis.version>
|
||||
<embedded-redis.version>1.4.2</embedded-redis.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
+8
-5
@@ -1,18 +1,21 @@
|
||||
package com.baeldung.boot.embeddedRedis;
|
||||
|
||||
import com.baeldung.boot.embeddedRedis.configuration.RedisProperties;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import redis.embedded.RedisServer;
|
||||
|
||||
import com.baeldung.boot.embeddedRedis.configuration.RedisProperties;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import redis.embedded.RedisServer;
|
||||
|
||||
@TestConfiguration
|
||||
public class TestRedisConfiguration {
|
||||
|
||||
private final RedisServer redisServer;
|
||||
|
||||
public TestRedisConfiguration(final RedisProperties redisProperties) {
|
||||
public TestRedisConfiguration(final RedisProperties redisProperties) throws IOException {
|
||||
this.redisServer = new RedisServer(redisProperties.getRedisPort());
|
||||
//Uncomment below if running on windows and can't start redis server
|
||||
// this.redisServer = RedisServer.builder().setting("maxheap 200m").port(6379).setting("bind localhost").build();
|
||||
@@ -20,12 +23,12 @@ public class TestRedisConfiguration {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
public void postConstruct() throws IOException {
|
||||
redisServer.start();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void preDestroy() {
|
||||
public void preDestroy() throws IOException {
|
||||
redisServer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
+10
-11
@@ -1,26 +1,25 @@
|
||||
package com.baeldung.boot.embeddedRedis.domain.repository;
|
||||
|
||||
import com.baeldung.boot.embeddedRedis.TestRedisConfiguration;
|
||||
import com.baeldung.boot.embeddedRedis.domain.User;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import com.baeldung.boot.embeddedRedis.TestRedisConfiguration;
|
||||
import com.baeldung.boot.embeddedRedis.domain.User;
|
||||
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = TestRedisConfiguration.class)
|
||||
public class UserRepositoryIntegrationTest {
|
||||
class UserRepositoryIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Test
|
||||
public void shouldSaveUser_toRedis() {
|
||||
void shouldSaveUser_toRedis() {
|
||||
final UUID id = UUID.randomUUID();
|
||||
final User user = new User(id, "name");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user