use of com.adaptris.core.Adapter in project interlok by adaptris.
the class AdapterRegistryTest method testAddAdapterMBean_ExistingObjectName.
@Test
public void testAddAdapterMBean_ExistingObjectName() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObjectName = adapterManager.createObjectName();
adapterManager.registerMBean();
AdapterRegistry myAdapterRegistry = (AdapterRegistry) AdapterRegistry.findInstance(new JunitBootstrapProperties(new Properties()));
int expectedCount = myAdapterRegistry.getAdapters().size() + 1;
myAdapterRegistry.addAdapter(adapterManager);
assertEquals(ClosedState.getInstance(), adapterManager.getComponentState());
assertEquals(expectedCount, myAdapterRegistry.getAdapters().size());
try {
myAdapterRegistry.addAdapter(adapterManager);
fail();
} catch (CoreException expected) {
assertTrue(expected.getMessage().contains("already exists in the registry, remove it first"));
}
}
use of com.adaptris.core.Adapter 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.core.Adapter 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.core.Adapter 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.core.Adapter in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddSharedConnection_NoUniqueID.
@Test
public void testMBean_AddSharedConnection_NoUniqueID() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
ObjectName adapterObj = adapterManager.createObjectName();
AdaptrisMarshaller m = DefaultMarshaller.getDefaultMarshaller();
try {
adapterManager.registerMBean();
AdapterManagerMBean amp = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
try {
amp.addSharedConnection(m.marshal(new NullConnection()));
fail();
} catch (IllegalArgumentException e) {
}
} finally {
}
}
Aggregations