ContentTypeRebuildingOutboundSoapInterceptor extends
		AbstractSoapInterceptor { @Override public void handleMessage(SoapMessage message) throws Fault { debug(() -> message.toString()); debug(() -> new StringBuilder().append(CONTENT_TYPE) .append(" before modification: ") .append(message.get(CONTENT_TYPE).toString()).toString()); final String contentType = (String) message.get(CONTENT_TYPE); final List<Pair> contentTypeList = new ArrayList<>(); try (Scanner scanner = new Scanner(contentType)) { scanner.useDelimiter(SEMICOLON); while (scanner.hasNext()) { final String next = scanner.next(); final String[] split = next.split(EQUAL); contentTypeList.add(new Pair(clean(split, IDX_KEY), split.length > IDX_VALUE ? Optional.of(clean(split, IDX_VALUE)) : Optional.empty())); } } final String correctedContentType = contentTypeList .stream() .map(ContentTypeRebuildingOutboundSoapInterceptor::toCorrectedContentType) .collect(joining(SEMICOLON_WITH_SPACE)); debug(() -> new StringBuilder().append(CONTENT_TYPE) .append(" after modification: ").append(correctedContentType) .toString()); message.put(CONTENT_TYPE, correctedContentType); } ContentTypeRebuildingOutboundSoapInterceptor(); @Override void handleMessage(SoapMessage message);  }
@Test public void testHandleMessage() { final String contentType = "\"a=1; b=2\"; c=\"3\""; final String expectedContentType = "a=\"1\"; b=\"2\"; c=\"3\""; final SoapMessage message = mock(SoapMessage.class); when(message.get(CONTENT_TYPE)).thenReturn(contentType); sut.handleMessage(message); verify(message, times(1)).put(CONTENT_TYPE, expectedContentType); }
@Test public void testHandleMessage_NoChange() { final String expectedContentType = "a=\"1\"; b=\"2\"; c=\"3\""; final SoapMessage message = mock(SoapMessage.class); when(message.get(CONTENT_TYPE)).thenReturn(expectedContentType); sut.handleMessage(message); verify(message, times(1)).put(CONTENT_TYPE, expectedContentType); }