diff --git a/.gitignore b/.gitignore index 8dfa3b08..c096c0a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ *.o *.py[co] +*.class +*.jar /uwsgi /uwsgibuild.* + +/t/ring/target diff --git a/t/ring/README.md b/t/ring/README.md new file mode 100644 index 00000000..27b507b3 --- /dev/null +++ b/t/ring/README.md @@ -0,0 +1,21 @@ +Ring Test Suite +================ + +how to build and run +--------------------- + +* cd UWSGIROOT +* cd t/ring +* lein uberjar +* cd ../.. +* uwsgi t/ring/config.ini +* open http://localhost:9090 in your browser + +run cases in jetty +------------------- + +* lein ring server +* open http://localhost:3000 in your browser + + + diff --git a/t/ring/config.ini b/t/ring/config.ini new file mode 100644 index 00000000..fcb819bf --- /dev/null +++ b/t/ring/config.ini @@ -0,0 +1,9 @@ +[uwsgi] +http = :9090 +http-modifier1 = 8 +http-modifier2 = 1 + +jvm-classpath = plugins/jvm/uwsgi.jar +jvm-classpath = t/ring/target/uwsgi-ring-tests-0.0.1-standalone.jar + +ring-app = uwsgi.ring.tests.app:app diff --git a/t/ring/project.clj b/t/ring/project.clj new file mode 100644 index 00000000..f3036710 --- /dev/null +++ b/t/ring/project.clj @@ -0,0 +1,10 @@ +(defproject unbit/uwsgi-ring-tests "0.0.1" + :description "uwsgi-ring-tests: test cases for uwsgi ring server" + :dependencies [[org.clojure/clojure "1.4.0"] + [compojure "1.1.3"] + [ring/ring "1.1.0"]] + + :source-paths ["src"] + + :plugins [[lein-ring "0.7.5"]] + :ring {:handler uwsgi.ring.tests.app/app}) diff --git a/t/ring/src/uwsgi/ring/tests/app.clj b/t/ring/src/uwsgi/ring/tests/app.clj new file mode 100644 index 00000000..77cd493e --- /dev/null +++ b/t/ring/src/uwsgi/ring/tests/app.clj @@ -0,0 +1,29 @@ +(ns uwsgi.ring.tests.app + (:use compojure.core) + (:use [ring.middleware params + keyword-params + nested-params + multipart-params]) + (:require [compojure.route :as route] + [uwsgi.ring.tests.basic :as basic] + [uwsgi.ring.tests.body :as body] + [uwsgi.ring.tests.simple :as simple] + [uwsgi.ring.tests.upload :as upload]) + (:gen-class + :main true)) + +(defn app-routes [req] + (if (= (get req :uri) "/") + (basic/index-page req) + ((routes simple/app-routes body/app-routes upload/app-routes) req))) + +(def app + (-> app-routes + wrap-keyword-params + wrap-nested-params + wrap-params + wrap-multipart-params)) + +(defn -main [& args] + (println "uwsgi ring tests app loaded")) + diff --git a/t/ring/src/uwsgi/ring/tests/basic.clj b/t/ring/src/uwsgi/ring/tests/basic.clj new file mode 100644 index 00000000..b95b6576 --- /dev/null +++ b/t/ring/src/uwsgi/ring/tests/basic.clj @@ -0,0 +1,30 @@ +(ns uwsgi.ring.tests.basic) + +(defn index-page [req] {:status 200 + :headers { "Content-Type" "text/html" , "Server" "uWSGI" } + :body (str "