Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Status line testing, using fixtures for tests.

  • Loading branch information...
commit 3c8c7431a7977c071c747c1f8847e3750bdbba9e 1 parent d3ed8f3
@neotyk authored
Showing with 22 additions and 10 deletions.
  1. +0 −3  src/clj/async/http/client.clj
  2. +22 −7 test/async/http/client/test.clj
View
3  src/clj/async/http/client.clj
@@ -51,7 +51,6 @@
(defn- convert-headers [#^Headers headers]
"Converts Headers to lazy map"
;; TODO write conversion
- ;; introspect
(let [mts (.. headers getClass getMethods)]
(println (map #(.getName %) mts))))
@@ -84,8 +83,6 @@
([#^Request req body-fn completed-fn headers-fn]
(execute-request req body-fn completed-fn headers-fn print-status))
([#^Request req body-fn completed-fn headers-fn status-fn]
- (println
- (str req " " body-fn " " completed-fn " " headers-fn " " status-fn))
(let [id (gensym "req-id__")]
(.executeRequest
ahc req
View
29 test/async/http/client/test.clj
@@ -1,12 +1,27 @@
(ns async.http.client.test
"Testing of ahc-clj"
#^{:author "Hubert Iwaniuk <neotyk@kungfoo.pl>"}
- (:use clojure.test async.http.client))
+ (:use clojure.test async.http.client)
+ (:import (org.apache.log4j ConsoleAppender Level Logger PatternLayout)))
+
+(defn once-fixture [f]
+ (doto (Logger/getRootLogger)
+ (.setLevel Level/WARN)
+ (.addAppender (ConsoleAppender. (PatternLayout. PatternLayout/TTCC_CONVERSION_PATTERN))))
+ (f)
+ (.close ahc))
+
+(use-fixtures :once once-fixture)
(deftest test-status
- (let [code (promise)]
- (execute-request
- (prepare-get "http://localhost:8080/")
- body-collect body-completed ignore-headers
- (fn [_ st] (do (println st) (deliver code (:code st)) :abort)))
- (is (= @code 200))))
+ (let [status# (promise)
+ _ (execute-request
+ (prepare-get "http://localhost:8080/")
+ body-collect body-completed ignore-headers
+ (fn [_ st] (do (deliver status# st) :abort)))
+ status @status#]
+ (is (= (status :code) 200))
+ (is (= (status :text) "OK"))
+ (is (= (status :protocol) "HTTP/1.1"))
+ (is (= (status :major) 1))
+ (is (= (status :minor) 1))))
Please sign in to comment.
Something went wrong with that request. Please try again.