SWS-595 - SoapUtils.setActionInContentType incorrectly replaces existing actions

This commit is contained in:
Tareq Abedrabbo
2010-01-13 21:42:37 +00:00
parent 12696a02e7
commit 9fedbace16
2 changed files with 19 additions and 1 deletions

View File

@@ -79,7 +79,7 @@ public abstract class SoapUtils {
Matcher matcher = ACTION_PATTERN.matcher(contentType);
if (matcher.find() && matcher.groupCount() == 1) {
StringBuffer buffer = new StringBuffer();
matcher.appendReplacement(buffer, action);
matcher.appendReplacement(buffer, "action=" + action);
matcher.appendTail(buffer);
return buffer.toString();
}

View File

@@ -34,6 +34,10 @@ public class SoapUtilsTest extends TestCase {
contentType = "application/soap+xml; action=" + soapAction + " ; charset=UTF-8";
result = SoapUtils.extractActionFromContentType(contentType);
assertEquals("Invalid SOAP action", soapAction, result);
contentType = "application/soap+xml; charset=UTF-8; action=" + soapAction;
result = SoapUtils.extractActionFromContentType(contentType);
assertEquals("Invalid SOAP action", soapAction, result);
}
public void testEscapeAction() throws Exception {
@@ -51,4 +55,18 @@ public class SoapUtilsTest extends TestCase {
}
public void testSetActionInContentType() throws Exception {
String soapAction = "http://springframework.org/spring-ws/Action";
String contentType = "application/soap+xml";
String result = SoapUtils.setActionInContentType(contentType, soapAction);
assertEquals("Invalid SOAP action", soapAction, SoapUtils.extractActionFromContentType(result));
String anotherSoapAction = "http://springframework.org/spring-ws/AnotherAction";
String contentTypeWithAction = "application/soap+xml; action=http://springframework.org/spring-ws/Action";
result = SoapUtils.setActionInContentType(contentTypeWithAction, anotherSoapAction);
assertEquals("Invalid SOAP action", anotherSoapAction, SoapUtils.extractActionFromContentType(result));
}
}