ソースを参照

Merge b85f89cc991180b9fe53d609af06a8755a1a22b9 into c2a877744a00d92ba70f01a01afba5e322f9c0a1

Andy Marks 9 年 前
コミット
e292300e01

+ 11
- 1
.travis.yml ファイルの表示

@@ -1,3 +1,13 @@
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 15
8
+
9
+script:
10
+  - mvn test
11
+
12
+after_script:
13
+  - mvn jetty:stop

+ 1
- 1
README.md ファイルの表示

@@ -9,4 +9,4 @@ Development blog: https://citerus.github.io/dddsample-core/
9 9
 
10 10
 Trello board: https://trello.com/b/PTDFRyxd
11 11
 
12
-[![Build Status](https://travis-ci.org/citerus/dddsample-core.svg?branch=master)](https://travis-ci.org/citerus/dddsample-core)
12
+[![Build Status](https://travis-ci.org/andeemarks/dddsample-core.svg?branch=master)](https://travis-ci.org/andeemarks/dddsample-core)

+ 44
- 7
pom.xml ファイルの表示

@@ -88,15 +88,40 @@
88 88
         </configuration>
89 89
       </plugin>
90 90
 
91
+        <!-- Downloader for Selenium server -->
92
+        <plugin>
93
+            <groupId>com.lazerycode.selenium</groupId>
94
+            <artifactId>driver-binary-downloader-maven-plugin</artifactId>
95
+            <version>1.0.14</version>
96
+            <configuration>
97
+                <!-- root directory that downloaded driver binaries will be stored in -->
98
+                <rootStandaloneServerDirectory>/tmp</rootStandaloneServerDirectory>
99
+                <!-- Where you want to store downloaded zip files -->
100
+                <downloadedZipFileDirectory>/tmp</downloadedZipFileDirectory>
101
+            </configuration>
102
+            <executions>
103
+                <execution>
104
+                    <goals>
105
+                        <goal>selenium</goal>
106
+                    </goals>
107
+                </execution>
108
+            </executions>
109
+        </plugin>
110
+
91 111
       <!-- Jetty plugin -->
92
-      <plugin>
93
-        <groupId>org.mortbay.jetty</groupId>
94
-        <artifactId>maven-jetty-plugin</artifactId>
95
-      </plugin>
112
+        <plugin>
113
+            <groupId>org.eclipse.jetty</groupId>
114
+            <artifactId>jetty-maven-plugin</artifactId>
115
+            <configuration>
116
+                <stopPort>9966</stopPort>
117
+                <stopKey>foo</stopKey>
118
+                <stopWait>10</stopWait>
119
+            </configuration>
120
+        </plugin>
96 121
 
97
-      <plugin>
98
-        <artifactId>maven-jar-plugin</artifactId>
99
-        <version>${maven-jar-plugin.version}</version>
122
+        <plugin>
123
+            <artifactId>maven-jar-plugin</artifactId>
124
+            <version>${maven-jar-plugin.version}</version>
100 125
         <executions>
101 126
 
102 127
           <!-- Package booking service facade classes in separate jar -->
@@ -141,6 +166,18 @@
141 166
       <scope>test</scope>
142 167
     </dependency>
143 168
     <dependency>
169
+      <groupId>org.seleniumhq.selenium</groupId>
170
+      <artifactId>selenium-server</artifactId>
171
+      <version>3.4.0</version>
172
+      <scope>test</scope>
173
+    </dependency>
174
+      <dependency>
175
+          <groupId>org.seleniumhq.selenium</groupId>
176
+          <artifactId>selenium-java</artifactId>
177
+          <version>2.28.0</version>
178
+          <scope>test</scope>
179
+      </dependency>
180
+      <dependency>
144 181
       <groupId>org.springframework</groupId>
145 182
       <artifactId>spring-webmvc</artifactId>
146 183
       <version>${spring.version}</version>

+ 4
- 1
src/main/java/se/citerus/dddsample/application/util/SampleDataGenerator.java ファイルの表示

@@ -1,5 +1,7 @@
1 1
 package se.citerus.dddsample.application.util;
2 2
 
3
+import org.apache.commons.logging.Log;
4
+import org.apache.commons.logging.LogFactory;
3 5
 import org.hibernate.SessionFactory;
4 6
 import org.hibernate.Session;
5 7
 import org.springframework.beans.factory.BeanFactoryUtils;
@@ -33,6 +35,7 @@ import java.util.Date;
33 35
  * Provides sample data.
34 36
  */
35 37
 public class SampleDataGenerator implements ServletContextListener {
38
+  private static final Log logger = LogFactory.getLog(SampleDataGenerator.class);
36 39
 
37 40
   private static final Timestamp base; 
38 41
   static {
@@ -202,7 +205,7 @@ public class SampleDataGenerator implements ServletContextListener {
202 205
   }
203 206
 
204 207
   public static void loadHibernateData(TransactionTemplate tt, final SessionFactory sf, final HandlingEventFactory handlingEventFactory, final HandlingEventRepository handlingEventRepository) {
205
-    System.out.println("*** Loading Hibernate data ***");
208
+    logger.info("*** Loading Hibernate data ***");
206 209
     tt.execute(new TransactionCallbackWithoutResult() {
207 210
       @Override
208 211
       protected void doInTransactionWithoutResult(TransactionStatus status) {

+ 2
- 2
src/main/resources/log4j.properties ファイルの表示

@@ -6,5 +6,5 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
6 6
 
7 7
 log4j.logger.net.sf.ehcache.config.ConfigurationFactory=error
8 8
 
9
-log4j.logger.org.hibernate.SQL=debug
10
-log4j.logger.org.hibernate.hbm2ddl=debug
9
+log4j.logger.org.hibernate.SQL=info
10
+log4j.logger.org.hibernate.hbm2ddl=info

+ 24
- 0
src/test/java/se/citerus/dddsample/acceptance/AbstractAcceptanceTest.java ファイルの表示

@@ -0,0 +1,24 @@
1
+package se.citerus.dddsample.acceptance;
2
+
3
+import org.junit.*;
4
+import org.openqa.selenium.WebDriver;
5
+import org.openqa.selenium.phantomjs.PhantomJSDriver;
6
+
7
+public abstract class AbstractAcceptanceTest {
8
+    protected WebDriver driver;
9
+
10
+    @Before
11
+    public void setup() {
12
+        driver = new PhantomJSDriver();
13
+        screenshotTestRule.updateDriver(driver);
14
+    }
15
+
16
+    @After
17
+    public void tearDown() {
18
+        driver.quit();
19
+
20
+    }
21
+    @Rule
22
+    public ScreenshotTestRule screenshotTestRule = new ScreenshotTestRule();
23
+
24
+}

+ 50
- 0
src/test/java/se/citerus/dddsample/acceptance/AdminAcceptanceTest.java ファイルの表示

@@ -0,0 +1,50 @@
1
+package se.citerus.dddsample.acceptance;
2
+
3
+import org.junit.Test;
4
+import se.citerus.dddsample.acceptance.pages.*;
5
+
6
+import java.text.SimpleDateFormat;
7
+import java.time.LocalDate;
8
+import java.time.format.DateTimeFormatter;
9
+import java.time.temporal.ChronoUnit;
10
+
11
+import static junit.framework.TestCase.assertTrue;
12
+
13
+public class AdminAcceptanceTest extends AbstractAcceptanceTest {
14
+    @Test
15
+    public void adminSiteCargoListContainsCannedCargo() {
16
+        LaunchPage home = new LaunchPage(driver,"http://localhost:8080/");
17
+        AdminPage page = home.goToAdminPage();
18
+        page.listAllCargo();
19
+
20
+        assertTrue("Cargo list doesn't contain ABC123", page.listedCargoContains("ABC123"));
21
+        assertTrue("Cargo list doesn't contain JKL567", page.listedCargoContains("JKL567"));
22
+    }
23
+
24
+    @Test
25
+    public void adminSiteCanBookNewCargo() {
26
+        LaunchPage home = new LaunchPage(driver,"http://localhost:8080/");
27
+        AdminPage adminPage = home.goToAdminPage();
28
+
29
+        CargoBookingPage cargoBookingPage = adminPage.bookNewCargo();
30
+        cargoBookingPage.selectOrigin("NLRTM");
31
+        cargoBookingPage.selectDestination("USDAL");
32
+        LocalDate arrivalDeadline = LocalDate.now().plus(3, ChronoUnit.WEEKS);
33
+        cargoBookingPage.selectArrivalDeadline(arrivalDeadline);
34
+        CargoDetailsPage cargoDetailsPage = cargoBookingPage.book();
35
+
36
+        String newCargoTrackingId = cargoDetailsPage.getTrackingId();
37
+        adminPage = cargoDetailsPage.listAllCargo();
38
+        assertTrue("Cargo list doesn't contain " + newCargoTrackingId, adminPage.listedCargoContains(newCargoTrackingId));
39
+
40
+        cargoDetailsPage = adminPage.showDetailsFor(newCargoTrackingId);
41
+        cargoDetailsPage.expectOriginOf("NLRTM");
42
+        cargoDetailsPage.expectDestinationOf("USDAL");
43
+
44
+        CargoDestinationPage cargoDestinationPage = cargoDetailsPage.changeDestination();
45
+        cargoDetailsPage = cargoDestinationPage.selectDestinationTo("AUMEL");
46
+        cargoDetailsPage.expectDestinationOf("AUMEL");
47
+        cargoDetailsPage.expectArrivalDeadlineOf(arrivalDeadline);
48
+
49
+    }
50
+}

+ 35
- 0
src/test/java/se/citerus/dddsample/acceptance/CustomerAcceptanceTest.java ファイルの表示

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

+ 43
- 0
src/test/java/se/citerus/dddsample/acceptance/ScreenshotTestRule.java ファイルの表示

@@ -0,0 +1,43 @@
1
+package se.citerus.dddsample.acceptance;
2
+
3
+import org.apache.commons.io.FileUtils;
4
+import org.junit.rules.MethodRule;
5
+import org.junit.runners.model.FrameworkMethod;
6
+import org.junit.runners.model.Statement;
7
+import org.openqa.selenium.OutputType;
8
+import org.openqa.selenium.TakesScreenshot;
9
+import org.openqa.selenium.WebDriver;
10
+
11
+import java.io.File;
12
+
13
+class ScreenshotTestRule implements MethodRule {
14
+    private WebDriver driver;
15
+
16
+    public Statement apply(final Statement statement, final FrameworkMethod frameworkMethod, final Object o) {
17
+        return new Statement() {
18
+            @Override
19
+            public void evaluate() throws Throwable {
20
+                try {
21
+                    statement.evaluate();
22
+                } catch (Throwable t) {
23
+                    captureScreenshot(frameworkMethod.getName());
24
+                    throw t;
25
+                }
26
+            }
27
+
28
+            public void captureScreenshot(String fileName) {
29
+                try {
30
+                    new File("target/surefire-reports/").mkdirs(); // Insure directory is there
31
+                    File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
32
+                    FileUtils.copyFile(scrFile, new File("target/surefire-reports/screenshot-" + fileName + ".png"));
33
+                } catch (Exception e) {
34
+                    System.err.println("ERROR: " + e);
35
+                }
36
+            }
37
+        };
38
+    }
39
+
40
+    public void updateDriver(WebDriver driver) {
41
+        this.driver = driver;
42
+    }
43
+}

+ 42
- 0
src/test/java/se/citerus/dddsample/acceptance/pages/AdminPage.java ファイルの表示

@@ -0,0 +1,42 @@
1
+package se.citerus.dddsample.acceptance.pages;
2
+
3
+import org.openqa.selenium.By;
4
+import org.openqa.selenium.WebDriver;
5
+import org.openqa.selenium.WebElement;
6
+
7
+import java.util.List;
8
+import java.util.Optional;
9
+
10
+import static org.junit.Assert.assertEquals;
11
+
12
+public class AdminPage {
13
+    private final WebDriver driver;
14
+
15
+    public AdminPage(WebDriver driver) {
16
+        this.driver = driver;
17
+        assertEquals("Cargo Administration", driver.getTitle());
18
+    }
19
+
20
+    public void listAllCargo() {
21
+        driver.findElement(By.linkText("List all cargos")).click();
22
+        assertEquals("Cargo Administration", driver.getTitle());
23
+    }
24
+
25
+    public CargoBookingPage bookNewCargo() {
26
+        driver.findElement(By.linkText("Book new cargo")).click();
27
+
28
+        return new CargoBookingPage(driver);
29
+    }
30
+
31
+    public boolean listedCargoContains(String expectedTrackingId) {
32
+        List<WebElement> cargoList = driver.findElements(By.cssSelector("#body table tbody tr td a"));
33
+        Optional<WebElement> matchingCargo = cargoList.stream().filter(cargo -> cargo.getText().equals(expectedTrackingId)).findFirst();
34
+        return matchingCargo.isPresent();
35
+    }
36
+
37
+    public CargoDetailsPage showDetailsFor(String cargoTrackingId) {
38
+        driver.findElement(By.linkText(cargoTrackingId)).click();
39
+
40
+        return new CargoDetailsPage(driver);
41
+    }
42
+}

+ 47
- 0
src/test/java/se/citerus/dddsample/acceptance/pages/CargoBookingPage.java ファイルの表示

@@ -0,0 +1,47 @@
1
+package se.citerus.dddsample.acceptance.pages;
2
+
3
+import org.openqa.selenium.By;
4
+import org.openqa.selenium.WebDriver;
5
+import org.openqa.selenium.WebElement;
6
+import org.openqa.selenium.support.ui.Select;
7
+
8
+import java.time.LocalDate;
9
+import java.time.format.DateTimeFormatter;
10
+import java.util.List;
11
+
12
+import static org.junit.Assert.assertEquals;
13
+
14
+public class CargoBookingPage {
15
+
16
+    private final WebDriver driver;
17
+
18
+    public CargoBookingPage(WebDriver driver) {
19
+        this.driver = driver;
20
+
21
+        WebElement newCargoTableCaption = driver.findElement(By.cssSelector("table caption"));
22
+
23
+        assertEquals("Book new cargo", newCargoTableCaption.getText());
24
+    }
25
+
26
+    public void selectOrigin(String origin) {
27
+        Select select = new Select(driver.findElement(By.name("originUnlocode")));
28
+        select.selectByVisibleText(origin);
29
+    }
30
+
31
+    public void selectDestination(String destination) {
32
+        Select select = new Select(driver.findElement(By.name("destinationUnlocode")));
33
+        select.selectByVisibleText(destination);
34
+    }
35
+
36
+    public CargoDetailsPage book() {
37
+        driver.findElement(By.name("originUnlocode")).submit();
38
+
39
+        return new CargoDetailsPage(driver);
40
+    }
41
+
42
+    public void selectArrivalDeadline(LocalDate arrivalDeadline) {
43
+        WebElement datePicker = driver.findElement(By.id("arrivalDeadline"));
44
+        datePicker.clear();
45
+        datePicker.sendKeys(arrivalDeadline.format(DateTimeFormatter.ofPattern("MM/dd/yyyy")));
46
+    }
47
+}

+ 29
- 0
src/test/java/se/citerus/dddsample/acceptance/pages/CargoDestinationPage.java ファイルの表示

@@ -0,0 +1,29 @@
1
+package se.citerus.dddsample.acceptance.pages;
2
+
3
+import org.openqa.selenium.By;
4
+import org.openqa.selenium.WebDriver;
5
+import org.openqa.selenium.WebElement;
6
+import org.openqa.selenium.support.ui.Select;
7
+
8
+import static junit.framework.TestCase.assertTrue;
9
+
10
+public class CargoDestinationPage {
11
+    private final WebDriver driver;
12
+
13
+    public CargoDestinationPage(WebDriver driver) {
14
+        this.driver = driver;
15
+        WebElement cargoDestinationHeader = driver.findElement(By.cssSelector("table caption"));
16
+
17
+        assertTrue(cargoDestinationHeader.getText().startsWith("Change destination for cargo "));
18
+    }
19
+
20
+    public CargoDetailsPage selectDestinationTo(String destination) {
21
+        WebElement destinationPicker = driver.findElement(By.name("unlocode"));
22
+        Select select = new Select(destinationPicker);
23
+        select.selectByVisibleText(destination);
24
+
25
+        destinationPicker.submit();
26
+
27
+        return new CargoDetailsPage(driver);
28
+    }
29
+}

+ 61
- 0
src/test/java/se/citerus/dddsample/acceptance/pages/CargoDetailsPage.java ファイルの表示

@@ -0,0 +1,61 @@
1
+package se.citerus.dddsample.acceptance.pages;
2
+
3
+import org.openqa.selenium.By;
4
+import org.openqa.selenium.WebDriver;
5
+import org.openqa.selenium.WebElement;
6
+
7
+import java.time.LocalDate;
8
+import java.time.format.DateTimeFormatter;
9
+import java.util.List;
10
+
11
+import static junit.framework.TestCase.assertTrue;
12
+import static org.junit.Assert.assertEquals;
13
+
14
+public class CargoDetailsPage {
15
+    public static final String TRACKING_ID_HEADER = "Details for cargo ";
16
+    private final WebDriver driver;
17
+    private String trackingId;
18
+
19
+    public CargoDetailsPage(WebDriver driver) {
20
+        this.driver = driver;
21
+
22
+        WebElement newCargoTableCaption = driver.findElement(By.cssSelector("table caption"));
23
+
24
+        assertTrue(newCargoTableCaption.getText().startsWith(TRACKING_ID_HEADER));
25
+        trackingId = newCargoTableCaption.getText().replaceFirst(TRACKING_ID_HEADER, "");
26
+    }
27
+
28
+    public String getTrackingId() {
29
+        return trackingId;
30
+    }
31
+
32
+    public AdminPage listAllCargo() {
33
+        driver.findElement(By.linkText("List all cargos")).click();
34
+
35
+        return new AdminPage(driver);
36
+    }
37
+
38
+    public void expectOriginOf(String expectedOrigin) {
39
+        String actualOrigin = driver.findElement(By.xpath("//div[@id='container']/table/tbody/tr[1]/td[2]")).getText();
40
+
41
+        assertEquals(expectedOrigin, actualOrigin);
42
+    }
43
+
44
+    public void expectDestinationOf(String expectedDestination) {
45
+        String actualDestination = driver.findElement(By.xpath("//div[@id='container']/table/tbody/tr[2]/td[2]")).getText();
46
+
47
+        assertEquals(expectedDestination, actualDestination);
48
+    }
49
+
50
+    public CargoDestinationPage changeDestination() {
51
+        driver.findElement(By.linkText("Change destination")).click();
52
+
53
+        return new CargoDestinationPage(driver);
54
+    }
55
+
56
+    public void expectArrivalDeadlineOf(LocalDate expectedArrivalDeadline) {
57
+        String actualArrivalDeadline = driver.findElement(By.xpath("//div[@id='container']/table/tbody/tr[4]/td[2]")).getText();
58
+
59
+        assertEquals(expectedArrivalDeadline.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")), actualArrivalDeadline);
60
+    }
61
+}

+ 39
- 0
src/test/java/se/citerus/dddsample/acceptance/pages/CustomerPage.java ファイルの表示

@@ -0,0 +1,39 @@
1
+package se.citerus.dddsample.acceptance.pages;
2
+
3
+import org.openqa.selenium.By;
4
+import org.openqa.selenium.WebDriver;
5
+import org.openqa.selenium.WebElement;
6
+
7
+import static org.junit.Assert.assertEquals;
8
+import static org.junit.Assert.assertTrue;
9
+
10
+public class CustomerPage {
11
+    private final WebDriver driver;
12
+
13
+    public CustomerPage(WebDriver driver) {
14
+        this.driver = driver;
15
+        assertEquals("Tracking cargo", driver.getTitle());
16
+    }
17
+
18
+    public void trackCargoWithIdOf(String trackingId) {
19
+        WebElement element = driver.findElement(By.id("idInput"));
20
+        element.sendKeys(trackingId);
21
+        element.submit();
22
+
23
+    }
24
+
25
+    public void expectCargoLocation(String expectedLocation) {
26
+        WebElement cargoSummary = driver.findElement(By.cssSelector("#result h2"));
27
+        assertTrue(cargoSummary.getText().endsWith(expectedLocation));
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
+    }
39
+}

+ 30
- 0
src/test/java/se/citerus/dddsample/acceptance/pages/LaunchPage.java ファイルの表示

@@ -0,0 +1,30 @@
1
+package se.citerus.dddsample.acceptance.pages;
2
+
3
+import org.openqa.selenium.By;
4
+import org.openqa.selenium.WebDriver;
5
+
6
+import static org.junit.Assert.assertEquals;
7
+
8
+public class LaunchPage {
9
+    private final WebDriver driver;
10
+    private final String baseUrl;
11
+
12
+    public LaunchPage(WebDriver driver, String baseUrl) {
13
+        this.driver = driver;
14
+        this.baseUrl = baseUrl;
15
+        driver.get(baseUrl);
16
+        assertEquals("DDDSample", driver.getTitle());
17
+    }
18
+
19
+    public CustomerPage goToCustomerPage() {
20
+        driver.findElement(By.linkText("cargo tracking")).click();
21
+
22
+        return new CustomerPage(driver);
23
+    }
24
+
25
+    public AdminPage goToAdminPage() {
26
+        driver.findElement(By.linkText("booking and routing")).click();
27
+
28
+        return new AdminPage(driver);
29
+    }
30
+}

+ 7
- 4
src/test/java/se/citerus/dddsample/infrastructure/messaging/stub/SynchronousApplicationEventsStub.java ファイルの表示

@@ -1,5 +1,7 @@
1 1
 package se.citerus.dddsample.infrastructure.messaging.stub;
2 2
 
3
+import org.apache.commons.logging.Log;
4
+import org.apache.commons.logging.LogFactory;
3 5
 import se.citerus.dddsample.application.ApplicationEvents;
4 6
 import se.citerus.dddsample.application.CargoInspectionService;
5 7
 import se.citerus.dddsample.domain.model.cargo.Cargo;
@@ -9,6 +11,7 @@ import se.citerus.dddsample.interfaces.handling.HandlingEventRegistrationAttempt
9 11
 public class SynchronousApplicationEventsStub implements ApplicationEvents {
10 12
 
11 13
   CargoInspectionService cargoInspectionService;
14
+  private final Log logger = LogFactory.getLog(getClass());
12 15
 
13 16
   public void setCargoInspectionService(CargoInspectionService cargoInspectionService) {
14 17
     this.cargoInspectionService = cargoInspectionService;
@@ -16,22 +19,22 @@ public class SynchronousApplicationEventsStub implements ApplicationEvents {
16 19
 
17 20
   @Override
18 21
   public void cargoWasHandled(HandlingEvent event) {
19
-    System.out.println("EVENT: cargo was handled: " + event);
22
+    logger.info("EVENT: cargo was handled: " + event);
20 23
     cargoInspectionService.inspectCargo(event.cargo().trackingId());
21 24
   }
22 25
 
23 26
   @Override
24 27
   public void cargoWasMisdirected(Cargo cargo) {
25
-    System.out.println("EVENT: cargo was misdirected");
28
+    logger.info("EVENT: cargo was misdirected");
26 29
   }
27 30
 
28 31
   @Override
29 32
   public void cargoHasArrived(Cargo cargo) {
30
-    System.out.println("EVENT: cargo has arrived: " + cargo.trackingId().idString());
33
+    logger.info("EVENT: cargo has arrived: " + cargo.trackingId().idString());
31 34
   }
32 35
 
33 36
   @Override
34 37
   public void receivedHandlingEventRegistrationAttempt(HandlingEventRegistrationAttempt attempt) {
35
-    System.out.println("EVENT: received handling event registration attempt");
38
+    logger.info("EVENT: received handling event registration attempt");
36 39
   }
37 40
 }

+ 3
- 3
src/test/resources/log4j.properties ファイルの表示

@@ -1,4 +1,4 @@
1
-log4j.rootLogger=info, stdout
1
+log4j.rootLogger=warn, stdout
2 2
 
3 3
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4 4
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
@@ -6,8 +6,8 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
6 6
 
7 7
 log4j.logger.net.sf.ehcache.config.ConfigurationFactory=error
8 8
 
9
-log4j.logger.se.citerus.dddsample=debug
10
-log4j.logger.org.hibernate.SQL=debug
9
+#log4j.logger.se.citerus.dddsample=info
10
+#log4j.logger.org.hibernate.SQL=info
11 11
 #log4j.logger.org.hibernate.tool.hbm2ddl.SchemaExport=debug
12 12
 
13 13
 #log4j.logger.org.springframework.orm=debug