Skip to content

Commit 3053eb7

Browse files
committed
Fixed sending response bug.
1 parent 01e0168 commit 3053eb7

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

core/src/main/java/org/springframework/ws/transport/support/WebServiceMessageReceiverObjectSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected final void handleConnection(WebServiceConnection connection, WebServic
8383
MessageContext messageContext = new DefaultMessageContext(request, getMessageFactory());
8484
receiver.receive(messageContext);
8585
if (messageContext.hasResponse()) {
86-
connection.send(request);
86+
connection.send(messageContext.getResponse());
8787
}
8888
}
8989
catch (NoEndpointFoundException ex) {
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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.support;
18+
19+
import junit.framework.TestCase;
20+
import org.easymock.MockControl;
21+
import org.springframework.ws.MockWebServiceMessage;
22+
import org.springframework.ws.MockWebServiceMessageFactory;
23+
import org.springframework.ws.context.MessageContext;
24+
import org.springframework.ws.transport.WebServiceConnection;
25+
import org.springframework.ws.transport.WebServiceMessageReceiver;
26+
27+
public class WebServiceMessageReceiverObjectSupportTest extends TestCase {
28+
29+
private WebServiceMessageReceiverObjectSupport receiverSupport;
30+
31+
private MockControl connectionControl;
32+
33+
private WebServiceConnection connectionMock;
34+
35+
private MockWebServiceMessageFactory messageFactory;
36+
37+
private MockWebServiceMessage request;
38+
39+
protected void setUp() throws Exception {
40+
receiverSupport = new MyReceiverSupport();
41+
messageFactory = new MockWebServiceMessageFactory();
42+
receiverSupport.setMessageFactory(messageFactory);
43+
connectionControl = MockControl.createStrictControl(WebServiceConnection.class);
44+
connectionMock = (WebServiceConnection) connectionControl.getMock();
45+
request = new MockWebServiceMessage();
46+
}
47+
48+
public void testHandleConnectionResponse() throws Exception {
49+
connectionControl.expectAndReturn(connectionMock.receive(messageFactory), request);
50+
connectionMock.send(new MockWebServiceMessage());
51+
connectionControl.setMatcher(MockControl.ALWAYS_MATCHER);
52+
connectionMock.close();
53+
54+
connectionControl.replay();
55+
56+
WebServiceMessageReceiver receiver = new WebServiceMessageReceiver() {
57+
58+
public void receive(MessageContext messageContext) throws Exception {
59+
assertNotNull("No message context", messageContext);
60+
messageContext.getResponse();
61+
}
62+
};
63+
64+
receiverSupport.handleConnection(connectionMock, receiver);
65+
66+
connectionControl.verify();
67+
}
68+
69+
public void testHandleConnectionNoResponse() throws Exception {
70+
connectionControl.expectAndReturn(connectionMock.receive(messageFactory), request);
71+
connectionMock.close();
72+
73+
connectionControl.replay();
74+
75+
WebServiceMessageReceiver receiver = new WebServiceMessageReceiver() {
76+
77+
public void receive(MessageContext messageContext) throws Exception {
78+
assertNotNull("No message context", messageContext);
79+
}
80+
};
81+
82+
receiverSupport.handleConnection(connectionMock, receiver);
83+
84+
connectionControl.verify();
85+
}
86+
87+
private static class MyReceiverSupport extends WebServiceMessageReceiverObjectSupport {
88+
89+
}
90+
}

0 commit comments

Comments
 (0)