-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgolokia_test.go
92 lines (82 loc) · 2.44 KB
/
golokia_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package golokia
import "testing"
// Note that these test currently expect a jolokia java process to be
// running on 7025. Currently tested with a cassandra process2
func TestListDomains(t *testing.T) {
domains, err := ListDomains("http://localhost:7025")
if err != nil {
t.Errorf("err(%s) returned", err)
}
if len(domains) != 11 {
t.Errorf("ListDomains = %v, want %v : %#v", len(domains), 11, domains)
}
}
func TestListBeans(t *testing.T) {
beans, err := ListBeans("http://localhost:7025", "java.lang")
if err != nil {
t.Errorf("err(%s) returned, err")
}
if len(beans) != 14 {
t.Errorf("ListBeans(java.lang) = %v, want %v : %#v", len(beans), 14, beans)
}
}
func TestListProperties(t *testing.T) {
props, err := ListProperties("http://localhost:7025", "java.lang", "type=Threading")
if err != nil {
t.Errorf("err(%s), returned, err")
}
if len(props) != 16 {
t.Errorf("ListProperties(type=Threading) = %v, want %v, : %#v", len(props), 16, props)
}
}
func TestGetAttr(t *testing.T) {
val, err := GetAttr("http://localhost:7025", "java.lang", "type=Threading", "PeakThreadCount")
if err != nil {
t.Errorf("err(%s), returned", err)
}
if val.(float64) <= 100.0 {
t.Errorf("GetAttr(PeakThreadCount) = %v, want > 100", val)
}
}
func TestClientListDomains(t *testing.T) {
client := NewClient("localhost", "7025")
domains, err := client.ListDomains()
if err != nil {
t.Errorf("err(%s) returned", err)
}
if len(domains) != 11 {
t.Errorf("ListDomains = %v, want %v : %#v", len(domains), 11, domains)
}
}
func TestClientListBeans(t *testing.T) {
client := NewClient("localhost", "7025")
beans, err := client.ListBeans("java.lang")
if err != nil {
t.Errorf("err(%s) returned", err)
}
if len(beans) != 14 {
t.Errorf("ListBeans(java.lang) = %v, want %v : %#v", len(beans), 14, beans)
}
}
func TestClientListProperties(t *testing.T) {
client := NewClient("localhost", "7025")
props, err := client.ListProperties("java.lang", "type=Threading")
if err != nil {
t.Errorf("err(%s), returned", err)
}
if len(props) != 16 {
t.Errorf("ListProperties(type=Threading) = %v, want %v, : %#v", len(props), 16, props)
}
}
func TestClientGetAttr(t *testing.T) {
client := NewClient("localhost", "7025")
val, err := client.GetAttr("java.lang", "type=Threading", "PeakThreadCount")
if err != nil {
t.Errorf("err(%s), returned", err)
return
}
if val.(float64) <= 100.0 {
t.Errorf("GetAttr(PeakThreadCount) = %v, want > 100", val)
return
}
}