#!/bin/bash
set -eo pipefail

dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"

image="$1"

# since we have curl in the tomcat image, we'll use that
clientImage="$1"

serverImage="$1"

# Create an instance of the container-under-test
cid="$(docker run -d "$serverImage")"
trap "docker rm -vf $cid > /dev/null" EXIT

_request() {
	local url="${1#/}"
	shift

	docker run --rm --link "$cid":tomcat "$clientImage" \
		wget -q -O - "$@" "http://tomcat:8080/$url"
}

# Make sure that Tomcat is listening
. "$dir/../../retry.sh" '_request / &> /dev/null'

# Check that we can request /
[ -n "$(_request '/')" ]

# Check that the example "Hello World" servlet works
helloWorld="$(_request '/examples/servlets/servlet/HelloWorldExample')"
[[ "$helloWorld" == *'Hello World!'* ]]

#!/bin/bash
set -eo pipefail

dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"

image="$1"

# since the "slim" tomcat variants don't have wget, we'll use buildpack-deps
clientImage='buildpack-deps:stretch-curl'

serverImage="$1"

# Create an instance of the container-under-test
cid="$(docker run -d "$serverImage")"
trap "docker rm -vf $cid > /dev/null" EXIT

_request() {
	local url="${1#/}"
	shift

	docker run --rm --link "$cid":tomcat "$clientImage" \
		wget -q -O - "$@" "http://tomcat:8080/$url"
}

# Make sure that Tomcat is listening
. "$dir/../../retry.sh" '_request / &> /dev/null'

# Check that we can request /
[ -n "$(_request '/')" ]

# Check that the example "Hello World" servlet works
helloWorld="$(_request '/examples/servlets/servlet/HelloWorldExample')"
[[ "$helloWorld" == *'Hello World!'* ]]

Update tomcat-hello-world to use "buildpack-deps:stretch-curl"
Update tomcat-hello-world to use "buildpack-deps:stretch-curl"

This is especially for https://github.com/docker-library/tomcat/pull/104, which creates new tomcat variants which do not include wget.
