#!/bin/sh -
#
# $Id: chk.bdb,v 1.2 2004/03/30 01:24:43 jtownsen Exp $
#
# Check to make sure the Greybird/bdb Java API pass our tests.

# The tests are really the combination of two (soon to be three)
# things; 1. the test code, 2. junit, (3. some coverage tool).
# The tests will pass if we are able to run the examples using the
# junit testing tool and get XXX% code coverage (100 would be nice).
#

# NOTES:
# This test requires three JARs not included with the Berkeley DB
# distribution.  JUnit (junit.jar), XML APIs (xml-apis.jar) and
# Xerces (xercesImpl.jar).  I've been using the 8/31/2002 version
# of JUnit.  You can download these JARs from http://jakarta.apache.org/
#
# JUNIT_JAR=/Users/gburd/Unix/opt/junit/junit.jar
# XMLAPI_JAR=/Users/gburd/Unix/opt/ant/lib/xml-apis.jar
# XMLIMPL_JAR=/Users/gburd/Unix/opt/ant/lib/xerxesImpl.jar

[ "x$JUNIT_JAR" = "x" ] && {
	echo 'FAIL: unset environment variable JUNIT_JAR for junit.jar.'
	exit 1
}

[ -f $JUNIT_JAR ] || {
	echo 'FAIL: JUNIT_JAR not a valid path to the junit.jar.'
	exit 1
}

[ "x$XMLAPI_JAR" = "x" ] && {
	echo 'FAIL: unset environment variable XMLAPI_JAR for xml-apis.jar.'
	exit 1
}

[ -f $XMLAPI_JAR ] || {
	echo 'FAIL: XMLAPI_JAR not a valid path to the xml-apis.jar.'
	exit 1
}

[ "x$XMLIMPL_JAR" = "x" ] && {
	echo 'FAIL: unset environment variable XMLIMPL_JAR for xerxesImpl.jar.'
	exit 1
}

[ -f $XMLIMPL_JAR ] || {
	echo 'FAIL: XMLIMPL_JAR  is not a valid path to the file xerxesImpl.jar.'
	exit 1
}

d=..
REQUIRED_JARS=$JUNIT_JAR:$XMLAPI_JAR:$XMLIMPL_JAR
DB_JAR=$d/db.jar
export DB_JAR
export REQUIRED_JARS

make clean

[ -f ./dbtest.jar ] || (make dbtest.jar) || {
	echo 'FAIL: unable to find or build dbtest.jar'
	exit 1
}

if java -cp $REQUIRED_JARS:$DB_JAR:./dbtest.jar com.sleepycat.bdb.test.Suite ; then
	:
else
	echo "FAIL: test program failed"
	exit 1
fi

exit 0
