예제 #1
0
 @Test
 public void readWithPattern() {
   JmxReadRequest req = JmxRequestFactory.createGetRequest("read/java.lang:type=*", procParams);
   assert req.getType() == RequestType.READ : "Type is read";
   assert req.getObjectName().getCanonicalName().equals("java.lang:type=*")
       : "Name properly parsed";
   assert req.getObjectName().isPattern() : "Name is pattern";
   assert req.getAttributeNames() == null : "No attributes names";
   assert req.getAttributeName() == null : "No attributes names";
   assert req.getPath() == null : "Path is null";
   req = JmxRequestFactory.createGetRequest("read/java.lang:type=*/HeapMemoryUsage", procParams);
   assert req.getAttributeName().equals("HeapMemoryUsage") : "No attributes names";
 }
예제 #2
0
 @Test
 public void simpleGetWithEscapedAttribute() {
   JmxReadRequest req =
       JmxRequestFactory.createGetRequest(
           "read/java.lang:type=Memory/!/Heap!/Memory!/Usage!/", procParams);
   assertEquals(req.getAttributeName(), "/Heap/Memory/Usage/", "Attribute properly parsed");
 }
예제 #3
0
 @Test
 public void simpleGetWithEscapedPath() {
   JmxReadRequest req =
       JmxRequestFactory.createGetRequest(
           "read/java.lang:type=Memory/HeapMemoryUsage/used!/bla!/blub/bloe", procParams);
   assertEquals(req.getPathParts().size(), 2, "Size of path");
   assertEquals(req.getPath(), "used!/bla!/blub/bloe", "Path properly parsed");
 }
예제 #4
0
 @Test
 public void simpleGetWithQueryPath() {
   Map<String, String> params = new HashMap<String, String>();
   params.put("p", "list/java.lang/type=Memory");
   JmxListRequest req =
       JmxRequestFactory.createGetRequest(
           null, new Configuration().getProcessingParameters(params));
   assert req.getHttpMethod() == HttpMethod.GET : "GET by default";
   assert req.getPath().equals("java.lang/type=Memory") : "Path extracted";
 }
예제 #5
0
 @Test
 public void simpleGet() {
   JmxReadRequest req =
       JmxRequestFactory.createGetRequest(
           "read/java.lang:type=Memory/HeapMemoryUsage", procParams);
   assert req.getType() == RequestType.READ : "Type is read";
   assert req.getObjectName().getCanonicalName().equals("java.lang:type=Memory")
       : "Name properly parsed";
   assertEquals(req.getAttributeName(), "HeapMemoryUsage", "Attribute parsed properly");
   assert req.getPathParts() == null : "PathParts are null";
   assert req.getPath() == null : "Path is null";
 }
예제 #6
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");
 }
예제 #7
0
 @Test(expectedExceptions = {ClassCastException.class})
 public void castException() {
   JmxReadRequest req =
       JmxRequestFactory.createGetRequest("exec/java.lang:type=Memory/gc", procParams);
 }
예제 #8
0
 @Test(expectedExceptions = NullPointerException.class)
 public void nullProcParams() {
   JmxRequestFactory.createGetRequest("", null);
 }
예제 #9
0
 @Test
 public void emptyRequest() {
   JmxVersionRequest req = JmxRequestFactory.createGetRequest("", procParams);
   req = JmxRequestFactory.createGetRequest(null, procParams);
 }
예제 #10
0
 @Test(expectedExceptions = {UnsupportedOperationException.class})
 public void unsupportedType() {
   JmxRequestFactory.createGetRequest("regnotif", procParams);
 }
예제 #11
0
 @Test(
     expectedExceptionsMessageRegExp = ".*Invalid object name.*",
     expectedExceptions = {IllegalArgumentException.class})
 public void invalidObjectName() {
   JmxRequestFactory.createGetRequest("read/bla::blub", procParams);
 }
예제 #12
0
 @Test(
     expectedExceptionsMessageRegExp = ".*pathinfo.*",
     expectedExceptions = {IllegalArgumentException.class})
 public void illegalPath() {
   JmxRequestFactory.createGetRequest("read", procParams);
 }