# validator.test - Copyright (C) 2001 Pat Thoyts # # Test the TclSOAP package client and server code using the Userland # validator request XML packets. # # The tests are done by using the XML data that was generated by the Userland # engine. This is read from the xml file and passed to the SOAP::CGI # procedures exactly as done for a real CGI request. The result is an XML # response packet which is then parsed by the client code - again - exactly # as is done for normal client calls. So using this technique we can test # both the server and client code within the test framework, but without # requiring a web server to be involved. # # ------------------------------------------------------------------------- # This software is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the accompanying file `LICENSE' # for more details. # ------------------------------------------------------------------------- # # @(#)$Id: validator.test,v 1.5 2002/02/19 01:15:08 patthoyts Exp $ # Initialize the required packages if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import ::tcltest::* #source [file join [pwd] [file dirname [info script]] defs.tcl] } if {[catch {package require SOAP}]} { catch {puts stderr "Cannot load the SOAP package"} return } if {[catch {package require XMLRPC}]} { catch {puts stderr "Cannot load the XMLRPC package"} return } if {[catch {package require SOAP::CGI}]} { catch {puts stderr "Cannot load the SOAP::CGI package"} return } catch {unset SOAP::CGI::logfile} # Load in the server implementation. source [file join [pwd] [file dirname [info script]] \ .. cgi-bin soap validator.tcl] # ------------------------------------------------------------------------- # Helper methods proc domload {filename} { set filename [file join [pwd] [file dirname [info script]] $filename] set f [open $filename r] set xml [read $f] close $f return [dom::DOMImplementation parse $xml] } # ------------------------------------------------------------------------- test validator-1.1 {SOAP echoStructTest} { set doc [domload soap/echoStructTest.xml] set xml [SOAP::CGI::soap_call $doc] set result [SOAP::parse_soap_response ::SOAP::_echoStructTest $xml] set result } {substruct0 {curly -48 larry 57 moe 75} substruct1 {curly -99 larry 51 moe 49} substruct2 {curly -73 larry 20 moe 33} substruct3 {curly -74 larry 1 moe 58} substruct4 {curly -42 larry 57 moe 34} substruct5 {curly -84 larry 95 moe 69} substruct6 {curly -13 larry 11 moe 93} substruct7 {curly -3 larry 23 moe 56} substruct8 {curly -42 larry 24 moe 27} substruct9 {curly -19 larry 16 moe 77}} test validator-1.2 {SOAP nestedStructTest} { set doc [domload soap/nestedStructTest.xml] set xml [SOAP::CGI::soap_call $doc] set result [SOAP::parse_soap_response ::SOAP::_nestedStructTest $xml] set result } {83} test validator-1.3 {SOAP countTheEntities} { set doc [domload soap/countTheEntities.xml] set xml [SOAP::CGI::soap_call $doc] set result [SOAP::parse_soap_response ::SOAP::_countTheEntities $xml] set result } {ctQuotes 0 ctLeftAngleBrackets 5 ctAmpersands 2 ctApostrophes 10 ctRightAngleBrackets 2} test validator-1.4 {SOAP easyStructTest} { set doc [domload soap/easyStructTest.xml] set xml [SOAP::CGI::soap_call $doc] set result [SOAP::parse_soap_response ::SOAP::_easyStructTest $xml] set result } {84} test validator-1.5 {SOAP manyTypesTest} { set doc [domload soap/manyTypesTest.xml] set xml [SOAP::CGI::soap_call $doc] set result [SOAP::parse_soap_response ::SOAP::_manyTypesTest $xml] set result [lrange $result 0 4] } {20384 false Kentucky 8845.33333333 1904-01-01T05:02:01-07:00} test validator-1.6 {SOAP moderateSizeArrayCheck} { set doc [domload soap/moderateSizeArrayCheck.xml] set xml [SOAP::CGI::soap_call $doc] set result [SOAP::parse_soap_response ::SOAP::_moderateSizeArrayCheck $xml] set result } {IowaMaryland} test validator-1.7 {SOAP simpleStructReturnTest} { set doc [domload soap/simpleStructReturnTest.xml] set xml [SOAP::CGI::soap_call $doc] set result [SOAP::parse_soap_response ::SOAP::_simpleStructReturnTest $xml] set result } {times1000 9000 times100 900 times10 90} # ------------------------------------------------------------------------- # XML-RPC Validator # ------------------------------------------------------------------------- test validator-2.1 {XMLRPC echoStructTest} { set doc [domload xmlrpc/echoStructTest.xml] set xml [SOAP::CGI::xmlrpc_call $doc] set result [SOAP::parse_xmlrpc_response echoStructTest $xml] set result } {substruct0 {curly -14 larry 33 moe 7} substruct1 {curly -20 larry 96 moe 33} substruct2 {curly -56 larry 78 moe 79} substruct3 {curly -24 larry 67 moe 57} substruct4 {curly -22 larry 84 moe 12} substruct5 {curly -16 larry 9 moe 35} substruct6 {curly -73 larry 64 moe 46} substruct7 {curly -99 larry 66 moe 0} substruct8 {curly -91 larry 5 moe 8} substruct9 {curly -18 larry 83 moe 96}} test validator-2.2 {XMLRPC nestedStructTest} { set doc [domload xmlrpc/nestedStructTest.xml] set xml [SOAP::CGI::xmlrpc_call $doc] set result [SOAP::parse_xmlrpc_response nestedStructTest $xml] set result } {25} test validator-2.3 {XMLRPC countTheEntities} { set doc [domload xmlrpc/countTheEntities.xml] set xml [SOAP::CGI::xmlrpc_call $doc] set result [SOAP::parse_xmlrpc_response countTheEntities $xml] set result } {ctQuotes 0 ctLeftAngleBrackets 4 ctAmpersands 6 ctApostrophes 5 ctRightAngleBrackets 10} test validator-2.4 {XMLRPC easyStructTest} { set doc [domload xmlrpc/easyStructTest.xml] set xml [SOAP::CGI::xmlrpc_call $doc] set result [SOAP::parse_xmlrpc_response easyStructTest $xml] set result } {138} test validator-2.5 {XMLRPC manyTypesTest} { set doc [domload xmlrpc/manyTypesTest.xml] set xml [SOAP::CGI::xmlrpc_call $doc] set result [SOAP::parse_xmlrpc_response manyTypesTest $xml] set result [lrange $result 0 4] } {6447 false {South Carolina} 1016.66666667 19040101T05:45:39} test validator-2.6 {XMLRPC moderateSizeArrayCheck} { set doc [domload xmlrpc/moderateSizeArrayCheck.xml] set xml [SOAP::CGI::xmlrpc_call $doc] set result [SOAP::parse_xmlrpc_response moderateSizeArrayCheck $xml] set result } {OhioVermont} test validator-2.7 {XMLRPC simpleStructReturnTest} { set doc [domload xmlrpc/simpleStructReturnTest.xml] set xml [SOAP::CGI::xmlrpc_call $doc] set result [SOAP::parse_xmlrpc_response simpleStructReturnTest $xml] set result } {times1000 36000 times100 3600 times10 360} # ------------------------------------------------------------------------- # Clean up the tests ::tcltest::cleanupTests return # Local variables: # mode: tcl # indent-tabs-mode: nil # End: