예제 #1
0
 @Test
 public void multiPostRequests() {
   Map<String, Object> req1Map =
       createMap(
           "type", "read",
           "mbean", "java.lang:type=Memory",
           "attribute", "HeapMemoryUsage");
   Map<String, Object> req2Map = createMap("type", "list");
   List<JmxRequest> req =
       JmxRequestFactory.createPostRequests(Arrays.asList(req1Map, req2Map), procParams);
   assertEquals(req.get(0).getType(), RequestType.READ);
   assertEquals(req.get(1).getType(), RequestType.LIST);
 }
예제 #2
0
 @Test
 public void simplePostWithPath() {
   Map<String, Object> reqMap =
       createMap(
           "type", "read",
           "mbean", "java.lang:type=Memory",
           "attribute", "HeapMemoryUsage",
           "path", "blub!/bla/hello");
   JmxReadRequest req = JmxRequestFactory.createPostRequest(reqMap, procParams);
   List<String> path = req.getPathParts();
   assertEquals(path.size(), 2);
   assertEquals(path.get(0), "blub/bla");
   assertEquals(path.get(1), "hello");
   assertEquals(req.getPath(), "blub!/bla/hello");
 }
예제 #3
0
 @Test
 public void simpleGetWithPath() {
   JmxWriteRequest req =
       JmxRequestFactory.createGetRequest(
           "write/java.lang:type=Runtime/SystemProperties/7788/[com.sun.management.jmxremote.port]/value",
           procParams);
   assert req.getType() == RequestType.WRITE : "Type is write";
   assert req.getObjectName().getCanonicalName().equals("java.lang:type=Runtime")
       : "Name properly parsed";
   List<String> parts = req.getPathParts();
   assert parts.get(0).equals("[com.sun.management.jmxremote.port]")
       : "Path part 0:" + parts.get(0);
   assert parts.get(1).equals("value") : "Path part 1: " + parts.get(1);
   assert req.getPath().equals("[com.sun.management.jmxremote.port]/value");
 }