diff --git a/src/oca/java/build.sh b/src/oca/java/build.sh index 514099bdc8..dfa2f37ee7 100755 --- a/src/oca/java/build.sh +++ b/src/oca/java/build.sh @@ -28,25 +28,29 @@ EXA_DIR="./share/examples" TEST_DIR="./test" OCA_JAR=$JAR_DIR"/org.opennebula.client.jar" -JUNIT_JAR="/usr/share/java/junit4.jar" + +JUNIT_URL="http://search.maven.org/remotecontent?filepath=junit/junit/4.12/junit-4.12.jar" +HAMCREST_URL="http://search.maven.org/remotecontent?filepath=org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" + #------------------------------------------------------------------------------- # COMMAND LINE PARSING #------------------------------------------------------------------------------- usage() { echo - echo "Usage: build.sh [-d ] [-h] [-s] [-t] [-p version]" + echo "Usage: build.sh [-d ] [-h] [-s] [-t] [-j] [-p version]" echo echo "-d: build the documentation" echo "-s: compile the examples" echo "-c: clean compilation files" + echo "-j: download junit lib for running the tests" echo "-t: build the tests" echo "-p: build the java-oca-version-tar.gz package" echo "-h: prints this help" } #------------------------------------------------------------------------------- -TEMP_OPT=`getopt -o hsdctp: -n 'build.sh' -- "$@"` +TEMP_OPT=`getopt -o hsdjctp: -n 'build.sh' -- "$@"` eval set -- "$TEMP_OPT" @@ -60,6 +64,7 @@ VERSION="" while true ; do case "$1" in -h) usage; exit 0;; + -j) DO_JUNIT="yes"; shift;; -d) DO_DOC="yes"; shift ;; -s) DO_EXA="yes"; shift ;; -t) DO_TESTS="yes"; shift ;; @@ -74,6 +79,15 @@ done # BUILD FUNCTIONS #------------------------------------------------------------------------------- +do_junit_install() +{ + cd $LIB_DIR + curl -LO $JUNIT_URL + curl -LO $HAMCREST_URL + cd - +} + + do_documentation() { echo "Generating javadocs..." @@ -111,13 +125,13 @@ do_jar() do_examples() { echo "Compiling OpenNebula Cloud API Examples..." - javac -d $EXA_DIR -classpath $OCA_JAR:$LIB_DIR `find share/examples -name *.java` + javac -d $EXA_DIR -classpath $OCA_JAR:$LIB_DIR/* `find share/examples -name *.java` } do_tests() { echo "Compiling OpenNebula Cloud API Tests..." - javac -d $TEST_DIR -classpath $OCA_JAR:$LIB_DIR:$JUNIT_JAR `find $TEST_DIR -name *.java` + javac -d $TEST_DIR -classpath $OCA_JAR:$LIB_DIR/* `find $TEST_DIR -name *.java` } do_clean() @@ -136,6 +150,10 @@ do_clean() rm -rf $JAR_DIR > /dev/null 2>&1 } +if [ "$DO_JUNIT" = "yes" ] ; then + do_junit_install +fi + if [ "$DO_CLEAN" = "yes" ] ; then do_clean exit 0 diff --git a/src/oca/java/test/all_tests.sh b/src/oca/java/test/all_tests.sh index 758bf19c18..5bb48d7148 100755 --- a/src/oca/java/test/all_tests.sh +++ b/src/oca/java/test/all_tests.sh @@ -80,6 +80,9 @@ let RC=RC+$? ./test.sh VirtualRouterTest 2>&1 | tee -a $LOG_FILE let RC=RC+$? +./test.sh VMGroupTest 2>&1 | tee -a $LOG_FILE +let RC=RC+$? + echo "" echo "Output saved in $LOG_FILE" diff --git a/src/oca/java/test/test.sh b/src/oca/java/test/test.sh index 8927cd288f..061fd2138b 100755 --- a/src/oca/java/test/test.sh +++ b/src/oca/java/test/test.sh @@ -19,7 +19,6 @@ # Usage: test.sh # For instance: test.sh ImageTest -JUNIT_JAR="/usr/share/java/junit4.jar" if [ -z $ONE_LOCATION ]; then DB_LOCATION="/var/lib/one/one.db" @@ -55,7 +54,7 @@ done echo 'SAFE_DIRS = "/"' > /tmp/one-javatest-ds.txt onedatastore update --append 1 /tmp/one-javatest-ds.txt -java -cp ../lib/*:../jar/*:$JUNIT_JAR:. org.junit.runner.JUnitCore $1 +java -cp ../lib/*:../jar/*:. org.junit.runner.JUnitCore $1 CODE=$?