use of com.adaptris.core.CoreException 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.CoreException in project interlok by adaptris.
the class AdapterManagerTest method testMBean_AddChannel_NoUniqueID.
@Test
public void testMBean_AddChannel_NoUniqueID() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel newChannel = new Channel();
ObjectName adapterObj = adapterManager.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
try {
adapterManagerProxy.addChannel(DefaultMarshaller.getDefaultMarshaller().marshal(newChannel));
fail();
} catch (CoreException expected) {
}
} finally {
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ChannelManagerTest method testAdapterInitialised_StopChannel.
@Test
public void testAdapterInitialised_StopChannel() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel c1 = createChannel(getName() + "_1");
Channel c2 = createChannel(getName() + "_2");
ChannelManager child1 = new ChannelManager(c1, adapterManager);
ChannelManager child2 = new ChannelManager(c2, adapterManager);
ObjectName adapterObj = adapterManager.createObjectName();
ObjectName channelObj = child1.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>(Arrays.asList(new BaseComponentMBean[] { adapterManager, child1, child2 }));
try {
register(mBeans);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
adapterManager.requestInit();
try {
channelManagerProxy.requestStop();
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(adapterManager.getComponentState(), StoppedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ChannelManagerTest method testAdapterStopped_StartChannel.
@Test
public void testAdapterStopped_StartChannel() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel c1 = createChannel(getName() + "_1");
Channel c2 = createChannel(getName() + "_2");
ChannelManager child1 = new ChannelManager(c1, adapterManager);
ChannelManager child2 = new ChannelManager(c2, adapterManager);
ObjectName adapterObj = adapterManager.createObjectName();
ObjectName channelObj = child1.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>(Arrays.asList(new BaseComponentMBean[] { adapterManager, child1, child2 }));
try {
register(mBeans);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
adapterManager.requestStart();
adapterManager.requestStop();
try {
channelManagerProxy.requestStart();
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(adapterManager.getComponentState(), StartedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ChannelManagerTest method testMBean_AddWorkflow_NoUniqueId.
@Test
public void testMBean_AddWorkflow_NoUniqueId() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel newChannel = createChannel(getName() + "_1");
ObjectName adapterObj = adapterManager.createObjectName();
ChannelManager channelManager = new ChannelManager(newChannel, adapterManager);
ObjectName channelObj = channelManager.createObjectName();
StandardWorkflow newWorkflow = new StandardWorkflow();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
adapterManager.registerMBean();
AdapterManagerMBean adapterManagerProxy = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
try {
ObjectName workflowObj = channelManagerProxy.addWorkflow(DefaultMarshaller.getDefaultMarshaller().marshal(newWorkflow));
fail();
} catch (CoreException e) {
}
} finally {
adapterManager.requestClose();
}
}
Aggregations