Bael 4461 3 (#4695)
* [BAEL-7574] - Fixed integration tests for spring-rest-simple module * Fixed integration tests for spring-all, data-flow-server, spring-cloud-rest-books-api, spring-cloud-rest-reviews-api modules
This commit is contained in:
parent
7e16275bd7
commit
7b68989ab1
@ -25,7 +25,7 @@ public class CacheRefinementsIntegrationTest extends AbstractJUnit4SpringContext
|
|||||||
executorService.execute(() -> service.getFoo("test").printInstanceNumber());
|
executorService.execute(() -> service.getFoo("test").printInstanceNumber());
|
||||||
}
|
}
|
||||||
executorService.awaitTermination(1, TimeUnit.SECONDS);
|
executorService.awaitTermination(1, TimeUnit.SECONDS);
|
||||||
assertEquals(Foo.getInstanceCount(), 1);
|
assertEquals(1, Foo.getInstanceCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
<description>Demo project for Spring Boot</description>
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-boot-1</artifactId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<groupId>com.baeldung</groupId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.4.3.RELEASE</version>
|
||||||
<relativePath>../../parent-boot-1</relativePath>
|
<relativePath />
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -2,7 +2,14 @@ package org.baeldung.spring.cloud;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
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 org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ -13,4 +20,24 @@ public class DataFlowServerApplicationIntegrationTest {
|
|||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EnableRedisHttpSession
|
||||||
|
@Configuration
|
||||||
|
static class Config {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public RedisSerializer<Object> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,14 @@ package org.baeldung;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
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 org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ -13,4 +20,24 @@ public class BooksApiIntegrationTest {
|
|||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EnableRedisHttpSession
|
||||||
|
@Configuration
|
||||||
|
static class Config {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public RedisSerializer<Object> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,43 @@
|
|||||||
package org.baeldung;
|
package org.baeldung;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
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 org.springframework.test.context.junit4.SpringRunner;
|
||||||
import redis.embedded.RedisServer;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class BookReviewsApiIntegrationTest {
|
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
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EnableRedisHttpSession
|
||||||
|
@Configuration
|
||||||
|
static class Config {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public RedisSerializer<Object> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
@ -18,6 +19,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = WebConfig.class)
|
@ContextConfiguration(classes = WebConfig.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
|
@AutoConfigureWebClient
|
||||||
public class ExampleControllerIntegrationTest {
|
public class ExampleControllerIntegrationTest {
|
||||||
|
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
@ -15,6 +15,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
@ -26,6 +27,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = WebConfig.class)
|
@ContextConfiguration(classes = WebConfig.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
|
@AutoConfigureWebClient
|
||||||
public class BazzNewMappingsExampleIntegrationTest {
|
public class BazzNewMappingsExampleIntegrationTest {
|
||||||
|
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user