Search in sources :

Example 1 with WaitCondition

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

the class EventRelayClassLoaderBundleIT method testThatEventHandlerClassLoaderIsInvokedWithCurrentClassLoaderSetAsEventRelaysClassLoader.

@Test
public void testThatEventHandlerClassLoaderIsInvokedWithCurrentClassLoaderSetAsEventRelaysClassLoader() throws InterruptedException {
    assertNotNull(eventListenerRegistry);
    assertNotNull(eventRelay);
    new Wait(new ContextPublishedWaitCondition(bundleContext, "org.motechproject.motech-platform-event"), 5000).start();
    eventRelay.sendEventMessage(new MotechEvent(TestHandler.SUBJECT_READ));
    final Properties properties = TestHandler.PROPERTIES;
    new Wait(new WaitCondition() {

        @Override
        public boolean needsToWait() {
            return properties.isEmpty();
        }
    }, 2000).start();
    assertTrue(properties.containsKey("message"));
    assertEquals("hello world", properties.get("message"));
}
Also used : WaitCondition(org.motechproject.testing.osgi.wait.WaitCondition) ContextPublishedWaitCondition(org.motechproject.testing.osgi.wait.ContextPublishedWaitCondition) ContextPublishedWaitCondition(org.motechproject.testing.osgi.wait.ContextPublishedWaitCondition) Wait(org.motechproject.testing.osgi.wait.Wait) Properties(java.util.Properties) MotechEvent(org.motechproject.event.MotechEvent) Test(org.junit.Test)

Example 2 with WaitCondition

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

the class ListenerBundleLifecycleBundleIT method waitForBundleState.

private void waitForBundleState(final Bundle bundle, final int state) throws Exception {
    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 3 with WaitCondition

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

the class BlueprintContextTrackerBundleIT method testThatHttpServiceTrackerWasAdded.

@Test
public void testThatHttpServiceTrackerWasAdded() throws InterruptedException {
    final Bundle testBundle = bundleContext.getBundle();
    new Wait(new WaitCondition() {

        @Override
        public boolean needsToWait() {
            return !httpServiceTrackers.isBeingTracked(testBundle);
        }
    }, WAIT_TIME).start();
    assertTrue(httpServiceTrackers.isBeingTracked(testBundle));
}
Also used : WaitCondition(org.motechproject.testing.osgi.wait.WaitCondition) Bundle(org.osgi.framework.Bundle) Wait(org.motechproject.testing.osgi.wait.Wait) Test(org.junit.Test)

Example 4 with WaitCondition

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

the class BlueprintContextTrackerBundleIT method testThatUIServiceTrackerWasAdded.

@Test
public void testThatUIServiceTrackerWasAdded() throws InterruptedException {
    final Bundle testBundle = bundleContext.getBundle();
    new Wait(new WaitCondition() {

        @Override
        public boolean needsToWait() {
            return !uiServiceTrackers.isBeingTracked(testBundle);
        }
    }, WAIT_TIME).start();
    assertTrue(uiServiceTrackers.isBeingTracked(testBundle));
}
Also used : WaitCondition(org.motechproject.testing.osgi.wait.WaitCondition) Bundle(org.osgi.framework.Bundle) Wait(org.motechproject.testing.osgi.wait.Wait) Test(org.junit.Test)

Example 5 with WaitCondition

use of org.motechproject.testing.osgi.wait.WaitCondition 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)

Aggregations

Wait (org.motechproject.testing.osgi.wait.Wait)5 WaitCondition (org.motechproject.testing.osgi.wait.WaitCondition)5 Test (org.junit.Test)3 Bundle (org.osgi.framework.Bundle)2 Properties (java.util.Properties)1 MotechEvent (org.motechproject.event.MotechEvent)1 ContextPublishedWaitCondition (org.motechproject.testing.osgi.wait.ContextPublishedWaitCondition)1