use of com.adaptris.core.Adapter in project interlok by adaptris.
the class ChannelManagerTest method testGetParent.
@Test
public void testGetParent() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
Adapter adapter2 = createAdapter(adapterName);
Channel channel = createChannel(getName(), 0);
try {
AdapterManager adapterManager = new AdapterManager(adapter);
AdapterManager adapterManager_2 = new AdapterManager(adapter2);
ChannelManager channelManager = new ChannelManager(channel, adapterManager);
assertEquals(adapterManager, channelManager.getParent());
assertTrue(adapterManager == channelManager.getParent());
assertEquals(adapterManager_2, channelManager.getParent());
assertFalse(adapterManager_2 == channelManager.getParent());
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class ChannelManagerTest method testChannelManager_HasRetryMonitor.
@Test
public void testChannelManager_HasRetryMonitor() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager adapterManager = new AdapterManager(adapter);
Channel c1 = createChannel(getName() + "_1");
c1.setMessageErrorHandler(new RetryMessageErrorHandler(getName()));
ChannelManager cm1 = new ChannelManager(c1, adapterManager);
ObjectName channelObj = cm1.createObjectName();
List<BaseComponentMBean> mBeans = new ArrayList<BaseComponentMBean>(Arrays.asList(new BaseComponentMBean[] { adapterManager, cm1 }));
try {
register(mBeans);
ObjectName handlerObjectName = ObjectName.getInstance(JMX_RETRY_MONITOR_TYPE + cm1.createObjectHierarchyString() + ID_PREFIX + getName());
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
assertTrue(channelManagerProxy.getChildRuntimeInfoComponents().contains(handlerObjectName));
RetryMessageErrorHandlerMonitorMBean monitor = JMX.newMBeanProxy(mBeanServer, handlerObjectName, RetryMessageErrorHandlerMonitorMBean.class);
} finally {
adapter.requestClose();
}
}
use of com.adaptris.core.Adapter 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.Adapter in project interlok by adaptris.
the class ChannelManagerTest method testClose.
@Test
public void testClose() 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();
try {
adapterManager.registerMBean();
adapterManager.requestStart();
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
channelManagerProxy.requestClose();
assertEquals(ClosedState.getInstance(), channelManagerProxy.getComponentState());
assertEquals(ClosedState.getInstance(), child1.getComponentState());
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.Adapter in project interlok by adaptris.
the class ChannelManagerTest method testLastStopTime.
@Test
public void testLastStopTime() 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();
try {
adapterManager.registerMBean();
ChannelManagerMBean channelManagerProxy = JMX.newMBeanProxy(mBeanServer, channelObj, ChannelManagerMBean.class);
long t1 = channelManagerProxy.requestStopTime();
assertTrue(t1 > 0);
adapterManager.requestStart();
adapterManager.requestStop();
assertTrue(t1 <= channelManagerProxy.requestStopTime());
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
Aggregations