mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-01-14 05:41:12 +00:00
#164 Spring Boot version of Petclinic ready to deploy to an external web container (ie Tomcat)
This commit is contained in:
parent
76a4ca330b
commit
a6e81a51a0
66 changed files with 385 additions and 1964 deletions
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.samples.petclinic.service;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* <p> Integration test using the jdbc profile.
|
||||
*
|
||||
* @author Thomas Risberg
|
||||
* @author Michael Isvy
|
||||
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
|
||||
*/
|
||||
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ActiveProfiles("jdbc")
|
||||
public class ClinicServiceJdbcTests extends AbstractClinicServiceTests {
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package org.springframework.samples.petclinic.service;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* <p> Integration test using the jpa profile.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Sam Brannen
|
||||
* @author Michael Isvy
|
||||
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
|
||||
*/
|
||||
|
||||
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ActiveProfiles("jpa")
|
||||
public class ClinicServiceJpaTests extends AbstractClinicServiceTests {
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package org.springframework.samples.petclinic.service;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.samples.petclinic.PetClinicApplication;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
|
@ -12,9 +14,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
* @see AbstractClinicServiceTests AbstractClinicServiceTests for more details. </p>
|
||||
*/
|
||||
|
||||
@ContextConfiguration(locations = {"classpath:spring/business-config.xml"})
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ActiveProfiles("spring-data-jpa")
|
||||
@SpringApplicationConfiguration(classes = PetClinicApplication.class)
|
||||
public class ClinicServiceSpringDataJpaTests extends AbstractClinicServiceTests {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,44 +1,43 @@
|
|||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.samples.petclinic.PetClinicApplication;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
/**
|
||||
* Test class for {@link CrashController}
|
||||
*
|
||||
* @author Colin But
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration({"classpath:spring/business-config.xml", "classpath:spring/tools-config.xml", "classpath:spring/mvc-core-config.xml"})
|
||||
@SpringApplicationConfiguration(classes = PetClinicApplication.class)
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("spring-data-jpa")
|
||||
// Waiting https://github.com/spring-projects/spring-boot/issues/5574
|
||||
@Ignore
|
||||
public class CrashControllerTests {
|
||||
|
||||
@Autowired
|
||||
private CrashController crashController;
|
||||
|
||||
@Autowired
|
||||
private SimpleMappingExceptionResolver simpleMappingExceptionResolver;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.mockMvc = MockMvcBuilders
|
||||
.standaloneSetup(crashController)
|
||||
.setHandlerExceptionResolvers(simpleMappingExceptionResolver)
|
||||
//.setHandlerExceptionResolvers(new SimpleMappingExceptionResolver())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.samples.petclinic.PetClinicApplication;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
|
@ -13,12 +13,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|||
|
||||
import static org.hamcrest.Matchers.hasProperty;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
/**
|
||||
* Test class for {@link OwnerController}
|
||||
|
|
@ -26,9 +23,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
* @author Colin But
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration({"classpath:spring/business-config.xml", "classpath:spring/tools-config.xml", "classpath:spring/mvc-core-config.xml"})
|
||||
@SpringApplicationConfiguration(classes = PetClinicApplication.class)
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("spring-data-jpa")
|
||||
public class OwnerControllerTests {
|
||||
|
||||
private static final int TEST_OWNER_ID = 1;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.format.support.DefaultFormattingConversionService;
|
||||
import org.springframework.format.support.FormattingConversionServiceFactoryBean;
|
||||
import org.springframework.samples.petclinic.PetClinicApplication;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
|
@ -24,9 +27,8 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|||
* @author Colin But
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration({"classpath:spring/business-config.xml", "classpath:spring/tools-config.xml", "classpath:spring/mvc-core-config.xml"})
|
||||
@SpringApplicationConfiguration(classes = PetClinicApplication.class)
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("spring-data-jpa")
|
||||
public class PetControllerTests {
|
||||
|
||||
private static final int TEST_OWNER_ID = 1;
|
||||
|
|
@ -36,15 +38,17 @@ public class PetControllerTests {
|
|||
private PetController petController;
|
||||
|
||||
@Autowired
|
||||
private FormattingConversionServiceFactoryBean formattingConversionServiceFactoryBean;
|
||||
private PetTypeFormatter petTypeFormatter;
|
||||
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
DefaultFormattingConversionService formattingConversionService = new DefaultFormattingConversionService();
|
||||
formattingConversionService.addFormatter(petTypeFormatter);
|
||||
this.mockMvc = MockMvcBuilders
|
||||
.standaloneSetup(petController)
|
||||
.setConversionService(formattingConversionServiceFactoryBean.getObject())
|
||||
.setConversionService(formattingConversionService)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,27 @@
|
|||
package org.springframework.samples.petclinic.web;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.samples.petclinic.PetClinicApplication;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
/**
|
||||
* Test class for the {@link VetController}
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration({"classpath:spring/business-config.xml", "classpath:spring/tools-config.xml", "classpath:spring/mvc-core-config.xml"})
|
||||
@SpringApplicationConfiguration(classes = PetClinicApplication.class)
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("spring-data-jpa")
|
||||
public class VetControllerTests {
|
||||
|
||||
@Autowired
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.samples.petclinic.PetClinicApplication;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
|
@ -13,9 +13,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
/**
|
||||
* Test class for {@link VisitController}
|
||||
|
|
@ -23,9 +21,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||
* @author Colin But
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration({"classpath:spring/business-config.xml", "classpath:spring/tools-config.xml", "classpath:spring/mvc-core-config.xml"})
|
||||
@SpringApplicationConfiguration(classes = PetClinicApplication.class)
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("spring-data-jpa")
|
||||
public class VisitControllerTests {
|
||||
|
||||
private static final int TEST_PET_ID = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue