use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testPutConfigurationUrl.
@Test
public void testPutConfigurationUrl() throws Exception {
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
URLString url = new URLString("http://localhost/1234");
myAdapterRegistry.putConfigurationURL(myAdapterRegistry.createObjectName(), url);
assertEquals(url, myAdapterRegistry.getConfigurationURL(myAdapterRegistry.createObjectName()));
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testProxy_PersistAdapter_Bean_to_URL.
@Test
public void testProxy_PersistAdapter_Bean_to_URL() throws Exception {
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
AdapterRegistryMBean registry = JMX.newMBeanProxy(mBeanServer, myAdapterRegistry.createObjectName(), AdapterRegistryMBean.class);
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
ObjectName objName = registry.createAdapter(xml);
assertNotNull(objName);
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
registry.persistAdapter(manager, new URLString(filename));
Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(filename);
assertRoundtripEquality(adapter, marshalledAdapter);
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testPersistAdapter_MBean_to_URL.
@Test
public void testPersistAdapter_MBean_to_URL() throws Exception {
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
ObjectName objName = myAdapterRegistry.createAdapter(xml);
assertNotNull(objName);
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
myAdapterRegistry.persistAdapter(manager, new URLString(filename));
Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(filename);
assertRoundtripEquality(adapter, marshalledAdapter);
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testPersistAdapter_ObjectName_To_File.
@Test
public void testPersistAdapter_ObjectName_To_File() throws Exception {
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
ObjectName objName = myAdapterRegistry.createAdapter(xml);
myAdapterRegistry.persistAdapter(objName, new URLString(filename));
Adapter marshalledAdapter = (Adapter) DefaultMarshaller.getDefaultMarshaller().unmarshal(filename);
assertRoundtripEquality(adapter, marshalledAdapter);
}
use of com.adaptris.util.URLString 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));
}
Aggregations