Search in sources :

Example 1 with PostRequest

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

the class HttpClientProxyTest method clientWasNotActive.

@Test
public void clientWasNotActive() {
    // given
    HttpClientProxy sut = HttpClientProxy.builder().build();
    PostRequest request = new PostRequest().setConnectTimeout(15000).setEntity(String.class).setResponseType(TestResponse.class).setResponseType(StatusCodes.OK, TestResponse.class).setURL("http://127.0.0.1:18081/greet");
    // when
    Throwable e = Asserts.assertThrows(() -> sut.call(request, 150000));
    // then
    Asserts.assertThat(e).isEqualsType(ClientNotActiveException.class);
    sut.close();
    sut.stop();
}
Also used : HttpClientProxy(com.tvd12.ezyhttp.client.HttpClientProxy) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) BaseTest(com.tvd12.test.base.BaseTest)

Example 2 with PostRequest

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

the class HttpClientTest method postMethodNotAllow.

@Test
public void postMethodNotAllow() {
    // given
    HttpClient sut = HttpClient.builder().build();
    PostRequest request = new PostRequest().setResponseType(TestResponse.class).setResponseType(StatusCodes.OK, TestResponse.class).setURL(URI.create("http://127.0.0.1:18081/405"));
    // when
    Throwable e = Asserts.assertThrows(() -> sut.call(request));
    // then
    Asserts.assertThat(e).isEqualsType(HttpMethodNotAllowedException.class);
}
Also used : PostRequest(com.tvd12.ezyhttp.client.request.PostRequest) HttpClient(com.tvd12.ezyhttp.client.HttpClient) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with PostRequest

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

the class HttpClientTest method postMethodNotFound.

@Test
public void postMethodNotFound() {
    // given
    HttpClient sut = HttpClient.builder().build();
    PostRequest request = new PostRequest().setResponseType(TestResponse.class).setResponseType(StatusCodes.OK, TestResponse.class).setURL(URI.create("http://127.0.0.1:18081/404"));
    // when
    Throwable e = Asserts.assertThrows(() -> sut.call(request));
    // then
    Asserts.assertThat(e).isEqualsType(HttpNotFoundException.class);
}
Also used : PostRequest(com.tvd12.ezyhttp.client.request.PostRequest) HttpClient(com.tvd12.ezyhttp.client.HttpClient) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with PostRequest

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

the class HttpClientTest method postMethodConflict.

@Test
public void postMethodConflict() {
    // given
    HttpClient sut = HttpClient.builder().build();
    PostRequest request = new PostRequest().setResponseType(TestResponse.class).setResponseType(StatusCodes.OK, TestResponse.class).setURL(URI.create("http://127.0.0.1:18081/409"));
    // when
    Throwable e = Asserts.assertThrows(() -> sut.call(request));
    // then
    Asserts.assertThat(e).isEqualsType(HttpConflictException.class);
}
Also used : PostRequest(com.tvd12.ezyhttp.client.request.PostRequest) HttpClient(com.tvd12.ezyhttp.client.HttpClient) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 5 with PostRequest

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

the class HttpClientTest method postMethodServer501.

@Test
public void postMethodServer501() {
    // given
    HttpClient sut = HttpClient.builder().build();
    PostRequest request = new PostRequest().setResponseType(TestResponse.class).setResponseType(StatusCodes.OK, TestResponse.class).setURL(URI.create("http://127.0.0.1:18081/501"));
    // when
    Throwable e = Asserts.assertThrows(() -> sut.call(request));
    // then
    Asserts.assertThat(e).isEqualsType(HttpRequestException.class);
}
Also used : PostRequest(com.tvd12.ezyhttp.client.request.PostRequest) HttpClient(com.tvd12.ezyhttp.client.HttpClient) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

PostRequest (com.tvd12.ezyhttp.client.request.PostRequest)22 BeforeTest (org.testng.annotations.BeforeTest)21 Test (org.testng.annotations.Test)21 HttpClient (com.tvd12.ezyhttp.client.HttpClient)20 HttpClientProxy (com.tvd12.ezyhttp.client.HttpClientProxy)5 BaseTest (com.tvd12.test.base.BaseTest)5 RequestEntity (com.tvd12.ezyhttp.client.request.RequestEntity)3 BadRequestException (com.tvd12.ezyfox.exception.BadRequestException)2 ClientNotActiveException (com.tvd12.ezyhttp.client.exception.ClientNotActiveException)2 DownloadCancelledException (com.tvd12.ezyhttp.client.exception.DownloadCancelledException)2 RequestQueueFullException (com.tvd12.ezyhttp.client.exception.RequestQueueFullException)2 HelloRequest (com.tvd12.ezyhttp.client.test.request.HelloRequest)2 UnknownHostException (java.net.UnknownHostException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 RequestCallback (com.tvd12.ezyhttp.client.callback.RequestCallback)1 DeleteRequest (com.tvd12.ezyhttp.client.request.DeleteRequest)1 GetRequest (com.tvd12.ezyhttp.client.request.GetRequest)1 Request (com.tvd12.ezyhttp.client.request.Request)1 Customer (com.tvd12.ezyhttp.client.test.request.Customer)1 ResponseEntity (com.tvd12.ezyhttp.core.response.ResponseEntity)1