|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2015 the original author or authors. |
| 2 | + * Copyright 2012-2016 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
22 | 22 | import javax.jms.JMSException;
|
23 | 23 |
|
24 | 24 | import org.junit.Test;
|
| 25 | +import org.mockito.Mockito; |
25 | 26 |
|
26 | 27 | import static org.junit.Assert.assertEquals;
|
27 | 28 | import static org.mockito.BDDMockito.given;
|
@@ -78,4 +79,21 @@ public void jmsBrokerCouldNotRetrieveProviderMetadata() throws JMSException {
|
78 | 79 | verify(connection, times(1)).close();
|
79 | 80 | }
|
80 | 81 |
|
| 82 | + @Test |
| 83 | + public void jmsBrokerUsesFailover() throws JMSException { |
| 84 | + ConnectionFactory connectionFactory = mock(ConnectionFactory.class); |
| 85 | + ConnectionMetaData connectionMetaData = mock(ConnectionMetaData.class); |
| 86 | + given(connectionMetaData.getJMSProviderName()).willReturn("JMS test provider"); |
| 87 | + Connection connection = mock(Connection.class); |
| 88 | + given(connection.getMetaData()).willReturn(connectionMetaData); |
| 89 | + Mockito.doThrow(new JMSException("Could not start", "123")) |
| 90 | + .when(connection).start(); |
| 91 | + given(connectionFactory.createConnection()) |
| 92 | + .willReturn(connection); |
| 93 | + JmsHealthIndicator indicator = new JmsHealthIndicator(connectionFactory); |
| 94 | + Health health = indicator.health(); |
| 95 | + assertEquals(Status.DOWN, health.getStatus()); |
| 96 | + assertEquals(null, health.getDetails().get("provider")); |
| 97 | + } |
| 98 | + |
81 | 99 | }
|
0 commit comments