1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.transport.jms;
18
19 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.test.context.ContextConfiguration;
21 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
22 import org.springframework.ws.client.core.WebServiceTemplate;
23 import org.springframework.xml.transform.StringResult;
24 import org.springframework.xml.transform.StringSource;
25
26 import org.custommonkey.xmlunit.XMLAssert;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29
30 @RunWith(SpringJUnit4ClassRunner.class)
31 @ContextConfiguration("jms-applicationContext.xml")
32 public class JmsIntegrationTest {
33
34 @Autowired
35 private WebServiceTemplate webServiceTemplate;
36
37
38 public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
39 this.webServiceTemplate = webServiceTemplate;
40 }
41
42 @Test
43 public void testTemporaryQueue() throws Exception {
44 String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
45 StringResult result = new StringResult();
46 webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
47 XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
48 }
49
50 @Test
51 public void testPermanentQueue() throws Exception {
52 String url = "jms:RequestQueue?deliveryMode=NON_PERSISTENT;replyToName=ResponseQueue";
53 String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
54 StringResult result = new StringResult();
55 webServiceTemplate.sendSourceAndReceiveToResult(url, new StringSource(content), result);
56 XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
57 }
58 }