queue.setAdminsThatShouldDeclare(admin);
context.getBeanFactory().registerSingleton("foo", queue);
DirectExchange exchange = new DirectExchange("bar");
exchange.setAdminsThatShouldDeclare(admin);
context.getBeanFactory().registerSingleton("bar", exchange);
Binding binding = new Binding("foo", DestinationType.QUEUE, "bar", "foo", null);
binding.setAdminsThatShouldDeclare(admin);
context.getBeanFactory().registerSingleton("baz", binding);
context.refresh();
admin.setApplicationContext(context);
admin.afterPropertiesSet();
assertNotNull(listener.get());