Skip to content
Browse files

Fixing IMMUTANT-245 again since we broke init by :ring previously

  • Loading branch information...
1 parent 3ef999c commit 80a6b4615258c1cbc529aa6b5390d91fc2a2e9d5 @jcrossley3 jcrossley3 committed Mar 18, 2013
View
5 integration-tests/apps/ring/init-from-ring/project.clj
@@ -0,0 +1,5 @@
+(defproject
+ init-from-ring "1.0.0-SNAPSHOT"
+ :description "FIXME: write description"
+ :dependencies [[org.clojure/clojure "1.3.0"]]
+ :ring {:handler init-from-ring.core/handler})
View
10 integration-tests/apps/ring/init-from-ring/src/init_from_ring/core.clj
@@ -0,0 +1,10 @@
+(ns init-from-ring.core)
+
+(defn response [body]
+ {:status 200
+ :headers {"Content-Type" "text/html"}
+ :body (pr-str body)})
+
+(defn handler [request]
+ (response "init-from-ring"))
+
View
31 integration-tests/src/test/clojure/immutant/integs/init_from_ring.clj
@@ -0,0 +1,31 @@
+;; Copyright 2008-2013 Red Hat, Inc, and individual contributors.
+;;
+;; This is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU Lesser General Public License as
+;; published by the Free Software Foundation; either version 2.1 of
+;; the License, or (at your option) any later version.
+;;
+;; This software is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this software; if not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+(ns immutant.integs.init-from-ring
+ (:use fntest.core
+ clojure.test
+ [immutant.integs.integ-helper :only [get-as-data]]))
+
+(use-fixtures :once (with-deployment *file*
+ '{
+ :root "target/apps/ring/init-from-ring/"
+ :context-path "/init-from-ring"
+ }))
+
+(deftest simple "it should work"
+ (is (= "init-from-ring" (get-as-data "/init-from-ring") )))
+
View
7 modules/core/src/main/clojure/immutant/runtime.clj
@@ -63,10 +63,11 @@ bootstrapping process. Applications shouldn't use anything here."
[]
(let [project (registry/get :project)]
(when-let [handler (get-in project [:ring :handler])]
- (require-and-invoke "immutant.web/start"
+ (require-and-invoke "immutant.web/start*"
+ "/"
(util/try-resolve handler)
- :init (util/try-resolve (get-in project [:ring :init]))
- :destroy (util/try-resolve (get-in project [:ring :destroy])))
+ {:init (util/try-resolve (get-in project [:ring :init]))
+ :destroy (util/try-resolve (get-in project [:ring :destroy]))})
(log/info "Initialized" (util/app-name) "from :ring options in project.clj")
true)))
View
3 modules/core/src/test/clojure/immutant/runtime_test.clj
@@ -84,7 +84,8 @@
:destroy guestbook.handler/destroy}})
(try
(initialize nil nil)
- (let [[handler & {:keys [init destroy]}] @a-value]
+ (let [[path handler {:keys [init destroy]}] @a-value]
+ (is (= "/" path))
(is (= "war-handler" (handler)))
(is (= "init" (init)))
(is (= "destroy" (destroy))))
View
2 modules/core/src/test/resources/mock-web/src/immutant/web.clj
@@ -1,4 +1,4 @@
(ns immutant.web)
-(defn start [& args]
+(defn start* [& args]
(reset! immutant.runtime-test/a-value args))

0 comments on commit 80a6b46

Please sign in to comment.
Something went wrong with that request. Please try again.