|
16 | 16 | */ |
17 | 17 | package org.apache.catalina.tribes.group; |
18 | 18 |
|
| 19 | +import java.util.Iterator; |
19 | 20 | import java.util.concurrent.ScheduledFuture; |
20 | 21 |
|
21 | 22 | import org.junit.After; |
22 | 23 | import org.junit.Assert; |
| 24 | +import org.junit.Assume; |
23 | 25 | import org.junit.Before; |
24 | 26 | import org.junit.Test; |
25 | 27 |
|
26 | 28 | import org.apache.catalina.tribes.Channel; |
| 29 | +import org.apache.catalina.tribes.ChannelInterceptor; |
27 | 30 | import org.apache.catalina.tribes.membership.McastService; |
28 | 31 | import org.apache.catalina.tribes.transport.ReceiverBase; |
29 | 32 | import org.apache.catalina.tribes.transport.ReplicationTransmitter; |
@@ -166,6 +169,36 @@ public void testPartialStopKeepsHeartbeatAlive() throws Exception { |
166 | 169 | Assert.assertTrue(heartbeat.isCancelled()); |
167 | 170 | } |
168 | 171 |
|
| 172 | + @Test |
| 173 | + public void testStagedStopReleasesSslContext() throws Exception { |
| 174 | + channel.setPskIdentity("tribes-test"); |
| 175 | + channel.setPskKey("000102030405060708090a0b0c0d0e0f"); |
| 176 | + channel.start(Channel.DEFAULT); |
| 177 | + // The TLS context is only available when the TLS implementation is |
| 178 | + Assume.assumeNotNull(channel.getSslContext()); |
| 179 | + // Stop in stages: no single call stops all of the services |
| 180 | + channel.stop(Channel.SND_RX_SEQ); |
| 181 | + Assert.assertNotNull(channel.getSslContext()); |
| 182 | + channel.stop(Channel.SND_TX_SEQ | Channel.MBR_RX_SEQ | Channel.MBR_TX_SEQ); |
| 183 | + Assert.assertNull(channel.getSslContext()); |
| 184 | + } |
| 185 | + |
| 186 | + @Test |
| 187 | + public void testPartialStopKeepsInterceptorChannel() throws Exception { |
| 188 | + channel.start(Channel.DEFAULT); |
| 189 | + channel.stop(Channel.SND_RX_SEQ); |
| 190 | + // services are still running, the interceptors must still be attached to the channel |
| 191 | + for (Iterator<ChannelInterceptor> it = channel.getInterceptors(); it.hasNext();) { |
| 192 | + ChannelInterceptor interceptor = it.next(); |
| 193 | + Assert.assertSame(interceptor.getClass().getName(), channel, interceptor.getChannel()); |
| 194 | + } |
| 195 | + channel.stop(Channel.SND_TX_SEQ | Channel.MBR_RX_SEQ | Channel.MBR_TX_SEQ); |
| 196 | + for (Iterator<ChannelInterceptor> it = channel.getInterceptors(); it.hasNext();) { |
| 197 | + ChannelInterceptor interceptor = it.next(); |
| 198 | + Assert.assertNull(interceptor.getClass().getName(), interceptor.getChannel()); |
| 199 | + } |
| 200 | + } |
| 201 | + |
169 | 202 | @Test |
170 | 203 | public void testOverlappingPartialStart() throws Exception { |
171 | 204 | // start one service, then start everything: the already |
|
0 commit comments