Skip to content

Commit

Permalink
Fix async tools-logging-test (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
miikka authored Jan 20, 2022
1 parent 62f0775 commit 350703e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 1 addition & 4 deletions test/ring/async_logger_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,7 @@
finish))
(is (pos? elapsed))))))

;; This test is similar to ring.logger-test/tools-logging-test,
;; only it uses the async middleware. However, for some reason
;; one of the tests fails when both of them are enabled.
#_(deftest tools-logging-test
(deftest tools-logging-test
(let [handler (-> ok-handler
logger/wrap-with-logger
wrap-params)
Expand Down
5 changes: 4 additions & 1 deletion test/ring/logger_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
[ring.logger.compat :as logger.compat]
[ring.mock.request :as mock])
(:import
[java.io ByteArrayOutputStream PrintStream]))
[java.io ByteArrayOutputStream PrintStream]
[org.apache.log4j LogManager]))

(def ok-handler
(fn [req]
Expand Down Expand Up @@ -347,6 +348,8 @@
tmp-out# (PrintStream. out-buffer# true "UTF-8")]
(try
(System/setOut tmp-out#)
;; The console appender needs to be re-activated to ensure it sees the new value of System/out
(.activateOptions (.getAppender (LogManager/getRootLogger) "console"))
~@body
(finally
(System/setOut original-out#)))
Expand Down

0 comments on commit 350703e

Please sign in to comment.