title: Testing web services with JUnit
body: <p>I'm developing an application to perform a series of tests on various web services. These web services consume and produce json, and for each of them we have a class to model the json request and response. For example:</p>
  
  <p>If the json request for serviceX is something like this:</p>
  
  <pre><code>{
    "name":"Alex",
    "id":"123"
  }
  </code></pre>
  
  <p>We have a class <code>serviceXrequest</code> like this:</p>
  
  <pre><code>public class serviceXrequest {
  
     String name;
     String id;
  
     //Constructor, getters/setters, etc
     ...
  }
  </code></pre>
  
  <p>With an object of that class as the starting point, we can perform a series of test on the web service. The idea is to make those test as generic as possible so they can be used with any web service by just writing a class that models it's request and a class to model the response.</p>
  
  <p>For that reason, all of the test methods developed so far work with plain java objects. This is an example of what I want to have:</p>
  
  <pre><code>public class WebServiceTest {
  
      String serviceURL;
      String requestJson;
      String requestClass;
      String responseClass;
  
      public WebServiceTest() {}
  
      @Test
      public static void Test1() { ... }
  
      @Test
      public static void Test2() { ... }
  
      ....
  
      @Test
      public static void TestN() { ... }
  }
  </code></pre>
  
  <p>And then, from another class, invoke those tests with doing something like this:</p>
  
  <pre><code>public class LoginTest { //To test the login web service, for example
  
      public static void main(String[] args) {
  
          WebServiceTest loginTest = New WebServiceTest();
  
          loginTest.setServiceURL("172.0.0.1/services/login");
          loginTest.setRequestJson("{"user":"ale","pass":"1234"}");
          ...
          loginTest.runTests();
      }
  }
  </code></pre>
  
  <p>I know it's not that simple, but any ideas on how to get there?
  Thanks in advance!!</p>