Reduced the time during which the configuration is locked. Computation of paths now...
[xmlrouter] / impl / src / test / java / org / wamblee / xmlrouter / impl / TransformationPathsTest.java
index a45853272272806d0441b8958c12796b1868919f..18e065fb2405c86ac7991c48119f6a75202e7592 100644 (file)
@@ -18,12 +18,12 @@ package org.wamblee.xmlrouter.impl;
 import static junit.framework.Assert.*;
 
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
 import javax.xml.transform.dom.DOMSource;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.wamblee.xmlrouter.common.Id;
 import org.wamblee.xmlrouter.config.Transformation;
@@ -68,11 +68,6 @@ public class TransformationPathsTest {
 
     private TransformationPaths transformations;
 
-    @Before
-    public void setUp() {
-        transformations = new TransformationPaths();
-    }
-
     private Map<Id<Transformation>, Transformation> createTransformations(
         long aStartId, Transformation... aTransformations) {
         Map<Id<Transformation>, Transformation> res = new LinkedHashMap<Id<Transformation>, Transformation>();
@@ -86,7 +81,7 @@ public class TransformationPathsTest {
 
     @Test
     public void testOneTransformation() {
-        transformations.replaceTransformations(createTransformations(10L,
+        transformations = new TransformationPaths(createTransformations(10L,
             new MyTransformation("A", "B")));
 
         System.out.println(transformations.toString());
@@ -106,14 +101,14 @@ public class TransformationPathsTest {
 
     @Test
     public void testMultipleTransformations() {
-        transformations.replaceTransformations(createTransformations(10L,
+        transformations = new TransformationPaths(createTransformations(10L,
             new MyTransformation("A", "B"), new MyTransformation("B", "C"),
             new MyTransformation("C", "A")));
 
         System.out.println(transformations);
         assertEquals(2, transformations.getPath("C", "B").size());
 
-        transformations.replaceTransformations(createTransformations(10L,
+        transformations = new TransformationPaths(createTransformations(10L,
             new MyTransformation("B", "C"), new MyTransformation("C", "A")));
 
         assertNull(transformations.getPath("C", "B"));
@@ -121,13 +116,15 @@ public class TransformationPathsTest {
 
     @Test
     public void testUnknownDestination() {
-        transformations.replaceTransformations(createTransformations(10L,
+        transformations = new TransformationPaths(createTransformations(10L,
             new MyTransformation("A", "B")));
         assertNull(transformations.getPath("A", "D"));
     }
 
     @Test
     public void testWithoutTransformations() {
+        transformations = new TransformationPaths(
+            new HashMap<Id<Transformation>, Transformation>());
         Collection<String> res = transformations.getPossibleTargetTypes("a");
         assertEquals(1, res.size());