private TestJmx makeTestJmx(String name, long nom, long div) throws Exception { TestJmx bean = new TestJmx(); bean.setNom(nom); bean.setDiv(div); testMbs.registerMBean(bean, new ObjectName(name)); return bean; }
@Test public void testZorkaLibRateFn1() throws Exception { TestJmx tj = makeTestJmx("test:name=bean1,type=TestJmx", 0, 0); assertEquals(0.0, zorka.rate("test", "test:name=bean1,type=TestJmx", "Nom", "Div", 60), 0.01); tj.setNom(5); tj.setDiv(5); assertEquals(1.0, zorka.rate("test", "test:name=bean1,type=TestJmx", "Nom", "Div", 60), 0.01); assertEquals( 1.0, zorka.rate("test", "test:name=bean1,type=TestJmx", "Nom", "Div", "AVG1"), 0.01); }
@Test public void testOneObjectAvgRateCount() throws Exception { TestJmx tj = makeTestJmx("test:name=bean1,type=TestJmx", 0, 0); List<Object> path = counter.list("test", "test:name=bean1,type=TestJmx"); assertEquals(0.0, counter.get(path, "Nom", "Div", AvgRateCounter.AVG1), 0.01); tj.setNom(5); tj.setDiv(5); assertEquals(1.0, counter.get(path, "Nom", "Div", AvgRateCounter.AVG1), 0.01); tj.setNom(10); tj.setDiv(20); assertEquals(0.5, counter.get(path, "Nom", "Div", AvgRateCounter.AVG1), 0.01); }