|
37 | 37 | import java.io.IOException;
|
38 | 38 | import java.util.List;
|
39 | 39 | import java.util.ArrayList;
|
40 |
| -import java.util.Hashtable; |
| 40 | +import java.util.HashMap; |
| 41 | +import java.util.Map; |
41 | 42 |
|
42 | 43 | public class Routing extends BrokerTestCase
|
43 | 44 | {
|
@@ -166,55 +167,74 @@ public void testTopicRouting() throws Exception {
|
166 | 167 | }
|
167 | 168 |
|
168 | 169 | public void testHeadersRouting() throws Exception {
|
169 |
| - Hashtable<String, Object> spec = new Hashtable<String, Object>(); |
170 |
| - spec.put("h1", "12345"); |
171 |
| - spec.put("h2", "bar"); |
172 |
| - // See bug 20154: no current way to add a "Void"-typed spec pattern. |
173 |
| - spec.put("x-match", "all"); |
174 |
| - channel.queueBind(Q1, "amq.match", "", spec); |
175 |
| - spec.put("x-match", "any"); |
176 |
| - channel.queueBind(Q2, "amq.match", "", spec); |
177 |
| - |
178 |
| - AMQP.BasicProperties props = new AMQP.BasicProperties(); |
179 |
| - |
180 |
| - channel.basicPublish("amq.match", "", null, "0".getBytes()); |
181 |
| - channel.basicPublish("amq.match", "", props, "0b".getBytes()); |
182 |
| - |
183 |
| - props.setHeaders(new Hashtable<String, Object>()); |
184 |
| - props.getHeaders().put("h1", "12345"); |
185 |
| - channel.basicPublish("amq.match", "", props, "1".getBytes()); |
186 |
| - |
187 |
| - props.setHeaders(new Hashtable<String, Object>()); |
188 |
| - props.getHeaders().put("h1", 12345); |
189 |
| - channel.basicPublish("amq.match", "", props, "1b".getBytes()); |
190 |
| - |
191 |
| - props.setHeaders(new Hashtable<String, Object>()); |
192 |
| - props.getHeaders().put("h2", "bar"); |
193 |
| - channel.basicPublish("amq.match", "", props, "2".getBytes()); |
194 |
| - |
195 |
| - props.setHeaders(new Hashtable<String, Object>()); |
196 |
| - props.getHeaders().put("h1", "12345"); |
197 |
| - props.getHeaders().put("h2", "bar"); |
198 |
| - channel.basicPublish("amq.match", "", props, "3".getBytes()); |
199 |
| - |
200 |
| - props.setHeaders(new Hashtable<String, Object>()); |
201 |
| - props.getHeaders().put("h1", "12345"); |
202 |
| - props.getHeaders().put("h2", "quux"); |
203 |
| - channel.basicPublish("amq.match", "", props, "4".getBytes()); |
204 |
| - |
205 |
| - props.setHeaders(new Hashtable<String, Object>()); |
206 |
| - props.getHeaders().put("h1", "zot"); |
207 |
| - props.getHeaders().put("h2", "quux"); |
208 |
| - channel.basicPublish("amq.match", "", props, "5".getBytes()); |
209 |
| - |
210 |
| - checkGet(Q1, true); // 3 |
211 |
| - checkGet(Q1, false); |
212 |
| - |
213 |
| - checkGet(Q2, true); // 1 |
214 |
| - checkGet(Q2, true); // 2 |
215 |
| - checkGet(Q2, true); // 3 |
216 |
| - checkGet(Q2, true); // 4 |
217 |
| - checkGet(Q2, false); |
| 170 | + Map<String, Object> spec = new HashMap<String, Object>(); |
| 171 | + spec.put("h1", "12345"); |
| 172 | + spec.put("h2", "bar"); |
| 173 | + spec.put("h3", null); |
| 174 | + spec.put("x-match", "all"); |
| 175 | + channel.queueBind(Q1, "amq.match", "", spec); |
| 176 | + spec.put("x-match", "any"); |
| 177 | + channel.queueBind(Q2, "amq.match", "", spec); |
| 178 | + |
| 179 | + AMQP.BasicProperties props = new AMQP.BasicProperties(); |
| 180 | + |
| 181 | + channel.basicPublish("amq.match", "", null, "0".getBytes()); |
| 182 | + channel.basicPublish("amq.match", "", props, "0b".getBytes()); |
| 183 | + |
| 184 | + props.setHeaders(new HashMap<String, Object>()); |
| 185 | + props.getHeaders().put("h1", "12345"); |
| 186 | + channel.basicPublish("amq.match", "", props, "1".getBytes()); |
| 187 | + |
| 188 | + props.setHeaders(new HashMap<String, Object>()); |
| 189 | + props.getHeaders().put("h1", 12345); |
| 190 | + channel.basicPublish("amq.match", "", props, "1b".getBytes()); |
| 191 | + |
| 192 | + props.setHeaders(new HashMap<String, Object>()); |
| 193 | + props.getHeaders().put("h2", "bar"); |
| 194 | + channel.basicPublish("amq.match", "", props, "2".getBytes()); |
| 195 | + |
| 196 | + props.setHeaders(new HashMap<String, Object>()); |
| 197 | + props.getHeaders().put("h1", "12345"); |
| 198 | + props.getHeaders().put("h2", "bar"); |
| 199 | + channel.basicPublish("amq.match", "", props, "3".getBytes()); |
| 200 | + |
| 201 | + props.setHeaders(new HashMap<String, Object>()); |
| 202 | + props.getHeaders().put("h1", "12345"); |
| 203 | + props.getHeaders().put("h2", "bar"); |
| 204 | + props.getHeaders().put("h3", null); |
| 205 | + channel.basicPublish("amq.match", "", props, "4".getBytes()); |
| 206 | + |
| 207 | + props.setHeaders(new HashMap<String, Object>()); |
| 208 | + props.getHeaders().put("h1", "12345"); |
| 209 | + props.getHeaders().put("h2", "quux"); |
| 210 | + channel.basicPublish("amq.match", "", props, "5".getBytes()); |
| 211 | + |
| 212 | + props.setHeaders(new HashMap<String, Object>()); |
| 213 | + props.getHeaders().put("h1", "zot"); |
| 214 | + props.getHeaders().put("h2", "quux"); |
| 215 | + props.getHeaders().put("h3", null); |
| 216 | + channel.basicPublish("amq.match", "", props, "6".getBytes()); |
| 217 | + |
| 218 | + props.setHeaders(new HashMap<String, Object>()); |
| 219 | + props.getHeaders().put("h3", null); |
| 220 | + channel.basicPublish("amq.match", "", props, "7".getBytes()); |
| 221 | + |
| 222 | + props.setHeaders(new HashMap<String, Object>()); |
| 223 | + props.getHeaders().put("h1", "zot"); |
| 224 | + props.getHeaders().put("h2", "quux"); |
| 225 | + channel.basicPublish("amq.match", "", props, "8".getBytes()); |
| 226 | + |
| 227 | + checkGet(Q1, true); // 4 |
| 228 | + checkGet(Q1, false); |
| 229 | + |
| 230 | + checkGet(Q2, true); // 1 |
| 231 | + checkGet(Q2, true); // 2 |
| 232 | + checkGet(Q2, true); // 3 |
| 233 | + checkGet(Q2, true); // 4 |
| 234 | + checkGet(Q2, true); // 5 |
| 235 | + checkGet(Q2, true); // 6 |
| 236 | + checkGet(Q2, true); // 7 |
| 237 | + checkGet(Q2, false); |
218 | 238 | }
|
219 | 239 |
|
220 | 240 | }
|
|
0 commit comments