Skip to content

Commit cb59ad8

Browse files
committed
Set up JMS destination in JUnit extension
1 parent 5bcdc80 commit cb59ad8

File tree

7 files changed

+309
-258
lines changed

7 files changed

+309
-258
lines changed

deps/rabbit/test/amqp_jms_SUITE.erl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,17 @@ jms_temporary_queue(Config) ->
122122

123123
%% Send different message types from JMS client to JMS client.
124124
message_types_jms_to_jms(Config) ->
125-
TestName = QName = atom_to_binary(?FUNCTION_NAME),
126-
ok = declare_queue(QName, <<"quorum">>, Config),
127-
ok = run_jms_test(TestName, [{"-Dqueue=~ts", [rabbitmq_amqp_address:queue(QName)]}], Config),
128-
ok = delete_queue(QName, Config).
125+
TestName = atom_to_binary(?FUNCTION_NAME),
126+
ok = run_jms_test(TestName, [], Config).
129127

130128
%% Send different message types from JMS client to Erlang AMQP 1.0 client.
131129
message_types_jms_to_amqp(Config) ->
132130
TestName = atom_to_binary(?FUNCTION_NAME),
133131
ok = run_jms_test(TestName, [], Config).
134132

135133
temporary_queue_rpc(Config) ->
136-
TestName = QName = atom_to_binary(?FUNCTION_NAME),
137-
ok = declare_queue(QName, <<"classic">>, Config),
138-
ok = run_jms_test(TestName, [{"-Dqueue=~ts", [rabbitmq_amqp_address:queue(QName)]}], Config),
139-
ok = delete_queue(QName, Config).
134+
TestName = atom_to_binary(?FUNCTION_NAME),
135+
ok = run_jms_test(TestName, [], Config).
140136

141137
temporary_queue_delete(Config) ->
142138
TestName = atom_to_binary(?FUNCTION_NAME),

deps/rabbit/test/amqp_jms_SUITE_data/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,26 @@
8989
<style>GOOGLE</style>
9090
</googleJavaFormat>
9191
</java>
92+
<ratchetFrom>origin/main</ratchetFrom>
93+
<licenseHeader>
94+
<content>// The contents of this file are subject to the Mozilla Public License
95+
// Version 2.0 (the "License"); you may not use this file except in
96+
// compliance with the License. You may obtain a copy of the License
97+
// at https://www.mozilla.org/en-US/MPL/2.0/
98+
//
99+
// Software distributed under the License is distributed on an "AS IS"
100+
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
101+
// the License for the specific language governing rights and
102+
// limitations under the License.
103+
//
104+
// The Original Code is RabbitMQ.
105+
//
106+
// The Initial Developer of the Original Code is Pivotal Software, Inc.
107+
// Copyright (c) $YEAR Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc.
108+
// and/or its subsidiaries. All rights reserved.
109+
//
110+
</content>
111+
</licenseHeader>
92112
</configuration>
93113
</plugin>
94114

deps/rabbit/test/amqp_jms_SUITE_data/src/test/java/com/rabbitmq/amqp/tests/jms/JmsConnectionTest.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// Copyright (c) 2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc.
1515
// and/or its subsidiaries. All rights reserved.
1616
//
17-
1817
package com.rabbitmq.amqp.tests.jms;
1918

2019
import static com.rabbitmq.amqp.tests.jms.Cli.startBroker;
@@ -41,20 +40,20 @@
4140
@JmsTestInfrastructure
4241
public class JmsConnectionTest {
4342

44-
String destination;
43+
ConnectionFactory factory;
4544

4645
@Test
4746
@Timeout(30)
4847
public void testCreateConnection() throws Exception {
49-
try (Connection connection = connection()) {
48+
try (Connection connection = factory.createConnection()) {
5049
assertNotNull(connection);
5150
}
5251
}
5352

5453
@Test
5554
@Timeout(30)
5655
public void testCreateConnectionAndStart() throws Exception {
57-
try (Connection connection = connection()) {
56+
try (Connection connection = factory.createConnection()) {
5857
assertNotNull(connection);
5958
connection.start();
6059
}
@@ -65,7 +64,6 @@ public void testCreateConnectionAndStart() throws Exception {
6564
// Currently not supported by RabbitMQ.
6665
@Disabled
6766
public void testCreateWithDuplicateClientIdFails() throws Exception {
68-
JmsConnectionFactory factory = (JmsConnectionFactory) connectionFactory();
6967
JmsConnection connection1 = (JmsConnection) factory.createConnection();
7068
connection1.setClientID("Test");
7169
assertNotNull(connection1);
@@ -89,7 +87,7 @@ public void testSetClientIdAfterStartedFails() {
8987
assertThrows(
9088
JMSException.class,
9189
() -> {
92-
try (Connection connection = connection()) {
90+
try (Connection connection = factory.createConnection()) {
9391
connection.setClientID("Test");
9492
connection.start();
9593
connection.setClientID("NewTest");
@@ -100,9 +98,10 @@ public void testSetClientIdAfterStartedFails() {
10098
@Test
10199
@Timeout(30)
102100
public void testCreateConnectionAsSystemAdmin() throws Exception {
103-
JmsConnectionFactory factory = (JmsConnectionFactory) connectionFactory();
104-
factory.setUsername(adminUsername());
105-
factory.setPassword(adminPassword());
101+
JmsConnectionFactory f = (JmsConnectionFactory) factory;
102+
103+
f.setUsername(adminUsername());
104+
f.setPassword(adminPassword());
106105
try (Connection connection = factory.createConnection()) {
107106
assertNotNull(connection);
108107
connection.start();
@@ -112,22 +111,21 @@ public void testCreateConnectionAsSystemAdmin() throws Exception {
112111
@Test
113112
@Timeout(30)
114113
public void testCreateConnectionCallSystemAdmin() throws Exception {
115-
try (Connection connection =
116-
connectionFactory().createConnection(adminUsername(), adminPassword())) {
114+
try (Connection connection = factory.createConnection(adminUsername(), adminPassword())) {
117115
assertNotNull(connection);
118116
connection.start();
119117
}
120118
}
121119

122120
@Test
123121
@Timeout(30)
124-
public void testCreateConnectionAsUnknwonUser() {
122+
public void testCreateConnectionAsUnknownUser() {
125123
assertThrows(
126124
JMSSecurityException.class,
127125
() -> {
128-
JmsConnectionFactory factory = (JmsConnectionFactory) connectionFactory();
129-
factory.setUsername("unknown");
130-
factory.setPassword("unknown");
126+
JmsConnectionFactory f = (JmsConnectionFactory) factory;
127+
f.setUsername("unknown");
128+
f.setPassword("unknown");
131129
try (Connection connection = factory.createConnection()) {
132130
assertNotNull(connection);
133131
connection.start();
@@ -137,11 +135,11 @@ public void testCreateConnectionAsUnknwonUser() {
137135

138136
@Test
139137
@Timeout(30)
140-
public void testCreateConnectionCallUnknwonUser() {
138+
public void testCreateConnectionCallUnknownUser() {
141139
assertThrows(
142140
JMSSecurityException.class,
143141
() -> {
144-
try (Connection connection = connectionFactory().createConnection("unknown", "unknown")) {
142+
try (Connection connection = factory.createConnection("unknown", "unknown")) {
145143
assertNotNull(connection);
146144
connection.start();
147145
}
@@ -150,11 +148,10 @@ public void testCreateConnectionCallUnknwonUser() {
150148

151149
@Test
152150
@Timeout(30)
153-
public void testBrokerStopWontHangConnectionClose() throws Exception {
154-
Connection connection = connection();
151+
public void testBrokerStopWontHangConnectionClose(Queue queue) throws Exception {
152+
Connection connection = factory.createConnection();
155153
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
156154

157-
Queue queue = queue(destination);
158155
connection.start();
159156

160157
MessageProducer producer = session.createProducer(queue);
@@ -179,7 +176,7 @@ public void testBrokerStopWontHangConnectionClose() throws Exception {
179176
@Timeout(60)
180177
public void testConnectionExceptionBrokerStop() throws Exception {
181178
final CountDownLatch latch = new CountDownLatch(1);
182-
try (Connection connection = connection()) {
179+
try (Connection connection = factory.createConnection()) {
183180
connection.setExceptionListener(exception -> latch.countDown());
184181
connection.start();
185182
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

deps/rabbit/test/amqp_jms_SUITE_data/src/test/java/com/rabbitmq/amqp/tests/jms/JmsTemporaryQueueTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
// Copyright (c) 2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc.
1515
// and/or its subsidiaries. All rights reserved.
1616
//
17-
1817
package com.rabbitmq.amqp.tests.jms;
1918

2019
import static com.rabbitmq.amqp.tests.jms.TestUtils.brokerUri;
21-
import static com.rabbitmq.amqp.tests.jms.TestUtils.connection;
2220
import static org.junit.jupiter.api.Assertions.*;
2321
import static org.junit.jupiter.api.Assertions.fail;
2422

@@ -35,13 +33,16 @@
3533
* Based on
3634
* https://github.com/apache/qpid-jms/tree/main/qpid-jms-interop-tests/qpid-jms-activemq-tests.
3735
*/
36+
@JmsTestInfrastructure
3837
public class JmsTemporaryQueueTest {
3938

39+
ConnectionFactory factory;
40+
4041
Connection connection;
4142

4243
@BeforeEach
4344
void init() throws JMSException {
44-
connection = connection();
45+
connection = factory.createConnection();
4546
}
4647

4748
@AfterEach

0 commit comments

Comments
 (0)