-
Notifications
You must be signed in to change notification settings - Fork 23
/
log4sh_test_property_config.sh
executable file
·87 lines (77 loc) · 1.72 KB
/
log4sh_test_property_config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#! /bin/sh
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
# Released under the LGPL (GNU Lesser General Public License)
# Author: [email protected] (Kate Ward)
#
# log4sh unit test for reading of configuration from property files.
# load test helpers
. ./log4sh_test_helpers
#------------------------------------------------------------------------------
# suite tests
#
testAppenders()
{
#
# invalid appender
#
cat <<EOF >${propF}
log4sh.rootLogger = INFO, A
log4sh.appender.A = InvalidAppender
EOF
echo '- expecting one error'
log4sh_doConfigure ${propF}
rtrn=$?
assertFalse 'the InvalidAppender was not caught' ${rtrn}
}
testLayouts()
{
#
# invalid layout
#
cat <<EOF >${propF}
log4sh.rootLogger = INFO, A
log4sh.appender.A = ConsoleAppender
log4sh.appender.A.layout = InvalidLayout
EOF
echo '- expecting one error'
log4sh_doConfigure ${propF}
rtrn=$?
assertFalse 'the InvalidLayout was not caught' ${rtrn}
}
testLayoutTypes()
{
#
# invalid layout type
#
cat <<EOF >${propF}
log4sh.rootLogger = INFO, A
log4sh.appender.A = ConsoleAppender
log4sh.appender.A.layout = SimpleLayout
log4sh.appender.A.layout.InvalidType = blah
EOF
echo '- expecting one error'
log4sh_doConfigure ${propF}
rtrn=$?
assertFalse 'the invalid layout type was not caught' ${rtrn}
}
#------------------------------------------------------------------------------
# suite functions
#
oneTimeSetUp()
{
LOG4SH_CONFIGURATION='none'
th_oneTimeSetUp
# this file will be cleaned up automatically by shunit2
propF="${TH_TMPDIR}/properties.log4sh"
}
setUp()
{
# reset log4sh
log4sh_resetConfiguration
}
# load and run shUnit2
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. ${TH_SHUNIT}