forked from kward/log4sh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log4sh_test_multiple_appenders.sh
executable file
·76 lines (63 loc) · 1.82 KB
/
log4sh_test_multiple_appenders.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
#! /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 simultaneous appender definitions.
# load test helpers
. ./log4sh_test_helpers
#------------------------------------------------------------------------------
# suite tests
#
testTwoSimilarFileAppenders()
{
# configure log4sh
logger_setLevel INFO
# setup first appender
logger_addAppender ${APP_ONE_NAME}
appender_setType ${APP_ONE_NAME} FileAppender
appender_file_setFile ${APP_ONE_NAME} "${APP_ONE_FILE}"
appender_activateOptions ${APP_ONE_NAME}
# setup second appender
logger_addAppender ${APP_TWO_NAME}
appender_setType ${APP_TWO_NAME} FileAppender
appender_file_setFile ${APP_TWO_NAME} "${APP_TWO_FILE}"
appender_activateOptions ${APP_TWO_NAME}
# log a message
th_generateRandom
random=${th_RANDOM}
logger_info "dummy message ${random}"
# verify first appender
matched=`tail "${APP_ONE_FILE}" |grep "${random}"`
assertNotNull \
'first appender did not properly receive message' \
"${matched}"
# verify second appender
matched=`tail "${APP_TWO_FILE}" |grep "${random}"`
assertNotNull \
'second appender did not properly receive message' \
"${matched}"
}
#------------------------------------------------------------------------------
# suite functions
#
oneTimeSetUp()
{
LOG4SH_CONFIGURATION='none'
th_oneTimeSetUp
# the logfiles will be cleaned up automatically by shunit2
APP_ONE_NAME='appenderOne'
APP_ONE_FILE="${TH_TMPDIR}/appender_one.log"
APP_TWO_NAME='appenderTwo'
APP_TWO_FILE="${TH_TMPDIR}/appender_two.log"
}
setUp()
{
log4sh_resetConfiguration
}
# load and run shUnit2
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
. ${TH_SHUNIT}