From 3b0a6e93789c127a3052ad6895cf5f2b58d196e7 Mon Sep 17 00:00:00 2001
From: TestBoost <153348110+TestBoost@users.noreply.github.com>
Date: Wed, 10 Apr 2024 09:35:13 -0500
Subject: [PATCH] only connect to the server once to speed up test
JmsIntegrationTest (#1405)
---
.../ws/transport/jms/JmsIntegrationTest.java | 74 +++++++++----------
1 file changed, 34 insertions(+), 40 deletions(-)
diff --git a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsIntegrationTest.java b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsIntegrationTest.java
index 9e07f9b9..6ef94484 100644
--- a/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsIntegrationTest.java
+++ b/spring-ws-support/src/test/java/org/springframework/ws/transport/jms/JmsIntegrationTest.java
@@ -13,11 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.springframework.ws.transport.jms;
import static org.xmlunit.assertj.XmlAssert.*;
-
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
@@ -31,52 +29,48 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.AfterAll;
@ExtendWith(SpringExtension.class)
@ContextConfiguration("jms-applicationContext.xml")
public class JmsIntegrationTest {
- @Autowired private WebServiceTemplate webServiceTemplate;
+ @Autowired
+ private WebServiceTemplate webServiceTemplate;
- private EmbeddedActiveMQ server;
+ private static EmbeddedActiveMQ server;
- @BeforeEach
- void setUp() throws Exception {
+ @BeforeAll
+ static void setUp() throws Exception {
+ Configuration config = new ConfigurationImpl();
+ config.addAcceptorConfiguration("vm", "vm://0");
+ config.addAcceptorConfiguration("tcp", "tcp://127.0.0.1:61616");
+ config.setSecurityEnabled(false);
+ server = new EmbeddedActiveMQ();
+ server.setConfiguration(config);
+ server.start();
+ }
- Configuration config = new ConfigurationImpl();
- config.addAcceptorConfiguration("vm", "vm://0");
- config.addAcceptorConfiguration("tcp", "tcp://127.0.0.1:61616");
- config.setSecurityEnabled(false);
- server = new EmbeddedActiveMQ();
- server.setConfiguration(config);
- server.start();
- }
+ @AfterAll
+ static void tearDown() throws Exception {
+ server.stop();
+ }
- @AfterEach
- void tearDown() throws Exception {
- server.stop();
- }
+ @Test
+ public void testTemporaryQueue() {
+ String content = "";
+ StringResult result = new StringResult();
+ webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
+ assertThat(result.toString()).and(content).ignoreWhitespace().areSimilar();
+ }
- @Test
- public void testTemporaryQueue() {
-
- String content = "";
- StringResult result = new StringResult();
-
- webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
-
- assertThat(result.toString()).and(content).ignoreWhitespace().areSimilar();
- }
-
- @Test
- public void testPermanentQueue() {
-
- String url = "jms:RequestQueue?deliveryMode=NON_PERSISTENT;replyToName=ResponseQueue";
- String content = "";
- StringResult result = new StringResult();
-
- webServiceTemplate.sendSourceAndReceiveToResult(url, new StringSource(content), result);
-
- assertThat(result.toString()).and(content).ignoreWhitespace().areSimilar();
- }
+ @Test
+ public void testPermanentQueue() {
+ String url = "jms:RequestQueue?deliveryMode=NON_PERSISTENT;replyToName=ResponseQueue";
+ String content = "";
+ StringResult result = new StringResult();
+ webServiceTemplate.sendSourceAndReceiveToResult(url, new StringSource(content), result);
+ assertThat(result.toString()).and(content).ignoreWhitespace().areSimilar();
+ }
}