mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-18 13:35:50 +00:00
Merge 54c8162fe3
into ffa967c94b
This commit is contained in:
commit
28df2847fa
18 changed files with 618 additions and 250 deletions
31
.travis.yml
31
.travis.yml
|
@ -1,2 +1,33 @@
|
|||
language: java
|
||||
sudo: false
|
||||
install: true
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
addons:
|
||||
sonarcloud:
|
||||
organization: "bpsdproject"
|
||||
token:
|
||||
secure: "FKHLAA1VC6XvrJTDFXwh7IvHAgX+hHkzuGmiOJ9RvguTkP8yQTQqczQA0QFUaCKoOXLQf7n1Xadx60vKDxk1FQS4GxhvB1n9muvhjkLOXstpRjKEBL/t3CgVeIYPdf676lT/vED2yeFmTC0BcC82k2h8dNpBpr2c/iRsHriiyf8NOOM9XO6sbDfPPGYhTzkuBRhplVZ6723z5KaHDvSgjQmT/dlIZkY00fqyVPI20JZqvScbR0/8QjED8jWtnlZpzU02lIrpkcIJF2gS4OGkucE1GBvJtkAejm5V2g++mdj3B+ja4x2rZmLmAhOVV2PzRatMSrEyoSCRpjXMf39WaTlehaii2foWPvj+CTl4iO4ApdVluFufS5EuPknJ3/pOQVAilR0qad3NBokUGCnfGhAqo06AA0aeLb05A3nfhT/CeOPEklwpkWNHNG6B4XWkNUH54WemqvmDvUjPspSbFlU3RBwjVcacj4Dyuh4eo48E/+bYnoIhaAZiyh/SXqrIx9Wh0COxYv1tgcqJ/xbDtJf3CZdjGZfKCpC3OUCliRTHtKQrzxQxai4oTlTtGTWhxm81BIOStRY0IgkTGvMiymv91wcWN6Q937D4CsRGJ7O4ZKWeqPXCmntVVqEiWd5av2Lpnv7W2QnajkcNZ4UyGtH3mzo4OykKGc9EV9fcu64="
|
||||
|
||||
jdk: oraclejdk8
|
||||
|
||||
install:
|
||||
- docker-compose build
|
||||
|
||||
before_script:
|
||||
- docker-compose up -d
|
||||
|
||||
script:
|
||||
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent test -Dskip.failsafe.tests sonar:sonar -Dsonar.pitest.mode=reuseReport
|
||||
- docker exec springpetclinic_pet-clinic_1 mvn verify -Dskip.surefire.tests -q --batch-mode
|
||||
|
||||
after_script:
|
||||
- docker-compose stop
|
||||
- docker-compose rm -f
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- '$HOME/.m2/repository'
|
||||
- '$HOME/.sonar/cache'
|
||||
|
|
18
Dockerfile
Normal file
18
Dockerfile
Normal file
|
@ -0,0 +1,18 @@
|
|||
FROM maven:latest
|
||||
|
||||
# Set the workdir
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the source to the container
|
||||
COPY . .
|
||||
|
||||
# Build the project
|
||||
RUN mvn package -Dskip.failsafe.tests -q --batch-mode && \
|
||||
mvn org.pitest:pitest-maven:mutationCoverage -q --batch-mode
|
||||
|
||||
# Copy and make the jar executable
|
||||
RUN sh -c 'mkdir dist/ && cp -a target/. dist/ && touch dist/spring-petclinic-*.jar'
|
||||
|
||||
#Start the project
|
||||
ENV JAVA_OPTS=""
|
||||
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar dist/spring-petclinic-*.jar" ]
|
|
@ -1,9 +1,23 @@
|
|||
mysql:
|
||||
image: mysql
|
||||
ports:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=root
|
||||
- MYSQL_DATABASE=test
|
||||
volumes:
|
||||
- "./conf.d:/etc/mysql/conf.d:ro"
|
||||
version: '2'
|
||||
services:
|
||||
pet-clinic:
|
||||
build: .
|
||||
ports:
|
||||
- "8080:8080"
|
||||
links:
|
||||
- selenium
|
||||
# - mysql:mysql
|
||||
# mysql:
|
||||
# image: mysql
|
||||
# ports:
|
||||
# - "3306:3306"
|
||||
# environment:
|
||||
# - MYSQL_ROOT_PASSWORD=root
|
||||
# - MYSQL_DATABASE=test
|
||||
# volumes:
|
||||
# - "./conf.d:/etc/mysql/conf.d:ro"
|
||||
selenium:
|
||||
image: selenium/standalone-firefox
|
||||
shm_size: 2g
|
||||
ports:
|
||||
- "4444:4444"
|
||||
|
|
482
pom.xml
482
pom.xml
|
@ -1,229 +1,275 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.samples</groupId>
|
||||
<artifactId>spring-petclinic</artifactId>
|
||||
<version>1.5.1</version>
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.samples.bpsd</groupId>
|
||||
<artifactId>spring-petclinic</artifactId>
|
||||
<version>1.5.1</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.1.RELEASE</version>
|
||||
</parent>
|
||||
<name>petclinic</name>
|
||||
|
||||
<properties>
|
||||
|
||||
<!-- Generic properties -->
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<!-- Web dependencies -->
|
||||
<webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
|
||||
<webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version>
|
||||
<webjars-jquery.version>2.2.4</webjars-jquery.version>
|
||||
<wro4j.version>1.8.0</wro4j.version>
|
||||
|
||||
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
|
||||
|
||||
<cobertura.version>2.7</cobertura.version>
|
||||
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring and Spring Boot dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
||||
<artifactId>thymeleaf-layout-dialect</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Databases - Uses HSQL by default -->
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- caching -->
|
||||
<dependency>
|
||||
<groupId>javax.cache</groupId>
|
||||
<artifactId>cache-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- webjars -->
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>webjars-locator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>jquery</artifactId>
|
||||
<version>${webjars-jquery.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>jquery-ui</artifactId>
|
||||
<version>${webjars-jquery-ui.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>bootstrap</artifactId>
|
||||
<version>${webjars-bootstrap.version}</version>
|
||||
</dependency>
|
||||
<!-- end of webjars -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Spring Boot Actuator displays build-related information
|
||||
if a META-INF/build-info.properties file is present -->
|
||||
<goals>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<additionalProperties>
|
||||
<encoding.source>${project.build.sourceEncoding}</encoding.source>
|
||||
<encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting>
|
||||
<java.source>${maven.compiler.source}</java.source>
|
||||
<java.target>${maven.compiler.target}</java.target>
|
||||
</additionalProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<version>${cobertura.version}</version>
|
||||
<configuration>
|
||||
<check />
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.1.RELEASE</version>
|
||||
</parent>
|
||||
<name>petclinic</name>
|
||||
|
||||
<!-- Spring Boot Actuator displays build-related information if a git.properties
|
||||
file is present at the classpath -->
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<verbose>true</verbose>
|
||||
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
|
||||
<generateGitPropertiesFile>true</generateGitPropertiesFile>
|
||||
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
|
||||
</generateGitPropertiesFilename>
|
||||
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<properties>
|
||||
|
||||
<plugin>
|
||||
<groupId>ro.isdc.wro4j</groupId>
|
||||
<artifactId>wro4j-maven-plugin</artifactId>
|
||||
<version>${wro4j.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
|
||||
<cssDestinationFolder>${project.build.directory}/classes/static/resources/css</cssDestinationFolder>
|
||||
<wroFile>${basedir}/src/main/wro/wro.xml</wroFile>
|
||||
<extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile>
|
||||
<contextFolder>${basedir}/src/main/less</contextFolder>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<!-- Generic properties -->
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<!-- Web dependencies -->
|
||||
<webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
|
||||
<webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version>
|
||||
<webjars-jquery.version>2.2.4</webjars-jquery.version>
|
||||
<wro4j.version>1.8.0</wro4j.version>
|
||||
|
||||
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
|
||||
|
||||
<cobertura.version>2.7</cobertura.version>
|
||||
|
||||
<selenium-java.version>3.4.0</selenium-java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring and Spring Boot dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
||||
<artifactId>thymeleaf-layout-dialect</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Databases - Uses HSQL by default -->
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- caching -->
|
||||
<dependency>
|
||||
<groupId>javax.cache</groupId>
|
||||
<artifactId>cache-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- webjars -->
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>webjars-locator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>jquery</artifactId>
|
||||
<version>${webjars-jquery.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>jquery-ui</artifactId>
|
||||
<version>${webjars-jquery-ui.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>bootstrap</artifactId>
|
||||
<version>${webjars-bootstrap.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<!-- integrate maven-cobertura-plugin to project site -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<version>${cobertura.version}</version>
|
||||
<configuration>
|
||||
<formats>
|
||||
<format>html</format>
|
||||
</formats>
|
||||
<check />
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
</dependency>
|
||||
<!-- end of webjars -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!--Selenium-->
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>${selenium-java.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- skips surefire tests without skipping failsafe tests.
|
||||
Property value seems to magically default to false -->
|
||||
<skipTests>${skip.surefire.tests}</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- skips failsafe tests without skipping surefire tests.
|
||||
Property value seems to magically default to false -->
|
||||
<skipTests>${skip.failsafe.tests}</skipTests>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>run-integration-tests</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.pitest</groupId>
|
||||
<artifactId>pitest-maven</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<configuration>
|
||||
<outputFormats>
|
||||
<outputFormat>XML</outputFormat>
|
||||
</outputFormats>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Spring Boot Actuator displays build-related information
|
||||
if a META-INF/build-info.properties file is present -->
|
||||
<goals>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<additionalProperties>
|
||||
<encoding.source>${project.build.sourceEncoding}</encoding.source>
|
||||
<encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting>
|
||||
<java.source>${maven.compiler.source}</java.source>
|
||||
<java.target>${maven.compiler.target}</java.target>
|
||||
</additionalProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<version>${cobertura.version}</version>
|
||||
<configuration>
|
||||
<check/>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Spring Boot Actuator displays build-related information if a git.properties
|
||||
file is present at the classpath -->
|
||||
<plugin>
|
||||
<groupId>pl.project13.maven</groupId>
|
||||
<artifactId>git-commit-id-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<verbose>true</verbose>
|
||||
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
|
||||
<generateGitPropertiesFile>true</generateGitPropertiesFile>
|
||||
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
|
||||
</generateGitPropertiesFilename>
|
||||
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>ro.isdc.wro4j</groupId>
|
||||
<artifactId>wro4j-maven-plugin</artifactId>
|
||||
<version>${wro4j.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
|
||||
<cssDestinationFolder>${project.build.directory}/classes/static/resources/css</cssDestinationFolder>
|
||||
<wroFile>${basedir}/src/main/wro/wro.xml</wroFile>
|
||||
<extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile>
|
||||
<contextFolder>${basedir}/src/main/less</contextFolder>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>bootstrap</artifactId>
|
||||
<version>${webjars-bootstrap.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<!-- integrate maven-cobertura-plugin to project site -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<version>${cobertura.version}</version>
|
||||
<configuration>
|
||||
<formats>
|
||||
<format>html</format>
|
||||
</formats>
|
||||
<check/>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@SpringBootApplication
|
||||
public class PetClinicApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PetClinicApplication.class, args);
|
||||
}
|
||||
|
||||
|
|
|
@ -126,13 +126,13 @@ public class Owner extends Person {
|
|||
* @param name to test
|
||||
* @return true if pet name is already in use
|
||||
*/
|
||||
public Pet getPet(String name, boolean ignoreNew) {
|
||||
name = name.toLowerCase();
|
||||
public Pet getPet(final String name, final boolean ignoreNew) {
|
||||
String lowerCaseName = name.toLowerCase();
|
||||
for (Pet pet : getPetsInternal()) {
|
||||
if (!ignoreNew || !pet.isNew()) {
|
||||
String compName = pet.getName();
|
||||
compName = compName.toLowerCase();
|
||||
if (compName.equals(name)) {
|
||||
if (compName.equals(lowerCaseName)) {
|
||||
return pet;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class OwnerController {
|
|||
}
|
||||
|
||||
@RequestMapping(value = "/owners", method = RequestMethod.GET)
|
||||
public String processFindForm(Owner owner, BindingResult result, Map<String, Object> model) {
|
||||
public String processFindForm(final Owner owner, final BindingResult result, final Map<String, Object> model) {
|
||||
|
||||
// allow parameterless GET request for /owners to return all records
|
||||
if (owner.getLastName() == null) {
|
||||
|
@ -93,8 +93,8 @@ class OwnerController {
|
|||
return "owners/findOwners";
|
||||
} else if (results.size() == 1) {
|
||||
// 1 owner found
|
||||
owner = results.iterator().next();
|
||||
return "redirect:/owners/" + owner.getId();
|
||||
Owner foundOwner = results.iterator().next();
|
||||
return "redirect:/owners/" + foundOwner.getId();
|
||||
} else {
|
||||
// multiple owners found
|
||||
model.put("selections", results);
|
||||
|
|
|
@ -31,8 +31,7 @@ class CrashController {
|
|||
|
||||
@RequestMapping(value = "/oups", method = RequestMethod.GET)
|
||||
public String triggerException() {
|
||||
throw new RuntimeException(
|
||||
"Expected: controller used to showcase what " + "happens when an exception is thrown");
|
||||
throw new ExampleException("Expected: controller used to showcase what happens when an exception is thrown");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package org.springframework.samples.petclinic.system;
|
||||
|
||||
/**
|
||||
* @author Martijn
|
||||
* @since 21-6-2017.
|
||||
*/
|
||||
public class ExampleException extends RuntimeException {
|
||||
public ExampleException(String message) {
|
||||
super(ExampleException.class.getSimpleName() + ": " + message);
|
||||
}
|
||||
|
||||
protected ExampleException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(ExampleException.class.getSimpleName() + ": " + message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
|
@ -31,11 +31,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
@Controller
|
||||
class VetController {
|
||||
|
||||
private final VetRepository vets;
|
||||
private final VetRepository vetRepository;
|
||||
|
||||
@Autowired
|
||||
public VetController(VetRepository clinicService) {
|
||||
this.vets = clinicService;
|
||||
this.vetRepository = clinicService;
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/vets.html" })
|
||||
|
@ -43,7 +43,7 @@ class VetController {
|
|||
// Here we are returning an object of type 'Vets' rather than a collection of Vet
|
||||
// objects so it is simpler for Object-Xml mapping
|
||||
Vets vets = new Vets();
|
||||
vets.getVetList().addAll(this.vets.findAll());
|
||||
vets.getVetList().addAll(this.vetRepository.findAll());
|
||||
model.put("vets", vets);
|
||||
return "vets/vetList";
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class VetController {
|
|||
// Here we are returning an object of type 'Vets' rather than a collection of Vet
|
||||
// objects so it is simpler for JSon/Object mapping
|
||||
Vets vets = new Vets();
|
||||
vets.getVetList().addAll(this.vets.findAll());
|
||||
vets.getVetList().addAll(this.vetRepository.findAll());
|
||||
return vets;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.springframework.samples.petclinic.vet;
|
|||
import java.util.Collection;
|
||||
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -40,7 +39,7 @@ public interface VetRepository extends Repository<Vet, Integer> {
|
|||
*/
|
||||
@Transactional(readOnly = true)
|
||||
@Cacheable("vets")
|
||||
Collection<Vet> findAll() throws DataAccessException;
|
||||
Collection<Vet> findAll();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -30,14 +30,14 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
@XmlRootElement
|
||||
public class Vets {
|
||||
|
||||
private List<Vet> vets;
|
||||
private List<Vet> vetList;
|
||||
|
||||
@XmlElement
|
||||
public List<Vet> getVetList() {
|
||||
if (vets == null) {
|
||||
vets = new ArrayList<>();
|
||||
if (vetList == null) {
|
||||
vetList = new ArrayList<>();
|
||||
}
|
||||
return vets;
|
||||
return vetList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.springframework.samples.petclinic.visit;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.samples.petclinic.model.BaseEntity;
|
||||
|
||||
|
@ -38,7 +37,7 @@ public interface VisitRepository extends Repository<Visit, Integer> {
|
|||
* @param visit the <code>Visit</code> to save
|
||||
* @see BaseEntity#isNew
|
||||
*/
|
||||
void save(Visit visit) throws DataAccessException;
|
||||
void save(Visit visit);
|
||||
|
||||
List<Visit> findByPetId(Integer petId);
|
||||
|
||||
|
|
52
src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java
Normal file
52
src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package nl.utwente.bpsd.selenium;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
* @author Martijn
|
||||
* @since 21-6-2017.
|
||||
*/
|
||||
public class AddOwnerIT extends SeleniumBaseIT {
|
||||
public AddOwnerIT() throws MalformedURLException {
|
||||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(SeleniumBaseIT.class)
|
||||
public void addOwnerIT() {
|
||||
driver.get(BASE_URL+"/owners/new");
|
||||
|
||||
//Add an owner
|
||||
fillTextField(By.name("firstName"), "Sophie");
|
||||
fillTextField(By.name("lastName"), "Lathouwers");
|
||||
fillTextField(By.name("address"), "Homeroad 12");
|
||||
fillTextField(By.name("city"), "Enschede");
|
||||
fillTextField(By.name("telephone"), "0534890000");
|
||||
driver.findElement(By.name("telephone")).submit();
|
||||
waitForPageToLoad();
|
||||
waitFor(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[text()='Sophie Lathouwers']")));
|
||||
Assert.assertTrue("Could not locate \"Sophie Lathouwers\" on the page. This is the html of the current page: "+getHTML(), pageContainsText("Sophie Lathouwers"));
|
||||
|
||||
//Add a pet
|
||||
//The link text has \n thats why it cannot find it
|
||||
waitFor(ExpectedConditions.presenceOfAllElementsLocatedBy(By.partialLinkText("Add")));
|
||||
driver.findElement(By.partialLinkText("Add")).click();
|
||||
waitForPageToLoad();
|
||||
fillTextField(By.name("name"), "Thumper");
|
||||
fillTextField(By.name("birthDate"), "1942/08/09");
|
||||
new Select(driver.findElement(By.name("type"))).selectByValue("hamster");
|
||||
driver.findElement(By.name("name")).submit();
|
||||
|
||||
waitForPageToLoad();
|
||||
Assert.assertTrue("Could not locate \"Thumper\" on the page. This is the html of the current page: "+getHTML(),pageContainsText("Thumper"));
|
||||
setTestFinished();
|
||||
}
|
||||
|
||||
}
|
60
src/test/java/nl/utwente/bpsd/selenium/AddVisitIT.java
Normal file
60
src/test/java/nl/utwente/bpsd/selenium/AddVisitIT.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package nl.utwente.bpsd.selenium;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Sophie
|
||||
* @since 21-6-2017.
|
||||
*/
|
||||
public class AddVisitIT extends SeleniumBaseIT {
|
||||
public AddVisitIT() throws MalformedURLException {
|
||||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(SeleniumBaseIT.class)
|
||||
public void editPetNameAndAddAVisit() {
|
||||
driver.get(BASE_URL+"/owners/find");
|
||||
|
||||
driver.findElement(By.name("lastName")).submit();
|
||||
waitForPageToLoad();
|
||||
|
||||
//Go to first owner
|
||||
WebElement table = driver.findElement(By.tagName("table"));
|
||||
List<WebElement> cells = table.findElements(By.xpath(".//tr/td"));
|
||||
cells.get(0).findElement(By.xpath("a")).click();
|
||||
waitForPageToLoad();
|
||||
|
||||
//Go to edit page of first pet
|
||||
driver.findElement(By.xpath("//table//tr/td/table/tbody//a[contains(text(),'Edit')]")).click();
|
||||
waitForPageToLoad();
|
||||
|
||||
//Edit Name of pet
|
||||
fillTextField(By.name("name"), "foobar");
|
||||
driver.findElement(By.name("name")).submit();
|
||||
|
||||
|
||||
waitForPageToLoad();
|
||||
Assert.assertNotNull(driver.findElement(By.xpath("//table//tr/td/dl/dd[contains(text(), 'foobar')]")));
|
||||
|
||||
driver.findElement(By.xpath("//table//tr/td/table/tbody//a[contains(text(),'Add')]")).click();
|
||||
waitForPageToLoad();
|
||||
|
||||
|
||||
fillTextField(By.name("date"), "2017/12/12");
|
||||
fillTextField(By.name("description"), "Foobar check for disease");
|
||||
driver.findElement(By.name("date")).submit();
|
||||
waitForPageToLoad();
|
||||
Assert.assertNotNull(driver.findElement(By.xpath("//table//tr/td/table/tbody//td[contains(text(), '2017-12-12')]")));
|
||||
|
||||
setTestFinished();
|
||||
}
|
||||
|
||||
}
|
33
src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java
Normal file
33
src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package nl.utwente.bpsd.selenium;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martijn
|
||||
* @since 21-6-2017.
|
||||
*/
|
||||
public class FindOwnerIT extends SeleniumBaseIT {
|
||||
public FindOwnerIT() throws MalformedURLException {
|
||||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(SeleniumBaseIT.class)
|
||||
public void findOwnerIT() {
|
||||
driver.get(BASE_URL+"/owners/find");
|
||||
fillTextField(By.name("lastName"),"Coleman");
|
||||
driver.findElement(By.name("lastName")).submit();
|
||||
waitForPageToLoad();
|
||||
Assert.assertTrue("Could not find \"Jean Coleman\" on the current page. This is the html of the current page: "+getHTML(),driver.findElements(By.xpath("//*[text()='Jean Coleman']")).size() == 1);
|
||||
setTestFinished();
|
||||
}
|
||||
|
||||
}
|
102
src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java
Normal file
102
src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
package nl.utwente.bpsd.selenium;
|
||||
|
||||
import org.junit.After;
|
||||
import org.openqa.selenium.*;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.remote.Augmenter;
|
||||
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||
import org.openqa.selenium.support.ui.ExpectedCondition;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Martijn
|
||||
* @since 21-6-2017.
|
||||
*/
|
||||
public class SeleniumBaseIT {
|
||||
protected final WebDriver driver;
|
||||
private boolean testFinished = false;
|
||||
public static final String BASE_URL = "http://pet-clinic:8080/";
|
||||
// public static final String BASE_URL = "http://localhost:8080/";
|
||||
|
||||
public SeleniumBaseIT() throws MalformedURLException {
|
||||
// System.setProperty("webdriver.chrome.driver","C:\\Users\\marti\\Downloads\\chromedriver_win32\\chromedriver.exe");
|
||||
// this.driver = new ChromeDriver();
|
||||
|
||||
this.driver = new Augmenter().augment(new RemoteWebDriver(new URL("http://selenium:4444/wd/hub"), DesiredCapabilities.firefox()));
|
||||
driver.get(BASE_URL);
|
||||
}
|
||||
|
||||
public void fillTextField(By by, String text) {
|
||||
driver.findElement(by).clear();
|
||||
driver.findElement(by).sendKeys(text);
|
||||
}
|
||||
|
||||
protected void setTestFinished() {
|
||||
testFinished = true;
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
if (!testFinished) {
|
||||
if (driver instanceof TakesScreenshot) {
|
||||
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
||||
Logger.getLogger(this.getClass().getName()).warning(screenshot.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
driver.close();
|
||||
}
|
||||
|
||||
|
||||
protected boolean pageContainsText(String text) {
|
||||
return driver.findElements(By.xpath("//*[text()='" + text + "']")).size() == 1;
|
||||
}
|
||||
|
||||
public String getHTML() {
|
||||
return driver.findElement(By.xpath("//html")).getAttribute("innerHTML");
|
||||
}
|
||||
|
||||
protected void waitForPageToLoad() {
|
||||
waitFor(new FixedPeriod(333));
|
||||
waitFor(new PageLoadedExpectedCondition());
|
||||
}
|
||||
|
||||
protected void waitFor(ExpectedCondition<?> condition) {
|
||||
new WebDriverWait(driver, 3).until(condition);
|
||||
}
|
||||
|
||||
private class PageLoadedExpectedCondition implements ExpectedCondition<Boolean> {
|
||||
|
||||
@Override
|
||||
public Boolean apply(WebDriver webDriver) {
|
||||
if (webDriver instanceof JavascriptExecutor) {
|
||||
return ((JavascriptExecutor) webDriver).executeScript("return document.readyState").equals("complete");
|
||||
}
|
||||
throw new ClassCastException("This webdriver is not able to execute javascript.");
|
||||
}
|
||||
}
|
||||
|
||||
protected class FixedPeriod implements ExpectedCondition<Boolean> {
|
||||
private final int time;
|
||||
|
||||
public FixedPeriod(int timeInMilliseconds) {
|
||||
this.time = timeInMilliseconds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(WebDriver webDriver) {
|
||||
try {
|
||||
Thread.sleep(time);
|
||||
return true;
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue