public void testSubscriptionPauseResume() throws JMSException, InterruptedException {
final Slot result = new Slot();
ActiveMQNotificationBroker broker = new ActiveMQNotificationBroker() {
protected org.servicemix.ws.notification.NotificationConsumer createNotificationConsumer(EndpointReferenceType consumerReference) {
return new StubNotificationConsumer(result);
}
};
EndpointReferenceType subRef = addSubscription(broker);
// The sub should be running and we should be getting notifed now.
sendNotification(broker);
NotifyDocument subNotifyDoc = (NotifyDocument) result.poll(2000);
assertNotNull(subNotifyDoc);
// Pause the subscription.
PauseSubscriptionDocument pauseRequest = PauseSubscriptionDocument.Factory.newInstance();
pauseRequest.addNewPauseSubscription();
broker.getSubscriptionManager().pauseSubcription(pauseRequest, subRef);
// The sub should be stopped and we should not be getting notifed now.
sendNotification(broker);
subNotifyDoc = (NotifyDocument) result.poll(2000);
assertNull(subNotifyDoc);
// Resume the subscription.
ResumeSubscriptionDocument resumeRequest = ResumeSubscriptionDocument.Factory.newInstance();
resumeRequest.addNewResumeSubscription();
broker.getSubscriptionManager().resumeSubscription(resumeRequest, subRef);
// We should now get the message that was previously sent since the sub is now running.
subNotifyDoc = (NotifyDocument) result.poll(2000);
assertNotNull(subNotifyDoc);
}