INT-2466: Propagate SOAP action from inbound
JIRA: https://jira.spring.io/browse/INT-2466 Current reference documentation says that: "If the incoming web service message is a SOAP message the SOAP Action header will be added to the headers of the Message that is forwarded onto the request channel." However, `DefaultSoapHeaderMapper` was actually missing to do that. Polishing
This commit is contained in:
committed by
Artem Bilan
parent
a8f47ee343
commit
f99183afca
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,10 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ws;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -32,6 +34,7 @@ import org.springframework.ws.soap.SoapMessage;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @author Mauro Molinari
|
||||
* @since 2.1
|
||||
*
|
||||
*/
|
||||
@@ -48,7 +51,7 @@ public class DefaultSoapHeaderMapperTests {
|
||||
@Test
|
||||
public void testCustomSoapHeader() {
|
||||
DefaultSoapHeaderMapper mapper = new DefaultSoapHeaderMapper();
|
||||
mapper.setReplyHeaderNames(new String[] {"x:attr", "x:elem"});
|
||||
mapper.setReplyHeaderNames("x:attr", "x:elem");
|
||||
SoapMessage soapMessage = mock(SoapMessage.class);
|
||||
SoapHeader soapHeader = mock(SoapHeader.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -75,4 +78,35 @@ public class DefaultSoapHeaderMapperTests {
|
||||
assertSame(soapHeaderElement, headers.get("x:elem"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractStandardHeadersNullSoapAction() {
|
||||
DefaultSoapHeaderMapper mapper = new DefaultSoapHeaderMapper();
|
||||
SoapMessage soapMessage = mock(SoapMessage.class);
|
||||
when(soapMessage.getSoapAction()).thenReturn(null);
|
||||
|
||||
assertTrue(mapper.extractStandardHeaders(soapMessage).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractStandardHeadersEmptySoapAction() {
|
||||
DefaultSoapHeaderMapper mapper = new DefaultSoapHeaderMapper();
|
||||
SoapMessage soapMessage = mock(SoapMessage.class);
|
||||
when(soapMessage.getSoapAction()).thenReturn("");
|
||||
|
||||
assertTrue(mapper.extractStandardHeaders(soapMessage).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractStandardHeadersNonEmptySoapAction() {
|
||||
DefaultSoapHeaderMapper mapper = new DefaultSoapHeaderMapper();
|
||||
SoapMessage soapMessage = mock(SoapMessage.class);
|
||||
when(soapMessage.getSoapAction()).thenReturn("foo");
|
||||
|
||||
Map<String, Object> standardHeaders = mapper.toHeadersFromRequest(soapMessage);
|
||||
|
||||
assertEquals(1, standardHeaders.size());
|
||||
assertTrue(standardHeaders.containsKey(WebServiceHeaders.SOAP_ACTION));
|
||||
assertEquals("foo", standardHeaders.get(WebServiceHeaders.SOAP_ACTION));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user