From d861ca635bca3798572a8463cb63a3de5cb34ee8 Mon Sep 17 00:00:00 2001 From: Vitaliy Fedoriv Date: Sat, 12 Nov 2016 22:53:43 +0200 Subject: [PATCH] Add ClinicServiceExt tests --- .../rest/SpecialtyRestControllerTests.java | 202 ++++++++++- .../AbstractClinicServiceExtTests.java | 330 ++++++++++++++++++ .../service/ClinicServiceExtJdbcTests.java | 35 ++ .../service/ClinicServiceExtJpaTests.java | 35 ++ .../ClinicServiceExtSpringDataJpaTests.java | 35 ++ src/test/resources/spring/mvc-test-config.xml | 6 +- 6 files changed, 640 insertions(+), 3 deletions(-) create mode 100644 src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceExtTests.java create mode 100644 src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtJdbcTests.java create mode 100644 src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtJpaTests.java create mode 100644 src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtSpringDataJpaTests.java diff --git a/src/test/java/org/springframework/samples/petclinic/rest/SpecialtyRestControllerTests.java b/src/test/java/org/springframework/samples/petclinic/rest/SpecialtyRestControllerTests.java index 0d9307a62..4ab6a6fcf 100644 --- a/src/test/java/org/springframework/samples/petclinic/rest/SpecialtyRestControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/rest/SpecialtyRestControllerTests.java @@ -1,5 +1,205 @@ +/* + * Copyright 2016 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.rest; +import static org.mockito.BDDMockito.given; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +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.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.samples.petclinic.model.Specialty; +import org.springframework.samples.petclinic.service.ClinicServiceExt; +import org.springframework.test.context.ContextConfiguration; +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 com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Test class for {@link SpecialtyRestController} + * + * @author Vitaliy Fedoriv + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration({"classpath:spring/mvc-test-config.xml", "classpath:spring/mvc-core-config.xml"}) +@WebAppConfiguration public class SpecialtyRestControllerTests { -} + @Autowired + private SpecialtyRestController specialtyRestController; + + @Autowired + private ClinicServiceExt clinicService; + + private MockMvc mockMvc; + + private List specialties; + + @Before + public void initSpecialtys(){ + this.mockMvc = MockMvcBuilders.standaloneSetup(specialtyRestController).build(); + specialties = new ArrayList(); + + Specialty specialty = new Specialty(); + specialty.setId(1); + specialty.setName("radiology"); + specialties.add(specialty); + + specialty = new Specialty(); + specialty.setId(2); + specialty.setName("surgery"); + specialties.add(specialty); + + specialty = new Specialty(); + specialty.setId(3); + specialty.setName("dentistry"); + specialties.add(specialty); + + } + + @Test + public void testGetSpecialtySuccess() throws Exception { + given(this.clinicService.findSpecialtyById(1)).willReturn(specialties.get(0)); + this.mockMvc.perform(get("/api/specialties/1") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isOk()) + .andExpect(content().contentType("application/json;charset=UTF-8")) + .andExpect(jsonPath("$.id").value(1)) + .andExpect(jsonPath("$.name").value("radiology")); + } + + @Test + public void testGetSpecialtyNotFound() throws Exception { + given(this.clinicService.findSpecialtyById(-1)).willReturn(null); + this.mockMvc.perform(get("/api/specialties/-1") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNotFound()); + } + + @Test + public void testGetAllSpecialtysSuccess() throws Exception { + specialties.remove(0); + given(this.clinicService.findAllSpecialties()).willReturn(specialties); + this.mockMvc.perform(get("/api/specialties/") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().contentType("application/json;charset=UTF-8")) + .andExpect(jsonPath("$.[0].id").value(2)) + .andExpect(jsonPath("$.[0].name").value("surgery")) + .andExpect(jsonPath("$.[1].id").value(3)) + .andExpect(jsonPath("$.[1].name").value("dentistry")); + } + + @Test + public void testGetAllSpecialtysNotFound() throws Exception { + specialties.clear(); + given(this.clinicService.findAllSpecialties()).willReturn(specialties); + this.mockMvc.perform(get("/api/specialties/") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isNotFound()); + } + + @Test + public void testCreateSpecialtySuccess() throws Exception { + Specialty newSpecialty = specialties.get(0); + newSpecialty.setId(999); + ObjectMapper mapper = new ObjectMapper(); + String newSpecialtyAsJSON = mapper.writeValueAsString(newSpecialty); + this.mockMvc.perform(post("/api/specialties/") + .content(newSpecialtyAsJSON).accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isCreated()); + } + + @Test + public void testCreateSpecialtyError() throws Exception { + Specialty newSpecialty = specialties.get(0); + newSpecialty.setId(null); + newSpecialty.setName(null); + ObjectMapper mapper = new ObjectMapper(); + String newSpecialtyAsJSON = mapper.writeValueAsString(newSpecialty); + this.mockMvc.perform(post("/api/specialties/") + .content(newSpecialtyAsJSON).accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isBadRequest()); + } + + @Test + public void testUpdateSpecialtySuccess() throws Exception { + given(this.clinicService.findSpecialtyById(2)).willReturn(specialties.get(1)); + Specialty newSpecialty = specialties.get(1); + newSpecialty.setName("surgery I"); + ObjectMapper mapper = new ObjectMapper(); + String newSpecialtyAsJSON = mapper.writeValueAsString(newSpecialty); + this.mockMvc.perform(put("/api/specialties/2") + .content(newSpecialtyAsJSON).accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(content().contentType("application/json;charset=UTF-8")) + .andExpect(status().isNoContent()); + + this.mockMvc.perform(get("/api/specialties/2") + .accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isOk()) + .andExpect(content().contentType("application/json;charset=UTF-8")) + .andExpect(jsonPath("$.id").value(2)) + .andExpect(jsonPath("$.name").value("surgery I")); + } + + @Test + public void testUpdateSpecialtyError() throws Exception { + Specialty newSpecialty = specialties.get(0); + newSpecialty.setName(""); + ObjectMapper mapper = new ObjectMapper(); + String newSpecialtyAsJSON = mapper.writeValueAsString(newSpecialty); + this.mockMvc.perform(put("/api/specialties/1") + .content(newSpecialtyAsJSON).accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isBadRequest()); + } + + @Test + public void testDeleteSpecialtySuccess() throws Exception { + Specialty newSpecialty = specialties.get(0); + ObjectMapper mapper = new ObjectMapper(); + String newSpecialtyAsJSON = mapper.writeValueAsString(newSpecialty); + given(this.clinicService.findSpecialtyById(1)).willReturn(specialties.get(0)); + this.mockMvc.perform(delete("/api/specialties/1") + .content(newSpecialtyAsJSON).accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isNoContent()); + } + + @Test + public void testDeleteSpecialtyError() throws Exception { + Specialty newSpecialty = specialties.get(0); + ObjectMapper mapper = new ObjectMapper(); + String newSpecialtyAsJSON = mapper.writeValueAsString(newSpecialty); + given(this.clinicService.findSpecialtyById(-1)).willReturn(null); + this.mockMvc.perform(delete("/api/specialties/-1") + .content(newSpecialtyAsJSON).accept(MediaType.APPLICATION_JSON_VALUE).contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().isNotFound()); + } +} \ No newline at end of file diff --git a/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceExtTests.java b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceExtTests.java new file mode 100644 index 000000000..e29ad0f1f --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/service/AbstractClinicServiceExtTests.java @@ -0,0 +1,330 @@ +/* + * Copyright 2016 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 static org.assertj.core.api.Assertions.assertThat; + +import java.util.Collection; +import java.util.Date; + +import javax.transaction.Transactional; + +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.samples.petclinic.model.Owner; +import org.springframework.samples.petclinic.model.Pet; +import org.springframework.samples.petclinic.model.PetType; +import org.springframework.samples.petclinic.model.Specialty; +import org.springframework.samples.petclinic.model.Vet; +import org.springframework.samples.petclinic.model.Visit; +import org.springframework.samples.petclinic.util.EntityUtils; +import org.springframework.test.context.ContextConfiguration; + +/** + *

Base class for {@link ClinicServiceExt} integration tests.

Subclasses should specify Spring context + * configuration using {@link ContextConfiguration @ContextConfiguration} annotation

+ * AbstractclinicServiceExtTests and its subclasses benefit from the following services provided by the Spring + * TestContext Framework:

  • Spring IoC container caching which spares us unnecessary set up + * time between test execution.
  • Dependency Injection of test fixture instances, meaning that + * we don't need to perform application context lookups. See the use of {@link Autowired @Autowired} on the {@link + * AbstractClinicServiceExtTests#clinicServiceExt clinicServiceExt} instance variable, which uses autowiring by + * type.
  • Transaction management, meaning each test method is executed in its own transaction, + * which is automatically rolled back by default. Thus, even if tests insert or otherwise change database state, there + * is no need for a teardown or cleanup script.
  • An {@link org.springframework.context.ApplicationContext + * ApplicationContext} is also inherited and can be used for explicit bean lookup if necessary.
+ * + * @author Vitaliy Fedoriv + * + */ + +public abstract class AbstractClinicServiceExtTests { + + @Autowired + @Qualifier("ClinicServiceExt") + protected ClinicServiceExt clinicService; + + @Test + public void shouldFindAllPets(){ + Collection pets = this.clinicService.findAllPets(); + Pet pet1 = EntityUtils.getById(pets, Pet.class, 1); + assertThat(pet1.getName()).isEqualTo("Leo"); + Pet pet3 = EntityUtils.getById(pets, Pet.class, 3); + assertThat(pet3.getName()).isEqualTo("Rosy"); + } + + @Test + @Transactional + public void shouldDeletePet(){ + Pet pet = this.clinicService.findPetById(1); + this.clinicService.deletePet(pet); + try { + pet = this.clinicService.findPetById(1); + } catch (Exception e) { + pet = null; + } + assertThat(pet).isNull(); + } + + @Test + public void shouldFindVisitDyId(){ + Visit visit = this.clinicService.findVisitById(1); + assertThat(visit.getId()).isEqualTo(1); + assertThat(visit.getPet().getName()).isEqualTo("Samantha"); + } + + @Test + public void shouldFindAllVisits(){ + Collection visits = this.clinicService.findAllVisits(); + Visit visit1 = EntityUtils.getById(visits, Visit.class, 1); + assertThat(visit1.getPet().getName()).isEqualTo("Samantha"); + Visit visit3 = EntityUtils.getById(visits, Visit.class, 3); + assertThat(visit3.getPet().getName()).isEqualTo("Max"); + } + + @Test + @Transactional + public void shouldInsertVisit() { + Collection visits = this.clinicService.findAllVisits(); + int found = visits.size(); + + Pet pet = this.clinicService.findPetById(1); + + Visit visit = new Visit(); + visit.setPet(pet); + visit.setDate(new Date()); + visit.setDescription("new visit"); + + + this.clinicService.saveVisit(visit); + assertThat(visit.getId().longValue()).isNotEqualTo(0); + + visits = this.clinicService.findAllVisits(); + assertThat(visits.size()).isEqualTo(found + 1); + } + + @Test + @Transactional + public void shouldUpdateVisit(){ + Visit visit = this.clinicService.findVisitById(1); + String oldDesc = visit.getDescription(); + String newDesc = oldDesc + "X"; + visit.setDescription(newDesc); + this.clinicService.saveVisit(visit); + visit = this.clinicService.findVisitById(1); + assertThat(visit.getDescription()).isEqualTo(newDesc); + } + + @Test + @Transactional + public void shouldDeleteVisit(){ + Visit visit = this.clinicService.findVisitById(1); + this.clinicService.deleteVisit(visit); + try { + visit = this.clinicService.findVisitById(1); + } catch (Exception e) { + visit = null; + } + assertThat(visit).isNull(); + } + + @Test + public void shouldFindVetDyId(){ + Vet vet = this.clinicService.findVetById(1); + assertThat(vet.getFirstName()).isEqualTo("James"); + assertThat(vet.getLastName()).isEqualTo("Carter"); + } + + @Test + @Transactional + public void shouldInsertVet() { + Collection vets = this.clinicService.findAllVets(); + int found = vets.size(); + + Vet vet = new Vet(); + vet.setFirstName("John"); + vet.setLastName("Dow"); + + this.clinicService.saveVet(vet); + assertThat(vet.getId().longValue()).isNotEqualTo(0); + + vets = this.clinicService.findAllVets(); + assertThat(vets.size()).isEqualTo(found + 1); + } + + @Test + @Transactional + public void shouldUpdateVet(){ + Vet vet = this.clinicService.findVetById(1); + String oldLastName = vet.getLastName(); + String newLastName = oldLastName + "X"; + vet.setLastName(newLastName); + this.clinicService.saveVet(vet); + vet = this.clinicService.findVetById(1); + assertThat(vet.getLastName()).isEqualTo(newLastName); + } + + @Test + @Transactional + public void shouldDeleteVet(){ + Vet vet = this.clinicService.findVetById(1); + this.clinicService.deleteVet(vet); + try { + vet = this.clinicService.findVetById(1); + } catch (Exception e) { + vet = null; + } + assertThat(vet).isNull(); + } + + @Test + public void shouldFindAllOwners(){ + Collection owners = this.clinicService.findAllOwners(); + Owner owner1 = EntityUtils.getById(owners, Owner.class, 1); + assertThat(owner1.getFirstName()).isEqualTo("George"); + Owner owner3 = EntityUtils.getById(owners, Owner.class, 3); + assertThat(owner3.getFirstName()).isEqualTo("Eduardo"); + } + + @Test + @Transactional + public void shouldDeleteOwner(){ + Owner owner = this.clinicService.findOwnerById(1); + this.clinicService.deleteOwner(owner); + try { + owner = this.clinicService.findOwnerById(1); + } catch (Exception e) { + owner = null; + } + assertThat(owner).isNull(); + } + + @Test + public void shouldFindPetTypeById(){ + PetType petType = this.clinicService.findPetTypeById(1); + assertThat(petType.getName()).isEqualTo("cat"); + } + + @Test + public void shouldFindAllPetTypes(){ + Collection petTypes = this.clinicService.findAllPetTypes(); + PetType petType1 = EntityUtils.getById(petTypes, PetType.class, 1); + assertThat(petType1.getName()).isEqualTo("cat"); + PetType petType3 = EntityUtils.getById(petTypes, PetType.class, 3); + assertThat(petType3.getName()).isEqualTo("lizard"); + } + + @Test + @Transactional + public void shouldInsertPetType() { + Collection petTypes = this.clinicService.findAllPetTypes(); + int found = petTypes.size(); + + PetType petType = new PetType(); + petType.setName("tiger"); + + this.clinicService.savePetType(petType); + assertThat(petType.getId().longValue()).isNotEqualTo(0); + + petTypes = this.clinicService.findAllPetTypes(); + assertThat(petTypes.size()).isEqualTo(found + 1); + } + + @Test + @Transactional + public void shouldUpdatePetType(){ + PetType petType = this.clinicService.findPetTypeById(1); + String oldLastName = petType.getName(); + String newLastName = oldLastName + "X"; + petType.setName(newLastName); + this.clinicService.savePetType(petType); + petType = this.clinicService.findPetTypeById(1); + assertThat(petType.getName()).isEqualTo(newLastName); + } + + @Test + @Transactional + public void shouldDeletePetType(){ + PetType petType = this.clinicService.findPetTypeById(1); + this.clinicService.deletePetType(petType); + try { + petType = this.clinicService.findPetTypeById(1); + } catch (Exception e) { + petType = null; + } + assertThat(petType).isNull(); + } + + @Test + public void shouldFindSpecialtyById(){ + Specialty specialty = this.clinicService.findSpecialtyById(1); + assertThat(specialty.getName()).isEqualTo("radiology"); + } + + @Test + public void shouldFindAllSpecialtys(){ + Collection specialties = this.clinicService.findAllSpecialties(); + Specialty specialty1 = EntityUtils.getById(specialties, Specialty.class, 1); + assertThat(specialty1.getName()).isEqualTo("radiology"); + Specialty specialty3 = EntityUtils.getById(specialties, Specialty.class, 3); + assertThat(specialty3.getName()).isEqualTo("dentistry"); + } + + @Test + @Transactional + public void shouldInsertSpecialty() { + Collection specialties = this.clinicService.findAllSpecialties(); + int found = specialties.size(); + + Specialty specialty = new Specialty(); + specialty.setName("dermatologist"); + + this.clinicService.saveSpecialty(specialty); + assertThat(specialty.getId().longValue()).isNotEqualTo(0); + + specialties = this.clinicService.findAllSpecialties(); + assertThat(specialties.size()).isEqualTo(found + 1); + } + + @Test + @Transactional + public void shouldUpdateSpecialty(){ + Specialty specialty = this.clinicService.findSpecialtyById(1); + String oldLastName = specialty.getName(); + String newLastName = oldLastName + "X"; + specialty.setName(newLastName); + this.clinicService.saveSpecialty(specialty); + specialty = this.clinicService.findSpecialtyById(1); + assertThat(specialty.getName()).isEqualTo(newLastName); + } + + @Test + @Transactional + public void shouldDeleteSpecialty(){ + Specialty specialty = this.clinicService.findSpecialtyById(1); + this.clinicService.deleteSpecialty(specialty); + try { + specialty = this.clinicService.findSpecialtyById(1); + } catch (Exception e) { + specialty = null; + } + assertThat(specialty).isNull(); + } + + + +} diff --git a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtJdbcTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtJdbcTests.java new file mode 100644 index 000000000..2f75ad276 --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtJdbcTests.java @@ -0,0 +1,35 @@ +/* + * Copyright 2016 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; + +/** + *

Integration test using the jdbc profile. + * + * @author Vitaliy Fedoriv + * @see AbstractClinicServiceExtTests AbstractClinicServiceExtTests for more details.

+ */ +@ContextConfiguration(locations = {"classpath:spring/business-config.xml"}) +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("jdbc") + +public class ClinicServiceExtJdbcTests extends AbstractClinicServiceExtTests { + +} diff --git a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtJpaTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtJpaTests.java new file mode 100644 index 000000000..db33b5820 --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtJpaTests.java @@ -0,0 +1,35 @@ +/* + * Copyright 2016 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; + +/** + *

Integration test using the jpa profile. + * + * @author Vitaliy Fedoriv + * @see AbstractClinicServiceExtTests AbstractClinicServiceExtTests for more details.

+ */ +@ContextConfiguration(locations = {"classpath:spring/business-config.xml"}) +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("jpa") + +public class ClinicServiceExtJpaTests extends AbstractClinicServiceExtTests { + +} diff --git a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtSpringDataJpaTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtSpringDataJpaTests.java new file mode 100644 index 000000000..93ac7a61c --- /dev/null +++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceExtSpringDataJpaTests.java @@ -0,0 +1,35 @@ +/* + * Copyright 2016 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; + +/** + *

Integration test using the jpa profile. + * + * @author Vitaliy Fedoriv + * @see AbstractClinicServiceExtTests AbstractClinicServiceExtTests for more details.

+ */ +@ContextConfiguration(locations = {"classpath:spring/business-config.xml"}) +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("spring-data-jpa") + +public class ClinicServiceExtSpringDataJpaTests extends AbstractClinicServiceExtTests { + +} diff --git a/src/test/resources/spring/mvc-test-config.xml b/src/test/resources/spring/mvc-test-config.xml index ab3b93bce..86f22aaf3 100644 --- a/src/test/resources/spring/mvc-test-config.xml +++ b/src/test/resources/spring/mvc-test-config.xml @@ -4,9 +4,11 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - - + + + +