<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -32,17 +32,17 @@
 (def *server*          (atom (or (System/getProperty &quot;com.leftrightfold.trixx.rabbit-server&quot;) &quot;localhost&quot;)))
 (def *rabbit-instance* (atom (or (System/getProperty &quot;com.leftrightfold.trixx.rabbit-instance&quot;) &quot;rabbit&quot;)))
 
-(defn #^String load-cookie 
+(defn- #^String load-cookie 
   &quot;Set the Erlang *cookie* from the contents of a local file (as a string).&quot;
   [#^String cookie-file]
   (reset! *cookie* (slurp cookie-file)))
 
-(defn #^String load-default-cookie-file
+(defn- #^String load-default-cookie-file
   &quot;Set the Erlang *cookie* from the file $HOME/.erlang.cookie (the default location).&quot;
   []
   (load-cookie (str (System/getProperty &quot;user.home&quot;) &quot;/.erlang.cookie&quot;)))
 
-(defn log 
+(defn- log 
   &quot;Log a message to stdout, to be replaced with a logging package.&quot;
   [&amp; args]
   (prn (format &quot;%s: %s&quot;
@@ -128,7 +128,7 @@
 (defn _nth  [item i]  (.elementAt item i))
 (defn _boolean [b]    (Boolean/parseBoolean b))
 
-(defn otp-&gt;pull 
+(defn- otp-&gt;pull 
   &quot;Most OTP types are nested strctures, this helper aids in pulling
 them apart.  The path is applied as a nested series of calls to
 .elementAt on the item.&quot;
@@ -139,7 +139,7 @@ them apart.  The path is applied as a nested series of calls to
       (recur (.elementAt item pos) path)
       item)))
 
-(defn otp-&gt;pullv 
+(defn- otp-&gt;pullv 
   &quot;Most OTP types are nested strctures, this helper aids in pulling
 them apart.  The path is applied as a nested series of calls to
 .elementAt on the item.  The final value pulled is then passed to the
@@ -158,19 +158,19 @@ them apart.  The path is applied as a nested series of calls to
 ;; it breaks with the convention set by with-open, which is an implict
 ;; do block (which this is not).
 (defmacro with-channel
-  &quot;Executes the given form (as if a doto) in the context of a fresh connection and channel.&quot;
+  &quot;Executes the given form (as if a doto) in the context of a fresh connection and channgel.&quot;
   [server vhost user password f]
   `(with-open [connection# (create-conn ~server (create-conn-params ~vhost ~user ~password))
 	       channel# (.createChannel connection#)]
      (doto channel# ~f)))
 
-(defn #^Connection create-conn
+(defn- #^Connection create-conn
   &quot;Create a connection from a fresh, discarded, connection factory.&quot;
   [#^String server #^ConnectionParameters params]
   (let [factory (ConnectionFactory. params)] factory
        (.newConnection factory server)))
 
-(defn create-conn-params
+(defn- create-conn-params
   &quot;Create a com.rabbitmq.client.ConnectionParameters instance, with the given vhost,
 user and password set on the instance.&quot;
   [#^String vhost #^String user #^String password]
@@ -179,7 +179,7 @@ user and password set on the instance.&quot;
     (.setUsername    user)
     (.setPassword    password)))
 
-(defn #^OtpErlangList create-args
+(defn- #^OtpErlangList create-args
   &quot;Helper to construct and return an OtpErlangList suitable for the var-args of rpc calls.&quot;
   [&amp; args]
   (OtpErlangList. 
@@ -191,20 +191,17 @@ user and password set on the instance.&quot;
                         (OtpErlangBinary. (.getBytes (str x)))))
 		    args))))
 
-;; TODO[AF]: needs to handle the fact the result returned may not be a OtpErlangList
-;; TODO[KB]: discuss renaming to something like `otp-rpc-exec' rather than the more general `execute'
-(defn execute 
+;; TODO : needs to handle the fact the result returned may not be a OtpErlangList
+(defn- execute 
   &quot;RPC Call into the erlang node.&quot;
-  ([from-node to-node command args rabbit-instance cookie]
-     (let [self (OtpSelf. from-node cookie)
-           peer (OtpPeer. rabbit-instance)]
-       (with-open [conn (.connect self peer)]
-         (.sendRPC conn to-node command args)
-         (.receiveRPC conn))))
   ([to-node command args]
-     (execute @*node-name* to-node command (apply create-args args) @*rabbit-instance* @*cookie*)))
+     (let [self (OtpSelf. @*node-name* @*cookie*)
+           peer (OtpPeer. @*rabbit-instance*)]
+       (with-open [conn (.connect self peer)]
+         (.sendRPC conn to-node command (apply create-args args))
+         (.receiveRPC conn)))))
 
-(defn execute-&gt;seq
+(defn- execute-&gt;seq
   &quot;Execute the rpc call, coercing the result into a sequence (must be an OtpErlangList or OtpErlangTuple).&quot;
   [to-node command args]
   (as-seq (execute to-node command args)))
@@ -215,7 +212,7 @@ user and password set on the instance.&quot;
 ;; difficult...also, it's often used to wrap an execute:
 ;; (is-successful? (execute ...)), which makes me think a helper
 ;; (execute? ...) might be in order...
-(defn is-successful? 
+(defn- is-successful? 
   &quot;TODO: Describe this function.&quot;
   [f]
   (try (f) true
@@ -314,13 +311,12 @@ user and password set on the instance.&quot;
   (let [result (execute-&gt;seq &quot;rabbit_access_control&quot; &quot;list_vhosts&quot; [])]
     (map (fn [h] (value h)) result)))
 
-(defn execute-list-permissions-&gt;seq
+(defn- execute-list-permissions-&gt;seq
   &quot;Taget is either user name or host name&quot;
   [target command]
   (execute-&gt;seq &quot;rabbit_access_control&quot; command [target]))
 
 (defn list-vhost-permissions
-  &quot;TODO: Document this function.&quot;
   [#^String vhost]
   (map #(struct user 
                (otp-&gt;pullv % 0)
@@ -330,8 +326,7 @@ user and password set on the instance.&quot;
                (otp-&gt;pullv % 3))
        (execute-list-permissions-&gt;seq vhost &quot;list_vhost_permissions&quot;)))
 
-(defn list-user-permissions 
-  &quot;TODO: Document this function.&quot;
+(defn list-user-permissions
   [u]
   (first (remove nil?
                  (map #(if (and (instance? OtpErlangTuple %) 
@@ -344,26 +339,22 @@ user and password set on the instance.&quot;
                                  (otp-&gt;pullv % 3)))
                       (execute-list-permissions-&gt;seq u &quot;list_user_permissions&quot;)))))
 
-;; TODO[KB]: this used to be wrapped in a flatten, why do we need the flatten?
 (defn list-users 
-  &quot;TODO: document this function.&quot;
   []
   (map
    #(list-user-permissions (value %))
    (execute-&gt;seq &quot;rabbit_access_control&quot; &quot;list_users&quot; [])))
 
+;; needs to handle user already exists error
 (defn add-user
-  &quot;TODO: document this function.&quot;
   [#^String name #^String password]
   (is-successful? #(execute &quot;rabbit_access_control&quot; &quot;add_user&quot; [name password]))) 
 
 (defn delete-user
-  &quot;TODO: document this function.&quot;
   [#^String name]
   (is-successful? #(execute &quot;rabbit_access_control&quot; &quot;delete_user&quot; [name]))) 
 
-(defn parse-ip
-  &quot;TODO: document this function.&quot;
+(defn- parse-ip
   [addr_tuple]
   (let [part1 (_1st addr_tuple)
 	part2 (_2nd addr_tuple)
@@ -372,7 +363,6 @@ user and password set on the instance.&quot;
     (str part1 &quot;.&quot; part2 &quot;.&quot; part3 &quot;.&quot; part4)))
 
 (defn list-connections 
-  &quot;TODO: document this function.&quot;
   []
   (map #(let [pid           (otp-&gt;pullv % 0 1)
               address       (parse-ip (otp-&gt;pull % 1 1))
@@ -398,50 +388,41 @@ user and password set on the instance.&quot;
        (execute-&gt;seq &quot;rabbit_networking&quot; &quot;connection_info_all&quot; [])))
 
 (defn set-permissions
-  &quot;TODO: document this function.&quot;
   [#^String user #^String vhost {config_regex :config write_regex :write read_regex :read}]
   (is-successful? #(execute &quot;rabbit_access_control&quot; &quot;set_permissions&quot; 
                             [user vhost config_regex write_regex read_regex])))
 
 (defn clear-permissions
-  &quot;TODO: document this function.&quot;
   [#^String user #^String vhost]
   (is-successful? #(execute &quot;rabbit_access_control&quot; &quot;set_permissions&quot; [user vhost &quot;^$&quot; &quot;^$&quot; &quot;^$&quot;])))
 
 ;;; via protocol
 (defn add-queue
-  &quot;TODO: document this function.&quot;
   [#^String vhost #^String user #^String password #^String queue-name durable]
   (is-successful? #(with-channel @*server* vhost user password (.queueDeclare queue-name durable))))
 
 (defn delete-queue
-  &quot;TODO: document this function.&quot;
   [#^String vhost #^String user #^String password #^String queue-name]
   (is-successful? #(with-channel @*server* vhost user password (.queueDelete queue-name))))
 
 (defn add-exchange
-  &quot;TODO: document this function.&quot;
   [#^String vhost #^String user #^String password #^String name type durable]
   (is-successful? #(with-channel @*server* vhost user password (.exchangeDeclare name type durable))))
 
 (defn delete-exchange
-  &quot;TODO: document this function.&quot;
   [#^String vhost #^String user #^String password #^String name]
   (is-successful? #(with-channel @*server* vhost user password (.exchangeDelete name))))
 
 (defn add-binding
-  &quot;TODO: document this function.&quot;
   [#^String vhost #^String user #^String password queue exchange routing-key]
   (is-successful? #(with-channel @*server* vhost user password (.queueBind queue exchange routing-key))))
 
-(defn is-user
-  &quot;TODO: document this function.&quot;
+(defn- is-user
   [tuple]
   (= (otp-&gt;pullv tuple 0) 
      &quot;user&quot;))
 
-(defn valid-user 
-  &quot;TODO: document this function.&quot;
+(defn- valid-user 
   [#^String name #^String password]
   (is-user (execute
             &quot;rabbit_access_control&quot; &quot;check_login&quot; </diff>
      <filename>src/com/leftrightfold/trixx.clj</filename>
    </modified>
    <modified>
      <diff>@@ -32,7 +32,7 @@
 (def *rabbit-password* (getprop &quot;password&quot; &quot;guest&quot;))
 (def *vhost*           (getprop &quot;vhost&quot;    &quot;/&quot;))
 (def *queue-name*      (getprop &quot;queue&quot;    &quot;com.leftrightfold.trixx-test.test-queue&quot;))
-(def *exchange-name*   (getprop &quot;exchange&quot; &quot;com.leftrightfold.trixx-test.test-queue&quot;))
+(def *exchange-name*   (getprop &quot;exchange&quot; &quot;com.leftrightfold.trixx-test.test-exchange&quot;))
 
 (def *test-suite*   (atom []))
 (def *test-results* (atom { :passed 0 :failed 0 }))
@@ -127,7 +127,7 @@
   (do (add-queue *vhost* *rabbit-user* *rabbit-password* *queue-name* true)
       (assert-true (queue-exists? *vhost* *queue-name*)))
   (do (add-exchange *vhost* *rabbit-user* *rabbit-password* *exchange-name* &quot;direct&quot; true)
-      (assert-true (exchange-exists? *vhost* *queue-name*)))
+      (assert-true (exchange-exists? *vhost* *exchange-name*)))
   (do (add-binding *vhost* *rabbit-user* *rabbit-password* *queue-name* *exchange-name* &quot;my-key&quot;)
       (assert-true (binding-exists? *vhost* &quot;my-key&quot;)))
   (do (delete-exchange *vhost* *rabbit-user* *rabbit-password* *exchange-name*)
@@ -141,7 +141,7 @@
   (assert (= 1 (count (list-vhosts))))
   (assert (add-vhost &quot;my-vhost&quot;))
   (assert (= 2 (count (list-vhosts))))
-  (assert (delete-vhost &quot;my-vhost&quot;)))
+  (assert-true (delete-vhost &quot;my-vhost&quot;)))
 
 (deftest add-delete-and-list-users
   ; default 'guest'
@@ -153,11 +153,11 @@
 (deftest set-clear-permissions
   ; when the user is first created, it is not associted with vhost until permissions are set
   ; ?how do you query for that user?
-  (assert (add-user &quot;my-user&quot; &quot;password&quot;))
-  (assert (set-permissions &quot;my-user&quot; *vhost* {:config &quot;c&quot; :write &quot;w&quot; :read &quot;r&quot;}))
-  ;;; needs to find my-user
+  (assert-true (add-user &quot;my-user&quot; &quot;password&quot;))
+  (assert-true (set-permissions &quot;my-user&quot; *vhost* {:config &quot;c&quot; :write &quot;w&quot; :read &quot;r&quot;}))
   
   (let [user (list-user-permissions &quot;my-user&quot;)]
+    (assert-false (nil? user))
     (assert (= &quot;c&quot; (:config user)))
     (assert (= &quot;w&quot; (:write user)))
     (assert (= &quot;r&quot; (:read user))))
@@ -166,8 +166,9 @@
   (assert (list-user-permissions &quot;my-user&quot;))
   (assert (delete-user &quot;my-user&quot;)))
 
-(deftest test-list-connections
-  (assert (= 0 (count (list-connections)))))
+;;; needs to hold a connection open during test then remove it after this test.
+;(deftest test-list-connections
+;  (assert (= 0 (count (list-connections)))))
 
 (deftest erlang-cookie
   (let [orig-value @*cookie*]</diff>
      <filename>test/src/com/leftrightfold/trixx_test.clj</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>415b2d00bb1945a912ce38e35502e3589dd13ca8</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Feng</name>
    <email>aaron.feng@gmail.com</email>
  </author>
  <url>http://github.com/aaronfeng/trixx/commit/d440c0b525563573e1cfc4114e1fa4760396cf44</url>
  <id>d440c0b525563573e1cfc4114e1fa4760396cf44</id>
  <committed-date>2009-05-29T11:35:36-07:00</committed-date>
  <authored-date>2009-05-29T11:35:36-07:00</authored-date>
  <message>fixed execute function with trixx, which caused it not to function at all.  fixed typos in the tests</message>
  <tree>37cfa03f7fe9c0df933bb39cbd4ff5f6956bafb3</tree>
  <committer>
    <name>Aaron Feng</name>
    <email>aaron.feng@gmail.com</email>
  </committer>
</commit>
