This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;Code rewriting macro | |
(defmacro loop-with-timeout [timeout bindings & forms] | |
`(let [starttime# (System/currentTimeMillis)] | |
(loop ~bindings | |
(if (> (- (System/currentTimeMillis) starttime#) ~timeout) | |
(throw (RuntimeException. (str "Hit timeout of " ~timeout "ms."))) | |
(do ~@forms))))) | |
;;example use of macro | |
(loop-with-timeout 60000 [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn method-name [f] | |
(str (:name (meta f)))) | |
(defn group-ann-val [t] | |
(->> (meta t) :groups (map name) (into []))) | |
(defn as-annotation [t] | |
{(if (configuration? t) (-> (configuration t) (testng-map)) Test) | |
{:groups (group-ann-val t)}}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns test-clj.sample-tests | |
(:use [test-clj.meta :only [gen-class-testng]])) | |
;sample tests | |
;------------------------------ | |
(defn ^{:test {:configuration :beforeSuite | |
:groups #{:group1 :group2}}} | |
config1 [_] | |
(do (println "running configuration1") | |
(println "configuration1 complete."))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Trying clojure!" | |
if ! sudo -S true < /dev/null &>/dev/null; then | |
echo "You need sudo permission to run this script." | |
exit 1 | |
fi | |
LEIN=/usr/local/bin/lein | |
if ! which lein; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Script that runs a testng suite or test within a suite | |
* Args = xml-suite-file [optional-test-name] | |
*/ | |
ant = new AntBuilder(); | |
workspace = System.getProperty("workspace.dir", System.getenv("WORKSPACE") ?: System.getProperty("user.dir")) //defaults to $WORKSPACE, or if that's null, pwd | |
println("workspace= "+workspace) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns test-clj.sample-tests | |
(:use [test-clj.testng :only [gen-class-testng]] | |
[test-clj.base-test :only [config-data]])) | |
;sample tests | |
;------------------------------ | |
(defn ^{:test {:configuration :beforeSuite | |
:groups #{:group1 :group2}}} | |
config1 [_] | |
(do (println "running configuration1") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ByValuePredicate implements Predicate<Object> { | |
Object value; | |
String fieldName; | |
public ByValuePredicate(String fieldName, Object value) { | |
this.value=value; | |
this.fieldName=fieldName; | |
} | |
public boolean apply(Object toTest) { | |
return toTest.class.getField(fieldName).get(toTest).equals(value); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(deferror myerror [] [s] {:msg (str "blerg! " s) :unhandled (throw-msg RuntimeException) }) | |
(raise myerror "foo") ;; gives exception message "blerg! foo" | |
(def x myerror) | |
(raise x "foo") ;; gives exception message "blerg!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns com.redhat.qe.handler | |
(:import [javax.naming NamingException])) | |
(def *handlers* []) | |
(def *error* nil) | |
(defn- e-to-map [e] | |
{:msg (.getMessage e) :type (class e) :exception e}) | |
(defn- wrapped? [e] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; in the task class | |
(defn register [username password & {:keys [system-name-input, autosubscribe] | |
:or {system-name-input nil, autosubscribe false}}] | |
(if (ui exists? :unregister-system) | |
(raise {:type :already-registered | |
:username username | |
:password password | |
:unregister-first (fn [] (unregister) | |
(register (:username *error*) (:password *error*)))})) | |
(ui click :register-system) |
OlderNewer