Просмотр исходного кода

Explicitly starting Jetty to run acceptance tests on Travis

Andy Marks 9 лет назад
Родитель
Сommit
e61d4a3ae3

+ 5
- 1
.travis.yml Просмотреть файл

@@ -1,3 +1,7 @@
1 1
 language: java
2 2
 jdk:
3
-  - oraclejdk8
3
+  - oraclejdk8
4
+
5
+before_script:
6
+  - mvn jetty:run  # start a Web server
7
+  - sleep 3 # give Web server some time to bind to sockets, etc

+ 7
- 7
pom.xml Просмотреть файл

@@ -109,14 +109,14 @@
109 109
         </plugin>
110 110
 
111 111
       <!-- Jetty plugin -->
112
-      <plugin>
113
-        <groupId>org.mortbay.jetty</groupId>
114
-        <artifactId>maven-jetty-plugin</artifactId>
115
-      </plugin>
112
+        <plugin>
113
+            <groupId>org.eclipse.jetty</groupId>
114
+            <artifactId>jetty-maven-plugin</artifactId>
115
+        </plugin>
116 116
 
117
-      <plugin>
118
-        <artifactId>maven-jar-plugin</artifactId>
119
-        <version>${maven-jar-plugin.version}</version>
117
+        <plugin>
118
+            <artifactId>maven-jar-plugin</artifactId>
119
+            <version>${maven-jar-plugin.version}</version>
120 120
         <executions>
121 121
 
122 122
           <!-- Package booking service facade classes in separate jar -->

+ 19
- 3
src/test/java/se/citerus/dddsample/acceptance/CustomerAcceptanceTest.java Просмотреть файл

@@ -1,19 +1,35 @@
1 1
 package se.citerus.dddsample.acceptance;
2 2
 
3
+import org.junit.Before;
3 4
 import org.junit.Test;
4 5
 import se.citerus.dddsample.acceptance.pages.CustomerPage;
5 6
 import se.citerus.dddsample.acceptance.pages.LaunchPage;
6 7
 
7 8
 public class CustomerAcceptanceTest extends AbstractAcceptanceTest {
8
-    @Test
9
-    public void customerSiteIsOperational() {
9
+    private CustomerPage customerPage;
10
+
11
+    @Before
12
+    public void goToCustomerPage() {
10 13
         LaunchPage home = new LaunchPage(driver,"http://localhost:8080/");
14
+        customerPage = home.goToCustomerPage();
15
+    }
11 16
 
12
-        CustomerPage customerPage = home.goToCustomerPage();
17
+    @Test
18
+    public void customerSiteCanTrackValidCargo() {
13 19
         customerPage.trackCargoWithIdOf("ABC123");
14 20
         customerPage.expectCargoLocation("New York");
21
+    }
15 22
 
23
+    @Test
24
+    public void customerSiteErrorsOnInvalidCargo() {
25
+        customerPage.trackCargoWithIdOf("XXX999");
26
+        customerPage.expectErrorFor("Unknown tracking id");
27
+    }
16 28
 
29
+    @Test
30
+    public void customerSiteNotifiesOnMisdirectedCargo() {
31
+        customerPage.trackCargoWithIdOf("JKL567");
32
+        customerPage.expectNotificationOf("Cargo is misdirected");
17 33
     }
18 34
 
19 35
 }

+ 10
- 0
src/test/java/se/citerus/dddsample/acceptance/pages/CustomerPage.java Просмотреть файл

@@ -26,4 +26,14 @@ public class CustomerPage {
26 26
         WebElement cargoSummary = driver.findElement(By.cssSelector("#result h2"));
27 27
         assertTrue(cargoSummary.getText().endsWith(expectedLocation));
28 28
     }
29
+
30
+    public void expectErrorFor(String expectedErrorMessage) {
31
+        WebElement error = driver.findElement(By.cssSelector(".error"));
32
+        assertTrue(error.getText().endsWith(expectedErrorMessage));
33
+    }
34
+
35
+    public void expectNotificationOf(String expectedNotificationMessage) {
36
+        WebElement error = driver.findElement(By.cssSelector(".notify"));
37
+        assertTrue(error.getText().endsWith(expectedNotificationMessage));
38
+    }
29 39
 }

+ 1
- 1
src/test/java/se/citerus/dddsample/acceptance/pages/LaunchPage.java Просмотреть файл

@@ -12,7 +12,7 @@ public class LaunchPage {
12 12
     public LaunchPage(WebDriver driver, String baseUrl) {
13 13
         this.driver = driver;
14 14
         this.baseUrl = baseUrl;
15
-        driver.get(baseUrl + "dddsample");
15
+        driver.get(baseUrl);
16 16
         assertEquals("DDDSample", driver.getTitle());
17 17
     }
18 18