From 827dc12325c91a297952c7e55bbddd555ade5c81 Mon Sep 17 00:00:00 2001
From: Dave Syer
Date: Mon, 11 Feb 2019 08:07:52 +0000
Subject: [PATCH] Revert "Remove redundant component scan filter"
This reverts commit ab567242851166983e5f0140ab7593fd04c7d365.
---
.gitignore | 2 --
.../petclinic/service/ClinicServiceTests.java | 36 ++++++++-----------
2 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/.gitignore b/.gitignore
index 559982f3d86..8cdbd1ff48f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,8 +2,6 @@ target/*
.settings/*
.classpath
.project
-.factorypath
-.attach_pid*
.idea
*.iml
/target
diff --git a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java
index b5626fae56f..9f12151d993 100644
--- a/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java
+++ b/src/test/java/org/springframework/samples/petclinic/service/ClinicServiceTests.java
@@ -16,14 +16,16 @@
package org.springframework.samples.petclinic.service;
+import static org.assertj.core.api.Assertions.assertThat;
+
import java.time.LocalDate;
import java.util.Collection;
import org.junit.Test;
import org.junit.runner.RunWith;
-
import org.springframework.beans.factory.annotation.Autowired;
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.OwnerRepository;
import org.springframework.samples.petclinic.owner.Pet;
@@ -33,32 +35,22 @@
import org.springframework.samples.petclinic.vet.VetRepository;
import org.springframework.samples.petclinic.visit.Visit;
import org.springframework.samples.petclinic.visit.VisitRepository;
+import org.springframework.stereotype.Service;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
-import static org.assertj.core.api.Assertions.assertThat;
-
/**
* Integration test of the Service and the Repository layer.
*
- * ClinicServiceSpringDataJpaTests 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
- * ClinicServiceTests#clinicService clinicService}
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.
- *
+ * ClinicServiceSpringDataJpaTests 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
+ * ClinicServiceTests#clinicService clinicService}
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 Ken Krebs
* @author Rod Johnson
@@ -69,7 +61,7 @@
*/
@RunWith(SpringRunner.class)
-@DataJpaTest
+@DataJpaTest(includeFilters = @ComponentScan.Filter(Service.class))
public class ClinicServiceTests {
@Autowired