<commit_before>/* Copyright 2011 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package wslite.soap

import spock.lang.*

class SOAPClientIntegrationSpec extends Specification {

    def "accessing a public SOAP 1.1 service"() {
        given:
        def soapClient = new SOAPClient('http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx')

        when:
        def resp = soapClient.send(SOAPAction:'http://www.27seconds.com/Holidays/US/Dates/GetMartinLutherKingDay') {
            body {
                GetMartinLutherKingDay('xmlns':'http://www.27seconds.com/Holidays/US/Dates/') {
                    year(2011)
                }
            }
        }

        then:
        "2011-01-15T00:00:00" == resp.GetMartinLutherKingDayResponse.GetMartinLutherKingDayResult.text()
        200 == resp.httpResponse.statusCode
        "OK" == resp.httpResponse.statusMessage
        "ASP.NET" == resp.httpResponse.headers['X-Powered-By']
    }

    def "accessing a public SOAP 1.1 service that throws a fault"() {
        given:
        def soapClient = new SOAPClient('http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx')

        when:
        def resp = soapClient.send(SOAPAction:'http://www.27seconds.com/Holidays/US/Dates/GetMartinLutherKingDay') {
            body {
                GetHomerSimposonDay('xmlns':'http://www.27seconds.com/Holidays/US/Dates/') {
                    year(2011)
                }
            }
        }

        then:
        thrown(SOAPFaultException)
    }

    def "accessing a public SOAP 1.2 service"() {
        given:
        def soapClient = new SOAPClient("http://www.webservicex.net/WeatherForecast.asmx")

        when:
        def response = soapClient.send {
            version SOAPVersion.V1_2
            body {
                GetWeatherByZipCode(xmlns:"http://www.webservicex.net") {
                    ZipCode("93657")
                }
            }
        }

        then:
        "SANGER" == response.GetWeatherByZipCodeResponse.GetWeatherByZipCodeResult.PlaceName.text()
    }

    def "accessing a public SOAP 1.2 service that throws a fault"() {
        given:
        def soapClient = new SOAPClient("http://www.webservicex.net/WeatherForecast.asmx")<commit_msg>fix test<commit_after>/* Copyright 2011 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package wslite.soap

import spock.lang.*

class SOAPClientIntegrationSpec extends Specification {

    def "accessing a public SOAP 1.1 service"() {
        given:
        def soapClient = new SOAPClient('http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx')

        when:
        def resp = soapClient.send(SOAPAction:'http://www.27seconds.com/Holidays/US/Dates/GetMartinLutherKingDay') {
            body {
                GetMartinLutherKingDay('xmlns':'http://www.27seconds.com/Holidays/US/Dates/') {
                    year(2011)
                }
            }
        }

        then:
        "2011-01-15T00:00:00" == resp.GetMartinLutherKingDayResponse.GetMartinLutherKingDayResult.text()
        200 == resp.httpResponse.statusCode
        "OK" == resp.httpResponse.statusMessage
        "ASP.NET" == resp.httpResponse.headers['X-Powered-By']
    }

    def "accessing a public SOAP 1.1 service that throws a fault"() {
        given:
        def soapClient = new SOAPClient('http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx')

        when:
        def resp = soapClient.send(SOAPAction:'http://www.27seconds.com/Holidays/US/Dates/GetMartinLutherKingDay') {
            body {
                GetHomerSimposonDay('xmlns':'http://www.27seconds.com/Holidays/US/Dates/') {
                    year(2011)
                }
            }
        }

        then:
        thrown(SOAPFaultException)
    }

    def "accessing a public SOAP 1.2 service that throws a fault"() {
        given:
        def soapClient = new SOAPClient("http://www.webservicex.net/WeatherForecast.asmx")
{'fraction_non_alphanumeric': 0.10386283011430823, 'fraction_numerical': 0.020299566417027987, 'mean_word_length': 2.38107928047968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 18, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6962475', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1471, 'n_words': 350}