mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-05-24 03:59:38 +00:00
Revert "Remove redundant component scan filter"
This reverts commit ab56724285
.
This commit is contained in:
parent
8472aa039e
commit
827dc12325
2 changed files with 14 additions and 24 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,8 +2,6 @@ target/*
|
||||||
.settings/*
|
.settings/*
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
.factorypath
|
|
||||||
.attach_pid*
|
|
||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
/target
|
/target
|
||||||
|
|
|
@ -16,14 +16,16 @@
|
||||||
|
|
||||||
package org.springframework.samples.petclinic.service;
|
package org.springframework.samples.petclinic.service;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
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.orm.jpa.DataJpaTest;
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.samples.petclinic.owner.Owner;
|
import org.springframework.samples.petclinic.owner.Owner;
|
||||||
import org.springframework.samples.petclinic.owner.OwnerRepository;
|
import org.springframework.samples.petclinic.owner.OwnerRepository;
|
||||||
import org.springframework.samples.petclinic.owner.Pet;
|
import org.springframework.samples.petclinic.owner.Pet;
|
||||||
|
@ -33,32 +35,22 @@ import org.springframework.samples.petclinic.vet.Vet;
|
||||||
import org.springframework.samples.petclinic.vet.VetRepository;
|
import org.springframework.samples.petclinic.vet.VetRepository;
|
||||||
import org.springframework.samples.petclinic.visit.Visit;
|
import org.springframework.samples.petclinic.visit.Visit;
|
||||||
import org.springframework.samples.petclinic.visit.VisitRepository;
|
import org.springframework.samples.petclinic.visit.VisitRepository;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test of the Service and the Repository layer.
|
* Integration test of the Service and the Repository layer.
|
||||||
* <p>
|
* <p>
|
||||||
* ClinicServiceSpringDataJpaTests subclasses benefit from the following services provided
|
* ClinicServiceSpringDataJpaTests subclasses benefit from the following services provided by the Spring
|
||||||
* by the Spring TestContext Framework:
|
* TestContext Framework: </p> <ul> <li><strong>Spring IoC container caching</strong> which spares us unnecessary set up
|
||||||
* </p>
|
* time between test execution.</li> <li><strong>Dependency Injection</strong> of test fixture instances, meaning that
|
||||||
* <ul>
|
* we don't need to perform application context lookups. See the use of {@link Autowired @Autowired} on the <code>{@link
|
||||||
* <li><strong>Spring IoC container caching</strong> which spares us unnecessary set up
|
* ClinicServiceTests#clinicService clinicService}</code> instance variable, which uses autowiring <em>by
|
||||||
* time between test execution.</li>
|
* type</em>. <li><strong>Transaction management</strong>, meaning each test method is executed in its own transaction,
|
||||||
* <li><strong>Dependency Injection</strong> of test fixture instances, meaning that we
|
* which is automatically rolled back by default. Thus, even if tests insert or otherwise change database state, there
|
||||||
* don't need to perform application context lookups. See the use of
|
* is no need for a teardown or cleanup script. <li> An {@link org.springframework.context.ApplicationContext
|
||||||
* {@link Autowired @Autowired} on the <code>{@link
|
* ApplicationContext} is also inherited and can be used for explicit bean lookup if necessary. </li> </ul>
|
||||||
* ClinicServiceTests#clinicService clinicService}</code> instance variable, which uses
|
|
||||||
* autowiring <em>by type</em>.
|
|
||||||
* <li><strong>Transaction management</strong>, 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.
|
|
||||||
* <li>An {@link org.springframework.context.ApplicationContext ApplicationContext} is
|
|
||||||
* also inherited and can be used for explicit bean lookup if necessary.</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
*
|
||||||
* @author Ken Krebs
|
* @author Ken Krebs
|
||||||
* @author Rod Johnson
|
* @author Rod Johnson
|
||||||
|
@ -69,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DataJpaTest
|
@DataJpaTest(includeFilters = @ComponentScan.Filter(Service.class))
|
||||||
public class ClinicServiceTests {
|
public class ClinicServiceTests {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
Loading…
Reference in a new issue