X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FTransformationsTest.java;h=775e5000b8dc7c01121881f18e5d6731d17e3122;hb=19413a6699295b4bbebc1b3bdb9838fd4370e581;hp=8489f89891d6ccc16c16c5772bb56d83f74a77e5;hpb=f7f3bbbc63a9e177f56064d821dc5f502dee378e;p=xmlrouter diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/TransformationsTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/TransformationsTest.java index 8489f89..775e500 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/TransformationsTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/TransformationsTest.java @@ -1,8 +1,25 @@ +/* + * Copyright 2005-2011 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.wamblee.xmlrouter.impl; import static junit.framework.Assert.*; import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; import javax.xml.transform.dom.DOMSource; @@ -23,6 +40,11 @@ public class TransformationsTest { to = aTo; } + @Override + public String getName() { + return "myname"; + } + @Override public String getFromType() { return from; @@ -51,10 +73,22 @@ public class TransformationsTest { transformations = new Transformations(); } + private Map, Transformation> createTransformations( + long aStartId, Transformation... aTransformations) { + Map, Transformation> res = new LinkedHashMap, Transformation>(); + + long id = aStartId; + for (Transformation t : aTransformations) { + res.put(new Id(id++), t); + } + return res; + } + @Test public void testOneTransformation() { - Id seqno = transformations - .addTransformation(new MyTransformation("A", "B")); + transformations.replaceTransformations(createTransformations(10L, + new MyTransformation("A", "B"))); + System.out.println(transformations.toString()); TransformationPath path = transformations.getPath("A", "B"); assertEquals(1, path.size()); @@ -72,22 +106,26 @@ public class TransformationsTest { @Test public void testMultipleTransformations() { - Id seqno1 = transformations - .addTransformation(new MyTransformation("A", "B")); - Id seqno2 = transformations - .addTransformation(new MyTransformation("B", "C")); - Id seqno3 = transformations - .addTransformation(new MyTransformation("C", "A")); + transformations.replaceTransformations(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()); - assertFalse(seqno1.equals(seqno2)); - assertFalse(seqno2.equals(seqno3)); - assertFalse(seqno1.equals(seqno3)); - transformations.removeTransformation(seqno1); + transformations.replaceTransformations(createTransformations(10L, + new MyTransformation("B", "C"), new MyTransformation("C", "A"))); + assertNull(transformations.getPath("C", "B")); } + @Test + public void testUnknownDestination() { + transformations.replaceTransformations(createTransformations(10L, + new MyTransformation("A", "B"))); + assertNull(transformations.getPath("A", "D")); + } + @Test public void testWithoutTransformations() { Collection res = transformations.getPossibleTargetTypes("a");