Search in sources :

Example 1 with CXFBusLifeCycleManager

use of org.apache.cxf.bus.managers.CXFBusLifeCycleManager in project cxf by apache.

the class CXFBusLifeCycleManagerTest method testSingleListenerRegistration.

@Test
public void testSingleListenerRegistration() {
    BusLifeCycleListener listener1 = EasyMock.createMock(BusLifeCycleListener.class);
    CXFBusLifeCycleManager mgr = new CXFBusLifeCycleManager();
    mgr.registerLifeCycleListener(listener1);
    EasyMock.reset(listener1);
    listener1.initComplete();
    EasyMock.replay(listener1);
    mgr.initComplete();
    EasyMock.verify(listener1);
    EasyMock.reset(listener1);
    listener1.preShutdown();
    EasyMock.replay(listener1);
    mgr.preShutdown();
    EasyMock.verify(listener1);
    EasyMock.reset(listener1);
    listener1.postShutdown();
    EasyMock.replay(listener1);
    mgr.postShutdown();
    EasyMock.verify(listener1);
}
Also used : CXFBusLifeCycleManager(org.apache.cxf.bus.managers.CXFBusLifeCycleManager) Test(org.junit.Test)

Example 2 with CXFBusLifeCycleManager

use of org.apache.cxf.bus.managers.CXFBusLifeCycleManager in project cxf by apache.

the class CXFBusLifeCycleManagerTest method testMultipleListeners.

@Test
public void testMultipleListeners() {
    IMocksControl ctrl = EasyMock.createStrictControl();
    BusLifeCycleListener listener1 = ctrl.createMock(BusLifeCycleListener.class);
    BusLifeCycleListener listener2 = ctrl.createMock(BusLifeCycleListener.class);
    CXFBusLifeCycleManager mgr = new CXFBusLifeCycleManager();
    mgr.registerLifeCycleListener(listener1);
    mgr.registerLifeCycleListener(listener2);
    ctrl.reset();
    listener1.initComplete();
    listener2.initComplete();
    ctrl.replay();
    mgr.initComplete();
    ctrl.verify();
    ctrl.reset();
    listener2.preShutdown();
    listener1.preShutdown();
    ctrl.replay();
    mgr.preShutdown();
    ctrl.verify();
    ctrl.reset();
    listener2.postShutdown();
    listener1.postShutdown();
    ctrl.replay();
    mgr.postShutdown();
    ctrl.verify();
}
Also used : IMocksControl(org.easymock.IMocksControl) CXFBusLifeCycleManager(org.apache.cxf.bus.managers.CXFBusLifeCycleManager) Test(org.junit.Test)

Example 3 with CXFBusLifeCycleManager

use of org.apache.cxf.bus.managers.CXFBusLifeCycleManager in project cxf by apache.

the class BusApplicationListenerTest method testParentApplicationEvent.

@Test
public void testParentApplicationEvent() {
    AbstractRefreshableApplicationContext parent = new ClassPathXmlApplicationContext();
    parent.refresh();
    SpringBusFactory factory = new SpringBusFactory(parent);
    Bus bus = factory.createBus();
    CXFBusLifeCycleManager manager = bus.getExtension(CXFBusLifeCycleManager.class);
    BusLifeCycleListener listener = EasyMock.createMock(BusLifeCycleListener.class);
    manager.registerLifeCycleListener(listener);
    EasyMock.reset(listener);
    listener.preShutdown();
    EasyMock.expectLastCall().times(1);
    listener.postShutdown();
    EasyMock.expectLastCall().times(1);
    EasyMock.replay(listener);
    parent.close();
    EasyMock.verify(listener);
}
Also used : Bus(org.apache.cxf.Bus) AbstractRefreshableApplicationContext(org.springframework.context.support.AbstractRefreshableApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) BusLifeCycleListener(org.apache.cxf.buslifecycle.BusLifeCycleListener) CXFBusLifeCycleManager(org.apache.cxf.bus.managers.CXFBusLifeCycleManager) Test(org.junit.Test)

Example 4 with CXFBusLifeCycleManager

use of org.apache.cxf.bus.managers.CXFBusLifeCycleManager in project cxf by apache.

the class CXFBusLifeCycleManagerTest method testDeregistration.

@Test
public void testDeregistration() {
    IMocksControl ctrl = EasyMock.createStrictControl();
    BusLifeCycleListener listener1 = ctrl.createMock(BusLifeCycleListener.class);
    BusLifeCycleListener listener2 = ctrl.createMock(BusLifeCycleListener.class);
    CXFBusLifeCycleManager mgr = new CXFBusLifeCycleManager();
    mgr.registerLifeCycleListener(listener2);
    mgr.registerLifeCycleListener(listener1);
    mgr.unregisterLifeCycleListener(listener2);
    ctrl.reset();
    listener1.initComplete();
    ctrl.replay();
    mgr.initComplete();
    ctrl.verify();
    ctrl.reset();
    listener1.preShutdown();
    ctrl.replay();
    mgr.preShutdown();
    ctrl.verify();
    ctrl.reset();
    listener1.postShutdown();
    ctrl.replay();
    mgr.postShutdown();
    ctrl.verify();
}
Also used : IMocksControl(org.easymock.IMocksControl) CXFBusLifeCycleManager(org.apache.cxf.bus.managers.CXFBusLifeCycleManager) Test(org.junit.Test)

Example 5 with CXFBusLifeCycleManager

use of org.apache.cxf.bus.managers.CXFBusLifeCycleManager in project cxf by apache.

the class CXFBusLifeCycleManagerTest method testListenerNotRegistered.

@Test
public void testListenerNotRegistered() {
    BusLifeCycleListener listener1 = EasyMock.createMock(BusLifeCycleListener.class);
    CXFBusLifeCycleManager mgr = new CXFBusLifeCycleManager();
    EasyMock.reset(listener1);
    EasyMock.replay(listener1);
    mgr.initComplete();
    EasyMock.verify(listener1);
    EasyMock.reset(listener1);
    EasyMock.replay(listener1);
    mgr.preShutdown();
    EasyMock.verify(listener1);
    EasyMock.reset(listener1);
    EasyMock.replay(listener1);
    mgr.postShutdown();
    EasyMock.verify(listener1);
}
Also used : CXFBusLifeCycleManager(org.apache.cxf.bus.managers.CXFBusLifeCycleManager) Test(org.junit.Test)

Aggregations

CXFBusLifeCycleManager (org.apache.cxf.bus.managers.CXFBusLifeCycleManager)5 Test (org.junit.Test)5 IMocksControl (org.easymock.IMocksControl)2 Bus (org.apache.cxf.Bus)1 BusLifeCycleListener (org.apache.cxf.buslifecycle.BusLifeCycleListener)1 AbstractRefreshableApplicationContext (org.springframework.context.support.AbstractRefreshableApplicationContext)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1