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;
}
}
+ private ExtendedRouterConfig routerConfig;
+ private XMLRouterConfiguration config;
private XMLRouter router;
private DOMSource source1;
private DOMSource source2;
@Before
public void setUp() {
+ routerConfig = new SingleRouterConfig(new AtomicLong(1L));
+ config = new XMLRouterConfigurationImpl(routerConfig,
+ new TransformationPaths());
EventListener logListener = new LoggingEventListener(Level.INFO);
listener = spy(logListener);
- router = new XMLRouter(new SystemClock(), listener);
+ router = new XMLRouter(new SystemClock(), config, listener);
source1 = mock(DOMSource.class);
source2 = mock(DOMSource.class);
source3 = mock(DOMSource.class);
DocumentType type = mock(DocumentType.class);
doThrow(new RuntimeException("x")).when(type).isInstance(
any(DOMSource.class));
- router.documentTypeConfig().add(type);
+ routerConfig.documentTypeConfig().add(type);
router.publish("xx", mock(DOMSource.class));
verify(listener).notDelivered(any(EventInfo.class));
// no exception should occur.
Filter filter = mock(Filter.class);
doThrow(new RuntimeException("x")).when(filter).isAllowed(anyString(),
any(DOMSource.class));
- router.filterConfig().add(filter);
+ routerConfig.filterConfig().add(filter);
router.publish("xx", mock(DOMSource.class));
verify(listener).notDelivered(any(EventInfo.class));
// no exception should occur.
DocumentType type = mock(DocumentType.class);
when(type.isInstance(any(DOMSource.class))).thenReturn(true);
when(type.getName()).thenReturn(aType);
- Id<DocumentType> typeId = router.documentTypeConfig().add(type);
+ Id<DocumentType> typeId = 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<DocumentType> typeId = router.documentTypeConfig().add(type);
+ Id<DocumentType> typeId = routerConfig.documentTypeConfig().add(type);
}
private Destination registerDestination(boolean aResult, String... types) {
when(transformation.getFromType()).thenReturn("any");
when(transformation.getToType()).thenReturn("bla");
when(transformation.transform(same(source1))).thenReturn(source2);
- router.transformationConfig().add(transformation);
+ routerConfig.transformationConfig().add(transformation);
Destination destination = mock(Destination.class);
when(
when(transformation.getToType()).thenReturn("bla");
doThrow(new RuntimeException("x")).when(transformation).transform(
same(source1));
- router.transformationConfig().add(transformation);
+ routerConfig.transformationConfig().add(transformation);
Destination destination = mock(Destination.class);
when(
Transformation transformation = createTransformation("any", "bla",
source1, null);
- router.transformationConfig().add(transformation);
+ routerConfig.transformationConfig().add(transformation);
Destination destination = mock(Destination.class);
when(
Transformation transformation2 = createTransformation("any", "bla2",
source1, source2);
- router.transformationConfig().add(transformation2);
+ routerConfig.transformationConfig().add(transformation2);
when(
destination.chooseFromTargetTypes((Collection<String>) anyObject()))
.thenReturn(Arrays.asList("bla", "bla2"));
registerDocumentType("other", source2);
Transformation transformation = createTransformation("any", "other",
source1, source2);
- router.transformationConfig().add(transformation);
+ routerConfig.transformationConfig().add(transformation);
router.publish("source", source1);
verify(listener, times(2)).delivered(any(EventInfo.class),
Transformation t1 = createTransformation("any", "intermediate",
source1, source2);
- router.transformationConfig().add(t1);
+ routerConfig.transformationConfig().add(t1);
Transformation t2 = createTransformation("intermediate", "other",
source2, source3);
- router.transformationConfig().add(t2);
+ routerConfig.transformationConfig().add(t2);
router.publish("source", source1);
verify(listener).delivered(any(EventInfo.class),