Skip to content
Browse files

#78 relaxing test expectations to eliminate spurious errors on IBM JDK

  • Loading branch information...
1 parent af2a730 commit aa4142cd93b83b2a28fab35772cb538c707200be @stuarthalloway stuarthalloway committed Apr 27, 2010
Showing with 21 additions and 15 deletions.
  1. +21 −15 src/test/clojure/clojure/contrib/test_jmx.clj
View
36 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)

0 comments on commit aa4142c

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