blob: bb6ce0b5b343ac0da7ec31d8b4d43d7ae97e499f [file] [log] [blame]
#!/bin/bash
# Read the .functions file
. .functions
declare -i start=$1
setPERL
# =========================================================================
# This script runs ConfigurationFileParsing java program with args1 and 2.
# It has the side effect of aggregating the following arguments to one
# file called $TEMP.
# It runs a perl filter to remove date, line and other variable
# information from the output.
# =========================================================================
function testConfigurationParsing {
configFile=$1;
options=$2; shift; shift;
echo -n " ConfigurationParsing test $TEST - "
java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $configFile
if [ -n "$*" ]; then
cat $* $TEMP >> $TEMP.x
mv $TEMP.x $TEMP
fi
$PERL filter.pl $TEMP $OUTPUT ConfigurationFileParsing $options
if [ $? != 0 ]; then
echo "The output is not in expected format. See the file [$OUTPUT]."
exit 1
fi
check witness/confParsing.$TEST $OUTPUT; echo " OK"
}
# =========================================================================
# Just run ConfigurationFileParsing and direct the output to STDOUT or
# STDERR.
# =========================================================================
function testConfigurationParsingII {
conf=$1;
target=$2
case $target in
OUT )
java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $conf>$TEMP
;;
ERR )
java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $conf>& $TEMP
;;
esac
check witness/confParsing.$TEST $TEMP; echo " OK"
}
# ======================================================
declare -i TEST
TEST=1;
if [ $TEST -ge $start ]; then
D_FLAG=$DEF_DEBUG
echo "log4j.rootCategory=DEBUG, testAppender" > $LCF
lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
lecho "log4j.appender.testAppender.File= $TEMP"
lecho "log4j.appender.testAppender.Append=false"
lecho "log4j.appender.testAppender.layout.ContextPrinting= false "
lecho "log4j.appender.testAppender.layout.ThreadPrinting= xx "
lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout "
testConfigurationParsing $LCF LINE_NUMBER
fi
TEST=2;
if [ $TEST -ge $start ]; then
D_FLAG=$DEF_DEBUG
echo "log4j.rootCategory=DEBUG, testAppender" > $LCF
lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
lecho "log4j.appender.testAppender.File= $TEMP"
lecho "log4j.appender.testAppender.Append=false"
lecho "log4j.appender.testAppender.MaxFileSize=1KB"
lecho "log4j.appender.testAppender.MaxBackupIndex= 1 "
lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
lecho "log4j.appender.testAppender.layout.ThreadPrinting=true"
lecho "log4j.appender.testAppender.layout.DateFormat=ReLaTIve"
testConfigurationParsing $LCF RELATIVE
fi
TEST=3;
if [ $TEST -ge $start ]; then
D_FLAG=$DEF_DEBUG
echo "18:25:32.394 [main] DEBUG testing - HELLO WORLD" > $TEMP
echo "log4j.rootCategory=DEBUG, testAppender" > $LCF
lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
lecho "log4j.appender.testAppender.File=$TEMP"
lecho "log4j.appender.testAppender.Append=true"
lecho "log4j.appender.testAppender.MaxFileSize=54"
lecho "log4j.appender.testAppender.MaxBackupIndex= 0 "
lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute"
lecho "log4j.appender.testAppender.layout.TimeZone=GMT"
testConfigurationParsing $LCF ABSOLUTE
fi
TEST=4;
if [ $TEST -ge $start ]; then
D_FLAG=$DEF_DEBUG
echo "18:25:32,394 [main] DEBUG testing - HELLO WORLD" > $TEMP
echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
lecho "log4j.appender.testAppender.File=$TEMP"
lecho "log4j.appender.testAppender.Append=true"
lecho "log4j.appender.testAppender.MaxFileSize=155"
lecho "log4j.appender.testAppender.MaxBackupIndex=0"
lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute"
lecho "log4j.appender.testAppender.layout.TimeZone=ECT"
testConfigurationParsing $LCF ABSOLUTE
fi
TEST=5;
if [ $TEST -ge $start ]; then
D_FLAG=""
echo "18:25:32,394 [main] DEBUG testing - HELLO WORLD" > $TEMP
echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
lecho "log4j.debug="
lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
lecho "log4j.appender.testAppender.File=$TEMP"
lecho "log4j.appender.testAppender.Append= true"
lecho "log4j.appender.testAppender.MaxFileSize= 1 "
lecho "log4j.appender.testAppender.MaxBackupIndex= 2"
lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute"
lecho "log4j.appender.testAppender.layout.TimeZone=ECT"
testConfigurationParsing $LCF ABSOLUTE $TEMP.2 $TEMP.1
fi
TEST=6;
if [ $TEST -ge $start ]; then
D_FLAG=""
echo "log4j.rootCategory= , testAppender" > $LCF
lecho "log4j.debug="
lecho "log4j.appender.testAppender=org.apache.log4j.FileAppender"
lecho "log4j.appender.testAppender.File=$TEMP"
lecho "log4j.appender.testAppender.Append= false "
lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
lecho "log4j.appender.testAppender.layout.DateFormat=dAtE"
lecho "log4j.appender.testAppender.layout.TimeZone="
testConfigurationParsing $LCF DATE
fi
TEST=7;
if [ $TEST -ge $start ]; then
D_FLAG=""
echo "18:25:32,394 [main] DEBUG testing - HELLO WORLD" > $TEMP
echo "log4j.rootCategory= DEBUG , testAppender, inexistentAppender" > $LCF
lecho "log4j.debug=false"
lecho "log4j.appender.testAppender=org.apache.log4j.RollingFileAppender"
lecho "log4j.appender.testAppender.File=$TEMP"
lecho "log4j.appender.testAppender.Append= true"
lecho "log4j.appender.testAppender.MaxFileSize= 1 "
lecho "log4j.appender.testAppender.MaxBackupIndex=2 "
lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
lecho "log4j.appender.testAppender.layout.DateFormat=aBSOlute"
lecho "log4j.appender.testAppender.layout.TimeZone=ECT"
testConfigurationParsing $LCF ABSOLUTE $TEMP.2 $TEMP.1
fi
TEST=8;
if [ $TEST -ge $start ]; then
D_FLAG=""
echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
lecho "log4j.debug=false"
lecho "log4j.appender.testAppender=org.apache.log4j.ConsoleAppender"
# Note the spaces
lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout "
lecho "log4j.appender.testAppender.layout.ConversionPattern=[%t] %p - %m%n"
echo -n " ConfigurationParsing test $TEST - "
testConfigurationParsingII $LCF OUT
fi
TEST=9;
if [ $TEST -ge $start ]; then
D_FLAG=""
echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
lecho "log4j.debug=false"
lecho "log4j.appender.testAppender=org.apache.log4j.ConsoleAppender"
lecho "log4j.appender.testAppender.Target= System.out "
# lecho "log4j.appender.testAppender.Append= true "
lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout"
lecho "log4j.appender.testAppender.layout.ConversionPattern=[%t] %p - %m%n"
echo -n " ConfigurationParsing test $TEST (can fail if anything is written to System.err) - "
testConfigurationParsingII $LCF ERR
fi
# Test variable subst from System properties
TEST=10;
if [ $TEST -ge $start ]; then
D_FLAG=""
echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
lecho "log4j.debug=false"
lecho "log4j.appender.testAppender=org.apache.log4j.FileAppender"
# We escape the dollar sign to avoid substitution at the shell level.
lecho "log4j.appender.testAppender.File=\${user.dir}/$TEMP"
lecho "log4j.appender.testAppender.Append=false"
lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout"
lecho "log4j.appender.testAppender.layout.ConversionPattern=AVY [%t] %p-%m%n"
testConfigurationParsing $LCF NONE
fi
rm $TEMP > /dev/null
# Test variable subst from the config file itself
TEST=11;
if [ $TEST -ge $start ]; then
D_FALG=""
echo "log4j.rootCategory= DEBUG , testAppender" > $LCF
lecho "log4j.configDebug=false"
# $TEMP will be replaced by the shell
lecho "t=$TEMP"
lecho "log4j.appender.testAppender=org.apache.log4j.FileAppender"
# We escape the dollar sign to avoid substitution at the shell level.
lecho "log4j.appender.testAppender.File=\${t}"
lecho "log4j.appender.testAppender.Append=false"
lecho "log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout"
lecho "log4j.appender.testAppender.layout.ConversionPattern=VSUB [%t] %p-%m%n"
testConfigurationParsing $LCF NONE
fi
# Do SyslogAppender test (not real tests)
TEST=100;
if [ $TEST -ge $start ]; then
D_FLAG=""
echo "log4j.rootCategory= , testAppender" > $LCF
lecho "log4j.debug=true"
lecho "log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender"
lecho "log4j.appender.testAppender.SyslogHost=localhost"
lecho "log4j.appender.testAppender.Facility= LOCAL0 "
lecho "log4j.appender.testAppender.FacilityPrinting=true"
lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
lecho "log4j.appender.testAppender.layout.DateFormat=NULL"
lecho "log4j.appender.testAppender.layout.TimeZone="
echo -n " ConfigurationParsing test $TEST - "
java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $LCF
fi
TEST=101;
if [ $TEST -ge $start ]; then
D_FLAG=""
echo "log4j.rootCategory= , testAppender" > $LCF
lecho "log4j.debug=true"
lecho "log4j.appender.testAppender=org.apache.log4j.net.SyslogAppender"
lecho "log4j.appender.testAppender.SyslogHost=localhost"
lecho "log4j.appender.testAppender.Facility="
lecho "log4j.appender.testAppender.FacilityPrinting="
lecho "log4j.appender.testAppender.layout=org.apache.log4j.TTCCLayout"
lecho "log4j.appender.testAppender.layout.DateFormat=NULL"
lecho "log4j.appender.testAppender.layout.TimeZone="
echo -n " ConfigurationParsing test $TEST - "
java $D_FLAG org.apache.log4j.test.ConfigurationFileParsing $LCF
fi