This repository has been archived on 2023-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
ring-custom-jetty-server/test/ring/server/test/utils.clj
2012-02-12 21:25:27 +00:00

24 lines
598 B
Clojure

(ns ring.server.test.utils
"Utility functions for running unit tests"
(:require [clj-http.client :as http])
(:use clojure.test
ring.util.response))
(defmacro with-server [server & body]
`(let [server# ~server]
(try
~@body
(finally (.stop server#)))))
(defn default-handler [req]
(response "Hello World"))
(defn http-get [port uri]
(http/get (str "http://localhost:" port uri)
{:conn-timeout 1000
:throw-exceptions false}))
(defn is-server-running-on-port [port]
(let [resp (http-get port "")]
(is (= (:status resp) 200))))