package vs;

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.MediaType;

public class TestClient {	

	public static void main(String[] args) {
		Client client = ClientBuilder.newClient();
		WebTarget target = client
				.target("http://localhost:8080")
				.path("/rest")
				.path("hello");
		
		System.out.println("GET HelloWorld: " +
				target
					.queryParam("year", "2016")
					.queryParam("month", "06")
					.queryParam("day", "21")
					.request()
					.get(String.class));
		 
		Form form = new Form();
		form.param("year", "2016");
		form.param("month", "06");
		form.param("day", "21");
		 
		System.out.println(target
				.request(MediaType.APPLICATION_JSON_TYPE)
				.post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), String.class));
	}
}
