當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpClientOptions.setDefaultPort方法代碼示例

本文整理匯總了Java中io.vertx.core.http.HttpClientOptions.setDefaultPort方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpClientOptions.setDefaultPort方法的具體用法?Java HttpClientOptions.setDefaultPort怎麽用?Java HttpClientOptions.setDefaultPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.vertx.core.http.HttpClientOptions的用法示例。


在下文中一共展示了HttpClientOptions.setDefaultPort方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test404Response

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@Test
public void test404Response() throws Exception {
	HttpClientOptions options = new HttpClientOptions();
	options.setDefaultHost("localhost");
	options.setDefaultPort(port());

	HttpClient client = Mesh.vertx().createHttpClient(options);
	CompletableFuture<String> future = new CompletableFuture<>();
	HttpClientRequest request = client.request(HttpMethod.POST, "/api/v1/test", rh -> {
		rh.bodyHandler(bh -> {
			future.complete(bh.toString());
		});
	});
	request.end();

	String response = future.get(1, TimeUnit.SECONDS);
	assertTrue("The response string should not contain any html specific characters but it was {" + response + "} ",
			response.indexOf("<") != 0);
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:20,代碼來源:MeshRestAPITest.java

示例2: exceptionInErrorHandler

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@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);
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:26,代碼來源:RESTServiceExceptionFallbackTest.java

示例3: asyncStringResponse

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@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",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    Assert.assertEquals(body.toString(), "test");
                  });
              testComplete();
            }
          });
  request.end();
  await();
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:24,代碼來源:RESTServiceSelfhostedAsyncTestStaticInitializer.java

示例4: basicTestAndThenWithErrorUnhandled

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@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) {
              Assert.assertEquals(resp.statusCode(), 500);
              Assert.assertEquals(resp.statusMessage(), "test error");
              testComplete();
            }
          });
  request.end();
  await();
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:22,代碼來源:RESTServiceBlockingChainByteTest.java

示例5: basicTestAndThenWithErrorUnhandledRetry

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@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());
                    Assert.assertEquals(body.toString(), "error 4 test error");
                    testComplete();
                  });
            }
          });
  request.end();
  await();
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:25,代碼來源:RESTServiceBlockingChainStringTest.java

示例6: basicTestSupplyWithErrorUnhandled

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@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) {
              Assert.assertEquals(resp.statusCode(), 500);
              Assert.assertEquals(resp.statusMessage(), "test error");
              testComplete();
            }
          });
  request.end();
  await();
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:22,代碼來源:RESTServiceChainObjectTest.java

示例7: endpointOne

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@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());
                    Assert.assertEquals(body.toString(), "1test final");
                    testComplete();
                  });
            }
          });
  request.end();
  await();
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:25,代碼來源:RESTServiceChainObjectTest.java

示例8: endpointFive

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@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",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse 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();
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:25,代碼來源:RESTServiceSelfhostedTestStaticInitializer.java

示例9: exceptionInStringResponseWithErrorHandler

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@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);
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:26,代碼來源:RESTServiceExceptionTest.java

示例10: catchedAsyncStringErrorDelay

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@Test
public void catchedAsyncStringErrorDelay() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/catchedAsyncStringErrorDelay?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("--------catchedAsyncStringErrorDelay: " + val);
                    // assertEquals(key, "val");
                    testComplete();
                  });
            }
          });
  request.end();

  await(5000, TimeUnit.MILLISECONDS);
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:26,代碼來源:RESTServiceExceptionTest.java

示例11: asyncStringResponseParameter

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@Test
public void asyncStringResponseParameter() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/asyncStringResponseParameter/123",
          new Handler<HttpClientResponse>() {
            public void handle(HttpClientResponse resp) {
              resp.bodyHandler(
                  body -> {
                    System.out.println("Got a createResponse: " + body.toString());
                    Assert.assertEquals(body.toString(), "123");
                  });
              testComplete();
            }
          });
  request.end();
  await();
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:24,代碼來源:RESTServiceSelfhostedAsyncTestStaticInitializer.java

示例12: catchedAsyncObjectErrorDelay

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@Test
public void catchedAsyncObjectErrorDelay() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/catchedAsyncObjectErrorDelay?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(10000, TimeUnit.MILLISECONDS);
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:26,代碼來源:RESTServiceExceptionTest.java

示例13: simpleOnFailureResponse

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@Test
public void simpleOnFailureResponse() throws InterruptedException {
  HttpClientOptions options = new HttpClientOptions();
  options.setDefaultPort(PORT);
  options.setDefaultHost(HOST);
  HttpClient client = vertx.createHttpClient(options);

  HttpClientRequest request =
      client.get(
          "/wsService/simpleOnFailureResponse",
          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);
}
 
開發者ID:amoAHCP,項目名稱:vxms,代碼行數:23,代碼來源:RESTServiceOnFailureStringResponseTest.java

示例14: testStockTradesAudited

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
@Test
public void testStockTradesAudited(TestContext context) {
    Async async = context.async();
    HttpClientOptions options = new HttpClientOptions().setDefaultHost(config.getString("http.host"));
    options.setDefaultPort(config.getInt("http.port"));
    HttpClient client = vertx.createHttpClient(options);
    client.get("/", response -> {
        context.assertEquals(response.statusCode(), 200);
        response.bodyHandler(buffer -> {
            JsonArray body = buffer.toJsonArray();
            context.assertTrue(body.size() >= 3);
            async.complete();
        });
    }).end();
}
 
開發者ID:docker-production-aws,項目名稱:microtrader,代碼行數:16,代碼來源:AuditVerticleTest.java

示例15: SpringConfigServerStore

import io.vertx.core.http.HttpClientOptions; //導入方法依賴的package包/類
SpringConfigServerStore(Vertx vertx, JsonObject configuration) {
  String url = configuration.getString("url");
  this.timeout = configuration.getLong("timeout", 3000L);
  Objects.requireNonNull(url);

  HttpClientOptions options = new HttpClientOptions();
  try {
    URL u = new URL(url);
    options.setDefaultHost(u.getHost());
    if (u.getPort() == -1) {
      options.setDefaultPort(u.getDefaultPort());
    } else {
      options.setDefaultPort(u.getPort());
    }

    if (u.getPath() != null) {
      path = u.getPath();
    } else {
      path = "/";
    }

  } catch (MalformedURLException e) {
    throw new IllegalArgumentException("Invalid url for the spring server: " + url);
  }


  if (configuration.getString("user") != null && configuration.getString("password") != null) {
    authHeaderValue = "Basic " + Base64.getEncoder().encodeToString((configuration.getString("user")
        + ":" + configuration.getString("password")).getBytes());
  } else {
    authHeaderValue = null;
  }

  client = vertx.createHttpClient(options);

}
 
開發者ID:cescoffier,項目名稱:vertx-configuration-service,代碼行數:37,代碼來源:SpringConfigServerStore.java


注:本文中的io.vertx.core.http.HttpClientOptions.setDefaultPort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。