Blame tests/p_java-openjdk/10-test_java.sh

8614a0
#!/bin/bash
8614a0
# Author: Pablo Greco <pablo@fliagreco.com.ar>
8614a0
# Based on java-1.6.0-openjdk test from Christoph Galuschka <christoph.galuschka@chello.at>
8614a0
8614a0
. $(dirname "$0")/p_java-openjdk-common
8614a0
8614a0
for i in $JAVA_VERSIONS;do
8614a0
t_Log "Running $0 - javac can compile and java can print 'hello centos'"
8614a0
8614a0
# selecting the right alternative
8614a0
t_Select_Alternative java "(jre|java)-$i-openjdk"
8614a0
t_Select_Alternative javac "java-$i-openjdk"
8614a0
8614a0
# creating source file
8614a0
PATH2FILE='/var/tmp/'
8614a0
FILE='HelloWorld'
8614a0
FILE2=$PATH2FILE$FILE.java
8614a0
8614a0
cat > $FILE2 <
8614a0
public class HelloWorld {
8614a0
8614a0
  public static void main(String[] args) {
8614a0
    System.out.println("hello centos");
8614a0
  }
8614a0
}
8614a0
EOF
8614a0
8614a0
# Compiling
8614a0
javac $FILE2
8614a0
if [ $? == 1 ]
8614a0
  then
8614a0
  t_Log "Java-Compilation failed"
8614a0
  exit
8614a0
fi
8614a0
8614a0
# executing java
8614a0
workpath=$(pwd)
8614a0
cd $PATH2FILE
8614a0
java $FILE |grep -q 'hello centos'
8614a0
8614a0
t_CheckExitStatus $?
8614a0
8614a0
cd $workpath
8614a0
# remove files
8614a0
/bin/rm $PATH2FILE$FILE.class $FILE2
8614a0
done