title: How to check JSON in response body with mockMvc
body: <p>This is my method inside my controller which is annotated by <code>@Controller</code></p>
  
  <pre><code>@RequestMapping(value = "/getServerAlertFilters/{serverName}/", produces = "application/json; charset=utf-8")
      @ResponseBody
      public JSONObject getServerAlertFilters(@PathVariable String serverName) {
          JSONObject json = new JSONObject();
          List&lt;FilterVO&gt; filteredAlerts = alertFilterService.getAlertFilters(serverName, "");
          JSONArray jsonArray = new JSONArray();
          jsonArray.addAll(filteredAlerts);
          json.put(SelfServiceConstants.DATA, jsonArray);
          return json;
      }
  </code></pre>
  
  <p>I am expecting <code>{"data":[{"useRegEx":"false","hosts":"v2v2v2"}]}</code> as my json.</p>
  
  <p>And this is my JUnit test:</p>
  
  <pre><code>@Test
      public final void testAlertFilterView() {       
          try {           
              MvcResult result = this.mockMvc.perform(get("/getServerAlertFilters/v2v2v2/").session(session)
                      .accept("application/json"))
                      .andDo(print()).andReturn();
              String content = result.getResponse().getContentAsString();
              LOG.info(content);
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>Here is the console output:</p>
  
  <pre><code>MockHttpServletResponse:
                Status = 406
         Error message = null
               Headers = {}
          Content type = null
                  Body = 
         Forwarded URL = null
        Redirected URL = null
               Cookies = []
  </code></pre>
  
  <p>Even <code>result.getResponse().getContentAsString()</code> is an empty string.</p>
  
  <p>Can someone please suggest how to get my JSON in my JUnit test method so that I can complete my test case.</p>