io.vertx.core.http.HttpClientOptions Java Examples

The following examples show how to use io.vertx.core.http.HttpClientOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RESTServiceBlockingChainObjectTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
// @Ignore
public void endpointOne() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointOne",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "1test final");
                    testComplete();
                  });
            }
          });
  request.end();
  await();
}
 
Example #2
Source File: RESTServiceChainStringTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
// @Ignore
public void basicTestAndThenWithError() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestAndThenWithError",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "error test error");
                    testComplete();
                  });
            }
          });
  request.end();
  await();
}
 
Example #3
Source File: RESTServiceExceptionTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void catchedAsyncByteErrorDelay() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/catchedAsyncByteErrorDelay?val=123&tmp=456",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    String val = body.getString(0, body.length());
                    System.out.println("--------catchedAsyncByteErrorDelay: " + val);
                    // assertEquals(key, "val");
                    testComplete();
                  });
            }
          });
  request.end();

  await(5000, TimeUnit.MILLISECONDS);
}
 
Example #4
Source File: RESTServiceBlockingChainObjectTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
// @Ignore
public void basicTestAndThenWithErrorUnhandled() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestAndThenWithErrorUnhandled",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              assertEquals(resp.statusCode(), 500);
              assertEquals(resp.statusMessage(), "test error");
              testComplete();
            }
          });
  request.end();
  await();
}
 
Example #5
Source File: HttpConfigStore.java    From vertx-config with Apache License 2.0 6 votes vote down vote up
public HttpConfigStore(Vertx vertx, JsonObject configuration) {
  String host = configuration.getString("host");
  int port = configuration.getInteger("port", 80);
  String path = configuration.getString("path", "/");
  long timeout = configuration.getLong("timeout", 3000L);
  boolean followRedirects = configuration.getBoolean("followRedirects", false);
  this.client = vertx.createHttpClient(new HttpClientOptions(configuration));
  this.requestOptions = new RequestOptions()
    .setHost(host)
    .setPort(port)
    .setURI(path)
    .setTimeout(timeout)
    .setFollowRedirects(followRedirects);
  configuration.getJsonObject("headers", new JsonObject()).stream()
    .filter(h -> h.getValue() != null)
    .forEach(h -> requestOptions.addHeader(h.getKey(), h.getValue().toString()));
}
 
Example #6
Source File: ResolveServicesByNameTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Before
public void startVerticles() throws InterruptedException {
  initKubernetes();
  initService();
  CountDownLatch latch2 = new CountDownLatch(1);
  DeploymentOptions options = new DeploymentOptions().setInstances(1);

  vertx.deployVerticle(
      new WsServiceOne(config),
      options,
      asyncResult -> {
        // Deployment is asynchronous and this this handler will be called when it's complete
        // (or failed)
        System.out.println("start service: " + asyncResult.succeeded());
        assertTrue(asyncResult.succeeded());
        assertNotNull("deploymentID should not be null", asyncResult.result());
        // If deployed correctly then start the tests!
        //   latch2.countDown();

        latch2.countDown();
      });

  httpClient = vertx.createHttpClient(new HttpClientOptions());
  awaitLatch(latch2);
}
 
Example #7
Source File: WebClientTest.java    From vertx-rx with Apache License 2.0 6 votes vote down vote up
@Test
public void testPost() {
  int times = 5;
  waitFor(times);
  HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
  server.requestStream().handler(req -> req.bodyHandler(buff -> {
    assertEquals("onetwothree", buff.toString());
    req.response().end();
  }));
  try {
    server.listen(ar -> {
      client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
      Observable<Buffer> stream = Observable.just(Buffer.buffer("one"), Buffer.buffer("two"), Buffer.buffer("three"));
      Single<HttpResponse<Buffer>> single = client
        .post(8080, "localhost", "/the_uri")
        .rxSendStream(stream);
      for (int i = 0; i < times; i++) {
        single.subscribe(resp -> complete(), this::fail);
      }
    });
    await();
  } finally {
    server.close();
  }
}
 
Example #8
Source File: RESTServiceChainStringTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
// @Ignore
public void basicTestSupply() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestSupply",
          resp ->
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "1 final");
                    testComplete();
                  }));
  request.end();
  await();
}
 
Example #9
Source File: RESTServiceSelfhostedTestStaticInitializer.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void endpointFive() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointFive?val=123&tmp=456",
          resp -> {
            resp.bodyHandler(
                body -> {
                  System.out.println("Got a createResponse: " + body.toString());
                  Payload<String> pp = new Gson().fromJson(body.toString(), Payload.class);
                  assertEquals(pp.getValue(), new Payload<>("123" + "456").getValue());
                });
            testComplete();
          });
  request.end();
  await();
}
 
Example #10
Source File: WebClientTest.java    From vertx-rx with Apache License 2.0 6 votes vote down vote up
@Test
public void testErrorHandling() throws Exception {
  try {
    client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
    Single<HttpResponse<WineAndCheese>> single = client
            .get(-1, "localhost", "/the_uri")
            .as(BodyCodec.json(WineAndCheese.class))
            .rxSend();
    single.subscribe(resp -> fail(), error -> {
      assertEquals(IllegalArgumentException.class, error.getClass());
      testComplete();
    });
    await();
  } catch (Throwable t) {
    fail();
  }
}
 
Example #11
Source File: RESTVerticleRouteBuilderSelfhostedTestStaticInitializer.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void endpointFourErrorRetryTest() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointFourErrorRetryTest?val=123&tmp=456",
          resp -> resp.bodyHandler(
              body -> {
                System.out.println("Got a createResponse: " + body.toString());
                assertEquals(body.toString(), "123456");
                testComplete();
              }));
  request.end();
  await();
}
 
Example #12
Source File: RESTServiceExceptionFallbackTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void exceptionInStringResponseWithErrorHandler() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/exceptionInStringResponseWithErrorHandler?val=123&tmp=456",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    String val = body.getString(0, body.length());
                    System.out.println("--------exceptionInStringResponse: " + val);
                    // assertEquals(key, "val");
                    testComplete();
                  });
            }
          });
  request.end();

  await(5000, TimeUnit.MILLISECONDS);
}
 
Example #13
Source File: RESTServiceOnFailureStringResponseTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void simpleOnFailureResponseBlocking() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/simpleOnFailureResponseBlocking",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    String val = body.getString(0, body.length());
                    System.out.println("--------catchedAsyncByteErrorDelay: " + val);
                    assertEquals("on failure", val);
                    testComplete();
                  });
            }
          });
  request.end();

  await(10000, TimeUnit.MILLISECONDS);
}
 
Example #14
Source File: RESTVerticleRouteBuilderSelfhostedTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void endpointThree() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointThree?val=123&tmp=456",
          resp -> {
            resp.bodyHandler(
                body -> {
                  System.out.println("Got a createResponse: " + body.toString());
                  assertEquals(body.toString(), "123456");
                    testComplete();
                });
          });
  request.end();
  await();
}
 
Example #15
Source File: ClientGenerator.java    From raml-module-builder with Apache License 2.0 6 votes vote down vote up
private void addConstructorOkapi6Args(JFieldVar tokenVar, JFieldVar options, JFieldVar httpClient) {
  /* constructor, init the httpClient - allow to pass keep alive option */
  JMethod constructor = constructor();
  JVar okapiUrlVar = constructor.param(String.class, OKAPI_URL);
  JVar tenantIdVar = constructor.param(String.class, TENANT_ID);
  JVar token = constructor.param(String.class, TOKEN);
  JVar keepAlive = constructor.param(boolean.class, KEEP_ALIVE);
  JVar connTimeout = constructor.param(int.class, "connTO");
  JVar idleTimeout = constructor.param(int.class, "idleTO");

  /* populate constructor */
  JBlock conBody = constructor.body();
  conBody.assign(JExpr._this().ref(tenantId), tenantIdVar);
  conBody.assign(JExpr._this().ref(tokenVar), token);
  conBody.assign(JExpr._this().ref(okapiUrl), okapiUrlVar);
  conBody.assign(options, JExpr._new(jcodeModel.ref(HttpClientOptions.class)));
  conBody.invoke(options, "setLogActivity").arg(JExpr.TRUE);
  conBody.invoke(options, "setKeepAlive").arg(keepAlive);
  conBody.invoke(options, "setConnectTimeout").arg(connTimeout);
  conBody.invoke(options, "setIdleTimeout").arg(idleTimeout);

  JExpression vertx = jcodeModel
      .ref("org.folio.rest.tools.utils.VertxUtils")
      .staticInvoke("getVertxFromContextOrNew");
  conBody.assign(httpClient, vertx.invoke("createHttpClient").arg(options));
}
 
Example #16
Source File: RESTAsyncThreadCheckStaticInitializer.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void simpleRetryTest() throws InterruptedException {

  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/simpleRetryTest",
          resp ->
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "test exception");
                    testComplete();
                  }));
  request.end();
  await();
}
 
Example #17
Source File: RESTServiceBlockingChainStringTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
// @Ignore
public void basicTestAndThenWithError() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestAndThenWithError",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "error test error");
                    testComplete();
                  });
            }
          });
  request.end();
  await();
}
 
Example #18
Source File: RESTJerseyClientTests.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void stringPOST() throws InterruptedException, ExecutionException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client
          .post(
              "/wsService/stringPOST",
              resp -> {
                resp.exceptionHandler(error -> {});

                resp.bodyHandler(
                    body -> {
                      System.out.println("Got a createResponse: " + body.toString());
                      testComplete();
                    });
              })
          .putHeader("content-length", String.valueOf("hello".getBytes().length))
          .putHeader("Content-Type", "application/json;charset=UTF-8");
  request.write("hello");
  request.end();
  await();
}
 
Example #19
Source File: RESTServiceSelfhostedAsyncTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void asyncStringResponse() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/asyncStringResponse",
          resp -> {
            resp.bodyHandler(
                body -> {
                  System.out.println("Got a createResponse: " + body.toString());
                  assertEquals(body.toString(), "test");
                  testComplete();
                });
          });
  request.end();
  await();
}
 
Example #20
Source File: RESTServiceBlockingChainStringTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
// @Ignore
public void basicTestAndThenWithErrorUnhandledRetry() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestAndThenWithErrorUnhandledRetry",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    assertEquals(body.toString(), "error 4 test error");
                    testComplete();
                  });
            }
          });
  request.end();
  await();
}
 
Example #21
Source File: TestVertxTLSBuilder.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Test
public void testbuildClientOptionsBaseSTORE_PKCS12() {
  SSLOption option = SSLOption.buildFromYaml("rest.consumer");
  SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
  HttpClientOptions serverOptions = new HttpClientOptions();
  new MockUp<SSLOption>() {

    @Mock
    public String getTrustStoreType() {
      return "PKCS12";
    }
  };
  VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
  Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
  Assert.assertEquals(serverOptions.isTrustAll(), true);
}
 
Example #22
Source File: RESTServiceBlockingChainObjectTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
// @Ignore
public void basicTestSupplyWithErrorUnhandled() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestSupplyWithErrorUnhandled",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              assertEquals(resp.statusCode(), 500);
              assertEquals(resp.statusMessage(), "test error");
              testComplete();
            }
          });
  request.end();
  await();
}
 
Example #23
Source File: WebClientTest.java    From vertx-rx with Apache License 2.0 6 votes vote down vote up
@Test
public void testResponseBodyAsAsJsonMapped() throws Exception {
  JsonObject expected = new JsonObject().put("cheese", "Goat Cheese").put("wine", "Condrieu");
  HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
  server.requestStream().handler(req -> req.response().end(expected.encode()));
  try {
    server.listen(ar -> {
      client = WebClient.wrap(vertx.createHttpClient(new HttpClientOptions()));
      Single<HttpResponse<WineAndCheese>> single = client
        .get(8080, "localhost", "/the_uri")
        .as(BodyCodec.json(WineAndCheese.class))
        .rxSend();
      single.subscribe(resp -> {
        assertEquals(200, resp.statusCode());
        assertEquals(new WineAndCheese().setCheese("Goat Cheese").setWine("Condrieu"), resp.body());
        testComplete();
      }, this::fail);
    });
    await();
  } finally {
    server.close();
  }
}
 
Example #24
Source File: TestVertxTLSBuilder.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Test
public void testbuildClientOptionsBaseSTORE_JKS() {
  SSLOption option = SSLOption.buildFromYaml("rest.consumer");
  SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
  HttpClientOptions serverOptions = new HttpClientOptions();
  new MockUp<SSLOption>() {

    @Mock
    public String getKeyStoreType() {
      return "JKS";
    }
  };
  VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
  Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
  Assert.assertEquals(serverOptions.isTrustAll(), true);
}
 
Example #25
Source File: ClientRecordTest.java    From cava with Apache License 2.0 6 votes vote down vote up
@BeforeEach
void setupClient(@TempDirectory Path tempDir, @VertxInstance Vertx vertx) throws Exception {
  knownServersFile = tempDir.resolve("known-hosts.txt");
  Files.write(
      knownServersFile,
      Arrays.asList("#First line", "localhost:" + foobarServer.actualPort() + " " + DUMMY_FINGERPRINT));

  HttpClientOptions options = new HttpClientOptions();
  options
      .setSsl(true)
      .setTrustOptions(VertxTrustOptions.recordServerFingerprints(knownServersFile, false))
      .setConnectTimeout(1500)
      .setReuseAddress(true)
      .setReusePort(true);
  client = vertx.createHttpClient(options);
}
 
Example #26
Source File: RESTServiceSelfhostedTestStaticInitializer.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void endpointFourErrorReturnRetryTest() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/endpointFourErrorReturnRetryTest?productType=123&product=456",
          resp -> resp.bodyHandler(
              body -> {
                System.out.println(
                    "Got a createResponse endpointFourErrorReturnRetryTest: "
                        + body.toString());
                assertEquals(body.toString(), "456123");
                testComplete();
              }));
  request.end();
  await();
}
 
Example #27
Source File: VertxHttpClient.java    From feign-vertx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates {@link HttpClientRequest} (Vert.x) from {@link Request} (feign).
 *
 * @param request  feign request
 * @return fully formed HttpClientRequest
 */
private HttpClientRequest makeHttpClientRequest(final Request request)
    throws MalformedURLException {
  final URL url = new URL(request.url());
  final int port = url.getPort() > -1
      ? url.getPort()
      : HttpClientOptions.DEFAULT_DEFAULT_PORT;
  final String host = url.getHost();
  final String requestUri = url.getFile();

  HttpClientRequest httpClientRequest = httpClient.request(
      HttpMethod.valueOf(request.method()),
      port,
      host,
      requestUri);

  /* Add headers to request */
  for (final Map.Entry<String, Collection<String>> header : request.headers().entrySet()) {
    httpClientRequest = httpClientRequest.putHeader(header.getKey(), header.getValue());
  }

  return httpClientRequest;
}
 
Example #28
Source File: RESTServiceExceptionFallbackTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void exceptionInErrorHandler() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/exceptionInErrorHandler",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    String val = body.getString(0, body.length());
                    System.out.println("--------exceptionInStringResponse: " + val);
                    assertEquals(val, "catched");
                    testComplete();
                  });
            }
          });
  request.end();

  await(5000, TimeUnit.MILLISECONDS);
}
 
Example #29
Source File: RESTJerseyClientEventStringResponseAsyncTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
public void onErrorResponseTest() throws InterruptedException {
  System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT2);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/onFailurePass",
          resp -> {
            resp.bodyHandler(
                body -> {
                  System.out.println("Got a createResponse" + body.toString());

                  assertEquals(body.toString(), "failed");
                });

            testComplete();
          });
  request.end();
  await();
}
 
Example #30
Source File: RESTServiceChainByteTest.java    From vxms with Apache License 2.0 6 votes vote down vote up
@Test
// @Ignore
public void basicTestSupplyWithErrorUnhandled() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/basicTestSupplyWithErrorUnhandled",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              assertEquals(resp.statusCode(), 500);
              assertEquals(resp.statusMessage(), "test error");
              testComplete();
            }
          });
  request.end();
  await();
}