Search in sources :

Example 1 with QuiesceCallback

use of org.apache.aries.quiesce.manager.QuiesceCallback in project aries by apache.

the class BPQuiesceTest method canQuiesceNoBPBundle.

@Test
public void canQuiesceNoBPBundle() throws Exception {
    IMocksControl c = EasyMock.createControl();
    BundleContext ctx = c.createMock(BundleContext.class);
    Bundle bpBundle = c.createMock(Bundle.class);
    Bundle testBundle = c.createMock(Bundle.class);
    EasyMock.expect(ctx.getBundle()).andReturn(bpBundle);
    BlueprintQuiesceParticipant bqp = new BlueprintQuiesceParticipant(ctx, new BlueprintExtender() {

        @Override
        protected BlueprintContainerImpl getBlueprintContainerImpl(Bundle bundle) {
            return null;
        }
    });
    final Semaphore result = new Semaphore(0);
    QuiesceCallback qc = new QuiesceCallback() {

        public void bundleQuiesced(Bundle... bundlesQuiesced) {
            result.release();
        }
    };
    c.replay();
    bqp.quiesce(qc, Arrays.asList(testBundle));
    c.verify();
    assertTrue(result.tryAcquire(2, TimeUnit.SECONDS));
}
Also used : IMocksControl(org.easymock.IMocksControl) Bundle(org.osgi.framework.Bundle) Semaphore(java.util.concurrent.Semaphore) QuiesceCallback(org.apache.aries.quiesce.manager.QuiesceCallback) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Aggregations

Semaphore (java.util.concurrent.Semaphore)1 QuiesceCallback (org.apache.aries.quiesce.manager.QuiesceCallback)1 IMocksControl (org.easymock.IMocksControl)1 Test (org.junit.Test)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1