X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FXMLRouterTest.java;h=2746253de58653f31b04a21d63ef990f89680b44;hb=e52385618670b54a5c6a4f2fbfab381bef43a905;hp=64aefa1a8ca9f77e8746d7b0f94c5eacb192a00c;hpb=0db97b9f39c69528900f915dd2bb463c27debe39;p=xmlrouter diff --git a/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java b/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java index 64aefa1..2746253 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java @@ -20,7 +20,6 @@ import static org.mockito.Mockito.*; import java.util.Arrays; import java.util.Collection; -import java.util.concurrent.atomic.AtomicLong; import java.util.logging.Level; import javax.xml.transform.dom.DOMSource; @@ -31,6 +30,7 @@ import org.wamblee.general.SystemClock; import org.wamblee.xmlrouter.common.Id; import org.wamblee.xmlrouter.config.DocumentType; import org.wamblee.xmlrouter.config.Filter; +import org.wamblee.xmlrouter.config.RouterConfig; import org.wamblee.xmlrouter.config.Transformation; import org.wamblee.xmlrouter.listener.EventInfo; import org.wamblee.xmlrouter.listener.EventListener; @@ -79,7 +79,8 @@ public class XMLRouterTest { @Before public void setUp() { - routerConfig = new SingleRouterConfig(new AtomicLong(1L)); + routerConfig = new SingleRouterConfig(new Id( + "routerconfig")); config = new XMLRouterConfigurationImpl(routerConfig); EventListener logListener = new LoggingEventListener(Level.INFO); listener = spy(logListener); @@ -129,7 +130,7 @@ public class XMLRouterTest { router.publish("any", source1); verify(listener).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(true)); + anyListOf(Transformation.class), anyString(), eq(true)); verify(destinationSpy).receive(same(source1)); // Unregister the destination. @@ -149,14 +150,14 @@ public class XMLRouterTest { DocumentType type = mock(DocumentType.class); when(type.isInstance(any(DOMSource.class))).thenReturn(true); when(type.getName()).thenReturn(aType); - Id typeId = routerConfig.documentTypeConfig().add(type); + routerConfig.documentTypeConfig().add(type); } private void registerDocumentType(String aType, DOMSource aSource) { DocumentType type = mock(DocumentType.class); when(type.isInstance(same(aSource))).thenReturn(true); when(type.getName()).thenReturn(aType); - Id typeId = routerConfig.documentTypeConfig().add(type); + routerConfig.documentTypeConfig().add(type); } private Destination registerDestination(boolean aResult, String... types) { @@ -200,7 +201,7 @@ public class XMLRouterTest { router.publish("any", source1); verify(listener).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(true)); + anyListOf(Transformation.class), anyString(), eq(true)); verify(destinationSpy2).receive(same(source1)); @@ -229,7 +230,7 @@ public class XMLRouterTest { .registerDestination(destinationSpy2); router.publish("any", source1); verify(listener).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(true)); + anyListOf(Transformation.class), anyString(), eq(true)); verify(destinationSpy, never()).receive(same(source1)); verify(destinationSpy2).receive(same(source1)); @@ -260,7 +261,7 @@ public class XMLRouterTest { .registerDestination(destinationSpy2); router.publish("any", source1); verify(listener).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(true)); + anyListOf(Transformation.class), anyString(), eq(true)); verify(destinationSpy, never()).receive(same(source1)); verify(destinationSpy2).receive(same(source1)); @@ -270,7 +271,8 @@ public class XMLRouterTest { public void testOneTransformationOneDestination() { registerDocumentType("any"); Transformation transformation = mock(Transformation.class); - when(transformation.getName()).thenReturn("trans"); + when(transformation.getId()) + .thenReturn(new Id("trans")); when(transformation.getFromType()).thenReturn("any"); when(transformation.getToType()).thenReturn("bla"); when(transformation.transform(same(source1))).thenReturn(source2); @@ -287,7 +289,7 @@ public class XMLRouterTest { when(destination.receive(any(DOMSource.class))).thenReturn(true); router.publish("bla", source1); verify(listener).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(true)); + anyListOf(Transformation.class), anyString(), eq(true)); verify(transformation).transform(source1); verify(destination).receive(same(source2)); @@ -302,7 +304,8 @@ public class XMLRouterTest { public void testMisbehavingTransformationOneDestination() { registerDocumentType("any"); Transformation transformation = mock(Transformation.class); - when(transformation.getName()).thenReturn("trans"); + when(transformation.getId()) + .thenReturn(new Id("trans")); when(transformation.getFromType()).thenReturn("any"); when(transformation.getToType()).thenReturn("bla"); doThrow(new RuntimeException("x")).when(transformation).transform( @@ -324,7 +327,8 @@ public class XMLRouterTest { private Transformation createTransformation(String aFrom, String aTo, DOMSource aSource, DOMSource aTarget) { Transformation transformation = mock(Transformation.class); - when(transformation.getName()).thenReturn("trans"); + when(transformation.getId()) + .thenReturn(new Id("trans")); when(transformation.getFromType()).thenReturn(aFrom); when(transformation.getToType()).thenReturn(aTo); when(transformation.transform(same(aSource))).thenReturn(aTarget); @@ -362,7 +366,8 @@ public class XMLRouterTest { .thenReturn(Arrays.asList("bla", "bla2")); reset(transformation); - when(transformation.getName()).thenReturn("trans"); + when(transformation.getId()) + .thenReturn(new Id("trans")); when(transformation.getFromType()).thenReturn("any"); when(transformation.getToType()).thenReturn("bla"); when(transformation.transform(same(source1))).thenReturn(null); @@ -370,7 +375,7 @@ public class XMLRouterTest { when(destination.receive(any(DOMSource.class))).thenReturn(true); router.publish("bla", source1); verify(listener).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(true)); + anyListOf(Transformation.class), anyString(), eq(true)); verify(transformation).transform(source1); verify(transformation2).transform(source1); @@ -387,7 +392,7 @@ public class XMLRouterTest { router.publish("source", source1); verify(listener, times(2)).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(true)); + anyListOf(Transformation.class), anyString(), eq(true)); verify(dest1).receive(same(source1)); verify(dest2).receive(same(source1)); @@ -405,7 +410,7 @@ public class XMLRouterTest { router.publish("source", source1); verify(listener, times(2)).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(true)); + anyListOf(Transformation.class), anyString(), eq(true)); verify(dest).receive(same(source1)); verify(dest).receive(same(source2)); @@ -427,7 +432,7 @@ public class XMLRouterTest { router.publish("source", source1); verify(listener).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(true)); + anyListOf(Transformation.class), anyString(), eq(true)); verify(dest).receive(same(source3)); } @@ -447,7 +452,7 @@ public class XMLRouterTest { router.publish("source", source1); verify(listener).delivered(any(EventInfo.class), - anyListOf(Transformation.class), anyLong(), anyString(), eq(false)); + anyListOf(Transformation.class), anyString(), eq(false)); } }