Permalink
Browse files

Added tests for deamon threads

  • Loading branch information...
1 parent 1fd6973 commit fa409ad860516ed1c9fc609926be2a5024d22f6d @jjcomer jjcomer committed Sep 29, 2012
Showing with 15 additions and 1 deletion.
  1. +15 −1 ring-jetty-adapter/test/ring/adapter/test/jetty.clj
@@ -42,7 +42,7 @@
(is (= (:body response) "Hello World")))))
(testing "configurator set to run last"
- (let [max-threads 20
+ (let [max-threads 20
new-handler (proxy [AbstractHandler] []
(handle [_ ^Request base-request request response]))
threadPool (QueuedThreadPool. ({} :max-threads max-threads))
@@ -56,6 +56,20 @@
(is (= 1 (count (.getHandlers server))))
(.stop server)))
+ (testing "setting daemon threads"
+ (testing "default (daemon off)"
+ (let [server (run-jetty hello-world {:port 4347 :join? false})]
+ (is (not (.. server getThreadPool isDaemon)))
+ (.stop server)))
+ (testing "daemon on"
+ (let [server (run-jetty hello-world {:port 4347 :join? false :daemon? true})]
+ (is (.. server getThreadPool isDaemon))
+ (.stop server)))
+ (testing "daemon off"
+ (let [server (run-jetty hello-world {:port 4347 :join? false :daemon? false})]
+ (is (not (.. server getThreadPool isDaemon)))
+ (.stop server))))
+
(testing "default character encoding"
(with-server (content-type-handler "text/plain") {:port 4347}
(let [response (http/get "http://localhost:4347")]

0 comments on commit fa409ad

Please sign in to comment.