From 82190c48e3b470b5eed191d7d4aa8516691aeaff Mon Sep 17 00:00:00 2001
From: Jimmy Lu <gongchuo.lu@gmail.com>
Date: Sat, 19 Dec 2015 18:19:21 -0500
Subject: [PATCH] Update dependencies & add tests

---
 .gitignore                         |  2 ++
 nreplds/project.clj                |  6 ++---
 nreplds/test/nreplds/core_test.clj | 36 ++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 3 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 nreplds/test/nreplds/core_test.clj

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e769723
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/*/target/
+.nrepl-port
diff --git a/nreplds/project.clj b/nreplds/project.clj
index db8f465..860df90 100644
--- a/nreplds/project.clj
+++ b/nreplds/project.clj
@@ -3,6 +3,6 @@
   :url "https://github.com/monsanto/nreplds"
   :license {:name "Eclipse Public License"
             :url "http://www.eclipse.org/legal/epl-v10.html"}
-  :dependencies [[org.clojure/clojure "1.5.1"]
-                 [org.clojure/tools.nrepl "0.2.3"]
-                 [org.newsclub/junixsocket "1.3"]])
+  :dependencies [[org.clojure/clojure "1.7.0"]
+                 [org.clojure/tools.nrepl "0.2.12"]
+                 [com.kohlschutter.junixsocket/junixsocket-native-common "2.0.4"]])
diff --git a/nreplds/test/nreplds/core_test.clj b/nreplds/test/nreplds/core_test.clj
new file mode 100644
index 0000000..115c35a
--- /dev/null
+++ b/nreplds/test/nreplds/core_test.clj
@@ -0,0 +1,36 @@
+(ns nreplds.core-test
+  (:require [clojure.test :refer :all]
+            [nreplds.core :refer :all]
+            [clojure.tools.nrepl :as nrepl])
+  (:import java.net.URI
+           (java.nio.file Files attribute.FileAttribute)))
+
+(def socket-file
+  (-> "nreplds-core-test"
+      (Files/createTempDirectory (make-array FileAttribute 0))
+      (.resolve "socket")
+      .toFile))
+
+(def socket-uri
+  (URI. "nreplds" (str socket-file) nil))
+
+(def ^:dynamic *server*)
+
+(use-fixtures :once
+  #(with-open [server (start-server :path socket-file)]
+     (binding [*server* server]
+       (%))))
+
+(defn- repl-eval [client code]
+  (nrepl/response-values (nrepl/message client {:op "eval" :code code})))
+
+(defn- validate-transport [transport]
+  (with-open [t transport]
+    (is (= [5] (repl-eval (nrepl/client transport 1000)
+                          (nrepl/code (+ 2 3)))))))
+
+(deftest test-connect
+  (validate-transport (connect :path socket-file)))
+
+(deftest test-url-connect
+  (validate-transport (nrepl/url-connect socket-uri)))