public class SoapActionInterceptorTest extends Assert {
@Test
public void testSoapAction() throws Exception {
SoapActionInterceptor i = new SoapActionInterceptor();
Message message = new MessageImpl();
message.setExchange(new ExchangeImpl());
message.getExchange().setOutMessage(message);
SoapBinding sb = new SoapBinding(null);
message = sb.createMessage(message);
assertNotNull(message);
assertTrue(message instanceof SoapMessage);
SoapMessage soapMessage = (SoapMessage) message;
assertEquals(Soap11.getInstance(), soapMessage.getVersion());
(new SoapActionInterceptor()).handleMessage(soapMessage);
Map<String, List<String>> reqHeaders = CastUtils.cast((Map)soapMessage.get(Message.PROTOCOL_HEADERS));
assertNotNull(reqHeaders);
assertEquals("\"\"", reqHeaders.get("SOAPAction").get(0));
sb.setSoapVersion(Soap12.getInstance());
soapMessage.clear();
soapMessage = (SoapMessage) sb.createMessage(soapMessage);
i.handleMessage(soapMessage);
String ct = (String) message.get(Message.CONTENT_TYPE);
assertEquals("application/soap+xml", ct);
BindingOperationInfo bop = createBindingOperation();
message.getExchange().put(BindingOperationInfo.class, bop);
SoapOperationInfo soapInfo = new SoapOperationInfo();
soapInfo.setAction("foo");
bop.addExtensor(soapInfo);
i.handleMessage(soapMessage);
ct = (String) message.get(Message.CONTENT_TYPE);
assertEquals("application/soap+xml; action=\"foo\"", ct);
}