diff --git a/tests/p_java-1.6.0-openjdk/0-install-openjdk.sh b/tests/p_java-1.6.0-openjdk/0-install-openjdk.sh new file mode 100755 index 0000000..104c96e --- /dev/null +++ b/tests/p_java-1.6.0-openjdk/0-install-openjdk.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Author: Christoph Galuschka <christoph.galuschka@chello.at> + +# Install python +t_Log "Running $0 - installing openjdk runtime environment." + +t_InstallPackage java-1.6.0-openjdk diff --git a/tests/p_java-1.6.0-openjdk/10-test_java.sh b/tests/p_java-1.6.0-openjdk/10-test_java.sh new file mode 100755 index 0000000..86630a5 --- /dev/null +++ b/tests/p_java-1.6.0-openjdk/10-test_java.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# Author: Christoph Galuschka <christoph.galuschka@chello.at> + +t_Log "Running $0 - javac can compile and java can print 'hello centos'" + +# creating source file +PATH2FILE='/var/tmp/' +FILE='HelloWorld' +FILE2=$PATH2FILE$FILE.java + +cat > $FILE2 <<EOF +public class HelloWorld { + + public static void main(String[] args) { + System.out.println("hello centos"); + } +} +EOF + +# Installing Java compiler +t_Log "installing openjdk compiler." +t_InstallPackage java-1.6.0-openjdk-devel + +# Compiling +javac $FILE2 +if [ $? == 1 ] + then + t_Log "Java-Compilation failed" + exit +fi + +# executing java +workpath=$(pwd) +cd $PATH2FILE +java $FILE |grep -cq 'hello centos' + +t_CheckExitStatus $? + +cd $workpath +# remove files +/bin/rm $PATH2FILE$FILE.class $FILE2