Browse Source

Merge pull request #7217 from infosiftr/improved-tomcat-test

Improve Tomcat test to actually load some JSP
yosifkit 5 years ago
parent
commit
488030ce86
2 changed files with 16 additions and 7 deletions
  1. 8 0
      test/tests/tomcat-hello-world/index.jsp
  2. 8 7
      test/tests/tomcat-hello-world/run.sh

+ 8 - 0
test/tests/tomcat-hello-world/index.jsp

@@ -0,0 +1,8 @@
+<html>
+	<head>
+		<title>Sample JSP Page</title>
+	</head>
+	<body>
+		<%= new String("Hello") %> <%= new String("Docker") %> <%= new String("World!") %>
+	</body>
+</html>

+ 8 - 7
test/tests/tomcat-hello-world/run.sh

@@ -8,7 +8,11 @@ image="$1"
 # since the "slim" tomcat variants don't have wget, we'll use buildpack-deps
 clientImage='buildpack-deps:stretch-curl'
 
-serverImage="$1"
+serverImage="$("$dir/../image-name.sh" librarytest/tomcat-hello-world "$image")"
+"$dir/../docker-build.sh" "$dir" "$serverImage" <<EOD
+FROM $image
+COPY dir/index.jsp \$CATALINA_HOME/webapps/ROOT/
+EOD
 
 # Create an instance of the container-under-test
 cid="$(docker run -d "$serverImage")"
@@ -25,9 +29,6 @@ _request() {
 # 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!'* ]]
+# Check that our simple servlet works
+helloWorld="$(_request '/')"
+[[ "$helloWorld" == *'Hello Docker World!'* ]]