diff --git a/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java b/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java index 986932dafe..fa72ed6d43 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java @@ -25,7 +25,7 @@ public class CacheRefinementsIntegrationTest extends AbstractJUnit4SpringContext executorService.execute(() -> service.getFoo("test").printInstanceNumber()); } executorService.awaitTermination(1, TimeUnit.SECONDS); - assertEquals(Foo.getInstanceCount(), 1); + assertEquals(1, Foo.getInstanceCount()); } } diff --git a/spring-cloud-data-flow/data-flow-server/pom.xml b/spring-cloud-data-flow/data-flow-server/pom.xml index 0133d65978..3b04985618 100644 --- a/spring-cloud-data-flow/data-flow-server/pom.xml +++ b/spring-cloud-data-flow/data-flow-server/pom.xml @@ -11,10 +11,10 @@ Demo project for Spring Boot - parent-boot-1 - com.baeldung - 0.0.1-SNAPSHOT - ../../parent-boot-1 + org.springframework.boot + spring-boot-starter-parent + 1.4.3.RELEASE + diff --git a/spring-cloud-data-flow/data-flow-server/src/test/java/org/baeldung/spring/cloud/DataFlowServerApplicationIntegrationTest.java b/spring-cloud-data-flow/data-flow-server/src/test/java/org/baeldung/spring/cloud/DataFlowServerApplicationIntegrationTest.java index bb8660b816..9eba12fc12 100644 --- a/spring-cloud-data-flow/data-flow-server/src/test/java/org/baeldung/spring/cloud/DataFlowServerApplicationIntegrationTest.java +++ b/spring-cloud-data-flow/data-flow-server/src/test/java/org/baeldung/spring/cloud/DataFlowServerApplicationIntegrationTest.java @@ -2,7 +2,14 @@ package org.baeldung.spring.cloud; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @@ -13,4 +20,24 @@ public class DataFlowServerApplicationIntegrationTest { public void contextLoads() { } + @EnableRedisHttpSession + @Configuration + static class Config { + + @Bean + @SuppressWarnings("unchecked") + public RedisSerializer defaultRedisSerializer() { + return Mockito.mock(RedisSerializer.class); + } + + @Bean + public RedisConnectionFactory connectionFactory() { + + RedisConnectionFactory factory = Mockito.mock(RedisConnectionFactory.class); + RedisConnection connection = Mockito.mock(RedisConnection.class); + Mockito.when(factory.getConnection()).thenReturn(connection); + + return factory; + } + } } diff --git a/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/BooksApiIntegrationTest.java b/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/BooksApiIntegrationTest.java index d6b0ee1694..15056e110c 100644 --- a/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/BooksApiIntegrationTest.java +++ b/spring-cloud/spring-cloud-rest/spring-cloud-rest-books-api/src/test/java/org/baeldung/BooksApiIntegrationTest.java @@ -2,7 +2,14 @@ package org.baeldung; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @@ -13,4 +20,24 @@ public class BooksApiIntegrationTest { public void contextLoads() { } + @EnableRedisHttpSession + @Configuration + static class Config { + + @Bean + @SuppressWarnings("unchecked") + public RedisSerializer defaultRedisSerializer() { + return Mockito.mock(RedisSerializer.class); + } + + @Bean + public RedisConnectionFactory connectionFactory() { + + RedisConnectionFactory factory = Mockito.mock(RedisConnectionFactory.class); + RedisConnection connection = Mockito.mock(RedisConnection.class); + Mockito.when(factory.getConnection()).thenReturn(connection); + + return factory; + } + } } diff --git a/spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/BookReviewsApiIntegrationTest.java b/spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/BookReviewsApiIntegrationTest.java index 98cda102e9..c63b4ebb08 100644 --- a/spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/BookReviewsApiIntegrationTest.java +++ b/spring-cloud/spring-cloud-rest/spring-cloud-rest-reviews-api/src/test/java/org/baeldung/BookReviewsApiIntegrationTest.java @@ -1,36 +1,43 @@ package org.baeldung; -import java.io.IOException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.serializer.RedisSerializer; +import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; import org.springframework.test.context.junit4.SpringRunner; -import redis.embedded.RedisServer; @RunWith(SpringRunner.class) @SpringBootTest public class BookReviewsApiIntegrationTest { - - private static RedisServer redisServer; - private static int port; - - @BeforeClass - public static void setUp() throws IOException { - - redisServer = new RedisServer(6379); - redisServer.start(); - } - - @AfterClass - public static void destroy() { - redisServer.stop(); - } @Test public void contextLoads() { } + @EnableRedisHttpSession + @Configuration + static class Config { + + @Bean + @SuppressWarnings("unchecked") + public RedisSerializer defaultRedisSerializer() { + return Mockito.mock(RedisSerializer.class); + } + + @Bean + public RedisConnectionFactory connectionFactory() { + + RedisConnectionFactory factory = Mockito.mock(RedisConnectionFactory.class); + RedisConnection connection = Mockito.mock(RedisConnection.class); + Mockito.when(factory.getConnection()).thenReturn(connection); + + return factory; + } + } }