use of org.talend.sdk.component.api.service.http.HttpException in project component-runtime by Talend.
the class HttpClientFactoryImplTest method handleHttpError.
@Test
void handleHttpError() throws IOException {
final HttpServer server = createTestServer(HttpURLConnection.HTTP_FORBIDDEN);
try {
server.start();
final ComplexOk ok = newDefaultFactory().create(ComplexOk.class, null);
ok.base("http://localhost:" + server.getAddress().getPort() + "/api");
ok.main1("search yes");
} catch (final HttpException e) {
assertEquals(HttpURLConnection.HTTP_FORBIDDEN, e.getResponse().status());
assertEquals("POST@Connection=keep-alive/Content-length=10/Content-type=application/x-www-form-urlencoded@/api/@search yes", e.getResponse().error(String.class));
} finally {
server.stop(0);
}
}
Aggregations