Skip to content

Commit

Permalink
Use wboss with fixes for stream closing in-container.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed Jan 26, 2015
1 parent 59a9d5a commit 06ea68a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -87,7 +87,7 @@
h2 "1.3.176"

;; org.projectodd.wunderboss "0.3.0"
org.projectodd.wunderboss "1.x.incremental.187"
org.projectodd.wunderboss "1.x.incremental.188"
;; org.projectodd.wunderboss "0.4.0-SNAPSHOT"

org.immutant :version}}
Expand Down
45 changes: 41 additions & 4 deletions web/test-integration/immutant/web/integ_test.clj
Expand Up @@ -189,7 +189,7 @@
(is (= (str "/" path)
(-> result (deref 5000 "nil") read-string :path-info)))))))

(deftest on-close-should-be-invoked-when-closing-on-server-side
(deftest ws-on-close-should-be-invoked-when-closing-on-server-side
(replace-handler
'(do
(reset! client-state (promise))
Expand All @@ -201,7 +201,7 @@
(ws/send-msg socket "hello")
(is (= 1000 (:code (read-string (get-body (str (cdef-url) "state"))))))))

(deftest on-complete-should-be-called-after-send
(deftest ws-on-complete-should-be-called-after-send
(replace-handler
'(do
(reset! client-state (promise))
Expand All @@ -215,7 +215,7 @@
(ws/send-msg socket "hello")
(is (= :complete! (read-string (get-body (str (cdef-url) "state")))))))

(deftest on-error-is-called-if-on-complete-throws
(deftest ws-on-error-is-called-if-on-complete-throws
(replace-handler
'(do
(reset! client-state (promise))
Expand All @@ -229,4 +229,41 @@
(ws/send-msg socket "hello")
(is (= "BOOM" (read-string (get-body (str (cdef-url) "state")))))))

;; TODO: replicate the above tests for streams
(deftest stream-on-close-should-be-invoked-when-closing-on-server-side
(replace-handler
'(do
(reset! client-state (promise))
(fn [request]
(async/as-channel request
:on-open (fn [ch] (async/close ch))
:on-close (fn [_ r] (deliver @client-state :closed))))))
(is (= nil (get-body (cdef-url))))
(is (= :closed (read-string (get-body (str (cdef-url) "state"))))))

(deftest stream-on-complete-should-be-called-after-send
(replace-handler
'(do
(reset! client-state (promise))
(fn [request]
(async/as-channel request
:on-open (fn [ch]
(async/send! ch "ahoy"
:close? true
:on-complete (fn [_]
(deliver @client-state :complete!))))))))
(is (= "ahoy" (get-body (cdef-url))))
(is (= :complete! (read-string (get-body (str (cdef-url) "state"))))))

(deftest stream-on-error-is-called-if-on-complete-throws
(replace-handler
'(do
(reset! client-state (promise))
(fn [request]
(async/as-channel request
:on-error (fn [_ err] (deliver @client-state (.getMessage err)))
:on-open (fn [ch]
(async/send! ch "ahoy"
:close? true
:on-complete (fn [_] (throw (Exception. "BOOM")))))))))
(is (= "ahoy" (get-body (cdef-url))))
(is (= "BOOM" (read-string (get-body (str (cdef-url) "state"))))))

0 comments on commit 06ea68a

Please sign in to comment.