 (deftest default-server-test
   (testing "handler added to user-specified default server if no server-id is given"
     (with-app-with-config app
-      [jetty9-service]
+      [jetty9-service
+       hello-webservice]
       default-server-config
-      (let [s                (tk-app/get-service app :WebserverService)
-            add-ring-handler (partial add-ring-handler s)
-            body             "Hi World"
-            path             "/hi_world"
-            ring-handler     (fn [req] {:status 200 :body body})]
-        (add-ring-handler ring-handler path)
-        (let [response (http-get "http://localhost:9000/hi_world")]
-          (is (= 200 (:status response)))
-          (is (= (:body response) body))))))
+      (let [response (http-get "http://localhost:9000/hi_world")]
+        (is (= 200 (:status response)))
+        (is (= (:body response) hello-body)))))
 
   (testing (str "exception thrown if user does not specify a "
                 "default server and no server-id is given")

  (testing "request logging occurs when :access-log-config is configured"
    (with-app-with-config
      app
      [jetty9-service]
      {:webserver {:port 8080
                   :access-log-config
                         "./dev-resources/puppetlabs/trapperkeeper/services/webserver/request-logging.xml"}}
      (let [s (tk-app/get-service app :WebserverService)
            add-ring-handler (partial add-ring-handler s)
            ring-handler (fn [req] {:status 200 :body "Hello, World!"})]
        (add-ring-handler ring-handler "/hello")
        (http-get "http://localhost:8080/hello/")
        ; Logging is done in a separate thread from Jetty and this test. As a result,
        ; we have to sleep the thread to avoid a race condition.
        (Thread/sleep 10)
        (let [list (TestListAppender/list)]
          (is (re-find #"\"GET /hello/ HTTP/1.1\" 200 13\n" (first list))))))))

(deftest graceful-shutdown-test
  (testing "jetty9 webservers shut down gracefully by default"

      (assoc :ssl-cert "./dev-resources/config/jetty/ssl/certs/unauthorized.pem")
      (assoc :ssl-key "./dev-resources/config/jetty/ssl/private_keys/unauthorized.pem")))

(def hello-path "/hi_world")
(def hello-body "Hi World")
(defn hello-handler
  [req]
  {:status 200 :body hello-body})

(tk-core/defservice hello-webservice
  [[:WebserverService add-ring-handler]]
  (init [this context]
        (add-ring-handler hello-handler hello-path)
        context))

(defn validate-ring-handler
  ([base-url config]
    (validate-ring-handler base-url config {:as :text} :default))
