0

In my case, I am running a eclipse project providing the Restful api, and I will call that api like in the following example. I am curious if I should create another project in the eclipse to run the following code to test the api.

Jersey Example

Form form = new Form();
form.add("x", "foo");
form.add("y", "bar");

Client client = ClientBuilder.newClient();

WebTarget resource = client.target("http://localhost:8080/someresource");

Builder request = resource.request();
request.accept(MediaType.APPLICATION_JSON);

Response response = request.get();

if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
    System.out.println("Success! " + response.getStatus());
    System.out.println(response.getEntity());
} else {
    System.out.println("ERROR! " + response.getStatus());    
    System.out.println(response.getEntity());
}
OPfan
  • 1,625
  • 2
  • 13
  • 18

1 Answers1

0

you can run your code as a java application using main method.

Or since you are saying you have you services running you can use POSTMAN REST Client available as a plugin for chrome and chromium browsers. i don't know about the support for the same in other browsers.

Using postman you'll be able to see exactly how your restful service is working. you'll be able to send request headers and other parameters as a part of the rest request. Postman is the way to go for end to end web service testing.

Abhishek
  • 2,485
  • 2
  • 18
  • 25