                                     context))
            app              (boot-service-and-jetty-with-default-config
                               test-service)
-           jetty-server     (-> (get-service app :WebserverService)
-                                (tk-services/service-context)
-                                (:jetty9-server)
-                                (:server))]
+           jetty-server     (get-jetty-server-from-app-context app)]
        (is (.isStarted jetty-server)
            "Jetty server was never started")
        (is (thrown-with-msg?

           "Service shutdown was not called.")
       (is (.isStopped jetty-server)
           "Jetty server was not stopped at shutdown."))))
  (testing (str "jetty and any dependent services are shutdown after a"
                "service throws an error from its init function")
    (with-test-logging
      (let [shutdown-called? (atom false)
            test-service     (tk-services/service

    [service jetty9-service]
    jetty-plaintext-config))

(defn get-jetty-server-from-app-context
  [app]
  (-> (get-service app :WebserverService)
      (tk-services/service-context)
      (:jetty9-server)
      (:server)))

(deftest jetty-and-dependent-service-shutdown-after-service-error
  (testing (str "jetty and any dependent services are shutdown after a"
                "service throws an error from its start function")
