Skip to content

Commit 99a7dd6

Browse files
committed
SWS-981 - Polish
1 parent 838c50a commit 99a7dd6

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

spring-ws-core/src/main/java/org/springframework/ws/soap/saaj/SaajSoapMessage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ public SaajSoapMessage(SOAPMessage soapMessage, boolean langAttributeOnSoap11Fau
115115
saajMessage = soapMessage;
116116
this.langAttributeOnSoap11FaultString = langAttributeOnSoap11FaultString;
117117
this.messageFactory = messageFactory;
118-
if (SoapVersion.SOAP_11.equals(getVersion()))
119-
{
118+
if (SoapVersion.SOAP_11.equals(getVersion())) {
120119
MimeHeaders headers = soapMessage.getMimeHeaders();
121120
if (ObjectUtils.isEmpty(headers.getHeader(TransportConstants.HEADER_SOAP_ACTION))) {
122121
headers.addHeader(TransportConstants.HEADER_SOAP_ACTION, "\"\"");
Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
package org.springframework.ws.soap.client.core;
22

33
import java.io.IOException;
4-
54
import javax.xml.soap.MessageFactory;
65
import javax.xml.soap.SOAPConstants;
76
import javax.xml.soap.SOAPException;
87

9-
import org.junit.Assert;
108
import org.junit.Before;
119
import org.junit.Test;
10+
1211
import org.springframework.ws.soap.SoapVersion;
1312
import org.springframework.ws.soap.saaj.SaajSoapMessage;
1413
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
1514
import org.springframework.ws.soap.support.SoapUtils;
1615
import org.springframework.ws.transport.TransportConstants;
1716

17+
import static org.hamcrest.CoreMatchers.*;
18+
import static org.hamcrest.core.Is.is;
19+
import static org.junit.Assert.*;
20+
1821
public class SaajSoapActionCallbackTest {
1922

2023
private SaajSoapMessageFactory saaj11Factory = new SaajSoapMessageFactory();
2124

2225
private SaajSoapMessageFactory saaj12Factory = new SaajSoapMessageFactory();
2326

2427
@Before
25-
public void init() throws SOAPException
26-
{
28+
public void init() throws SOAPException {
2729
MessageFactory messageFactory11 = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
2830

2931
saaj11Factory.setSoapVersion(SoapVersion.SOAP_11);
@@ -37,63 +39,66 @@ public void init() throws SOAPException
3739
}
3840

3941
@Test
40-
public void noSoapAction11() throws IOException
41-
{
42+
public void noSoapAction11ShouldProduceEmptySoapActionHeader() throws IOException {
4243
SaajSoapMessage message = saaj11Factory.createWebServiceMessage();
4344
String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_SOAP_ACTION);
44-
Assert.assertEquals("\"\"", soapActionHeaders[0]);
45+
46+
assertThat(soapActionHeaders.length, is(1));
47+
assertThat(soapActionHeaders[0], is("\"\""));
4548
}
4649

4750
@Test
48-
public void soapAction11() throws IOException
49-
{
51+
public void soapAction11ShouldProduceSoapActionHeader() throws IOException {
5052
SaajSoapMessage message = saaj11Factory.createWebServiceMessage();
5153
SoapActionCallback callback = new SoapActionCallback("testAction");
5254
callback.doWithMessage(message);
5355
String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_SOAP_ACTION);
54-
Assert.assertEquals("\"testAction\"", soapActionHeaders[0]);
56+
57+
assertThat(soapActionHeaders.length, is(1));
58+
assertThat(soapActionHeaders[0], is("\"testAction\""));
5559
}
5660

5761
@Test
58-
public void emptySoapAction11() throws IOException
59-
{
62+
public void emptySoapAction11() throws IOException {
6063
SaajSoapMessage message = saaj11Factory.createWebServiceMessage();
6164
SoapActionCallback callback = new SoapActionCallback(null);
6265
callback.doWithMessage(message);
6366
String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_SOAP_ACTION);
64-
Assert.assertEquals("\"\"", soapActionHeaders[0]);
67+
68+
assertThat(soapActionHeaders.length, is(1));
69+
assertThat(soapActionHeaders[0], is("\"\""));
6570
}
6671

6772
@Test
68-
public void noSoapAction12() throws IOException
69-
{
73+
public void noSoapAction12() throws IOException {
7074
SaajSoapMessage message = saaj12Factory.createWebServiceMessage();
7175
String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_SOAP_ACTION);
72-
Assert.assertNull(soapActionHeaders);
76+
77+
assertThat(soapActionHeaders, is(nullValue()));
7378
}
7479

7580
@Test
76-
public void soapAction12() throws IOException
77-
{
81+
public void soapAction12ShouldProduceNoSoapActionHeader() throws IOException {
7882
SaajSoapMessage message = saaj12Factory.createWebServiceMessage();
7983
SoapActionCallback callback = new SoapActionCallback("testAction");
8084
callback.doWithMessage(message);
8185
String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_SOAP_ACTION);
82-
Assert.assertNull(soapActionHeaders);
8386
String[] contentTypes = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_CONTENT_TYPE);
84-
Assert.assertEquals("\"testAction\"", SoapUtils.extractActionFromContentType(contentTypes[0]));
87+
88+
assertThat(soapActionHeaders, is(nullValue()));
89+
assertThat(SoapUtils.extractActionFromContentType(contentTypes[0]), is("\"testAction\""));
8590
}
8691

8792
@Test
88-
public void emptySoapAction12() throws IOException
89-
{
93+
public void emptySoapAction12ShouldProduceNoSoapActionHeader() throws IOException {
9094
SaajSoapMessage message = saaj12Factory.createWebServiceMessage();
9195
SoapActionCallback callback = new SoapActionCallback(null);
9296
callback.doWithMessage(message);
9397
String[] soapActionHeaders = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_SOAP_ACTION);
94-
Assert.assertNull(soapActionHeaders);
9598
String[] contentTypes = message.getSaajMessage().getMimeHeaders().getHeader(TransportConstants.HEADER_CONTENT_TYPE);
96-
Assert.assertEquals("\"\"", SoapUtils.extractActionFromContentType(contentTypes[0]));
99+
100+
assertThat(soapActionHeaders, is(nullValue()));
101+
assertThat(SoapUtils.extractActionFromContentType(contentTypes[0]), is("\"\""));
97102
}
98103

99104
}

0 commit comments

Comments
 (0)