X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FXMLRouterTest.java;fp=impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fimpl%2FXMLRouterTest.java;h=ae40327050f34eae08805923a65397fc5096d0a1;hb=75f42f00e16ceee9ea333e598c9287de20ede1c3;hp=2746253de58653f31b04a21d63ef990f89680b44;hpb=3cb88352bdfd5454043a6ee1369330d1fd4aa0dd;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 2746253..ae40327 100644 --- a/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java +++ b/impl/src/test/java/org/wamblee/xmlrouter/impl/XMLRouterTest.java @@ -20,6 +20,7 @@ import static org.mockito.Mockito.*; import java.util.Arrays; import java.util.Collection; +import java.util.UUID; import java.util.logging.Level; import javax.xml.transform.dom.DOMSource; @@ -102,7 +103,7 @@ public class XMLRouterTest { @Test public void testMisBehavingDocumentType() { - DocumentType type = mock(DocumentType.class); + DocumentType type = mockDocument("docid"); doThrow(new RuntimeException("x")).when(type).isInstance( any(DOMSource.class)); routerConfig.documentTypeConfig().add(type); @@ -111,10 +112,16 @@ public class XMLRouterTest { // no exception should occur. } + private DocumentType mockDocument(String docid) { + DocumentType type = mock(DocumentType.class); + when(type.getId()).thenReturn(new Id(docid)); + return type; + } + @Test public void testMisBehavingFilter() { registerDocumentType("any"); - Filter filter = mock(Filter.class); + Filter filter = mockFilter("filterid"); doThrow(new RuntimeException("x")).when(filter).isAllowed(anyString(), any(DOMSource.class)); routerConfig.filterConfig().add(filter); @@ -123,6 +130,12 @@ public class XMLRouterTest { // no exception should occur. } + private Filter mockFilter(String filterId) { + Filter filter = mock(Filter.class); + when(filter.getId()).thenReturn(new Id(filterId)); + return filter; + } + @Test public void testOneDestinationNoTransformationSuccess() { destinationSpy = registerDestination(true, "any"); @@ -147,7 +160,7 @@ public class XMLRouterTest { } private void registerDocumentType(String aType) { - DocumentType type = mock(DocumentType.class); + DocumentType type = mockDocument(UUID.randomUUID().toString()); when(type.isInstance(any(DOMSource.class))).thenReturn(true); when(type.getName()).thenReturn(aType); routerConfig.documentTypeConfig().add(type); @@ -157,6 +170,7 @@ public class XMLRouterTest { DocumentType type = mock(DocumentType.class); when(type.isInstance(same(aSource))).thenReturn(true); when(type.getName()).thenReturn(aType); + when(type.getId()).thenReturn(new Id(aType)); routerConfig.documentTypeConfig().add(type); }