Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit c37dcfb0e4435609edabea2ed3d2e4bc85bcf2c9 @semperos committed Mar 7, 2011
Showing with 131 additions and 0 deletions.
  1. +11 −0 .gitignore
  2. +15 −0 README.md
  3. +7 −0 project.clj
  4. +6 −0 resources/test.txt
  5. +72 −0 src/robot_remote_server/core.clj
  6. +14 −0 src/robot_remote_server/keyword.clj
  7. +6 −0 test/robot_remote_server/test/core.clj
@@ -0,0 +1,11 @@
+pom.xml
+*jar
+lib
+classes
+output.xml
+report.html
+log.html
+*rb
+*py
+*#
+*\#
@@ -0,0 +1,15 @@
+# RobotFramework Remote Server in Clojure
+
+This is a remote server implementation written in Clojure, to be used with the RobotFramework automated testing framework.
+
+## Usage
+
+(use 'robot-remote-server.core)
+
+I've included a couple of example keywords under the robot-remote-server.keyword namespace. See the file `resources/test.txt` for an example.
+
+## License
+
+Copyright (C) 2010 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
@@ -0,0 +1,7 @@
+(defproject robot-remote-server "0.1.0-SNAPSHOT"
+ :description "Implementation of a RobotFramework remote server in Clojure"
+ :dependencies [[org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]
+ [ring/ring-jetty-adapter "0.3.6"]
+ [necessary-evil "1.0.0-SNAPSHOT"]]
+ :dev-dependencies [[swank-clojure "1.3.0-SNAPSHOT"]])
@@ -0,0 +1,6 @@
+***Settings***
+Library Remote http://localhost:8271
+
+***Test Cases***
+Test Keywords
+ Open Dialog
@@ -0,0 +1,72 @@
+(ns robot-remote-server.core
+ (:require [necessary-evil.core :as xml-rpc])
+ (:use robot-remote-server.keyword
+ ring.adapter.jetty))
+
+(def *result* (atom {:status "PASS", :return "", :output "", :error "", :traceback ""}))
+
+(defn- handle-return-val
+ "Convert everything to RobotFramework-acceptable types. See implementations in other languages for examples"
+ [ret]
+ (condp class ret
+ java.lang.String ret
+ java.util.concurrent.atomic.AtomicInteger ret
+ java.util.concurrent.atomic.AtomicLong ret
+ java.math.BigDecimal ret
+ java.math.BigInteger ret
+ java.lang.Byte ret
+ java.lang.Double ret
+ java.lang.Float ret
+ java.lang.Integer ret
+ java.lang.Long ret
+ java.lang.Short ret
+ clojure.lang.PersistentVector (map handle-return-val ret)
+ clojure.lang.PersistentArrayMap (into {}
+ (for [[k v] ret]
+ [(.toString k) (handle-return-val v)]))
+ clojure.lang.PersistentTreeMap (into {}
+ (for [[k v] ret]
+ [(.toString k) (handle-return-val v)]))
+ :else ret))
+
+(defn- run-keyword
+ "Run a single keyword"
+ [name args]
+ (let [a-fn (ns-resolve (find-ns 'robot-remote-server.keyword) (symbol name))
+ output (with-out-str (try
+ (apply a-fn args)
+ (catch Exception e
+ (do
+ (reset! *result* {:status "FAIL", :return "", :output "",
+ :error (with-out-str (prn e)), :traceback (with-out-str (.printStackTrace e))})
+ @*result*))))]
+ (swap! *result* assoc :output output)
+ (swap! *result* assoc :return output)
+ @*result*))
+
+(defn- get-keyword-names
+ []
+ (vec (map #(.toString %) (map first (ns-publics 'robot-remote-server.keyword)))))
+
+(defn- get-keyword-arguments
+ [name]
+ (let [a-fn (ns-resolve (find-ns 'robot-remote-server.keyword) (symbol name))]
+ (vec (map #(.toString %) (last (:arglists (meta a-fn)))))))
+
+(defn- get-keyword-documentation
+ [name]
+ (let [a-fn (ns-resolve (find-ns 'robot-remote-server.keyword) (symbol name))]
+ (:doc (meta a-fn))))
+
+(declare *server*)
+(def handler (xml-rpc/end-point
+ {:run_keyword run-keyword
+ :get_keyword_names get-keyword-names
+ :get_keyword_arguments get-keyword-arguments
+ :get_keyword_documentation get-keyword-documentation
+ :stop_remote_server (fn []
+ (.stop *server*)
+ (str "Server stopped"))}))
+
+(defonce *server* (run-jetty #'handler {:port 8271 :join? false}))
+;;(doto (Thread. #(run-jetty #'handler {:port 8271})) .start)
@@ -0,0 +1,14 @@
+(ns robot-remote-server.keyword
+ (:import javax.swing.JOptionPane))
+
+(defn my_keyword
+ "Documentation for myKeyword"
+ [arg1 arg2]
+ (println (str "My first keyword! Arg1: " arg1 ", Arg2: " arg2)))
+
+(defn open_dialog
+ "Open a JOptionPane, just testing things"
+ []
+ (JOptionPane/showMessageDialog
+ nil "Hello, Clojure World!" "Greeting"
+ JOptionPane/INFORMATION_MESSAGE))
@@ -0,0 +1,6 @@
+(ns robot-remote-server.test.core
+ (:use [robot-remote-server.core] :reload)
+ (:use [clojure.test]))
+
+(deftest replace-me ;; FIXME: write
+ (is false "No tests have been written."))

0 comments on commit c37dcfb

Please sign in to comment.