aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2010-04-27 11:13:47 -0400
committerStuart Halloway <stu@thinkrelevance.com>2010-04-27 11:13:47 -0400
commitaa4142cd93b83b2a28fab35772cb538c707200be (patch)
tree3c571059019025b0699efb07a6a693e40bbb8181 /src
parentaf2a730fde0d8df0ab4a41153580105a36a20e7f (diff)
#78 relaxing test expectations to eliminate spurious errors on IBM JDK
Diffstat (limited to 'src')
-rw-r--r--src/test/clojure/clojure/contrib/test_jmx.clj36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/test/clojure/clojure/contrib/test_jmx.clj b/src/test/clojure/clojure/contrib/test_jmx.clj
index 83065fa9..17ba1e55 100644
--- a/src/test/clojure/clojure/contrib/test_jmx.clj
+++ b/src/test/clojure/clojure/contrib/test_jmx.clj
@@ -15,13 +15,19 @@
[javax.management MBeanAttributeInfo AttributeList]
[java.util.logging LogManager Logger]
clojure.contrib.jmx.Bean)
- (:use clojure.test)
+ (:use clojure.test [clojure.contrib.seq :only (includes?)])
(:require [clojure.contrib [jmx :as jmx]]))
(defn =set [a b]
(= (set a) (set b)))
+(defn includes-all?
+ "Does container contain every item in containee?
+ Not fast. Testing use only"
+ [container containee]
+ (every? #(includes? container %) containee))
+
(deftest finding-mbeans
(testing "as-object-name"
(are [cname object-name]
@@ -32,15 +38,20 @@
(= cnames (map #(.getCanonicalName %) object-name))
["java.lang:type=Memory"] (jmx/mbean-names "java.lang:type=Memory"))))
-; don't know which attributes are common on all JVM platforms. May
-; need to change expectations.
-(deftest reflecting-on-capabilities
- (are [attr-list mbean-name]
- (= (set attr-list) (set (jmx/attribute-names mbean-name)))
- [:Verbose :ObjectPendingFinalizationCount :HeapMemoryUsage :NonHeapMemoryUsage] "java.lang:type=Memory")
- (are [a b]
- (= (set a) (set b))
- [:gc] (jmx/operation-names "java.lang:type=Memory")))
+; These actual beans may differ on different JVM platforms.
+; Tested April 2010 to work on Sun and IBM JDKs.
+(deftest testing-actual-beans
+ (testing "reflecting on capabilities"
+ (are [attr-list mbean-name]
+ (includes-all? (jmx/attribute-names mbean-name) attr-list)
+ [:Verbose :ObjectPendingFinalizationCount :HeapMemoryUsage :NonHeapMemoryUsage] "java.lang:type=Memory")
+ (are [op-list mbean-name]
+ (includes-all? (jmx/operation-names mbean-name) op-list)
+ [:gc] "java.lang:type=Memory"))
+ (testing "mbean-from-oname"
+ (are [key-names oname]
+ (includes-all? (keys (jmx/mbean oname)) key-names)
+ [:Verbose :ObjectPendingFinalizationCount :HeapMemoryUsage :NonHeapMemoryUsage] "java.lang:type=Memory")))
(deftest raw-reading-attributes
(let [mem "java.lang:type=Memory"
@@ -61,11 +72,6 @@
(testing "tabular attributes"
(is (map? (jmx/read "java.lang:type=Runtime" :SystemProperties)))))
-(deftest mbean-from-oname
- (are [oname key-names]
- (= (set key-names) (set (keys (jmx/mbean oname))))
- "java.lang:type=Memory" [:Verbose :ObjectPendingFinalizationCount :HeapMemoryUsage :NonHeapMemoryUsage]))
-
(deftest writing-attributes
(let [mem "java.lang:type=Memory"]
(jmx/write! mem :Verbose true)