client/servlet/test/src/webservice/config.sh

Code
Comments
Other
Rev Date Author Line
3486 16 Nov 09 gregory 1 # This file contains global test configuration
3486 16 Nov 09 gregory 2 # It's included once in test_webservice.sh file
3486 16 Nov 09 gregory 3 proteios="http://localhost:8080/proteios"
3486 16 Nov 09 gregory 4 resource="${proteios}/resource"
3486 16 Nov 09 gregory 5 curl_cmd=`which curl`
3504 30 Nov 09 gregory 6
3486 16 Nov 09 gregory 7 A=./A
3486 16 Nov 09 gregory 8 B=./B
3486 16 Nov 09 gregory 9 C=./C
3486 16 Nov 09 gregory 10 D=./D
3486 16 Nov 09 gregory 11 E=./E
3486 16 Nov 09 gregory 12 user=demo
3486 16 Nov 09 gregory 13 pwd=demo
3486 16 Nov 09 gregory 14 auth="username=$user&password=$pwd"
3486 16 Nov 09 gregory 15
3504 30 Nov 09 gregory 16
3504 30 Nov 09 gregory 17 # Used to call on curl and to log commands if the verbose flag is set
3486 16 Nov 09 gregory 18 curlit()
3486 16 Nov 09 gregory 19 {
3486 16 Nov 09 gregory 20   params=$1
3486 16 Nov 09 gregory 21   url=$2
3489 16 Nov 09 gregory 22   case $arg2 in
3486 16 Nov 09 gregory 23     "-v")
3486 16 Nov 09 gregory 24       if [ "$3" != "" ];then
3486 16 Nov 09 gregory 25         echo " $curl_cmd $params \"$url\" \"$3\""
3486 16 Nov 09 gregory 26       else
3486 16 Nov 09 gregory 27         echo " $curl_cmd $params \"$url\""
3486 16 Nov 09 gregory 28       fi
3486 16 Nov 09 gregory 29       ;;
3486 16 Nov 09 gregory 30      *)
3486 16 Nov 09 gregory 31             ;;
3486 16 Nov 09 gregory 32   esac
3486 16 Nov 09 gregory 33   if [ "$3" != "" ];then
3486 16 Nov 09 gregory 34     $curl_cmd $params "$url" "$3"
3486 16 Nov 09 gregory 35   else
3486 16 Nov 09 gregory 36     $curl_cmd $params "$url"
3486 16 Nov 09 gregory 37   fi
3486 16 Nov 09 gregory 38 }
3486 16 Nov 09 gregory 39
3486 16 Nov 09 gregory 40 DELETE() 
3486 16 Nov 09 gregory 41 {
3486 16 Nov 09 gregory 42   url=$1
3486 16 Nov 09 gregory 43   curlit "-X DELETE" $url
3486 16 Nov 09 gregory 44 }
3486 16 Nov 09 gregory 45
3486 16 Nov 09 gregory 46  
3486 16 Nov 09 gregory 47 PUT()
3486 16 Nov 09 gregory 48 {
3486 16 Nov 09 gregory 49   file=$1
3486 16 Nov 09 gregory 50   url=$2
3486 16 Nov 09 gregory 51   curlit "-T $file" $url
3486 16 Nov 09 gregory 52 }
3486 16 Nov 09 gregory 53
3486 16 Nov 09 gregory 54 GET()
3486 16 Nov 09 gregory 55 {
3486 16 Nov 09 gregory 56   file=$1
3486 16 Nov 09 gregory 57   url=$2
3486 16 Nov 09 gregory 58   curlit "-s -o $file" $url
3486 16 Nov 09 gregory 59 }
3486 16 Nov 09 gregory 60
3486 16 Nov 09 gregory 61 generate_name()
3486 16 Nov 09 gregory 62 {
3504 30 Nov 09 gregory 63   sec=`date +%s`
3504 30 Nov 09 gregory 64     name=test_${sec}.txt
3486 16 Nov 09 gregory 65 }
3486 16 Nov 09 gregory 66
3486 16 Nov 09 gregory 67 fail()
3486 16 Nov 09 gregory 68 {
3486 16 Nov 09 gregory 69   date >> /dev/stderr
3493 23 Nov 09 gregory 70     echo "Failed [$test_file]: $test" >> /dev/stderr
3486 16 Nov 09 gregory 71     echo "Message: $2" >> /dev/stderr
3486 16 Nov 09 gregory 72   echo "" >> /dev/stderr
3486 16 Nov 09 gregory 73   exit
3486 16 Nov 09 gregory 74 }