Search in sources :

Example 1 with ConfigPreProcessors

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));
}
Also used : ConfigPreProcessors(com.adaptris.core.config.ConfigPreProcessors) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Adapter(com.adaptris.core.Adapter) URLString(com.adaptris.util.URLString) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) File(java.io.File) URLString(com.adaptris.util.URLString) Test(org.junit.Test)

Example 2 with ConfigPreProcessors

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));
}
Also used : ConfigPreProcessors(com.adaptris.core.config.ConfigPreProcessors) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Adapter(com.adaptris.core.Adapter) URLString(com.adaptris.util.URLString) BootstrapProperties(com.adaptris.core.management.BootstrapProperties) JunitBootstrapProperties(com.adaptris.core.stubs.JunitBootstrapProperties) Properties(java.util.Properties) File(java.io.File) URLString(com.adaptris.util.URLString) Test(org.junit.Test)

Aggregations

Adapter (com.adaptris.core.Adapter)2 ConfigPreProcessors (com.adaptris.core.config.ConfigPreProcessors)2 BootstrapProperties (com.adaptris.core.management.BootstrapProperties)2 JunitBootstrapProperties (com.adaptris.core.stubs.JunitBootstrapProperties)2 URLString (com.adaptris.util.URLString)2 File (java.io.File)2 Properties (java.util.Properties)2 Test (org.junit.Test)2