|
1 | 1 | /*
|
2 |
| - * Copyright 2020-2021 the original author or authors. |
| 2 | + * Copyright 2020-2022 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.
|
@@ -110,6 +110,36 @@ void testBasic() throws Exception {
|
110 | 110 | .isFalse();
|
111 | 111 | }
|
112 | 112 |
|
| 113 | + @Test |
| 114 | + void testClose() throws Exception { |
| 115 | + ConnectionFactory rabbitConnectionFactory = new ConnectionFactory(); |
| 116 | + rabbitConnectionFactory.setHost("localhost"); |
| 117 | + ThreadChannelConnectionFactory tccf = new ThreadChannelConnectionFactory(rabbitConnectionFactory); |
| 118 | + Connection conn = tccf.createConnection(); |
| 119 | + Channel chann1 = conn.createChannel(false); |
| 120 | + Channel targetChannel1 = ((ChannelProxy) chann1).getTargetChannel(); |
| 121 | + chann1.close(); |
| 122 | + Channel chann2 = conn.createChannel(false); |
| 123 | + Channel targetChannel2 = ((ChannelProxy) chann2).getTargetChannel(); |
| 124 | + assertThat(chann2).isSameAs(chann1); |
| 125 | + assertThat(targetChannel2).isSameAs(targetChannel1); |
| 126 | + } |
| 127 | + |
| 128 | + @Test |
| 129 | + void testTxClose() throws Exception { |
| 130 | + ConnectionFactory rabbitConnectionFactory = new ConnectionFactory(); |
| 131 | + rabbitConnectionFactory.setHost("localhost"); |
| 132 | + ThreadChannelConnectionFactory tccf = new ThreadChannelConnectionFactory(rabbitConnectionFactory); |
| 133 | + Connection conn = tccf.createConnection(); |
| 134 | + Channel chann1 = conn.createChannel(true); |
| 135 | + Channel targetChannel1 = ((ChannelProxy) chann1).getTargetChannel(); |
| 136 | + chann1.close(); |
| 137 | + Channel chann2 = conn.createChannel(true); |
| 138 | + Channel targetChannel2 = ((ChannelProxy) chann2).getTargetChannel(); |
| 139 | + assertThat(chann2).isSameAs(chann1); |
| 140 | + assertThat(targetChannel2).isSameAs(targetChannel1); |
| 141 | + } |
| 142 | + |
113 | 143 | @Test
|
114 | 144 | void queueDeclared(@Autowired RabbitAdmin admin, @Autowired Config config,
|
115 | 145 | @Autowired ThreadChannelConnectionFactory tccf) throws Exception {
|
|
0 commit comments