Search in sources :

Example 1 with DeleteRequest

use of com.tvd12.ezyhttp.client.request.DeleteRequest in project ezyhttp by youngmonkeys.

the class HttpClientProxyTest method deleteJsonTest.

@Test
public void deleteJsonTest() throws Exception {
    // given
    HttpClientProxy sut = newClientProxy();
    DeleteRequest request = new DeleteRequest().setConnectTimeout(15000).setEntity(new TestRequest("Monkey")).setResponseType(TestResponse.class).setResponseType(StatusCodes.OK, TestResponse.class).setURL("http://127.0.0.1:18081/greet").setURL(new URL("http://127.0.0.1:18081/greet")).setURL(URI.create("http://127.0.0.1:18081/greet"));
    // when
    Throwable e = Asserts.assertThrows(() -> sut.call(request, 15000));
    // then
    Asserts.assertEqualsType(e, IllegalArgumentException.class);
    sut.close();
    sut.stop();
}
Also used : HttpClientProxy(com.tvd12.ezyhttp.client.HttpClientProxy) URL(java.net.URL) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) BaseTest(com.tvd12.test.base.BaseTest)

Example 2 with DeleteRequest

use of com.tvd12.ezyhttp.client.request.DeleteRequest in project ezyhttp by youngmonkeys.

the class V018HttpClientTest method main.

public static void main(String[] args) throws Exception {
    HttpClient client = HttpClient.builder().build();
    PostRequest loveRequest = new PostRequest().setURL("http://localhost:8083/love");
    System.out.println(client.request(loveRequest));
    DeleteRequest deleteRequest = new DeleteRequest().setURL("http://localhost:8083/api/v1/customer/delete").setEntity(RequestEntity.builder().header("token", "123456").build());
    System.out.println(client.request(deleteRequest));
    System.out.println(client.request(deleteRequest).getBody().toString());
    GetRequest textRequest = new GetRequest().setURL("http://localhost:8083/text");
    System.out.println((String) client.call(textRequest));
    GetRequest listRequest = new GetRequest().setResponseType(List.class).setURL("http://localhost:8083/list");
    System.out.println(client.call(listRequest).toString());
}
Also used : PostRequest(com.tvd12.ezyhttp.client.request.PostRequest) HttpClient(com.tvd12.ezyhttp.client.HttpClient) GetRequest(com.tvd12.ezyhttp.client.request.GetRequest) List(java.util.List) DeleteRequest(com.tvd12.ezyhttp.client.request.DeleteRequest)

Aggregations

HttpClient (com.tvd12.ezyhttp.client.HttpClient)1 HttpClientProxy (com.tvd12.ezyhttp.client.HttpClientProxy)1 DeleteRequest (com.tvd12.ezyhttp.client.request.DeleteRequest)1 GetRequest (com.tvd12.ezyhttp.client.request.GetRequest)1 PostRequest (com.tvd12.ezyhttp.client.request.PostRequest)1 BaseTest (com.tvd12.test.base.BaseTest)1 URL (java.net.URL)1 List (java.util.List)1 BeforeTest (org.testng.annotations.BeforeTest)1 Test (org.testng.annotations.Test)1