Skip to content
Snippets Groups Projects
Commit 4da41dbb authored by Antoine Rey's avatar Antoine Rey
Browse files

#164 Disable cache configuration for unit tests

parent e9f5f7b5
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,6 @@ import org.springframework.web.servlet.view.xml.MarshallingView; ...@@ -45,7 +45,6 @@ import org.springframework.web.servlet.view.xml.MarshallingView;
*/ */
@Configuration @Configuration
@EnableAutoConfiguration @EnableAutoConfiguration
@EnableCaching
@ComponentScan @ComponentScan
public class PetClinicApplication extends SpringBootServletInitializer { public class PetClinicApplication extends SpringBootServletInitializer {
......
package org.springframework.samples.petclinic.config;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
/**
* Cache could be disable in unit test.
*/
@Configuration
@EnableCaching
@Profile("production")
public class CacheConfig {
}
...@@ -21,3 +21,6 @@ management.contextPath: /manage ...@@ -21,3 +21,6 @@ management.contextPath: /manage
# Logging # Logging
logging.level.org.springframework=INFO logging.level.org.springframework=INFO
# Active Spring profiles
spring.profiles.active=production
...@@ -6,6 +6,7 @@ import org.junit.runner.RunWith; ...@@ -6,6 +6,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.samples.petclinic.PetClinicApplication; import org.springframework.samples.petclinic.PetClinicApplication;
import org.springframework.test.context.ActiveProfiles;
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;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
...@@ -25,6 +26,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. ...@@ -25,6 +26,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = PetClinicApplication.class) @SpringApplicationConfiguration(classes = PetClinicApplication.class)
@WebAppConfiguration @WebAppConfiguration
@ActiveProfiles("test")
public class OwnerControllerTests { public class OwnerControllerTests {
private static final int TEST_OWNER_ID = 1; private static final int TEST_OWNER_ID = 1;
......
...@@ -29,6 +29,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; ...@@ -29,6 +29,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = PetClinicApplication.class) @SpringApplicationConfiguration(classes = PetClinicApplication.class)
@WebAppConfiguration @WebAppConfiguration
@ActiveProfiles("test")
public class PetControllerTests { public class PetControllerTests {
private static final int TEST_OWNER_ID = 1; private static final int TEST_OWNER_ID = 1;
......
...@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.samples.petclinic.PetClinicApplication; import org.springframework.samples.petclinic.PetClinicApplication;
import org.springframework.test.context.ActiveProfiles;
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;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
...@@ -22,6 +23,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. ...@@ -22,6 +23,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = PetClinicApplication.class) @SpringApplicationConfiguration(classes = PetClinicApplication.class)
@WebAppConfiguration @WebAppConfiguration
@ActiveProfiles("test")
public class VetControllerTests { public class VetControllerTests {
@Autowired @Autowired
......
...@@ -6,6 +6,7 @@ import org.junit.runner.RunWith; ...@@ -6,6 +6,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.samples.petclinic.PetClinicApplication; import org.springframework.samples.petclinic.PetClinicApplication;
import org.springframework.test.context.ActiveProfiles;
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;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
...@@ -23,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. ...@@ -23,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = PetClinicApplication.class) @SpringApplicationConfiguration(classes = PetClinicApplication.class)
@WebAppConfiguration @WebAppConfiguration
@ActiveProfiles("test")
public class VisitControllerTests { public class VisitControllerTests {
private static final int TEST_PET_ID = 1; private static final int TEST_PET_ID = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment