Exemplo n.º 1
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";
 }
Exemplo n.º 2
0
 @Test
 public void simplePostWithMergedMaps() {
   Map config = new HashMap();
   config.put("maxDepth", "10");
   Map<String, Object> reqMap =
       createMap(
           "type", "read",
           "mbean", "java.lang:type=Memory",
           "attribute", "HeapMemoryUsage",
           "config", config);
   Map param = new HashMap();
   ;
   param.put("maxObjects", "100");
   JmxReadRequest req =
       (JmxReadRequest)
           JmxRequestFactory.createPostRequest(
               reqMap, new Configuration().getProcessingParameters(param));
   assertEquals(req.getAttributeName(), "HeapMemoryUsage");
   assertEquals(req.getParameter(ConfigKey.MAX_DEPTH), "10");
   assertEquals(req.getParameterAsInt(ConfigKey.MAX_OBJECTS), 100);
 }
Exemplo n.º 3
0
 // Get parameter map either directly from an Servlet 2.4 compliant implementation
 // or by looking it up explictely (thanks to codewax for the patch)
 private Map<String, String[]> getParameterMap(HttpServletRequest pReq) {
   try {
     // Servlet 2.4 API
     return pReq.getParameterMap();
   } catch (UnsupportedOperationException exp) {
     // Thrown by 'pseudo' 2.4 Servlet API implementations which fake a 2.4 API
     // As a service for the parameter map is build up explicitely
     Map<String, String[]> ret = new HashMap<String, String[]>();
     Enumeration params = pReq.getParameterNames();
     while (params.hasMoreElements()) {
       String param = (String) params.nextElement();
       ret.put(param, pReq.getParameterValues(param));
     }
     return ret;
   }
 }