June 2018
Intermediate to advanced
596 pages
12h 39m
English
Let's now create a test method for calling the previous web service that consumes form-encoded data. Open CourseManagementClient.java from the CourseManagementRESTClient project and add the following method:
//Test addCourse method (Form-Encoded version) of CourseService
public static void testAddCourseForm() {
//create JAX-RS client
Client client = ClientBuilder.newClient();
//Get WebTarget for a URL
WebTarget webTarget = client.target("http://localhost:8600/CourseManagementREST/services/course/add"); //Create Form object and populate fields Form form = new Form(); form.param("name", "Course-5"); form.param("credits", "5"); //Execute HTTP post method Response response = webTarget.request(). ...Read now
Unlock full access