mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-19 14:05:50 +00:00
Merge branch 'master' into gera/jenkinsfile
This commit is contained in:
commit
e8b660bac0
4 changed files with 27 additions and 19 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,6 +2,8 @@ target/*
|
|||
.settings/*
|
||||
.classpath
|
||||
.project
|
||||
.factorypath
|
||||
.attach_pid*
|
||||
.idea
|
||||
*.iml
|
||||
/target
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.0.BUILD-SNAPSHOT</version>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
</parent>
|
||||
<name>petclinic</name>
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
<a href="https://speakerdeck.com/michaelisvy/spring-petclinic-sample-application">See the presentation here</a>
|
||||
|
||||
## Running petclinic locally
|
||||
Petclinic is a https://spring.io/guides/gs/spring-boot[Spring Boot] application built using https://spring.io/guides/gs/maven/[Maven]. You can build a jar file and run it from the command line:
|
||||
##
|
||||
|
||||
```
|
||||
git clone https://github.com/spring-projects/spring-petclinic.git
|
||||
|
@ -42,7 +40,7 @@ docker run -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:
|
|||
|
||||
## Working with Petclinic in your IDE
|
||||
|
||||
### prerequisites
|
||||
### Prerequisites
|
||||
The following items should be installed in your system:
|
||||
* Java 8 or newer.
|
||||
* git command line tool (https://help.github.com/articles/set-up-git)
|
||||
|
@ -113,7 +111,7 @@ Here is a list of them:
|
|||
|
||||
The [issue tracker](https://github.com/spring-projects/spring-petclinic/issues) is the preferred channel for bug reports, features requests and submitting pull requests.
|
||||
|
||||
For pull requests, editor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at <http://editorconfig.org>. If you have not previously done so, please fill out and submit the https://cla.pivotal.io/sign/spring[Contributor License Agreement].
|
||||
For pull requests, editor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at <http://editorconfig.org>. If you have not previously done so, please fill out and submit the [Contributor License Agreement](https://cla.pivotal.io/sign/spring).
|
||||
|
||||
# License
|
||||
|
||||
|
|
|
@ -16,16 +16,14 @@
|
|||
|
||||
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;
|
||||
|
@ -35,22 +33,32 @@ import org.springframework.samples.petclinic.vet.Vet;
|
|||
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.
|
||||
* <p>
|
||||
* ClinicServiceSpringDataJpaTests subclasses benefit from the following services provided by the Spring
|
||||
* TestContext Framework: </p> <ul> <li><strong>Spring IoC container caching</strong> which spares us unnecessary set up
|
||||
* time between test execution.</li> <li><strong>Dependency Injection</strong> of test fixture instances, meaning that
|
||||
* we don't need to perform application context lookups. See the use of {@link Autowired @Autowired} on the <code>{@link
|
||||
* 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>
|
||||
* ClinicServiceSpringDataJpaTests subclasses benefit from the following services provided
|
||||
* by the Spring TestContext Framework:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li><strong>Spring IoC container caching</strong> which spares us unnecessary set up
|
||||
* time between test execution.</li>
|
||||
* <li><strong>Dependency Injection</strong> of test fixture instances, meaning that we
|
||||
* don't need to perform application context lookups. See the use of
|
||||
* {@link Autowired @Autowired} on the <code>{@link
|
||||
* 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 Rod Johnson
|
||||
|
@ -61,7 +69,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
*/
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@DataJpaTest(includeFilters = @ComponentScan.Filter(Service.class))
|
||||
@DataJpaTest
|
||||
public class ClinicServiceTests {
|
||||
|
||||
@Autowired
|
||||
|
|
Loading…
Reference in a new issue