forked from kward/log4sh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log4sh_test_log4j_compatibility.sh
executable file
·88 lines (78 loc) · 1.76 KB
/
log4sh_test_log4j_compatibility.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
88
#! /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 log4j compatibility support.
# load test helpers
. ./log4sh_test_helpers
#------------------------------------------------------------------------------
# suite tests
#
testAppenders()
{
for appender in \
ConsoleAppender \
FileAppender \
RollingFileAppender \
DailyRollingFileAppender \
SMTPAppender \
SyslogAppender
do
cat <<EOF >${propertiesF}
log4j.rootLogger = INFO, A
log4j.appender.A = org.apache.log4j.${appender}
EOF
log4sh_doConfigure ${propertiesF}
rtrn=$?
assertTrue \
"compatibility problems with the log4j ${appender}" \
"[ ${rtrn} -eq ${LOG4SH_TRUE} ]"
done
}
testLayouts()
{
for layout in \
SimpleLayout \
PatternLayout \
HTMLLayout
do
cat <<EOF >${propertiesF}
log4j.rootLogger = INFO, A
log4j.appender.A = org.apache.log4j.ConsoleAppender
log4j.appender.A.layout = org.apache.log4j.${layout}
EOF
log4sh_doConfigure ${propertiesF}
rtrn=$?
assertTrue \
"compatibility problems with the log4j ${layout}" \
"[ ${rtrn} -eq ${LOG4SH_TRUE} ]"
done
}
#------------------------------------------------------------------------------
# suite functions
#
oneTimeSetUp()
{
LOG4SH_CONFIGURATION='none'
LOG4SH_CONFIG_PREFIX='log4j'
th_oneTimeSetUp
# declare the properties file
propertiesF="${TH_TMPDIR}/properties.log4sh"
}
setUp()
{
# reset log4sh
log4sh_resetConfiguration
}
tearDown()
{
# remove the properties file
rm -f "${propertiesF}"
}
# load and run shUnit2
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. ${TH_SHUNIT}