use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class AdapterManagerTest method testRestart_WithTimeout.
@Test
public void testRestart_WithTimeout() throws Exception {
TimeInterval standardTimeout = new TimeInterval(3L, 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();
log.trace(getName() + ": Requesting Restart with Timeout=" + standardTimeout.toMilliseconds());
manager.requestRestart(standardTimeout.toMilliseconds());
log.trace(getName() + ": Restarted");
assertEquals(StartedState.getInstance(), manager.getComponentState());
try {
log.trace(getName() + ": Requesting Restart with TimeInterval = 100");
manager.requestRestart(new TimeInterval(100L, TimeUnit.MILLISECONDS).toMilliseconds());
fail();
} catch (TimeoutException expected) {
log.trace(getName() + ": TimeoutException (as expected)");
}
} finally {
adapterManager.requestClose();
adapterManager.unregisterMBean();
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class AdapterManagerTest method testStart_WithTimeout.
@Test
public void testStart_WithTimeout() throws Exception {
TimeInterval standardTimeout = new TimeInterval(3L, 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);
manager.requestStart(standardTimeout.toMilliseconds());
assertEquals(StartedState.getInstance(), manager.getComponentState());
adapterManager.requestClose();
try {
manager.requestStart(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 testInitialise_WithTimeout.
@Test
public void testInitialise_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);
try {
manager.requestInit(-1);
fail();
} catch (IllegalArgumentException expected) {
}
manager.requestInit(standardTimeout.toMilliseconds());
assertEquals(InitialisedState.getInstance(), manager.getComponentState());
adapterManager.requestClose();
try {
manager.requestInit(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 BasicMessageSplitterServiceTest method testServiceSetters.
@Test
public void testServiceSetters() {
BasicMessageSplitterService service = new BasicMessageSplitterService();
assertEquals(NullConnection.class, service.getConnection().getClass());
assertEquals(NullMessageProducer.class, service.getProducer().getClass());
try {
service.setConnection(null);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
;
}
assertEquals(NullConnection.class, service.getConnection().getClass());
service.setConnection(new MockConnection());
assertEquals(MockConnection.class, service.getConnection().getClass());
try {
service.setProducer(null);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
;
}
assertEquals(NullMessageProducer.class, service.getProducer().getClass());
service.setProducer(new MockMessageProducer());
assertEquals(MockMessageProducer.class, service.getProducer().getClass());
try {
service.setSplitter(null);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
;
}
}
use of com.adaptris.core.stubs.MockConnection in project interlok by adaptris.
the class SharedComponentListTest method testLifecycle_Init.
@Test
public void testLifecycle_Init() 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);
assertEquals(2, list.getConnections().size());
for (AdaptrisConnection c : list.getConnections()) {
assertEquals(InitialisedState.getInstance(), c.retrieveComponentState());
}
} finally {
stop(list);
}
}
Aggregations