use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testProxy_CreateAdapter_URL.
@Test
public void testProxy_CreateAdapter_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);
DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
ObjectName objName = registry.createAdapter(new URLString(filename));
assertNotNull(objName);
assertTrue(mBeanServer.isRegistered(objName));
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
assertNotNull(manager);
assertEquals(ClosedState.getInstance(), manager.getComponentState());
assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
assertEquals(expectedCount, registry.getAdapters().size());
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testProxy_Destroy_With_GetConfigurationURL.
@Test
public void testProxy_Destroy_With_GetConfigurationURL() throws Exception {
AdapterRegistry adapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
AdapterRegistryMBean registry = JMX.newMBeanProxy(mBeanServer, adapterRegistry.createObjectName(), AdapterRegistryMBean.class);
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
URLString expectedURL = new URLString(filename);
ObjectName objName = registry.createAdapter(expectedURL);
assertNotNull(objName);
assertTrue(mBeanServer.isRegistered(objName));
assertEquals(expectedURL, registry.getConfigurationURL(objName));
registry.destroyAdapter(objName);
assertEquals(expectedURL, registry.getConfigurationURL(objName));
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testReloadFromVersionControl_WithVCS.
@Test
public void testReloadFromVersionControl_WithVCS() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
Properties p = new Properties();
p.put("adapterConfigUrl.1", filename.toURI().toURL().toString());
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(p));
int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
ObjectName myObjectName = myAdapterRegistry.createAdapter(new URLString(filename));
assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
AdapterBuilder builder = new ArrayList<AdapterBuilder>(myAdapterRegistry.builders()).get(0);
builder.overrideRuntimeVCS(new MockRuntimeVersionControl());
// This should destroy the adapter just created; and create a new one...
myAdapterRegistry.reloadFromVersionControl();
assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testReloadFromConfig.
@Test
public void testReloadFromConfig() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
Properties p = new Properties();
p.put("adapterConfigUrl.1", filename.toURI().toURL().toString());
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(p));
int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
ObjectName myObjectName = myAdapterRegistry.createAdapter(new URLString(filename));
assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
// This should destroy the adapter just created; and create a new one...
myAdapterRegistry.reloadFromConfig();
assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
}
use of com.adaptris.util.URLString in project interlok by adaptris.
the class AdapterRegistryTest method testPreProcessorsLoaded.
@Test
public void testPreProcessorsLoaded() throws Exception {
Properties bsProperties = new Properties();
bsProperties.put(AdapterConfigManager.CONFIGURATION_PRE_PROCESSORS, DummyConfigurationPreProcessor.class.getName());
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(bsProperties));
AdapterBuilder builder = new ArrayList<AdapterBuilder>(myAdapterRegistry.builders()).get(0);
builder.setConfigurationPreProcessorLoader(spyPreProcessorLoader);
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
File filename = deleteLater(adapter);
DefaultMarshaller.getDefaultMarshaller().marshal(adapter, filename);
myAdapterRegistry.createAdapter(new URLString(filename));
verify(spyPreProcessorLoader, times(1)).load(any(BootstrapProperties.class));
}
Aggregations