Search in sources :

Example 1 with GoMessageListener

use of com.thoughtworks.go.server.messaging.GoMessageListener in project gocd by gocd.

the class JMSMessageListenerAdapterTest method shouldNotKillTheThreadWhenThereIsAnException.

@Test
public void shouldNotKillTheThreadWhenThereIsAnException() throws Exception {
    MessageConsumer consumer = mock(MessageConsumer.class);
    when(consumer.receive()).thenThrow(new RuntimeException("should swallow me"));
    GoMessageListener mockListener = new GoMessageListener() {

        public void onMessage(GoMessage message) {
            throw new UnsupportedOperationException("not implemented yet");
        }

        @Override
        public String toString() {
            return "test-listener";
        }
    };
    JMSMessageListenerAdapter listenerAdapter = JMSMessageListenerAdapter.startListening(consumer, mockListener, mock(DaemonThreadStatsCollector.class));
    try {
        listenerAdapter.runImpl();
    } catch (Exception e) {
        e.printStackTrace();
        fail("expected no exception get: " + e);
    }
}
Also used : MessageConsumer(javax.jms.MessageConsumer) DaemonThreadStatsCollector(com.thoughtworks.go.server.service.support.DaemonThreadStatsCollector) GoMessageListener(com.thoughtworks.go.server.messaging.GoMessageListener) GoMessage(com.thoughtworks.go.server.messaging.GoMessage) Test(org.junit.Test)

Aggregations

GoMessage (com.thoughtworks.go.server.messaging.GoMessage)1 GoMessageListener (com.thoughtworks.go.server.messaging.GoMessageListener)1 DaemonThreadStatsCollector (com.thoughtworks.go.server.service.support.DaemonThreadStatsCollector)1 MessageConsumer (javax.jms.MessageConsumer)1 Test (org.junit.Test)1