1#! /bin/sh 2# $Id: testPropertyConfig 562 2007-05-31 23:31:34Z sfsetse $ 3# vim:sts=2 4 5MY_NAME=`basename $0` 6MY_PATH=`dirname $0` 7 8# load common unit test functions 9. "${MY_PATH}/test-functions.inc" 10 11#------------------------------------------------------------------------------ 12# suite tests 13# 14 15testAppenders() 16{ 17 # 18 # invalid appender 19 # 20 cat <<EOF >${propFile} 21log4sh.rootLogger = INFO, A 22log4sh.appender.A = InvalidAppender 23EOF 24 echo '- expecting one error' 25 log4sh_doConfigure ${propFile} 26 rtrn=$? 27 assertTrue \ 28 'the InvalidAppender was not caught' \ 29 "[ ${rtrn} -ne ${__LOG4SH_TRUE} ]" 30} 31 32testLayouts() 33{ 34 # 35 # invalid layout 36 # 37 cat <<EOF >${propFile} 38log4sh.rootLogger = INFO, A 39log4sh.appender.A = ConsoleAppender 40log4sh.appender.A.layout = InvalidLayout 41EOF 42 echo '- expecting one error' 43 log4sh_doConfigure ${propFile} 44 rtrn=$? 45 assertTrue \ 46 'the InvalidLayout was not caught' \ 47 "[ ${rtrn} -ne ${__LOG4SH_TRUE} ]" 48} 49 50testLayoutTypes() 51{ 52 # 53 # invalid layout type 54 # 55 cat <<EOF >${propFile} 56log4sh.rootLogger = INFO, A 57log4sh.appender.A = ConsoleAppender 58log4sh.appender.A.layout = SimpleLayout 59log4sh.appender.A.layout.InvalidType = blah 60EOF 61 echo '- expecting one error' 62 log4sh_doConfigure ${propFile} 63 rtrn=$? 64 assertTrue \ 65 'the invalid layout type was not caught' \ 66 "[ ${rtrn} -ne ${__LOG4SH_TRUE} ]" 67} 68 69#------------------------------------------------------------------------------ 70# suite functions 71# 72 73oneTimeSetUp() 74{ 75 # source log4sh 76 ${DEBUG} echo 'loading log4sh' >&2 77 LOG4SH_CONFIGURATION='none' . ./log4sh 78 79 # declare the properties file 80 propFile="${__shunit_tmpDir}/properties.log4sh" 81} 82 83setUp() 84{ 85 # reset log4sh 86 log4sh_resetConfiguration 87} 88 89tearDown() 90{ 91 # remove the properties file 92 rm -f "${propFile}" 93} 94 95#------------------------------------------------------------------------------ 96# main 97# 98 99# load and run shUnit 100${DEBUG} echo 'loading shUnit' >&2 101. ./shunit2 102