|
|
@@ -1,27 +1,64 @@
|
|
1
|
|
-package se.citerus.dddsample.infrastructure.persistence.hibernate;
|
|
2
|
|
-
|
|
3
|
|
-import se.citerus.dddsample.domain.model.voyage.Voyage;
|
|
4
|
|
-import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
|
|
5
|
|
-import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
|
|
6
|
|
-
|
|
7
|
|
-//public class CarrierMovementRepositoryTest extends AbstractRepositoryTest {
|
|
8
|
|
-//
|
|
9
|
|
-// VoyageRepository voyageRepository;
|
|
10
|
|
-//
|
|
11
|
|
-// public void setVoyageRepository(VoyageRepository voyageRepository) {
|
|
12
|
|
-// this.voyageRepository = voyageRepository;
|
|
13
|
|
-// }
|
|
14
|
|
-//
|
|
15
|
|
-// public void testFind() throws Exception {
|
|
16
|
|
-// Voyage voyage = voyageRepository.find(new VoyageNumber("0101"));
|
|
17
|
|
-// assertNotNull(voyage);
|
|
18
|
|
-// assertEquals("0101", voyage.voyageNumber().idString());
|
|
19
|
|
-// /* TODO adapt
|
|
20
|
|
-// assertEquals(STOCKHOLM, carrierMovement.departureLocation());
|
|
21
|
|
-// assertEquals(HELSINKI, carrierMovement.arrivalLocation());
|
|
22
|
|
-// assertEquals(DateTestUtil.toDate("2007-09-23", "02:00"), carrierMovement.departureTime());
|
|
23
|
|
-// assertEquals(DateTestUtil.toDate("2007-09-23", "03:00"), carrierMovement.arrivalTime());
|
|
24
|
|
-// */
|
|
25
|
|
-// }
|
|
26
|
|
-//
|
|
27
|
|
-//}
|
|
|
1
|
+package se.citerus.dddsample.infrastructure.persistence.hibernate;
|
|
|
2
|
+
|
|
|
3
|
+import org.hibernate.SessionFactory;
|
|
|
4
|
+import org.junit.Before;
|
|
|
5
|
+import org.junit.Test;
|
|
|
6
|
+import org.junit.runner.RunWith;
|
|
|
7
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
8
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
9
|
+import org.springframework.orm.hibernate3.HibernateTransactionManager;
|
|
|
10
|
+import org.springframework.test.context.ContextConfiguration;
|
|
|
11
|
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
12
|
+import org.springframework.test.context.transaction.TransactionConfiguration;
|
|
|
13
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
14
|
+import org.springframework.transaction.support.TransactionTemplate;
|
|
|
15
|
+import se.citerus.dddsample.application.util.SampleDataGenerator;
|
|
|
16
|
+import se.citerus.dddsample.domain.model.voyage.Voyage;
|
|
|
17
|
+import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
|
|
|
18
|
+import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
|
|
|
19
|
+
|
|
|
20
|
+import javax.sql.DataSource;
|
|
|
21
|
+
|
|
|
22
|
+import static org.junit.Assert.assertEquals;
|
|
|
23
|
+import static org.junit.Assert.assertNotNull;
|
|
|
24
|
+
|
|
|
25
|
+@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
26
|
+@ContextConfiguration(value = {"/context-infrastructure-persistence.xml", "/context-domain.xml"})
|
|
|
27
|
+@TransactionConfiguration(transactionManager = "transactionManager")
|
|
|
28
|
+@Transactional
|
|
|
29
|
+public class CarrierMovementRepositoryTest {
|
|
|
30
|
+
|
|
|
31
|
+ @Autowired
|
|
|
32
|
+ VoyageRepository voyageRepository;
|
|
|
33
|
+
|
|
|
34
|
+ @Autowired
|
|
|
35
|
+ SessionFactory sessionFactory;
|
|
|
36
|
+
|
|
|
37
|
+ @Autowired
|
|
|
38
|
+ private DataSource dataSource;
|
|
|
39
|
+
|
|
|
40
|
+ @Autowired
|
|
|
41
|
+ private HibernateTransactionManager transactionManager;
|
|
|
42
|
+
|
|
|
43
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
44
|
+
|
|
|
45
|
+ @Before
|
|
|
46
|
+ public void setup() {
|
|
|
47
|
+ jdbcTemplate = new JdbcTemplate(dataSource);
|
|
|
48
|
+ SampleDataGenerator.loadSampleData(jdbcTemplate, new TransactionTemplate(transactionManager));
|
|
|
49
|
+ }
|
|
|
50
|
+
|
|
|
51
|
+ @Test
|
|
|
52
|
+ public void testFind() throws Exception {
|
|
|
53
|
+ Voyage voyage = voyageRepository.find(new VoyageNumber("0101"));
|
|
|
54
|
+ assertNotNull(voyage);
|
|
|
55
|
+ assertEquals("0101", voyage.voyageNumber().idString());
|
|
|
56
|
+ /* TODO adapt
|
|
|
57
|
+ assertEquals(STOCKHOLM, carrierMovement.departureLocation());
|
|
|
58
|
+ assertEquals(HELSINKI, carrierMovement.arrivalLocation());
|
|
|
59
|
+ assertEquals(DateTestUtil.toDate("2007-09-23", "02:00"), carrierMovement.departureTime());
|
|
|
60
|
+ assertEquals(DateTestUtil.toDate("2007-09-23", "03:00"), carrierMovement.arrivalTime());
|
|
|
61
|
+ */
|
|
|
62
|
+ }
|
|
|
63
|
+
|
|
|
64
|
+}
|