1:
17: package ;
18:
19: import ;
20: import ;
21: import ;
22:
23: import ;
24: import ;
25: import ;
26:
27: import ;
28:
29:
33:
... public class NewConsumerCreatesDestinationTest extends EmbeddedBrokerTestSupport {
34:
35:
private Connection connection;
36:
private ActiveMQQueue wildcard;
37:
38:
... public void testNewConsumerCausesNewDestinationToBeAutoCreated() throws Exception {
39:
connection = createConnection();
40:
41:
42:
String wildcardText = "org.*" + getDestinationString().substring("org.apache".length());
43:
wildcard = new ActiveMQQueue(wildcardText);
44:
45:
System.out.println("Using wildcard: " + wildcard);
46:
System.out.println("on destination: " + destination);
47:
48:
assertDestinationCreated(destination, false);
49:
assertDestinationCreated(wildcard, false);
50:
51:
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
52:
session.createConsumer(destination);
53:
54:
assertDestinationCreated(destination, true);
55:
assertDestinationCreated(wildcard, true);
56:
}
57:
58:
... protected void tearDown() throws Exception {
59:
... if (connection != null) {
60:
connection.close();
61:
}
62:
super.tearDown();
63:
}
64:
65:
... protected void assertDestinationCreated(Destination destination, boolean expected) throws Exception {
66:
Set answer = broker.getBroker().getDestinations((ActiveMQDestination) destination);
67:
int size = expected ? 1 : 0;
68:
assertEquals("Size of found destinations: " + answer, size, answer.size());
69:
}
70:
}