Upgraded tests.
This commit is contained in:
@@ -16,32 +16,30 @@
|
||||
|
||||
package org.springframework.ws.transport.jms;
|
||||
|
||||
import org.custommonkey.xmlunit.XMLAssert;
|
||||
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.ws.client.core.WebServiceTemplate;
|
||||
import org.springframework.xml.transform.StringResult;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
|
||||
public class JmsIntegrationTest extends AbstractDependencyInjectionSpringContextTests {
|
||||
import org.custommonkey.xmlunit.XMLAssert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("jms-applicationContext.xml")
|
||||
public class JmsIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private WebServiceTemplate webServiceTemplate;
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"classpath:org/springframework/ws/transport/jms/jms-applicationContext.xml"};
|
||||
}
|
||||
|
||||
public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
|
||||
this.webServiceTemplate = webServiceTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTearDown() throws Exception {
|
||||
applicationContext.close();
|
||||
setDirty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemporaryQueue() throws Exception {
|
||||
String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
|
||||
StringResult result = new StringResult();
|
||||
@@ -49,6 +47,7 @@ public class JmsIntegrationTest extends AbstractDependencyInjectionSpringContext
|
||||
XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPermanentQueue() throws Exception {
|
||||
String url = "jms:RequestQueue?deliveryMode=NON_PERSISTENT;replyToName=ResponseQueue";
|
||||
String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
|
||||
|
||||
@@ -26,44 +26,44 @@ import javax.jms.TextMessage;
|
||||
import javax.xml.soap.MessageFactory;
|
||||
import javax.xml.soap.SOAPConstants;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.core.MessageCreator;
|
||||
import org.springframework.jms.core.MessagePostProcessor;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.SoapVersion;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessage;
|
||||
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
|
||||
import org.springframework.ws.transport.WebServiceConnection;
|
||||
|
||||
public class JmsMessageSenderIntegrationTest extends AbstractDependencyInjectionSpringContextTests {
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("jms-sender-applicationContext.xml")
|
||||
public class JmsMessageSenderIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private JmsMessageSender messageSender;
|
||||
|
||||
@Autowired
|
||||
private JmsTemplate jmsTemplate;
|
||||
|
||||
private MessageFactory messageFactory;
|
||||
|
||||
private static final String SOAP_ACTION = "\"http://springframework.org/DoIt\"";
|
||||
|
||||
@Override
|
||||
protected void onSetUp() throws Exception {
|
||||
@Before
|
||||
public void createMessageFactory() throws Exception {
|
||||
messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"classpath:org/springframework/ws/transport/jms/jms-sender-applicationContext.xml"};
|
||||
}
|
||||
|
||||
public void setJmsTemplate(JmsTemplate jmsTemplate) {
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
}
|
||||
|
||||
public void setMessageSender(JmsMessageSender messageSender) {
|
||||
this.messageSender = messageSender;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendAndReceiveQueueBytesMessage() throws Exception {
|
||||
WebServiceConnection connection = null;
|
||||
try {
|
||||
@@ -102,6 +102,7 @@ public class JmsMessageSenderIntegrationTest extends AbstractDependencyInjection
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendAndReceiveQueueTextMessage() throws Exception {
|
||||
WebServiceConnection connection = null;
|
||||
try {
|
||||
@@ -140,6 +141,7 @@ public class JmsMessageSenderIntegrationTest extends AbstractDependencyInjection
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendNoResponse() throws Exception {
|
||||
WebServiceConnection connection = null;
|
||||
try {
|
||||
@@ -163,6 +165,7 @@ public class JmsMessageSenderIntegrationTest extends AbstractDependencyInjection
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostProcessor() throws Exception {
|
||||
MessagePostProcessor processor = new MessagePostProcessor() {
|
||||
public Message postProcessMessage(Message message) throws JMSException {
|
||||
|
||||
@@ -24,50 +24,40 @@ import javax.jms.Session;
|
||||
import javax.jms.TextMessage;
|
||||
import javax.jms.Topic;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.core.MessageCreator;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
public class WebServiceMessageListenerIntegrationTest extends AbstractDependencyInjectionSpringContextTests {
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("jms-receiver-applicationContext.xml")
|
||||
public class WebServiceMessageListenerIntegrationTest {
|
||||
|
||||
private static final String CONTENT =
|
||||
"<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>" + "<SOAP-ENV:Body>\n" +
|
||||
"<m:GetLastTradePrice xmlns:m='http://www.springframework.org/spring-ws'>\n" +
|
||||
"<symbol>DIS</symbol>\n" + "</m:GetLastTradePrice>\n" + "</SOAP-ENV:Body></SOAP-ENV:Envelope>";
|
||||
|
||||
@Autowired
|
||||
private JmsTemplate jmsTemplate;
|
||||
|
||||
@Autowired
|
||||
private Queue responseQueue;
|
||||
|
||||
@Autowired
|
||||
private Queue requestQueue;
|
||||
|
||||
@Autowired
|
||||
private Topic requestTopic;
|
||||
|
||||
public WebServiceMessageListenerIntegrationTest() {
|
||||
setAutowireMode(AUTOWIRE_BY_NAME);
|
||||
}
|
||||
|
||||
public void setJmsTemplate(JmsTemplate jmsTemplate) {
|
||||
this.jmsTemplate = jmsTemplate;
|
||||
}
|
||||
|
||||
public void setRequestQueue(Queue requestQueue) {
|
||||
this.requestQueue = requestQueue;
|
||||
}
|
||||
|
||||
public void setRequestTopic(Topic requestTopic) {
|
||||
this.requestTopic = requestTopic;
|
||||
}
|
||||
|
||||
public void setResponseQueue(Queue responseQueue) {
|
||||
this.responseQueue = responseQueue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getConfigLocations() {
|
||||
return new String[]{"classpath:org/springframework/ws/transport/jms/jms-receiver-applicationContext.xml"};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReceiveQueueBytesMessage() throws Exception {
|
||||
final byte[] b = CONTENT.getBytes("UTF-8");
|
||||
jmsTemplate.send(requestQueue, new MessageCreator() {
|
||||
@@ -82,6 +72,7 @@ public class WebServiceMessageListenerIntegrationTest extends AbstractDependency
|
||||
assertNotNull("No response received", response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReceiveQueueTextMessage() throws Exception {
|
||||
jmsTemplate.send(requestQueue, new MessageCreator() {
|
||||
public Message createMessage(Session session) throws JMSException {
|
||||
@@ -94,6 +85,7 @@ public class WebServiceMessageListenerIntegrationTest extends AbstractDependency
|
||||
assertNotNull("No response received", response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReceiveTopic() throws Exception {
|
||||
final byte[] b = CONTENT.getBytes("UTF-8");
|
||||
jmsTemplate.send(requestTopic, new MessageCreator() {
|
||||
|
||||
Reference in New Issue
Block a user