use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.
the class AdapterRegistryTest method testProxy_CreateAdapter_String.
@Test
public void testProxy_CreateAdapter_String() 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);
String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
ObjectName objName = registry.createAdapter(xml);
assertNotNull(objName);
assertNotNull(registry.getBuilder(objName));
assertTrue(mBeanServer.isRegistered(objName));
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
assertNotNull(manager);
assertEquals(ClosedState.getInstance(), manager.getComponentState());
assertEquals(expectedCount, registry.getAdapters().size());
}
use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.
the class AdapterRegistryTest method testSendShutdownEvent.
@Test
public void testSendShutdownEvent() throws Exception {
AdapterRegistry adapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
DefaultEventHandler evh = new DefaultEventHandler();
StaticMockEventProducer producer = new StaticMockEventProducer(Arrays.asList(new Class[] { AdapterShutdownEvent.class }));
producer.getMessages().clear();
evh.setProducer(producer);
adapter.setEventHandler(evh);
String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
int expectedCount = adapterRegistry.getAdapters().size() + 1;
ObjectName objName = adapterRegistry.createAdapter(xml);
assertEquals(expectedCount, adapterRegistry.getAdapters().size());
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
manager.requestStart();
assertEquals(0, producer.messageCount());
// This should send an extra event.
AdapterRegistry.sendShutdownEvent(adapterRegistry.getAdapters());
waitForMessages(producer, 1);
assertEquals(1, producer.messageCount());
AdapterRegistry.close(adapterRegistry.getAdapters());
producer.getMessages().clear();
}
use of com.adaptris.core.stubs.JunitBootstrapProperties 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));
}
use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.
the class ConfigPreProcessorImplTest method testProperties.
@Test
public void testProperties() {
BootstrapProperties props = new JunitBootstrapProperties(new Properties());
DummyConfigurationPreProcessor p = new DummyConfigurationPreProcessor(props);
p.setProperties(new Properties());
assertNotNull(p.getProperties());
}
use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.
the class ConfigPreProcessorImplTest method testConfiguration.
@Test
@SuppressWarnings("deprecation")
public void testConfiguration() {
BootstrapProperties props = new JunitBootstrapProperties(new Properties());
DummyConfigurationPreProcessor p = new DummyConfigurationPreProcessor(props);
assertNotSame(props, p.getBootstrapProperties());
assertNotNull(p.getConfiguration());
assertEquals(0, p.getConfiguration().size());
}
Aggregations