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


Java ResteasyClientBuilder.newClient方法代碼示例

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


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

示例1: testGsonConfig

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
@Test
public void testGsonConfig() {

	Client client = ResteasyClientBuilder.newClient(); // Avoid conflict with Jersey in classpath
	// ClientBuilder.newClient()

	String pong = client.target(TestPortProvider.generateURL("/test/ping")).request().get(String.class);
	assertEquals("pong", pong);

	PropertyBox box = SET.execute(() -> client.target(TestPortProvider.generateURL("/test/data/{num}"))
			.resolveTemplate("num", 1).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(1), box.getValue(NUM));
	assertEquals("Str_1", box.getValue(STR));

	box = SET.execute(
			() -> client.target(TestPortProvider.generateURL("/test/data/2")).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(2), box.getValue(NUM));
	assertEquals("Str_2", box.getValue(STR));

}
 
開發者ID:holon-platform,項目名稱:holon-json,代碼行數:24,代碼來源:TestResteasyServicesIntegration.java

示例2: testSpanLogging

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入方法依賴的package包/類
@Test
public void testSpanLogging() throws Exception {
    ResteasyClient client = (ResteasyClient) ResteasyClientBuilder.newClient();
    client.register(ClientRequestInterceptor.class);
    client.register(ClientResponseInterceptor.class);

    Response response = client.target("http://localhost:8080").request(MediaType.TEXT_PLAIN).get();
    Assert.assertEquals(200, response.getStatus());

    // check log file for span reporting & the specified service name
    // the default zipkin fraction logs to system out

    List<String> logContent = Files.readAllLines(Paths.get(LOG_FILE));
    boolean spanPresent = logContent.stream().anyMatch(line -> line.contains(SPAN_COLLECTOR));
    Assert.assertTrue("Span logging missing from log file", spanPresent);

    boolean serviceNamePresent = logContent.stream().anyMatch(line -> line.contains(SERVICE_NAME));
    Assert.assertTrue("Service name " + SERVICE_NAME + " missing from log file", serviceNamePresent);
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:20,代碼來源:ZipkinJAXRSTest.java

示例3: testGsonConfig

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
@Test
public void testGsonConfig() {

	Client client = ResteasyClientBuilder.newClient(); // Avoid conflict with Jersey in classpath
	// ClientBuilder.newClient();

	String pong = client.target(TestPortProvider.generateURL("/test/ping")).request().get(String.class);
	assertEquals("pong", pong);

	PropertyBox box = SET.execute(() -> client.target(TestPortProvider.generateURL("/test/data/{num}"))
			.resolveTemplate("num", 1).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(1), box.getValue(NUM));
	assertEquals("Str_1", box.getValue(STR));

	box = SET.execute(
			() -> client.target(TestPortProvider.generateURL("/test/data/2")).request().get(PropertyBox.class));
	assertNotNull(box);
	assertEquals(Integer.valueOf(2), box.getValue(NUM));
	assertEquals("Str_2", box.getValue(STR));

	PropertyBox boxToSrlz = PropertyBox.builder(SET).set(NUM, 100).set(DBL, 77.7).build();

	Response response = client.target(TestPortProvider.generateURL("/test/srlz")).request()
			.put(Entity.entity(boxToSrlz, MediaType.APPLICATION_JSON));
	assertNotNull(response);
	assertEquals(Status.ACCEPTED.getStatusCode(), response.getStatus());

}
 
開發者ID:holon-platform,項目名稱:holon-json,代碼行數:31,代碼來源:TestResteasyServicesIntegration.java


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