Skip to content

Commit 14eab13

Browse files
committed
Added HTTP method constants.
1 parent 9231a7d commit 14eab13

File tree

8 files changed

+32
-22
lines changed

8 files changed

+32
-22
lines changed

core/src/main/java/org/springframework/ws/transport/http/HttpTransportConstants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,10 @@ public interface HttpTransportConstants extends TransportConstants {
5555

5656
/** The "https" URI scheme. */
5757
String HTTPS_URI_SCHEME = "https";
58+
59+
/** The "GET" HTTP method */
60+
String METHOD_GET = "GET";
61+
62+
/** The "POST" HTTP method */
63+
String METHOD_POST = "POST";
5864
}

core/src/main/java/org/springframework/ws/transport/http/HttpUrlConnectionMessageSender.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
*/
3939
public class HttpUrlConnectionMessageSender extends AbstractHttpWebServiceMessageSender {
4040

41-
private static final String HTTP_METHOD_POST = "POST";
42-
4341
public WebServiceConnection createConnection(URI uri) throws IOException {
4442
URL url = uri.toURL();
4543
URLConnection connection = url.openConnection();
@@ -48,7 +46,7 @@ public WebServiceConnection createConnection(URI uri) throws IOException {
4846
}
4947
else {
5048
HttpURLConnection httpURLConnection = (HttpURLConnection) connection;
51-
httpURLConnection.setRequestMethod(HTTP_METHOD_POST);
49+
httpURLConnection.setRequestMethod(HttpTransportConstants.METHOD_POST);
5250
httpURLConnection.setUseCaches(false);
5351
httpURLConnection.setDoInput(true);
5452
httpURLConnection.setDoOutput(true);

core/src/main/java/org/springframework/ws/transport/http/MessageDispatcherServlet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ protected WebServiceMessageReceiver getMessageReceiver() {
231231
* @return a definition, or <code>null</code>
232232
*/
233233
protected WsdlDefinition getWsdlDefinition(HttpServletRequest request) {
234-
if ("GET".equals(request.getMethod()) && request.getRequestURI().endsWith(WSDL_SUFFIX_NAME)) {
234+
if (HttpTransportConstants.METHOD_GET.equals(request.getMethod()) &&
235+
request.getRequestURI().endsWith(WSDL_SUFFIX_NAME)) {
235236
String fileName = WebUtils.extractFilenameFromUrlPath(request.getRequestURI());
236237
return (WsdlDefinition) wsdlDefinitions.get(fileName);
237238
}

core/src/main/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public long getLastModified(HttpServletRequest request, Object handler) {
5252
public ModelAndView handle(HttpServletRequest httpServletRequest,
5353
HttpServletResponse httpServletResponse,
5454
Object handler) throws Exception {
55-
if ("POST".equals(httpServletRequest.getMethod())) {
55+
if (HttpTransportConstants.METHOD_POST.equals(httpServletRequest.getMethod())) {
5656
WebServiceConnection connection = new HttpServletConnection(httpServletRequest, httpServletResponse);
5757
handleConnection(connection, (WebServiceMessageReceiver) handler);
5858
}

core/src/main/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
import org.apache.commons.logging.Log;
3131
import org.apache.commons.logging.LogFactory;
32+
import org.w3c.dom.Attr;
33+
import org.w3c.dom.Document;
34+
3235
import org.springframework.beans.factory.InitializingBean;
3336
import org.springframework.util.StringUtils;
3437
import org.springframework.web.servlet.HandlerAdapter;
@@ -37,8 +40,6 @@
3740
import org.springframework.xml.transform.TransformerObjectSupport;
3841
import org.springframework.xml.xpath.XPathExpression;
3942
import org.springframework.xml.xpath.XPathExpressionFactory;
40-
import org.w3c.dom.Attr;
41-
import org.w3c.dom.Document;
4243

4344
/**
4445
* Adapter to use the <code>WsdlDefinition</code> interface with the generic <code>DispatcherServlet</code>.
@@ -113,7 +114,7 @@ public long getLastModified(HttpServletRequest request, Object handler) {
113114

114115
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
115116
throws Exception {
116-
if ("GET".equals(request.getMethod())) {
117+
if (HttpTransportConstants.METHOD_GET.equals(request.getMethod())) {
117118
response.setContentType(CONTENT_TYPE);
118119
Transformer transformer = createTransformer();
119120
WsdlDefinition definition = (WsdlDefinition) handler;

core/src/test/java/org/springframework/ws/transport/http/MessageDispatcherServletTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import org.custommonkey.xmlunit.XMLTestCase;
1111
import org.custommonkey.xmlunit.XMLUnit;
12+
import org.w3c.dom.Document;
13+
1214
import org.springframework.beans.BeansException;
1315
import org.springframework.beans.MutablePropertyValues;
1416
import org.springframework.core.io.ClassPathResource;
@@ -22,7 +24,6 @@
2224
import org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping;
2325
import org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver;
2426
import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition;
25-
import org.w3c.dom.Document;
2627

2728
public class MessageDispatcherServletTest extends XMLTestCase {
2829

@@ -61,7 +62,8 @@ public void testDetectedStrategies() throws ServletException {
6162
public void testDetectWsdlDefinitions() throws Exception {
6263
servlet.setContextClass(WsdlDefinitionWebApplicationContext.class);
6364
servlet.init(config);
64-
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/definition.wsdl");
65+
MockHttpServletRequest request =
66+
new MockHttpServletRequest(HttpTransportConstants.METHOD_GET, "/definition.wsdl");
6567
MockHttpServletResponse response = new MockHttpServletResponse();
6668
servlet.service(request, response);
6769
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();

core/src/test/java/org/springframework/ws/transport/http/WebServiceMessageReceiverHandlerAdapterTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import junit.framework.TestCase;
2222
import org.easymock.MockControl;
23+
2324
import org.springframework.mock.web.MockHttpServletRequest;
2425
import org.springframework.mock.web.MockHttpServletResponse;
2526
import org.springframework.ws.FaultAwareWebServiceMessage;
@@ -65,7 +66,7 @@ protected void setUp() throws Exception {
6566
}
6667

6768
public void testHandleNonPost() throws Exception {
68-
httpRequest.setMethod("GET");
69+
httpRequest.setMethod(HttpTransportConstants.METHOD_GET);
6970
replayMockControls();
7071
WebServiceMessageReceiver endpoint = new WebServiceMessageReceiver() {
7172

@@ -79,7 +80,7 @@ public void receive(MessageContext messageContext) throws Exception {
7980
}
8081

8182
public void testHandlePostNoResponse() throws Exception {
82-
httpRequest.setMethod("POST");
83+
httpRequest.setMethod(HttpTransportConstants.METHOD_POST);
8384
httpRequest.setContent(REQUEST.getBytes("UTF-8"));
8485
httpRequest.setContentType("text/xml; charset=\"utf-8\"");
8586
httpRequest.setCharacterEncoding("UTF-8");
@@ -102,7 +103,7 @@ public void receive(MessageContext messageContext) throws Exception {
102103
}
103104

104105
public void testHandlePostResponse() throws Exception {
105-
httpRequest.setMethod("POST");
106+
httpRequest.setMethod(HttpTransportConstants.METHOD_POST);
106107
httpRequest.setContent(REQUEST.getBytes("UTF-8"));
107108
httpRequest.setContentType("text/xml; charset=\"utf-8\"");
108109
httpRequest.setCharacterEncoding("UTF-8");
@@ -129,7 +130,7 @@ public void receive(MessageContext messageContext) throws Exception {
129130
}
130131

131132
public void testHandlePostFault() throws Exception {
132-
httpRequest.setMethod("POST");
133+
httpRequest.setMethod(HttpTransportConstants.METHOD_POST);
133134
httpRequest.setContent(REQUEST.getBytes("UTF-8"));
134135
httpRequest.setContentType("text/xml; charset=\"utf-8\"");
135136
httpRequest.setCharacterEncoding("UTF-8");
@@ -157,7 +158,7 @@ public void receive(MessageContext messageContext) throws Exception {
157158
}
158159

159160
public void testHandleNotFound() throws Exception {
160-
httpRequest.setMethod("POST");
161+
httpRequest.setMethod(HttpTransportConstants.METHOD_POST);
161162
httpRequest.setContent(REQUEST.getBytes("UTF-8"));
162163
httpRequest.setContentType("text/xml; charset=\"utf-8\"");
163164
httpRequest.setCharacterEncoding("UTF-8");

core/src/test/java/org/springframework/ws/transport/http/WsdlDefinitionHandlerAdapterTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
2828

2929
import org.custommonkey.xmlunit.XMLTestCase;
3030
import org.easymock.MockControl;
31+
import org.w3c.dom.Document;
32+
import org.xml.sax.InputSource;
33+
3134
import org.springframework.core.io.ClassPathResource;
3235
import org.springframework.mock.web.MockHttpServletRequest;
3336
import org.springframework.mock.web.MockHttpServletResponse;
3437
import org.springframework.ws.wsdl.WsdlDefinition;
3538
import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition;
3639
import org.springframework.xml.transform.StringSource;
37-
import org.w3c.dom.Document;
38-
import org.xml.sax.InputSource;
3940

4041
public class WsdlDefinitionHandlerAdapterTest extends XMLTestCase {
4142

@@ -59,7 +60,7 @@ protected void setUp() throws Exception {
5960
}
6061

6162
public void testHandleGet() throws Exception {
62-
request.setMethod("GET");
63+
request.setMethod(HttpTransportConstants.METHOD_GET);
6364
String definition = "<definition xmlns='http://schemas.xmlsoap.org/wsdl/'/>";
6465
definitionControl.expectAndReturn(definitionMock.getSource(), new StringSource(definition));
6566
definitionControl.replay();
@@ -69,7 +70,7 @@ public void testHandleGet() throws Exception {
6970
}
7071

7172
public void testHandleNonGet() throws Exception {
72-
request.setMethod("POST");
73+
request.setMethod(HttpTransportConstants.METHOD_POST);
7374
definitionControl.replay();
7475
adapter.handle(request, response, definitionMock);
7576
definitionControl.verify();
@@ -79,7 +80,7 @@ public void testHandleNonGet() throws Exception {
7980

8081
public void testTransformLocations() throws Exception {
8182
adapter.setTransformLocations(true);
82-
request.setMethod("GET");
83+
request.setMethod(HttpTransportConstants.METHOD_GET);
8384
request.setScheme("http");
8485
request.setServerName("example.com");
8586
request.setServerPort(8080);
@@ -156,7 +157,7 @@ public void testTransformLocationEmptyContextRelativeUrl() throws Exception {
156157

157158
public void testHandleSimpleWsdl11DefinitionWithoutTransformLocations() throws Exception {
158159
adapter.setTransformLocations(false);
159-
request.setMethod("GET");
160+
request.setMethod(HttpTransportConstants.METHOD_GET);
160161
request.setScheme("http");
161162
request.setServerName("example.com");
162163
request.setServerPort(8080);
@@ -189,7 +190,7 @@ public void testHandleSimpleWsdl11DefinitionWithoutTransformLocations() throws E
189190

190191
public void testHandleSimpleWsdl11DefinitionWithTransformLocation() throws Exception {
191192
adapter.setTransformLocations(true);
192-
request.setMethod("GET");
193+
request.setMethod(HttpTransportConstants.METHOD_GET);
193194
request.setScheme("http");
194195
request.setServerName("example.com");
195196
request.setServerPort(8080);

0 commit comments

Comments
 (0)