
olokia-client-javascript.2.2.8.source-code.jolokia-simple.test.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jolokia-client-javascript
Show all versions of jolokia-client-javascript
JavaScript client library for Jolokia agents
The newest version!
const Jolokia = require("./jolokia");
require("./jolokia-simple");
const $ = require("jquery");
describe("jolokia-simple", () => {
beforeEach(() => {
jest.resetAllMocks();
});
test("getAttribute", () => {
$.ajax = jest.fn(() => ({
status: 200,
responseText: JSON.stringify({
request: {type: "read", mbean: "java.lang:type=Memory", attribute: "HeapMemoryUsage", path: "used"},
status: 200,
value: 12345,
timestamp: 1694682372,
})
}));
const jolokia = new Jolokia("/jolokia");
const value = jolokia.getAttribute("java.lang:type=Memory", "HeapMemoryUsage", "used");
expect(value).toEqual(12345);
});
test("list (sync)", () => {
$.ajax = jest.fn(() => ({
status: 200,
responseText: JSON.stringify({
request: {type: "list", path: "java.lang/type=Memory/attr/HeapMemoryUsage"},
status: 200,
value: {
type: "javax.management.openmbean.CompositeData",
desc: "HeapMemoryUsage",
rw: false
},
timestamp: 1694682372,
})
}));
const jolokia = new Jolokia("/jolokia");
const value = jolokia.list("java.lang", "type=Memory", "attr", "HeapMemoryUsage");
expect(value).toEqual({
type: "javax.management.openmbean.CompositeData",
desc: "HeapMemoryUsage",
rw: false
});
});
});
© 2015 - 2025 Weber Informatics LLC | Privacy Policy