1   /*
2    * Copyright 2006 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.ws.soap.saaj;
18  
19  import java.util.Locale;
20  import javax.xml.soap.MessageFactory;
21  import javax.xml.soap.SOAPBody;
22  import javax.xml.soap.SOAPConstants;
23  import javax.xml.soap.SOAPMessage;
24  
25  import org.springframework.ws.soap.SoapBody;
26  import org.springframework.ws.soap.soap11.AbstractSoap11BodyTestCase;
27  
28  public class SaajSoap11BodyTest extends AbstractSoap11BodyTestCase {
29  
30      protected SoapBody createSoapBody() throws Exception {
31          MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
32          SOAPMessage saajMessage = messageFactory.createMessage();
33          return new SaajSoap11Body(saajMessage.getSOAPPart().getEnvelope().getBody(), true);
34      }
35  
36      public void testLangAttributeOnSoap11FaultString() throws Exception {
37          MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
38          SOAPMessage saajMessage = messageFactory.createMessage();
39  
40          SOAPBody saajSoapBody = saajMessage.getSOAPPart().getEnvelope().getBody();
41          SaajSoap11Body soapBody = new SaajSoap11Body(saajSoapBody, true);
42  
43          soapBody.addClientOrSenderFault("Foo", Locale.ENGLISH);
44          assertNotNull("No Language set", saajSoapBody.getFault().getFaultStringLocale());
45  
46          saajSoapBody = saajMessage.getSOAPPart().getEnvelope().getBody();
47          soapBody = new SaajSoap11Body(saajSoapBody, false);
48  
49          soapBody.addClientOrSenderFault("Foo", Locale.ENGLISH);
50          assertNull("Language set", saajSoapBody.getFault().getFaultStringLocale());
51      }
52  
53  
54  }