-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgo_jolokia_test.go
81 lines (72 loc) · 2.51 KB
/
go_jolokia_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
// Maintainer Swarvanu Sengupta <[email protected]>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package go_jolokia
import "testing"
import "fmt"
// Note that these test currently expect a jolokia java process to be
// running on 7025. Currently tested with a cassandra process2
var (
host = "localhost"
port = "8080"
jolokia = "jolokia-war-1.2.3"
targetHost = "localhost"
targetPort = "9999"
)
func TestClientExecuteOperation(t *testing.T) {
client := NewJolokiaClient("http://" + host + ":" + port + "/" + jolokia)
client.SetTarget(targetHost + ":" + targetPort)
result, err := client.ExecuteOperation("java.lang:type=Threading", "getThreadInfo([J,boolean,boolean)",
[]interface{}{[]int{153, 263}, true, true}, "")
if err != nil {
t.Errorf("err(%s) returned", err)
}
fmt.Println("Operation result: ", result)
}
func TestClientListDomainsOverridingInternalUrl(t *testing.T) {
client := NewJolokiaClient("http://" + host + ":" + port + "/" + jolokia)
client.SetTarget("service:jmx:rmi:///jndi/rmi://" + targetHost + ":" + targetPort + "/jmxrmi")
domains, err := client.ListDomains()
if err != nil {
t.Errorf("err(%s) returned", err)
}
fmt.Println("Domains: ", domains)
}
func TestClientListDomains(t *testing.T) {
client := NewJolokiaClient("http://" + host + ":" + port + "/" + jolokia)
client.SetTarget(targetHost + ":" + targetPort)
domains, err := client.ListDomains()
if err != nil {
t.Errorf("err(%s) returned", err)
}
fmt.Println("Domains: ", domains)
}
func TestClientListBeans(t *testing.T) {
client := NewJolokiaClient("http://" + host + ":" + port + "/" + jolokia)
client.SetTarget(targetHost + ":" + targetPort)
beans, err := client.ListBeans("java.lang")
if err != nil {
t.Errorf("err(%s) returned", err)
}
fmt.Println("Beans: ", beans)
}
func TestClientListProperties(t *testing.T) {
client := NewJolokiaClient("http://" + host + ":" + port + "/" + jolokia)
client.SetTarget(targetHost + ":" + targetPort)
props, err := client.ListProperties("java.lang", []string{"type=Threading"})
if err != nil {
t.Errorf("err(%s), returned", err)
}
fmt.Println("Properties: ", props)
}
func TestClientGetAttr(t *testing.T) {
client := NewJolokiaClient("http://" + host + ":" + port + "/" + jolokia)
client.SetTarget(targetHost + ":" + targetPort)
val, err := client.GetAttr("java.lang", []string{"type=Threading"}, "PeakThreadCount")
if err != nil {
t.Errorf("err(%s), returned", err)
return
}
fmt.Println("Value:", val)
}