use of com.adaptris.core.config.ConfigPreProcessors in project interlok by adaptris.
the class AdapterRegistryTest method testPreProcessorCalled.
@Test
public void testPreProcessorCalled() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
AdapterBuilder builder = new ArrayList<AdapterBuilder>(myAdapterRegistry.builders()).get(0);
builder.setConfigurationPreProcessorLoader(mockPreProcessorLoader);
ConfigPreProcessors preProcessorsList = new ConfigPreProcessors();
preProcessorsList.add(mockPreProcessor);
when(mockPreProcessorLoader.load(any(BootstrapProperties.class))).thenReturn(preProcessorsList);
when(mockPreProcessor.process(any(String.class))).thenReturn(FileUtils.readFileToString(filename));
myAdapterRegistry.createAdapter(new URLString(filename));
// Make sure our pre-processor was called - even though our pre-processor does nothing!
verify(mockPreProcessor, times(1)).process(any(String.class));
}
use of com.adaptris.core.config.ConfigPreProcessors in project interlok by adaptris.
the class AdapterRegistryTest method testMultiPreProcessorCalled.
@Test
public void testMultiPreProcessorCalled() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
AdapterBuilder builder = new ArrayList<AdapterBuilder>(myAdapterRegistry.builders()).get(0);
builder.setConfigurationPreProcessorLoader(mockPreProcessorLoader);
ConfigPreProcessors preProcessorsList = new ConfigPreProcessors();
preProcessorsList.add(mockPreProcessor);
preProcessorsList.add(mockPreProcessor);
preProcessorsList.add(mockPreProcessor);
when(mockPreProcessorLoader.load(any(BootstrapProperties.class))).thenReturn(preProcessorsList);
when(mockPreProcessor.process(any(String.class))).thenReturn(FileUtils.readFileToString(filename));
myAdapterRegistry.createAdapter(new URLString(filename));
// Make sure our pre-processors are called - even though our pre-processors do nothing!
verify(mockPreProcessor, times(3)).process(any(String.class));
}
Aggregations