mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:15:50 +00:00
Merge branch 'master' of https://github.com/marty30/spring-petclinic
This commit is contained in:
commit
a5c39a50cf
10 changed files with 487 additions and 249 deletions
18
.travis.yml
18
.travis.yml
|
@ -2,16 +2,30 @@ language: java
|
|||
sudo: false
|
||||
install: true
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
addons:
|
||||
sonarcloud:
|
||||
organization: "bpsdproject"
|
||||
token:
|
||||
secure: "GBSEwXoZaohdFQyW5yJ3h6t8+HIztd+sEMS8jt10zo5tnenrGNv59YTl7B5VwxR2X/mJcdLsouR4z81TZfP4FX93NZAKwAdkj1d3yAyvEDYSlLywI7Xp3BGcO7Zc4mnHAU+yMhVI98Ww6C45OjirUgBT8STmjLTXk2yuA9T6IttwAmGdLzzzPjon710/6mIY3MzoqRpyhGhuJJjbJLA9BM5h1X79ikbOMk4e2ig3KaTIANS3oeCiQlNHgdikBZcsxow7qMXA5d8mgrBJnKH52EerLbMgVuKPBxdV+RMZQxOLZR6xzg5EQVUpoXCG8EqMbZw6lEdqfIYasm8EPQPaRM4fT6zIbJoQEFFXCIL1Wht7h0pO5RTavPE9jcpjni/QG+MAcr+v80/8RGOQ5MhQ/vF6T5DDf6J/03zAGX4LpPOb7s/8YuWWz+wB+uFYXsdZLOhFb8uuAyEiBzyXIn3ZgkLHxo57sGVgfSDiLgKGea7fIw+xN72JzTKts19jR1x+Sy6SvIgOJdjdmV+qzpbkn1nFtXo0t73RxwQkLLBx5hin02fEr1jWVXszVGCqKrxwglE0oTucMP6qtujMoqNo+eUUE064IAhRl9EPPcDMezctIKLp4vTUP3X5RCL1KRfE8uzeaY+Nnd+/DCh71Nhr4AHm570ISw6q7mKeStaB1dQ="
|
||||
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 install sonar:sonar
|
||||
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Dskip.failsafe.tests sonar:sonar
|
||||
- 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:
|
||||
|
|
|
@ -7,7 +7,7 @@ WORKDIR /app
|
|||
COPY . .
|
||||
|
||||
# Build the project
|
||||
RUN mvn package
|
||||
RUN mvn package -Dskip.failsafe.tests -q --batch-mode
|
||||
|
||||
# Make the jar executable
|
||||
RUN sh -c 'touch target/spring-petclinic-*.jar'
|
||||
|
|
|
@ -5,14 +5,20 @@ services:
|
|||
ports:
|
||||
- "8080:8080"
|
||||
links:
|
||||
- mysql:mysql
|
||||
# - mysql:mysql
|
||||
- selenium
|
||||
command: java -jar ./target/*.jar
|
||||
mysql:
|
||||
image: 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:
|
||||
- "3306:3306"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=root
|
||||
- MYSQL_DATABASE=test
|
||||
volumes:
|
||||
- "./conf.d:/etc/mysql/conf.d:ro"
|
||||
- "4444:4444"
|
||||
|
|
40
pom.xml
40
pom.xml
|
@ -31,6 +31,7 @@
|
|||
|
||||
<cobertura.version>2.7</cobertura.version>
|
||||
|
||||
<selenium-java.version>3.4.0</selenium-java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -116,10 +117,45 @@
|
|||
<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.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
@ -146,7 +182,7 @@
|
|||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<version>${cobertura.version}</version>
|
||||
<configuration>
|
||||
<check />
|
||||
<check/>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -220,7 +256,7 @@
|
|||
<formats>
|
||||
<format>html</format>
|
||||
</formats>
|
||||
<check />
|
||||
<check/>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
@ -11,6 +11,3 @@ sonar.language=java
|
|||
|
||||
# Encoding of the source files
|
||||
sonar.sourceEncoding=UTF-8
|
||||
|
||||
sonar.organization=ihristovut-github
|
||||
sonar.login=CqXf1kvNas7kaHHD3TKCcVrAL//0kdYsg/EjVphwABi7JsKILKGHSPiu4JZNG0fQf9DQZpAMBolTnVEyBC89sCR2NalML0m+MZZzBeihvnhqo8wETWoyGvnkPrLe9WILiZBK591qOVRoyipWMqYacyiV42mDpJjTcMJf1HkDPDxcD7kCQTw6qo3TLXbpphR8Y8LeZMDsty0HxPc02QtKS5kOTCiW7NljKWXdnsNDc2ZrGQDj7zVNRsYZ5ULgH8Psi06I7vC2HS9/o7QJcc42nRcoFzkGjVxWEBYPS9r11GQoUM+FwRCL/CKGv2Xzw2H7h/5zrJ89A0ZxHyHR4fKQTv4MRkCHj5WIMSL9a9K1E6nnP9Rk6OTzbKAr+iPt1IMRvU5lxsEzy5yZwOaGw9t6ebtdo8PB6IxVeNVwsg2rFTjeB+G/ct6eOnCU8Kd9yB5WAeA2ySZf9qBIjHKReq1fS9pI9/ps+85a+irW8Ei6TSD3JFWI6wkWPAG00NErWmeWN1AWWgmR16u8uXMQxQcCHRUs1To5aNV4HsNtCqbZOMe8VtH6MF0Yir2vVLG7Ljes5Il1hp2Qhsqxqv2aWmgbtiM6yobJTUMYpZLVuXml5RDoq72b+wgJduH7gwy0H0FzvRQKn+NTEDcKeEt06nI0U42F8mb6TDYeSQsF038rDs8=
|
||||
|
|
47
src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java
Normal file
47
src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
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 org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
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();
|
||||
Assert.assertTrue(pageContainsText("Sophie Lathouwers"));
|
||||
|
||||
//Add a pet
|
||||
new WebDriverWait(driver, 3).until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.linkText("Add New Pet")));
|
||||
driver.findElement(By.linkText("Add New Pet")).click();
|
||||
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();
|
||||
|
||||
Assert.assertTrue(pageContainsText("Thumper"));
|
||||
}
|
||||
|
||||
}
|
41
src/test/java/nl/utwente/bpsd/selenium/AddVisitIT.java
Normal file
41
src/test/java/nl/utwente/bpsd/selenium/AddVisitIT.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
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 Martijn
|
||||
* @since 21-6-2017.
|
||||
*/
|
||||
public class AddVisitIT extends SeleniumBaseIT {
|
||||
public AddVisitIT() throws MalformedURLException {
|
||||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(SeleniumBaseIT.class)
|
||||
public void addOwnerTest() {
|
||||
driver.findElement(By.name("lastName")).submit();
|
||||
|
||||
//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();
|
||||
|
||||
//Go to edit page of first pet
|
||||
driver.findElement(By.xpath("//table//tr/td/table/tbody//a[text()='Edit Pet']")).click();
|
||||
|
||||
//Edit Name of pet
|
||||
fillTextField(By.name("name"), "foobar");
|
||||
driver.findElement(By.name("name")).submit();
|
||||
|
||||
Assert.assertNotNull(driver.findElement(By.xpath("//table//tr/td/dl/dd/[contains(text(), 'foobar')]")));
|
||||
}
|
||||
|
||||
}
|
26
src/test/java/nl/utwente/bpsd/selenium/FailingIT.java
Normal file
26
src/test/java/nl/utwente/bpsd/selenium/FailingIT.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package nl.utwente.bpsd.selenium;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
* @author Martijn
|
||||
* @since 21-6-2017.
|
||||
*/
|
||||
public class FailingIT extends SeleniumBaseIT {
|
||||
public FailingIT() throws MalformedURLException {
|
||||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Category(SeleniumBaseIT.class)
|
||||
@Ignore
|
||||
public void failIT() {
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
}
|
28
src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java
Normal file
28
src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
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 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();
|
||||
Assert.assertTrue(driver.findElementsByXPath("//*[text()='Jean Coleman']").size() == 1);
|
||||
}
|
||||
}
|
43
src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java
Normal file
43
src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package nl.utwente.bpsd.selenium;
|
||||
|
||||
import org.junit.After;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martijn
|
||||
* @since 21-6-2017.
|
||||
*/
|
||||
public class SeleniumBaseIT {
|
||||
protected final RemoteWebDriver driver;
|
||||
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 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);
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
driver.close();
|
||||
}
|
||||
|
||||
|
||||
protected boolean pageContainsText(String text) {
|
||||
return driver.findElementsByXPath("//*[text()='"+text+"']").size() == 1;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue