From 1260b6ec5fa776bb920b09af18f8bcdde9791003 Mon Sep 17 00:00:00 2001 From: Marty30 Date: Wed, 21 Jun 2017 11:32:14 +0200 Subject: [PATCH 1/8] Add selenium and two selenium tests to the project --- docker-compose.yml | 8 +- pom.xml | 444 +++++++++--------- .../utwente/bpsd/selenium/AddOwnerTest.java | 47 ++ .../utwente/bpsd/selenium/FindOwnerTest.java | 30 ++ .../bpsd/selenium/SeleniumBaseTest.java | 43 ++ 5 files changed, 353 insertions(+), 219 deletions(-) create mode 100644 src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java create mode 100644 src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java create mode 100644 src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java diff --git a/docker-compose.yml b/docker-compose.yml index b2c662c3f..73da6f62a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: - "8080:8080" links: - mysql:mysql + - selenium command: java -jar ./target/*.jar mysql: image: mysql @@ -15,4 +16,9 @@ services: - MYSQL_ROOT_PASSWORD=root - MYSQL_DATABASE=test volumes: - - "./conf.d:/etc/mysql/conf.d:ro" \ No newline at end of file + - "./conf.d:/etc/mysql/conf.d:ro" + selenium: + image: selenium/standalone-firefox + shm_size: 2g + ports: + - "4444:4444" diff --git a/pom.xml b/pom.xml index ff677d097..757c84577 100644 --- a/pom.xml +++ b/pom.xml @@ -1,229 +1,237 @@ - 4.0.0 - org.springframework.samples - spring-petclinic - 1.5.1 + 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"> + 4.0.0 + org.springframework.samples + spring-petclinic + 1.5.1 - - org.springframework.boot - spring-boot-starter-parent - 1.5.1.RELEASE - - petclinic - - - - - 1.8 - UTF-8 - UTF-8 - - - 3.3.6 - 1.11.4 - 2.2.4 - 1.8.0 - - 3.0.2.RELEASE - - 2.7 - - - - - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-cache - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - nz.net.ultraq.thymeleaf - thymeleaf-layout-dialect - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - org.hsqldb - hsqldb - runtime - - - mysql - mysql-connector-java - runtime - - - - - javax.cache - cache-api - - - org.ehcache - ehcache - - - - - org.webjars - webjars-locator - - - org.webjars - jquery - ${webjars-jquery.version} - - - org.webjars - jquery-ui - ${webjars-jquery-ui.version} - - - org.webjars - bootstrap - ${webjars-bootstrap.version} - - - - - org.springframework.boot - spring-boot-devtools - runtime - - - - - - + org.springframework.boot - spring-boot-maven-plugin - - - - - build-info - - - - ${project.build.sourceEncoding} - ${project.reporting.outputEncoding} - ${maven.compiler.source} - ${maven.compiler.target} - - - - - - - org.codehaus.mojo - cobertura-maven-plugin - ${cobertura.version} - - - - - - - clean - check - - - - + spring-boot-starter-parent + 1.5.1.RELEASE + + petclinic - - - pl.project13.maven - git-commit-id-plugin - - - - revision - - - - - true - yyyy-MM-dd'T'HH:mm:ssZ - true - ${project.build.outputDirectory}/git.properties - - false - - + - - ro.isdc.wro4j - wro4j-maven-plugin - ${wro4j.version} - - - generate-resources - - run - - - - - ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory - ${project.build.directory}/classes/static/resources/css - ${basedir}/src/main/wro/wro.xml - ${basedir}/src/main/wro/wro.properties - ${basedir}/src/main/less - - - + + 1.8 + UTF-8 + UTF-8 + + + 3.3.6 + 1.11.4 + 2.2.4 + 1.8.0 + + 3.0.2.RELEASE + + 2.7 + + 3.4.0 + + + + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-cache + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + nz.net.ultraq.thymeleaf + thymeleaf-layout-dialect + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + org.hsqldb + hsqldb + runtime + + + mysql + mysql-connector-java + runtime + + + + + javax.cache + cache-api + + + org.ehcache + ehcache + + + + + org.webjars + webjars-locator + + + org.webjars + jquery + ${webjars-jquery.version} + + + org.webjars + jquery-ui + ${webjars-jquery-ui.version} + + org.webjars bootstrap ${webjars-bootstrap.version} - - - - - - - - - - org.codehaus.mojo - cobertura-maven-plugin - ${cobertura.version} - - - html - - - - - - + + + + + org.springframework.boot + spring-boot-devtools + runtime + + + + + org.seleniumhq.selenium + selenium-java + ${selenium-java.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + build-info + + + + ${project.build.sourceEncoding} + ${project.reporting.outputEncoding} + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + + org.codehaus.mojo + cobertura-maven-plugin + ${cobertura.version} + + + + + + + clean + check + + + + + + + + pl.project13.maven + git-commit-id-plugin + + + + revision + + + + + true + yyyy-MM-dd'T'HH:mm:ssZ + true + ${project.build.outputDirectory}/git.properties + + false + + + + + ro.isdc.wro4j + wro4j-maven-plugin + ${wro4j.version} + + + generate-resources + + run + + + + + ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory + ${project.build.directory}/classes/static/resources/css + ${basedir}/src/main/wro/wro.xml + ${basedir}/src/main/wro/wro.properties + ${basedir}/src/main/less + + + + org.webjars + bootstrap + ${webjars-bootstrap.version} + + + + + + + + + + org.codehaus.mojo + cobertura-maven-plugin + ${cobertura.version} + + + html + + + + + + diff --git a/src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java b/src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java new file mode 100644 index 000000000..888e501c3 --- /dev/null +++ b/src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java @@ -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 AddOwnerTest extends SeleniumBaseTest { + public AddOwnerTest() throws MalformedURLException { + super(); + } + + @Test + @Category(SeleniumBaseTest.class) + public void addOwnerTest() { + 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")); + } + +} diff --git a/src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java b/src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java new file mode 100644 index 000000000..ff6700f6d --- /dev/null +++ b/src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java @@ -0,0 +1,30 @@ +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 FindOwnerTest extends SeleniumBaseTest { + public FindOwnerTest() throws MalformedURLException { + super(); + } + + @Test + @Category(SeleniumBaseTest.class) + public void findOwnerTest() { + 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); + } +} diff --git a/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java b/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java new file mode 100644 index 000000000..8b72d1edf --- /dev/null +++ b/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java @@ -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 SeleniumBaseTest { + protected final RemoteWebDriver driver; + public static final String BASE_URL = "http://pet-clinic:8080/"; +// public static final String BASE_URL = "http://localhost:8080/"; + + public SeleniumBaseTest() 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; + } +} From 162f86302677ca10ed9617117670f2c938351eac Mon Sep 17 00:00:00 2001 From: Sophie Lathouwers Date: Wed, 21 Jun 2017 11:50:27 +0200 Subject: [PATCH 2/8] Added failing test and fixed spacing in docker-compose.yml --- docker-compose.yml | 10 +++---- .../nl/utwente/bpsd/selenium/FailingTest.java | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 src/test/java/nl/utwente/bpsd/selenium/FailingTest.java diff --git a/docker-compose.yml b/docker-compose.yml index 73da6f62a..bb5601aec 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,8 +17,8 @@ services: - MYSQL_DATABASE=test volumes: - "./conf.d:/etc/mysql/conf.d:ro" - selenium: - image: selenium/standalone-firefox - shm_size: 2g - ports: - - "4444:4444" + selenium: + image: selenium/standalone-firefox + shm_size: 2g + ports: + - "4444:4444" diff --git a/src/test/java/nl/utwente/bpsd/selenium/FailingTest.java b/src/test/java/nl/utwente/bpsd/selenium/FailingTest.java new file mode 100644 index 000000000..403e2ce71 --- /dev/null +++ b/src/test/java/nl/utwente/bpsd/selenium/FailingTest.java @@ -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 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 FailingTest extends SeleniumBaseTest { + public FailingTest() throws MalformedURLException { + super(); + } + + @Test + @Category(SeleniumBaseTest.class) + public void failTest() { + Assert.fail(); + } + +} From 3fffb7234e5d2feaacc745f5c9f9a1cdfd47eec9 Mon Sep 17 00:00:00 2001 From: Marty30 Date: Wed, 21 Jun 2017 13:02:23 +0200 Subject: [PATCH 3/8] Selenium now uses the failsafe plugin --- .travis.yml | 13 ++++++- Dockerfile | 34 +++++++++---------- pom.xml | 28 +++++++++++++++ .../{AddOwnerTest.java => AddOwnerIT.java} | 8 ++--- .../nl/utwente/bpsd/selenium/FailingIT.java | 26 ++++++++++++++ .../nl/utwente/bpsd/selenium/FailingTest.java | 28 --------------- .../{FindOwnerTest.java => FindOwnerIT.java} | 10 +++--- ...eniumBaseTest.java => SeleniumBaseIT.java} | 4 +-- 8 files changed, 93 insertions(+), 58 deletions(-) rename src/test/java/nl/utwente/bpsd/selenium/{AddOwnerTest.java => AddOwnerIT.java} (88%) create mode 100644 src/test/java/nl/utwente/bpsd/selenium/FailingIT.java delete mode 100644 src/test/java/nl/utwente/bpsd/selenium/FailingTest.java rename src/test/java/nl/utwente/bpsd/selenium/{FindOwnerTest.java => FindOwnerIT.java} (65%) rename src/test/java/nl/utwente/bpsd/selenium/{SeleniumBaseTest.java => SeleniumBaseIT.java} (92%) diff --git a/.travis.yml b/.travis.yml index e55f2b2b6..d0ad0d56f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,19 @@ addons: 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 verify -Dskip.surefire.tests +# - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar + +after_script: + - docker-compose stop + - docker-compose rm cache: directories: diff --git a/Dockerfile b/Dockerfile index a1c890445..d258da6b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ -FROM maven:latest - -# Set the workdir -WORKDIR /app - -# Copy the source to the container -COPY . . - -# Build the project -RUN mvn package - -# Make the jar executable -RUN sh -c 'touch target/spring-petclinic-*.jar' - -#Start the project -ENV JAVA_OPTS="" -ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar target/spring-petclinic-*.jar" ] \ No newline at end of file +FROM maven:latest + +# Set the workdir +WORKDIR /app + +# Copy the source to the container +COPY . . + +# Build the project +RUN mvn package -Dskip.failsafe.tests + +# Make the jar executable +RUN sh -c 'touch target/spring-petclinic-*.jar' + +#Start the project +ENV JAVA_OPTS="" +ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar target/spring-petclinic-*.jar" ] diff --git a/pom.xml b/pom.xml index 757c84577..a0b3f0eba 100644 --- a/pom.xml +++ b/pom.xml @@ -128,6 +128,34 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + ${skip.surefire.tests} + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + ${skip.failsafe.tests} + + + + run-integration-tests + integration-test + + integration-test + verify + + + + org.springframework.boot spring-boot-maven-plugin diff --git a/src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java b/src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java similarity index 88% rename from src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java rename to src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java index 888e501c3..de1dfaba9 100644 --- a/src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java +++ b/src/test/java/nl/utwente/bpsd/selenium/AddOwnerIT.java @@ -14,14 +14,14 @@ import java.net.MalformedURLException; * @author Martijn * @since 21-6-2017. */ -public class AddOwnerTest extends SeleniumBaseTest { - public AddOwnerTest() throws MalformedURLException { +public class AddOwnerIT extends SeleniumBaseIT { + public AddOwnerIT() throws MalformedURLException { super(); } @Test - @Category(SeleniumBaseTest.class) - public void addOwnerTest() { + @Category(SeleniumBaseIT.class) + public void addOwnerIT() { driver.get(BASE_URL+"/owners/new"); //Add an owner diff --git a/src/test/java/nl/utwente/bpsd/selenium/FailingIT.java b/src/test/java/nl/utwente/bpsd/selenium/FailingIT.java new file mode 100644 index 000000000..87a26e3ad --- /dev/null +++ b/src/test/java/nl/utwente/bpsd/selenium/FailingIT.java @@ -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(); + } + +} diff --git a/src/test/java/nl/utwente/bpsd/selenium/FailingTest.java b/src/test/java/nl/utwente/bpsd/selenium/FailingTest.java deleted file mode 100644 index 403e2ce71..000000000 --- a/src/test/java/nl/utwente/bpsd/selenium/FailingTest.java +++ /dev/null @@ -1,28 +0,0 @@ -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 FailingTest extends SeleniumBaseTest { - public FailingTest() throws MalformedURLException { - super(); - } - - @Test - @Category(SeleniumBaseTest.class) - public void failTest() { - Assert.fail(); - } - -} diff --git a/src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java b/src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java similarity index 65% rename from src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java rename to src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java index ff6700f6d..17fcd7de4 100644 --- a/src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java +++ b/src/test/java/nl/utwente/bpsd/selenium/FindOwnerIT.java @@ -4,8 +4,6 @@ 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; @@ -14,14 +12,14 @@ import java.net.MalformedURLException; * @author Martijn * @since 21-6-2017. */ -public class FindOwnerTest extends SeleniumBaseTest { - public FindOwnerTest() throws MalformedURLException { +public class FindOwnerIT extends SeleniumBaseIT { + public FindOwnerIT() throws MalformedURLException { super(); } @Test - @Category(SeleniumBaseTest.class) - public void findOwnerTest() { + @Category(SeleniumBaseIT.class) + public void findOwnerIT() { driver.get(BASE_URL+"/owners/find"); fillTextField(By.name("lastName"),"Coleman"); driver.findElement(By.name("lastName")).submit(); diff --git a/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java b/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java similarity index 92% rename from src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java rename to src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java index 8b72d1edf..d4f701966 100644 --- a/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java +++ b/src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseIT.java @@ -14,12 +14,12 @@ import java.net.URL; * @author Martijn * @since 21-6-2017. */ -public class SeleniumBaseTest { +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 SeleniumBaseTest() throws MalformedURLException { + 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()); From f80905648c40a026bcfa82b328ac07f29c432407 Mon Sep 17 00:00:00 2001 From: Marty30 Date: Wed, 21 Jun 2017 13:04:38 +0200 Subject: [PATCH 4/8] Add docker to the travis config --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index d0ad0d56f..cb9f47b31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ language: java sudo: false install: true +services: + - docker + addons: sonarcloud: organization: "nqkavkey" From 90d10b70430b050f2c2efd649a4033dbb9c4bf01 Mon Sep 17 00:00:00 2001 From: Marty30 Date: Wed, 21 Jun 2017 13:10:51 +0200 Subject: [PATCH 5/8] Remove mysql from the docker-compose file --- docker-compose.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index bb5601aec..fba4e9a6c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,18 +5,18 @@ services: ports: - "8080:8080" links: - - mysql:mysql +# - mysql:mysql - selenium command: java -jar ./target/*.jar - mysql: - image: mysql - ports: - - "3306:3306" - environment: - - MYSQL_ROOT_PASSWORD=root - - MYSQL_DATABASE=test - volumes: - - "./conf.d:/etc/mysql/conf.d:ro" +# 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 From f8f68bfb82b5bf3f0370d2f2e55ed24be85e2e4b Mon Sep 17 00:00:00 2001 From: Marty30 Date: Wed, 21 Jun 2017 13:28:17 +0200 Subject: [PATCH 6/8] Make maven more quiet --- .travis.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cb9f47b31..be41421a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ before_script: - docker-compose up -d script: - - mvn verify -Dskip.surefire.tests + - mvn verify -Dskip.surefire.tests -q --batch-mode # - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar after_script: diff --git a/Dockerfile b/Dockerfile index d258da6b9..e43802fb4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /app COPY . . # Build the project -RUN mvn package -Dskip.failsafe.tests +RUN mvn package -Dskip.failsafe.tests -q --batch-mode # Make the jar executable RUN sh -c 'touch target/spring-petclinic-*.jar' From cb40c4276cdf795bddcb1f4e8809c31c1589900d Mon Sep 17 00:00:00 2001 From: Marty30 Date: Wed, 21 Jun 2017 13:41:05 +0200 Subject: [PATCH 7/8] Run ITs in docker --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index be41421a1..b800a7369 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,12 +20,12 @@ before_script: - docker-compose up -d script: - - mvn verify -Dskip.surefire.tests -q --batch-mode + - docker exec springpetclinic_pet-clinic_1 mvn verify -Dskip.surefire.tests -q --batch-mode # - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar after_script: - docker-compose stop - - docker-compose rm + - docker-compose rm -f cache: directories: From a1de7e2ca39a315951b3737e757571b7ccf1125c Mon Sep 17 00:00:00 2001 From: Sophie Lathouwers Date: Wed, 21 Jun 2017 13:41:32 +0200 Subject: [PATCH 8/8] Renamed AddVisitTest to AddVisitIT --- .../nl/utwente/bpsd/selenium/AddVisitIT.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/test/java/nl/utwente/bpsd/selenium/AddVisitIT.java diff --git a/src/test/java/nl/utwente/bpsd/selenium/AddVisitIT.java b/src/test/java/nl/utwente/bpsd/selenium/AddVisitIT.java new file mode 100644 index 000000000..c36098cda --- /dev/null +++ b/src/test/java/nl/utwente/bpsd/selenium/AddVisitIT.java @@ -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 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')]"))); + } + +}