Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit aa4142cd93b83b2a28fab35772cb538c707200be 1 parent af2a730
Stuart Halloway authored April 27, 2010
36  src/test/clojure/clojure/contrib/test_jmx.clj
@@ -15,13 +15,19 @@
15 15
            [javax.management MBeanAttributeInfo AttributeList]
16 16
            [java.util.logging LogManager Logger]
17 17
            clojure.contrib.jmx.Bean)
18  
-  (:use clojure.test)
  18
+  (:use clojure.test [clojure.contrib.seq :only (includes?)])
19 19
   (:require [clojure.contrib [jmx :as jmx]]))
20 20
 
21 21
 
22 22
 (defn =set [a b]
23 23
   (= (set a) (set b)))
24 24
 
  25
+(defn includes-all?
  26
+  "Does container contain every item in containee?
  27
+   Not fast. Testing use only"
  28
+  [container containee]
  29
+  (every? #(includes? container %) containee))
  30
+
25 31
 (deftest finding-mbeans
26 32
   (testing "as-object-name"
27 33
            (are [cname object-name]
@@ -32,15 +38,20 @@
32 38
                 (= cnames (map #(.getCanonicalName %) object-name))
33 39
                 ["java.lang:type=Memory"] (jmx/mbean-names "java.lang:type=Memory"))))
34 40
 
35  
-; don't know which attributes are common on all JVM platforms. May
36  
-; need to change expectations.
37  
-(deftest reflecting-on-capabilities
38  
-  (are [attr-list mbean-name]
39  
-       (= (set attr-list) (set (jmx/attribute-names mbean-name)))
40  
-       [:Verbose :ObjectPendingFinalizationCount :HeapMemoryUsage :NonHeapMemoryUsage] "java.lang:type=Memory")
41  
-  (are [a b]
42  
-       (= (set a) (set b))
43  
-       [:gc] (jmx/operation-names "java.lang:type=Memory")))
  41
+; These actual beans may differ on different JVM platforms.
  42
+; Tested April 2010 to work on Sun and IBM JDKs.
  43
+(deftest testing-actual-beans
  44
+  (testing "reflecting on capabilities"
  45
+    (are [attr-list mbean-name]
  46
+         (includes-all? (jmx/attribute-names mbean-name) attr-list)
  47
+         [:Verbose :ObjectPendingFinalizationCount :HeapMemoryUsage :NonHeapMemoryUsage] "java.lang:type=Memory")
  48
+    (are [op-list mbean-name]
  49
+         (includes-all? (jmx/operation-names mbean-name) op-list)
  50
+         [:gc] "java.lang:type=Memory"))
  51
+  (testing "mbean-from-oname"
  52
+    (are [key-names oname]
  53
+         (includes-all? (keys (jmx/mbean oname)) key-names)
  54
+         [:Verbose :ObjectPendingFinalizationCount :HeapMemoryUsage :NonHeapMemoryUsage]  "java.lang:type=Memory")))
44 55
 
45 56
 (deftest raw-reading-attributes
46 57
   (let [mem "java.lang:type=Memory"
@@ -61,11 +72,6 @@
61 72
   (testing "tabular attributes"
62 73
            (is (map? (jmx/read "java.lang:type=Runtime" :SystemProperties)))))
63 74
 
64  
-(deftest mbean-from-oname
65  
-  (are [oname key-names]
66  
-       (= (set key-names) (set (keys (jmx/mbean oname))))
67  
-       "java.lang:type=Memory" [:Verbose :ObjectPendingFinalizationCount :HeapMemoryUsage :NonHeapMemoryUsage]))
68  
-
69 75
 (deftest writing-attributes
70 76
   (let [mem "java.lang:type=Memory"]
71 77
     (jmx/write! mem :Verbose true)

0 notes on commit aa4142c

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