Skip to content
Browse files

Return a list of Attribute objects from .getAttributes

patch by Chris Jeris for JMX-6
  • Loading branch information...
1 parent 9c2e3ce commit 25c416f2d82aca272bfb248cbc5847fd81530d4c @nickmbailey nickmbailey committed Sep 28, 2012
Showing with 7 additions and 5 deletions.
  1. +1 −1 src/main/clojure/clojure/java/jmx.clj
  2. +6 −4 src/test/clojure/clojure/java/test_jmx.clj
View
2 src/main/clojure/clojure/java/jmx.clj
@@ -321,7 +321,7 @@
(getAttributes [_ attrs]
(let [result (AttributeList.)]
(doseq [attr attrs]
- (.add result (.getAttribute _ attr)))
+ (.add result (Attribute. attr (.getAttribute _ attr))))
result)))
(defn create-bean
View
10 src/test/clojure/clojure/java/test_jmx.clj
@@ -12,7 +12,7 @@
(ns clojure.java.test-jmx
(:import javax.management.openmbean.CompositeDataSupport
- [javax.management MBeanAttributeInfo AttributeList]
+ [javax.management MBeanAttributeInfo Attribute AttributeList]
[java.util.logging LogManager Logger])
(:use clojure.test)
(:require [clojure.java [jmx :as jmx]]))
@@ -168,8 +168,9 @@
(let [state (reftype {:a 1 :b 2})
bean (jmx/create-bean state)]
(testing (str "accessing values from a " (class state))
- (are [result expr] (= result expr)
- 1 (.getAttribute bean "a"))))))
+ (are [result expr] (= result expr)
+ 1 (.getAttribute bean "a")
+ 2 (.getAttribute bean "b"))))))
(deftest test-bean-info
(let [state (ref {:a 1 :b 2})
@@ -184,7 +185,8 @@
atts (.getAttributes bean (into-array ["r" "d"]))]
(are [x y] (= x y)
AttributeList (class atts)
- [5 4] (seq atts))))
+ ["r" "d"] (map (memfn getName) (seq atts))
+ [5 4] (map (memfn getValue) (seq atts)))))
(def primitive-int? (< (.compareTo (clojure-version) "1.3.0") 0))

0 comments on commit 25c416f

Please sign in to comment.
Something went wrong with that request. Please try again.