+ router.publish("any", source1);
+ verify(listener).notDelivered(any(EventInfo.class));
+ }
+
+ @Test
+ public void testMisBehavingDocumentType() {
+ DocumentType type = mockDocument("docid");
+ doThrow(new RuntimeException("x")).when(type).isInstance(
+ any(DOMSource.class));
+ routerConfig.documentTypeConfig().add(type);
+ router.publish("xx", mock(DOMSource.class));
+ verify(listener).notDelivered(any(EventInfo.class));
+ // no exception should occur.
+ }
+
+ private DocumentType mockDocument(String docid) {
+ DocumentType type = mock(DocumentType.class);
+ when(type.getId()).thenReturn(new Id<DocumentType>(docid));
+ return type;
+ }
+
+ @Test
+ public void testMisBehavingFilter() {
+ registerDocumentType("any");
+ Filter filter = mockFilter("filterid");
+ doThrow(new RuntimeException("x")).when(filter).isAllowed(anyString(),
+ any(DOMSource.class));
+ routerConfig.filterConfig().add(filter);
+ router.publish("xx", mock(DOMSource.class));
+ verify(listener).notDelivered(any(EventInfo.class));
+ // no exception should occur.
+ }
+
+ private Filter mockFilter(String filterId) {
+ Filter filter = mock(Filter.class);
+ when(filter.getId()).thenReturn(new Id<Filter>(filterId));
+ return filter;