diff --git a/clj-browserchannel/test/net/thegeez/browserchannel/common.clj b/clj-browserchannel/test/net/thegeez/browserchannel/common.clj index 3ce9c5a..36fdd61 100644 --- a/clj-browserchannel/test/net/thegeez/browserchannel/common.clj +++ b/clj-browserchannel/test/net/thegeez/browserchannel/common.clj @@ -57,6 +57,13 @@ [] (Thread/sleep 500)) -(defn wait-for-heartbeat-interval +(defn wait-for-scheduled-interval [secs] + ; add 1 extra second just to be 100% safe + ; (intervals specified to scheduled job/task timers are never _exact_) (Thread/sleep (+ 1000 (* 1000 secs)))) + +(defn session-id-string? + [s] + (and (string? s) + (not (string/blank? s)))) diff --git a/clj-browserchannel/test/net/thegeez/browserchannel/server/bind_channel_http_request_tests.clj b/clj-browserchannel/test/net/thegeez/browserchannel/server/bind_channel_http_request_tests.clj index bbcd218..7ab8778 100644 --- a/clj-browserchannel/test/net/thegeez/browserchannel/server/bind_channel_http_request_tests.clj +++ b/clj-browserchannel/test/net/thegeez/browserchannel/server/bind_channel_http_request_tests.clj @@ -52,8 +52,7 @@ (let [arrays (get-response-arrays (:body resp)) [[id [c session-id host-prefix version]]] (first arrays)] (is (= "c" c)) - (is (and (string? session-id) - (not (string/blank? session-id)))) + (is (session-id-string? session-id)) (is (nil? host-prefix)) (is (= protocol-version version)) (is (get @sessions session-id)) @@ -107,8 +106,7 @@ (let [arrays (get-response-arrays (:body new-session-response)) [[_ [c session-id _ _]]] (first arrays)] (is (= "c" c)) - (is (and (string? session-id) - (not (string/blank? session-id)))) + (is (session-id-string? session-id)) session-id)) (deftest backchannel-request-test @@ -195,7 +193,7 @@ create-resp (app (->new-session-request) options) session-id (get-session-id create-resp) back-resp (app (->new-backchannel-request session-id))] - (wait-for-heartbeat-interval (:keep-alive-interval options)) + (wait-for-scheduled-interval (:keep-alive-interval options)) (let [async-resp @async-output arrays (get-response-arrays (:body async-resp))] (is (= 200 (:status back-resp))) diff --git a/clj-browserchannel/test/net/thegeez/browserchannel/server/test_channel_http_request_tests.clj b/clj-browserchannel/test/net/thegeez/browserchannel/server/test_channel_http_request_tests.clj index e4d3aab..d7f5d0d 100644 --- a/clj-browserchannel/test/net/thegeez/browserchannel/server/test_channel_http_request_tests.clj +++ b/clj-browserchannel/test/net/thegeez/browserchannel/server/test_channel_http_request_tests.clj @@ -81,9 +81,7 @@ ; browserchannel's buffering proxy test is supposed to work by initially sending ; "11111", then waits for 2 seconds (without closing the response), then sends ; "2" and finally closes the response. - ; wait for 3 secs just to be safe - (println "*** WAITING 3 SECONDS FOR BUFFERING PROXY TEST RESPONSE TO FINISH ***") - (Thread/sleep 3000) + (wait-for-scheduled-interval 2) (let [async-resp @async-output] (is (:closed? async-resp)) (is (= "111112" (:body async-resp))))))