title: How to make Jersey Unit test for Post method
body: <h2>Questions</h2>
  
  <p>How do create a Jersey Unit Test for a POST?</p>
  
  <p>How do I add post parameters?</p>
  
  <h2>What I tried</h2>
  
  <p>For a GET it is easy (<a href="https://jersey.java.net/documentation/latest/test-framework.html" rel="nofollow">https://jersey.java.net/documentation/latest/test-framework.html</a>):</p>
  
  <pre><code>    @Test
      public void test() {
          final String hello = target("hello").request().get(String.class);
          assertEquals("Hello World!", hello);
      }
  </code></pre>
  
  <p>For a post it is more diffuse. I managed to get the response object, but how do I get the actual response object (the String)?</p>
  
  <pre><code>@Test
  public void test() {
      Response r = target("hello").request().post(Entity.json("test"));
      System.out.println(r.toString());
  }
  </code></pre>
  
  <p>Result: <code>InboundJaxrsResponse{context=ClientResponse{method=POST, uri=http://localhost:9998/hello, status=200, reason=OK}}</code></p>