1   /*
2    * Copyright 2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.ws.transport.jms;
18  
19  import org.custommonkey.xmlunit.XMLAssert;
20  
21  import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
22  import org.springframework.ws.client.core.WebServiceTemplate;
23  import org.springframework.xml.transform.StringResult;
24  import org.springframework.xml.transform.StringSource;
25  
26  public class JmsIntegrationTest extends AbstractDependencyInjectionSpringContextTests {
27  
28      private WebServiceTemplate webServiceTemplate;
29  
30      protected String[] getConfigLocations() {
31          return new String[]{"classpath:org/springframework/ws/transport/jms/jms-applicationContext.xml"};
32      }
33  
34      public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
35          this.webServiceTemplate = webServiceTemplate;
36      }
37  
38      protected void onTearDown() throws Exception {
39          applicationContext.close();
40          setDirty();
41      }
42  
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      public void testPermanentQueue() throws Exception {
51          String url = "jms:RequestQueue?deliveryMode=NON_PERSISTENT;replyToName=ResponseQueue";
52          String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
53          StringResult result = new StringResult();
54          webServiceTemplate.sendSourceAndReceiveToResult(url, new StringSource(content), result);
55          XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
56      }
57  }