All Downloads are FREE. Search and download functionalities are using the official Maven repository.

olokia-client-javascript.2.1.0.source-code.jolokia-cubism.test.js Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
const cubism = require("cubism");
require("./jolokia");
require("./jolokia-cubism");
const $ = require("jquery");

describe("jolokia-cubism", () => {
    beforeEach(() => {
        jest.resetAllMocks();
    });

    test("basic metric", () => {
        $.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 context = cubism.context();
        const jolokia = context.jolokia("/jolokia");
        const metricMem = jolokia.metric({
            type: "read",
            mbean: "java.lang:type=Memory",
            attribute: "HeapMemoryUsage",
            path: "used"
        }, "HeapMemory Usage");

        expect(metricMem).not.toBeNull();
    });
});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy