#!/bin/bash

# Read the .functions file
. .functions

# If set, allows to skip tests 
declare -i start=$1

# ==================================================
function testGetOptions {
 echo -n "OptionHandler.getOption() test $TEST - "

 if [ -e $TEMP ]; then
   #echo "Deleting $TEMP."
   rm $TEMP
   touch $TEMP
 fi

 java $1 -Dlog4j.configuration=$LCF org.apache.log4j.test.PrintProperties | sort > $TEMP

 check witness/getOptions.$TEST $TEMP; echo "OK."
}
# ==================================================


declare -i TEST

function createProperties {
  echo -n "" > $LCF
  #if [ -n "$1" ]; then
  #  lecho "log4j.configurator=$1"
  #fi
  lecho "log4j.appender.f=org.apache.log4j.FileAppender"
  lecho "log4j.appender.f.File=$TEMP"
  lecho "log4j.appender.f.Append=false"
  lecho "log4j.appender.f.layout=org.apache.log4j.PatternLayout "
  lecho "log4j.appender.f.layout.ConversionPattern=%m%n"
  lecho "log4j.rootCategory=DEBUG, f"
  lecho "log4j.category.org.apache.log4j=INFO, f"
}

createProperties

TEST=1
if [ $TEST -ge $start ]; then
  testGetOptions 
fi

rm $LCF
