#!/bin/sh
# ---------------------------------------------------------------------------
# JOnAS: Java(TM) Open Application Server
# Copyright (C) 1999 Bull S.A.
# Contact: jonas-team@objectweb.org
# 
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or any later version.
# 
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
# USA
#
# ---------------------------------------------------------------------------
# $Id$
# ---------------------------------------------------------------------------

#
# Usage:	junit [ dir-name [ suite-name [ test-name ] ] ]
#
# This script allows to run the jonas-test all the tests or a sub-set of the tests:
# - the tests of the given directory
# - the tests of the given suite of the given directory
# - only the given test of the given suite of the given directory
#



if [ ! -f $JONAS_ROOT/bin/unix/config_env ]
then
    echo "JONAS_ROOT must be set"
    exit 1
fi
. $JONAS_ROOT/bin/unix/config_env


DIR=suite
SUITE=C_suite
TEST=

if [ $# -gt 0 ]
then
	DIR=$1
	SUITE=C_$DIR
	shift
fi
if [ $# -gt 0 ]
then
	SUITE=$1
	shift
fi
if [ $# -gt 0 ]
then
	PREFIX=`echo "$SUITE" | cut -b 1-2`
	if [ "$PREFIX" != "F_" ]
	then
		echo "$0 ERROR: a test-name may be specified only for a final suite (F_xxx)"
		exit 2
	fi
	TEST="-n $1"
	shift
fi

set -x

java \
    -Dinstall.root=$JONAS_ROOT \
    -Djava.security.policy=$JONAS_ROOT/config/java.policy \
    org.objectweb.jonas.jtests.clients.$DIR.$SUITE $TEST
