Add java hello world test for openjdk
This commit is contained in:
parent
bda46ec76b
commit
630fde105d
|
|
@ -98,8 +98,6 @@ imageTests+=(
|
|||
hylang-sh
|
||||
hylang-hello-world
|
||||
'
|
||||
[java]='
|
||||
'
|
||||
[jetty]='
|
||||
jetty-hello-web
|
||||
'
|
||||
|
|
@ -129,6 +127,9 @@ imageTests+=(
|
|||
nuxeo-conf
|
||||
nuxeo-basics
|
||||
'
|
||||
[openjdk]='
|
||||
java-hello-world
|
||||
'
|
||||
[percona]='
|
||||
'
|
||||
[perl]='
|
||||
|
|
@ -194,7 +195,7 @@ imageTests+=(
|
|||
'
|
||||
[swift]='
|
||||
swift-hello-world
|
||||
'
|
||||
'
|
||||
[tomcat]='
|
||||
tomcat-hello-world
|
||||
'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
public class container {
|
||||
/**
|
||||
* Simple "hello world" to test the java can compile and/or run
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
Hello World!
|
||||
|
|
@ -0,0 +1 @@
|
|||
../run-java-in-container.sh
|
||||
|
|
@ -1,9 +1,30 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
set -eo pipefail
|
||||
|
||||
# NOT INTENDED TO BE USED AS A TEST "run.sh" DIRECTLY
|
||||
# SEE OTHER "run-*-in-container.sh" SCRIPTS FOR USAGE
|
||||
|
||||
# arguments to docker
|
||||
args=()
|
||||
opts="$(getopt -o '+' --long 'docker-arg:' -- "$@")"
|
||||
eval set -- "$opts"
|
||||
|
||||
while true; do
|
||||
flag="$1"
|
||||
shift
|
||||
case "$flag" in
|
||||
--docker-arg) args+=( "$1" ) && shift ;;
|
||||
--) break ;;
|
||||
*)
|
||||
{
|
||||
echo "error: unknown flag: $flag"
|
||||
#usage
|
||||
} >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
testDir="$1"
|
||||
shift
|
||||
|
||||
|
|
@ -29,7 +50,7 @@ WORKDIR $workdir
|
|||
ENTRYPOINT ["$entrypoint"]
|
||||
EOD
|
||||
|
||||
args=( --rm )
|
||||
args+=( --rm )
|
||||
|
||||
# there is strong potential for nokogiri+overlayfs failure
|
||||
# see https://github.com/docker-library/ruby/issues/55
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
testDir="$(readlink -f "$(dirname "$BASH_SOURCE")")"
|
||||
runDir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
||||
|
||||
image="$1"
|
||||
# TODO make this work for ibmjava too (jre or sfj -> sdk)
|
||||
jdk="${image/jre/jdk}"
|
||||
|
||||
volume="$(docker volume create)"
|
||||
trap "docker volume rm '$volume' >/dev/null 2>&1" EXIT
|
||||
|
||||
# jdk image to build java class
|
||||
"$runDir/run-in-container.sh" \
|
||||
--docker-arg "--volume=$volume:/container/" \
|
||||
-- \
|
||||
"$testDir" \
|
||||
"$jdk" \
|
||||
sh -c 'javac -d /container/ ./container.java'
|
||||
|
||||
# jre image to run class
|
||||
"$runDir/run-in-container.sh" \
|
||||
--docker-arg "--volume=$volume:/container/" \
|
||||
-- \
|
||||
"$testDir" \
|
||||
"$image" \
|
||||
sh -c 'exec java -cp /container/ container'
|
||||
Loading…
Reference in New Issue