use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.
the class StatisticsMBeanCase method testRegistration.
@Test
public void testRegistration() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager am = new AdapterManager(adapter);
try {
start(adapter);
am.registerMBean();
} finally {
am.unregisterMBean();
stop(adapter);
}
}
use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.
the class StatisticsMBeanCase method createJmxManagers.
protected List<BaseComponentMBean> createJmxManagers(Adapter adapter) throws Exception {
List<BaseComponentMBean> result = new ArrayList<BaseComponentMBean>();
AdapterManager am = new AdapterManager(adapter);
result.add(am);
result.addAll(am.getAllDescendants());
return result;
}
use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.
the class FsConsumerCase method testFsMonitor.
@Test
public void testFsMonitor() throws Exception {
String subdir = new GuidGenerator().safeUUID();
FsConsumerImpl fs = createConsumer(subdir);
fs.setUniqueId(getName());
Adapter adapter = new Adapter();
adapter.setUniqueId(getName());
Channel channel = new Channel();
channel.setUniqueId(getName());
StandardWorkflow wf = new StandardWorkflow();
wf.setUniqueId(getName());
wf.setConsumer(fs);
channel.getWorkflowList().add(wf);
adapter.getChannelList().add(channel);
AdapterManager am = new AdapterManager(adapter);
try {
am.registerMBean();
am.requestInit();
String objectNameString = String.format("com.adaptris:type=ConsumerMonitor,adapter=%s,channel=%s,workflow=%s,id=%s", getName(), getName(), getName(), getName());
MBeanServer mBeanServer = JmxHelper.findMBeanServer();
FsConsumerMonitorMBean mbean = JMX.newMBeanProxy(mBeanServer, ObjectName.getInstance(objectNameString), FsConsumerMonitorMBean.class);
assertEquals(0, mbean.messagesRemaining());
} finally {
am.requestClose();
am.unregisterMBean();
}
}
use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.
the class AdapterTest method testBug469AndBug1268.
@Test
public void testBug469AndBug1268() throws Exception {
final Adapter adapter = AdapterTest.createRetryingAdapter("testBug469AndBug1268");
// NonBlockingChannelStartStrategy tests Bug1268...
adapter.getChannelList().setLifecycleStrategy(new com.adaptris.core.lifecycle.NonBlockingChannelStartStrategy());
AdapterManager am = new AdapterManager(adapter);
try {
adapter.requestStart();
waitFor(adapter, StartedState.getInstance());
assertEquals(StartedState.getInstance(), adapter.retrieveComponentState());
// So the Adapter is started but channel1 should currently be "retrying",
// so let's try and stop the adapter.
// Channel should have a componentState of closed.
Channel c = adapter.getChannelList().getChannel("testBug469AndBug1268_c1");
assertEquals(ClosedState.getInstance(), c.retrieveComponentState());
new Thread() {
@Override
public void run() {
Thread.currentThread().setName("testBug469AndBug1268 stop");
adapter.requestClose();
}
}.start();
waitFor(adapter, ClosedState.getInstance());
// Bug469 is tested by the fact that the Adapter is now closed.
assertEquals(ClosedState.getInstance(), adapter.retrieveComponentState());
} finally {
am.forceClose();
}
}
use of com.adaptris.core.runtime.AdapterManager in project interlok by adaptris.
the class StatisticsMBeanCase method testStandardGetters.
@Test
public void testStandardGetters() throws Exception {
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
AdapterManager am = new AdapterManager(adapter);
try {
start(adapter);
am.registerMBean();
Collection<BaseComponentMBean> children = am.getAllDescendants();
for (BaseComponentMBean bean : children) {
assertNotNull(bean.createObjectName());
if (bean instanceof ChildRuntimeInfoComponent) {
assertNotNull(((ChildRuntimeInfoComponent) bean).getParentId());
assertNotNull(((ChildRuntimeInfoComponent) bean).getParentObjectName());
assertNotNull(((ChildRuntimeInfoComponent) bean).getParentRuntimeInfoComponent());
}
}
} finally {
stop(adapter);
am.unregisterMBean();
}
}
Aggregations