use of org.motechproject.testing.osgi.wait.Wait in project motech by motech.
the class EmailChannelBundleIT method testEmailSentOnSendEmailEvent.
@Test
public void testEmailSentOnSendEmailEvent() throws MessagingException, IOException, InterruptedException {
SMTPServer smtpServer = new SMTPServer(new SimpleMessageListenerAdapter(this));
new Wait(new ContextPublishedWaitCondition(bundleContext, "org.motechproject.motech-platform-event"), 5000).start();
new Wait(new ContextPublishedWaitCondition(bundleContext), 5000).start();
try {
smtpServer.setPort(8099);
smtpServer.start();
String messageText = "test message";
String from = "testfromaddress";
String to = "testtoaddress";
String subject = "test subject";
Map<String, Object> values = new HashMap<>();
values.put("fromAddress", from);
values.put("toAddress", to);
values.put("message", messageText);
values.put("subject", subject);
eventRelay.sendEventMessage(new MotechEvent(SendEmailConstants.SEND_EMAIL_SUBJECT, values));
new Wait(lock, this, 100, 60000).start();
assertTrue("Message not received", messageReceived);
assertNotNull(receivedMessageText);
assertEquals(messageText, receivedMessageText.trim());
} finally {
smtpServer.stop();
}
}
use of org.motechproject.testing.osgi.wait.Wait 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"));
}
use of org.motechproject.testing.osgi.wait.Wait 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());
}
use of org.motechproject.testing.osgi.wait.Wait 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));
}
use of org.motechproject.testing.osgi.wait.Wait 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));
}
Aggregations