Skip to content
This repository
Browse code

Added tests for deamon threads

  • Loading branch information...
commit fa409ad860516ed1c9fc609926be2a5024d22f6d 1 parent 1fd6973
Josh Comer authored September 29, 2012
16  ring-jetty-adapter/test/ring/adapter/test/jetty.clj
@@ -42,7 +42,7 @@
42 42
         (is (= (:body response) "Hello World")))))
43 43
 
44 44
   (testing "configurator set to run last"
45  
-    (let [max-threads 20 
  45
+    (let [max-threads 20
46 46
           new-handler  (proxy [AbstractHandler] []
47 47
                          (handle [_ ^Request base-request request response]))
48 48
           threadPool (QueuedThreadPool. ({} :max-threads max-threads))
@@ -56,6 +56,20 @@
56 56
       (is (= 1 (count (.getHandlers server))))
57 57
       (.stop server)))
58 58
 
  59
+  (testing "setting daemon threads"
  60
+    (testing "default (daemon off)"
  61
+      (let [server (run-jetty hello-world {:port 4347 :join? false})]
  62
+        (is (not (.. server getThreadPool isDaemon)))
  63
+        (.stop server)))
  64
+    (testing "daemon on"
  65
+      (let [server (run-jetty hello-world {:port 4347 :join? false :daemon? true})]
  66
+        (is (.. server getThreadPool isDaemon))
  67
+        (.stop server)))
  68
+    (testing "daemon off"
  69
+      (let [server (run-jetty hello-world {:port 4347 :join? false :daemon? false})]
  70
+        (is (not (.. server getThreadPool isDaemon)))
  71
+        (.stop server))))
  72
+
59 73
   (testing "default character encoding"
60 74
     (with-server (content-type-handler "text/plain") {:port 4347}
61 75
       (let [response (http/get "http://localhost:4347")]

0 notes on commit fa409ad

Please sign in to comment.
Something went wrong with that request. Please try again.