use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ChannelManagerTest method testAdapterInitialised_StartChannel.
@Test
public void testAdapterInitialised_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.requestInit();
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 AdapterManagerTest method testInitialise_WithTimeout_InitFailure.
@Test
public void testInitialise_WithTimeout_InitFailure() throws Exception {
TimeInterval standardTimeout = new TimeInterval(2L, TimeUnit.SECONDS);
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
MockFailingConnection conn = new MockFailingConnection(getName(), "Init");
conn.setConnectionAttempts(3);
conn.setConnectionRetryInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS));
adapter.getSharedComponents().addConnection(conn);
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
ObjectName adapterObj = createAdapterObjectName(adapterName);
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
try {
manager.requestInit(standardTimeout.toMilliseconds());
fail();
} catch (CoreException expected) {
}
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class AdapterComponentCheckerTest method testCheckInitialised_NotComponent.
@Test
public void testCheckInitialised_NotComponent() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName, 2, 2);
List<BaseComponentMBean> mBeans = createJmxManagers(adapter);
ObjectName objectName = createComponentCheckerObjectName(adapterName);
register(mBeans);
AdapterComponentCheckerMBean manager = JMX.newMBeanProxy(mBeanServer, objectName, AdapterComponentCheckerMBean.class);
try {
manager.checkInitialise("<Document/>");
fail();
} catch (CoreException expected) {
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ChannelManagerTest method testAdapterClosed_StopChannel.
@Test
public void testAdapterClosed_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>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
assertEquals(ClosedState.getInstance(), channelManagerProxy.getComponentState());
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 testAdapterClosed_InitChannel.
@Test
public void testAdapterClosed_InitChannel() 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>();
mBeans.add(adapterManager);
mBeans.addAll(adapterManager.getAllDescendants());
try {
register(mBeans);
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
assertEquals(ClosedState.getInstance(), channelManagerProxy.getComponentState());
try {
channelManagerProxy.requestInit();
fail();
} catch (CoreException e) {
assertEquals(createErrorMessageString(adapterManager.getComponentState(), InitialisedState.getInstance()), e.getMessage());
}
} finally {
adapter.requestClose();
}
}
Aggregations