本文整理匯總了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));
}
示例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);
}
示例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());
}