use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.
the class AdapterRegistryTest method testProxy_DestroyAdapter_MBean_SharedConnection_JNDI.
@Test
public void testProxy_DestroyAdapter_MBean_SharedConnection_JNDI() 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);
adapter.getSharedComponents().addConnection(new NullConnection(getName()));
String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter);
int expectedCount = myAdapterRegistry.getAdapters().size();
ObjectName objName = registry.createAdapter(xml);
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class);
manager.requestStart();
InitialContext context = new InitialContext(contextEnv);
context.lookup("adapter:comp/env/" + getName());
myAdapterRegistry.destroyAdapter(manager);
try {
context.lookup("adapter:comp/env/" + getName());
} catch (NamingException expected) {
}
assertFalse(mBeanServer.isRegistered(objName));
assertEquals(expectedCount, registry.getAdapters().size());
}
use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.
the class AdapterRegistryTest method testSendShutdownEvent_AdapterAlreadyClosed.
@Test
public void testSendShutdownEvent_AdapterAlreadyClosed() 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();
manager.requestClose();
assertEquals(0, producer.messageCount());
// This shouldn't send an extra event because the adapter is already closed.
AdapterRegistry.sendShutdownEvent(adapterRegistry.getAdapters());
Thread.sleep(1000);
assertEquals(0, 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 testGetConfigurationURL.
@Test
public void testGetConfigurationURL() throws Exception {
AdapterRegistry adapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
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 = adapterRegistry.createAdapter(expectedURL);
assertNotNull(objName);
assertTrue(mBeanServer.isRegistered(objName));
assertEquals(expectedURL, adapterRegistry.getConfigurationURL(objName));
}
use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.
the class AdapterRegistryTest method testCreateAdapter_URL.
@Test
public void testCreateAdapter_URL() 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()));
int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
ObjectName objName = myAdapterRegistry.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());
}
use of com.adaptris.core.stubs.JunitBootstrapProperties in project interlok by adaptris.
the class AdapterRegistryTest method testCreateAdapter_NoUniqueId_NoValidation.
@Test
public void testCreateAdapter_NoUniqueId_NoValidation() throws Exception {
String xml = DefaultMarshaller.getDefaultMarshaller().marshal(new Adapter());
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
try {
ObjectName objName = myAdapterRegistry.createAdapter(xml);
fail();
} catch (CoreException expected) {
assertEquals("Adapter Unique ID is null/empty", expected.getMessage());
}
}
Aggregations