use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testSetConnections.
@Test
public void testSetConnections() throws Exception {
SharedComponentList list = new SharedComponentList();
List<AdaptrisConnection> bad = Arrays.asList(new AdaptrisConnection[] { new MockConnection(getName()), new MockConnection() });
List<AdaptrisConnection> alsoBad = Arrays.asList(new AdaptrisConnection[] { new MockConnection(getName()), new MockConnection(getName()) });
List<AdaptrisConnection> good = Arrays.asList(new AdaptrisConnection[] { new MockConnection(getName()), new MockConnection(getName() + "_1") });
try {
list.setConnections(bad);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(0, list.getConnections().size());
try {
list.setConnections(alsoBad);
fail();
} catch (IllegalArgumentException expected) {
}
assertEquals(0, list.getConnections().size());
list.setConnections(good);
assertEquals(2, list.getConnections().size());
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testLifecycle_Start.
@Test
public void testLifecycle_Start() throws Exception {
SharedComponentList list = new SharedComponentList();
List<AdaptrisConnection> good = Arrays.asList(new AdaptrisConnection[] { new MockConnection(getName()), new MockConnection(getName() + "_1") });
list.setConnections(good);
try {
LifecycleHelper.init(list);
LifecycleHelper.start(list);
assertEquals(2, list.getConnections().size());
for (AdaptrisConnection c : list.getConnections()) {
assertEquals(StartedState.getInstance(), c.retrieveComponentState());
}
} finally {
stop(list);
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class AdapterManagerTest method testStop_WithTimeout.
@Test
public void testStop_WithTimeout() throws Exception {
TimeInterval standardTimeout = new TimeInterval(2L, TimeUnit.SECONDS);
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
MockConnection conn = new MockConnection(getName(), new TimeInterval(250L, TimeUnit.MILLISECONDS).toMilliseconds());
adapter.getSharedComponents().addConnection(conn);
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
ObjectName adapterObj = createAdapterObjectName(adapterName);
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
adapterManager.requestStart();
manager.requestStop(standardTimeout.toMilliseconds());
assertEquals(StoppedState.getInstance(), manager.getComponentState());
adapterManager.requestStart();
assertEquals(StartedState.getInstance(), manager.getComponentState());
try {
manager.requestStop(new TimeInterval(100L, TimeUnit.MILLISECONDS).toMilliseconds());
fail();
} catch (TimeoutException expected) {
}
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class AdapterManagerTest method testClose_WithTimeout.
@Test
public void testClose_WithTimeout() throws Exception {
TimeInterval standardTimeout = new TimeInterval(2L, TimeUnit.SECONDS);
String adapterName = this.getClass().getSimpleName() + "." + getName();
Adapter adapter = createAdapter(adapterName);
MockConnection conn = new MockConnection(getName(), new TimeInterval(100L, TimeUnit.MILLISECONDS).toMilliseconds());
adapter.getSharedComponents().addConnection(conn);
AdapterManager adapterManager = new AdapterManager(adapter);
try {
adapterManager.registerMBean();
ObjectName adapterObj = createAdapterObjectName(adapterName);
AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, adapterObj, AdapterManagerMBean.class);
adapterManager.requestStart();
manager.requestClose(standardTimeout.toMilliseconds());
assertEquals(ClosedState.getInstance(), manager.getComponentState());
adapterManager.requestStart();
assertEquals(StartedState.getInstance(), manager.getComponentState());
try {
manager.requestClose(new TimeInterval(100L, TimeUnit.MILLISECONDS).toMilliseconds());
fail();
} catch (TimeoutException expected) {
}
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
Aggregations