Search in sources :

Example 6 with Wait

use of org.motechproject.testing.osgi.wait.Wait in project motech by motech.

the class BaseIT method waitForBundleState.

protected void waitForBundleState(final Bundle bundle, final int state) throws InterruptedException {
    new Wait(new WaitCondition() {

        @Override
        public boolean needsToWait() {
            return state == bundle.getState();
        }
    }, 2000).start();
    assertEquals(state, bundle.getState());
}
Also used : WaitCondition(org.motechproject.testing.osgi.wait.WaitCondition) Wait(org.motechproject.testing.osgi.wait.Wait)

Example 7 with Wait

use of org.motechproject.testing.osgi.wait.Wait in project motech by motech.

the class BundleContextWrapperBundleIT method testThatBundleContextWrapperReturnsCorrectApplicationContext.

@Test
public void testThatBundleContextWrapperReturnsCorrectApplicationContext() throws InterruptedException {
    BundleContextWrapper bundleContextWrapper = new BundleContextWrapper(bundleContext);
    Bundle bundle = bundleContext.getBundle();
    assertEquals(bundle.getSymbolicName(), bundleContextWrapper.getCurrentBundleSymbolicName());
    new Wait(new ContextPublishedWaitCondition(bundleContext), 5000).start();
    ApplicationContext applicationContextForCurrentBundle = bundleContextWrapper.getBundleApplicationContext();
    assertNotNull(applicationContextForCurrentBundle);
    Object testBundleContextWrapper = applicationContextForCurrentBundle.getBean("testBundleContextWrapper");
    assertNotNull(testBundleContextWrapper);
}
Also used : BundleContextWrapper(org.motechproject.osgi.web.BundleContextWrapper) ContextPublishedWaitCondition(org.motechproject.testing.osgi.wait.ContextPublishedWaitCondition) ApplicationContext(org.springframework.context.ApplicationContext) Bundle(org.osgi.framework.Bundle) Wait(org.motechproject.testing.osgi.wait.Wait) Test(org.junit.Test)

Aggregations

Wait (org.motechproject.testing.osgi.wait.Wait)7 Test (org.junit.Test)5 WaitCondition (org.motechproject.testing.osgi.wait.WaitCondition)5 ContextPublishedWaitCondition (org.motechproject.testing.osgi.wait.ContextPublishedWaitCondition)3 Bundle (org.osgi.framework.Bundle)3 MotechEvent (org.motechproject.event.MotechEvent)2 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 BundleContextWrapper (org.motechproject.osgi.web.BundleContextWrapper)1 ApplicationContext (org.springframework.context.ApplicationContext)1 SimpleMessageListenerAdapter (org.subethamail.smtp.helper.SimpleMessageListenerAdapter)1 SMTPServer (org.subethamail.smtp.server.SMTPServer)1