Permalink
Browse files

isReadable is called in MBeanAttributeInfo, not MBeanInfo

  • Loading branch information...
1 parent 05bb13c commit 69ebdef1881709b21bc1ae3181d41a54129f7f8f @nickmbailey nickmbailey committed Dec 16, 2012
Showing with 7 additions and 3 deletions.
  1. +4 −3 src/main/clojure/clojure/java/jmx.clj
  2. +3 −0 src/test/clojure/clojure/java/test_jmx.clj
@@ -239,13 +239,14 @@
(defn ^{:skip-wiki true} attribute-info
"Get the MBeanAttributeInfo for an attribute."
[object-name attr-name]
- (filter #(= (name attr-name) (.getName %))
- (.getAttributes (mbean-info object-name))))
+ (first
+ (filter #(= (name attr-name) (.getName %))
+ (.getAttributes (mbean-info object-name)))))
(defn readable?
"Is attribute readable?"
[n attr]
- (.isReadable (mbean-info n)))
+ (.isReadable (attribute-info n attr)))
(defn ^{:skip-wiki true} operations
"All operations available on an MBean."
@@ -69,12 +69,15 @@
(deftest reading-attributes
(testing "simple scalar attributes"
+ (is (jmx/readable? "java.lang:type=Memory" :ObjectPendingFinalizationCount))
(are [type attr] (instance? type attr)
Number (jmx/read "java.lang:type=Memory" :ObjectPendingFinalizationCount)))
(testing "composite attributes"
+ (is (jmx/readable? "java.lang:type=Memory" :HeapMemoryUsage))
(are [ks attr] (=set ks (keys attr))
[:used :max :init :committed] (jmx/read "java.lang:type=Memory" :HeapMemoryUsage)))
(testing "tabular attributes"
+ (is (jmx/readable? "java.lang:type=Runtime" :SystemProperties))
(is (map? (jmx/read "java.lang:type=Runtime" :SystemProperties)))))
(deftest reading-multiple-attributes

0 comments on commit 69ebdef

Please sign in to comment.