Skip to content

Commit

Permalink
Merge local changes with changes from remote.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruedigergad committed Apr 17, 2016
2 parents 3cf4b16 + f1084e0 commit 0c0efcd
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 22 deletions.
1 change: 1 addition & 0 deletions project.clj
Expand Up @@ -10,4 +10,5 @@
:test2junit-run-ant true
:aot [clj-assorted-utils.JavaUtils]
:plugins [[lein-cloverage "1.0.6"]]
:profiles {:repl {:dependencies [[jonase/eastwood "0.2.2" :exclusions [org.clojure/clojure]]]}}
)
6 changes: 4 additions & 2 deletions src/clj_assorted_utils/JavaUtils.clj
Expand Up @@ -10,8 +10,10 @@
^{:author "Ruediger Gad",
:doc "Java utility and helper functions"}
clj-assorted-utils.JavaUtils
(:use clj-assorted-utils.java-utils
clj-assorted-utils.util)
(:require
(clj-assorted-utils
[java-utils :refer :all]
[util :refer :all]))
(:import (java.util ArrayList HashMap HashSet List Map Set))
(:gen-class
:methods [#^{:static true} [readObjectFromClojureString [String] Object]
Expand Down
5 changes: 3 additions & 2 deletions src/clj_assorted_utils/java_utils.clj
Expand Up @@ -10,16 +10,17 @@
^{:author "Ruediger Gad",
:doc "Utility and helper functions for Java"}
clj-assorted-utils.java-utils
(:use clj-assorted-utils.util))
(:require
(clj-assorted-utils [util :refer :all])))

(defn no-eval-read-string
[input]
(binding [*read-eval* false] (read-string input)))

(defn read-object-from-clojure-string
[input]
"Tries to read data from a string that contains data expressed in Clojure data structures.
Note that *read-eval* is set to false for reading the string in order to avoid unintended code execution."
[input]
(let [read-input (no-eval-read-string input)]
(convert-from-clojure-to-java read-input)))

Expand Down
22 changes: 13 additions & 9 deletions src/clj_assorted_utils/util.clj
Expand Up @@ -10,14 +10,17 @@
^{:author "Ruediger Gad",
:doc "Utility and helper functions"}
clj-assorted-utils.util
(:use clojure.java.io
clojure.walk
clojure.xml)
(:require (clojure [string :as str]))
(:import (java.io BufferedReader BufferedWriter ByteArrayOutputStream IOException ObjectOutputStream)
(java.util ArrayList HashMap HashSet List Map)
(java.util.concurrent CountDownLatch Executors ThreadFactory TimeUnit)
(java.util.zip GZIPOutputStream ZipOutputStream)))
(:require
(clojure
[string :as str]
[walk :refer :all]
[xml :refer :all])
(clojure.java [io :refer :all]))
(:import
(java.io BufferedReader BufferedWriter ByteArrayOutputStream IOException ObjectOutputStream)
(java.util ArrayList HashMap HashSet List Map)
(java.util.concurrent CountDownLatch Executors ThreadFactory TimeUnit)
(java.util.zip GZIPOutputStream ZipOutputStream)))


(defn sleep
Expand Down Expand Up @@ -74,8 +77,9 @@
;;;
;;; Helper functions for handling system properties.
;;;
(defn get-system-property [p]
(defn get-system-property
"Get system property p. p is a String naming the property go get."
[p]
(System/getProperty p))
(def get-arch (partial get-system-property "os.arch"))
(def get-os (partial get-system-property "os.name"))
Expand Down
12 changes: 8 additions & 4 deletions test/clj_assorted_utils/test/java_utils.clj
Expand Up @@ -10,10 +10,14 @@
^{:author "Ruediger Gad",
:doc "Unit tests for Java utility and helper functions"}
clj-assorted-utils.test.java-utils
(:use clojure.test
clojure.test.junit
clj-assorted-utils.JavaUtils
clj-assorted-utils.java-utils)
(:require
(clojure
[test :refer :all])
(clojure.test
[junit :refer :all])
(clj-assorted-utils
[JavaUtils :refer :all]
[java-utils :refer :all]))
(:import (clj_assorted_utils JavaUtils)
(java.util ArrayList HashMap HashSet)))

Expand Down
15 changes: 10 additions & 5 deletions test/clj_assorted_utils/test/util.clj
Expand Up @@ -10,10 +10,15 @@
^{:author "Ruediger Gad",
:doc "Unit tests for utility and helper functions"}
clj-assorted-utils.test.util
(:use clojure.test
clojure.test.junit
clojure.java.io
clj-assorted-utils.util)
(:require
(clojure
[test :refer :all])
(clojure.test
[junit :refer :all])
(clojure.java
[io :refer :all])
(clj-assorted-utils
[util :refer :all]))
(:import (java.util ArrayList HashMap HashSet)))


Expand Down Expand Up @@ -54,7 +59,7 @@
(sleep 100)
(is (flag-set? stdout-run))))

(deftest test-exec-with-out-process-output
(deftest test-exec-with-out-process-output-2
(let [command (into-array java.lang.String ["/bin/sh" "-c" "ls /etc/passwd 1>&2"])
stderr-run (prepare-flag)
stderr-fn (fn [out] (if (= out "/etc/passwd") (set-flag stderr-run)))
Expand Down

0 comments on commit 0c0efcd

Please sign in to comment.