public class SoapActionInterceptorTest extends Assert {
@Test
public void testSoapAction() throws Exception {
SoapPreProtocolOutInterceptor i = new SoapPreProtocolOutInterceptor();
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;
soapMessage.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
assertEquals(Soap11.getInstance(), soapMessage.getVersion());
(new SoapPreProtocolOutInterceptor()).handleMessage(soapMessage);
Map<String, List<String>> reqHeaders = CastUtils.cast((Map)soapMessage.get(Message.PROTOCOL_HEADERS));
assertNotNull(reqHeaders);
assertEquals("\"\"", reqHeaders.get(SoapBindingConstants.SOAP_ACTION).get(0));
sb.setSoapVersion(Soap12.getInstance());
soapMessage.clear();
soapMessage = (SoapMessage) sb.createMessage(soapMessage);
soapMessage.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
i.handleMessage(soapMessage);
String ct = (String) soapMessage.get(Message.CONTENT_TYPE);
assertEquals("application/soap+xml", ct);
BindingOperationInfo bop = createBindingOperation();
soapMessage.getExchange().put(BindingOperationInfo.class, bop);
SoapOperationInfo soapInfo = new SoapOperationInfo();
soapInfo.setAction("foo");
bop.addExtensor(soapInfo);
i.handleMessage(soapMessage);
ct = (String) soapMessage.get(Message.CONTENT_TYPE);
assertEquals("application/soap+xml; action=\"foo\"", ct);
}