|
1 | 1 | /* |
2 | | - * Copyright 2005-2010 the original author or authors. |
| 2 | + * Copyright 2005-2012 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | 7 | * |
8 | | - * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 | * |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
@@ -64,7 +64,7 @@ public void createMessageFactory() throws Exception { |
64 | 64 | } |
65 | 65 |
|
66 | 66 | @Test |
67 | | - public void testSendAndReceiveQueueBytesMessage() throws Exception { |
| 67 | + public void testSendAndReceiveQueueBytesMessageTemporaryQueue() throws Exception { |
68 | 68 | WebServiceConnection connection = null; |
69 | 69 | try { |
70 | 70 | URI uri = new URI("jms:SenderRequestQueue?deliveryMode=NON_PERSISTENT"); |
@@ -102,6 +102,48 @@ public Message createMessage(Session session) throws JMSException { |
102 | 102 | } |
103 | 103 | } |
104 | 104 |
|
| 105 | + @Test |
| 106 | + public void testSendAndReceiveQueueBytesMessagePermanentQueue() throws Exception { |
| 107 | + WebServiceConnection connection = null; |
| 108 | + try { |
| 109 | + String responseQueueName = "SenderResponseQueue"; |
| 110 | + URI uri = new URI( |
| 111 | + "jms:SenderRequestQueue?replyToName=" + responseQueueName + "&deliveryMode=NON_PERSISTENT"); |
| 112 | + connection = messageSender.createConnection(uri); |
| 113 | + SoapMessage soapRequest = new SaajSoapMessage(messageFactory.createMessage()); |
| 114 | + soapRequest.setSoapAction(SOAP_ACTION); |
| 115 | + connection.send(soapRequest); |
| 116 | + |
| 117 | + final BytesMessage request = (BytesMessage) jmsTemplate.receive(); |
| 118 | + assertNotNull("No message received", request); |
| 119 | + assertTrue("No message content received", request.readByte() != -1); |
| 120 | + ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
| 121 | + messageFactory.createMessage().writeTo(bos); |
| 122 | + final byte[] buf = bos.toByteArray(); |
| 123 | + jmsTemplate.send(responseQueueName, new MessageCreator() { |
| 124 | + |
| 125 | + public Message createMessage(Session session) throws JMSException { |
| 126 | + BytesMessage response = session.createBytesMessage(); |
| 127 | + response.setJMSCorrelationID(request.getJMSMessageID()); |
| 128 | + response.setStringProperty(JmsTransportConstants.PROPERTY_SOAP_ACTION, SOAP_ACTION); |
| 129 | + response.setStringProperty(JmsTransportConstants.PROPERTY_CONTENT_TYPE, |
| 130 | + SoapVersion.SOAP_11.getContentType()); |
| 131 | + response.writeBytes(buf); |
| 132 | + return response; |
| 133 | + } |
| 134 | + }); |
| 135 | + SoapMessage response = (SoapMessage) connection.receive(new SaajSoapMessageFactory(messageFactory)); |
| 136 | + assertNotNull("No response received", response); |
| 137 | + assertEquals("Invalid SOAPAction", SOAP_ACTION, response.getSoapAction()); |
| 138 | + assertFalse("Message is fault", response.hasFault()); |
| 139 | + } |
| 140 | + finally { |
| 141 | + if (connection != null) { |
| 142 | + connection.close(); |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + |
105 | 147 | @Test |
106 | 148 | public void testSendAndReceiveQueueTextMessage() throws Exception { |
107 | 149 | WebServiceConnection connection = null; |
|
0 commit comments