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


Java ResteasyClientBuilder類代碼示例

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


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

示例1: testAddSkill

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
@Test
public void testAddSkill(@ArquillianResource URL baseUrl) throws IOException {
    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target = client.target(baseUrl.toExternalForm() + "rest");
    SkillRestService skillRestService = target.proxy(SkillRestService.class);
    int tenantId = generateDatabase(baseUrl);
    
    skillRestService.addSkill(tenantId, new Skill(tenantId, "D"));
    
    List<Skill> skills = skillRestService.getSkillList(tenantId);
    
    assertEquals("List size don't match", SKILLS.length + 1, skills.size());
    
    for (String name : SKILLS) {
        assertContainsSkill(skills, tenantId, name);
    }
    assertContainsSkill(skills, tenantId, "D");
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:19,代碼來源:SkillRestServiceTest.java

示例2: RedfishWebClient

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
public RedfishWebClient()
{
    ResteasyJackson2Provider jackson2Provider = new ResteasyJackson2Provider();

    ObjectMapper mapper = new ObjectMapper()
        .enable( DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL )
        .enable( DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES )
        .disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );

    jackson2Provider.setMapper( mapper );

    this.client = ( (ResteasyClientBuilder) ResteasyClientBuilder.newBuilder() )
        .register( jackson2Provider )
        .disableTrustManager()
        .build();
}
 
開發者ID:vmware,項目名稱:OHMS,代碼行數:17,代碼來源:RedfishWebClient.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));

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

示例4: testEngineWithInjectedClientPost

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
@Test
public void testEngineWithInjectedClientPost() {

    final HttpClient httpClient = Vertx.vertx().createHttpClient(httpClientOptions);
    final Client client = new ResteasyClientBuilder().httpEngine(new VertxClientEngine(httpClient))
        .register(GsonMessageBodyHandler.class).build();
    final Form xform = new Form();
    xform.param("userName", "ca1\\\\meowmix");
    xform.param("password", "mingnamulan");
    xform.param("state", "authenticate");
    xform.param("style", "xml");
    xform.param("xsl", "none");

    final JsonObject arsString = client.target("https://httpbin.org/post").request()
        .post(Entity.form(xform), JsonObject.class);
    assertEquals("xml", arsString.getAsJsonObject("form").get("style").getAsString());
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:18,代碼來源:SpringJaxrsHandlerTest.java

示例5: testEngineWithInjectedClientPost2

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
@Test
public void testEngineWithInjectedClientPost2() {

    final ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.start();
    final ResteasyProviderFactory providerFactory = deployment.getProviderFactory();
    final HttpClient httpClient = Vertx.vertx().createHttpClient(httpClientOptions);
    final Client client = new ResteasyClientBuilder()
        .providerFactory(providerFactory)
        .httpEngine(new VertxClientEngine(httpClient))
        .register(GsonMessageBodyHandler.class)
        .build();
    final Form xform = new Form();
    xform.param("userName", "ca1\\\\meowmix");
    xform.param("password", "mingnamulan");
    xform.param("state", "authenticate");
    xform.param("style", "xml");
    xform.param("xsl", "none");

    final Response response = client.target("https://httpbin.org/post").request(MediaType.APPLICATION_JSON)
        .post(Entity.form(xform), Response.class);
    assertFalse(response.getStringHeaders().isEmpty());
    System.out.println(response.getStringHeaders());
    assertFalse(response.getHeaders().isEmpty());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType());
    assertTrue(response.hasEntity());
    final JsonObject arsString = response.readEntity(JsonObject.class);
    assertEquals("xml", arsString.getAsJsonObject("form").get("style").getAsString());
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:30,代碼來源:SpringJaxrsHandlerTest.java

示例6: getAccessToken

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
/**
 * get access token form realm
 * 
 * @param userName
 *            the user login
 * @param password
 *            the user password
 * @return json OpenID token
 */
public AccessToken getAccessToken(String userName, String password) {

    ResteasyClient client = new ResteasyClientBuilder().register(AccessTokenProvider.class).build();

    //queryParameters.add("grant_type", "id_token");
    queryParameters.add("grant_type","password");
    queryParameters.add("username", userName);
    queryParameters.add("password", password);
    queryParameters.add("client_id", clientID);
    //queryParameters.add("secret", "7812f8e6-3d9d-4013-a253-9cbbe0b4fb54");

    Response response = client.target(this.url).request()
            .accept(MediaType.APPLICATION_JSON).post(Entity.entity(queryParameters, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
    LOG.debug("get accesstoken response status: " + response.getStatus());
    
    AccessToken accessToken = response.readEntity(AccessToken.class);
    response.close();

    return accessToken;
}
 
開發者ID:nmajorov,項目名稱:keycloak_training,代碼行數:30,代碼來源:OpenIDClient.java

示例7: testGetSkill

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
@Test
public void testGetSkill(@ArquillianResource URL baseUrl) throws IOException {
    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target = client.target(baseUrl.toExternalForm() + "rest");
    SkillRestService skillRestService = target.proxy(SkillRestService.class);
    int tenantId = generateDatabase(baseUrl);
    
    List<Skill> skills = skillRestService.getSkillList(tenantId);
    
    Skill skill1 = getSkill(skills, "A").get();
    Skill skill2 = skillRestService.getSkill(tenantId, skill1.getId());
    
    assertNotNull("REST method did not return a result", skill2);
    assertEquals(skill1.getId(), skill2.getId());
    assertEquals(skill1.getName(), skill2.getName());
    assertEquals(skill1.getTenantId(), skill2.getTenantId());
    
    assertEquals("List size don't match", SKILLS.length, skills.size());
    
    for (String name : SKILLS) {
        assertContainsSkill(skills, tenantId, name);
    }
}
 
開發者ID:kiegroup,項目名稱:optashift-employee-rostering,代碼行數:24,代碼來源:SkillRestServiceTest.java

示例8: sendInquiry

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
public String sendInquiry(RentalOrder entityOrder, String processInstanceID) {
	// parse RentalOrder object to Order object (which represents the agreed upon JSON format)
	System.out.println("PARSING SENDING OBJECT");
	User user = parseUser(entityOrder);
	Collection<org.camunda.bpm.bvis.rest.send.dto.Car> cars = parseCars(entityOrder);
	org.camunda.bpm.bvis.rest.send.dto.Insurance insurance = parseInsurance(entityOrder);
	Order order = parseOrder(cars, insurance, user, entityOrder);
	ContractDetailsDTO contractDetails = new ContractDetailsDTO();
	contractDetails.setOrder(order);
	contractDetails.setProcessinstance_id_bvis(processInstanceID);
	System.out.println("SENDING OBJECT SUCCESSFULLY PARSED");

	System.out.println("SENDING PARSED OBJECT ORDER ID: " + contractDetails.getOrder().getOrder_id());
	RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
	ResteasyWebTarget target = new ResteasyClientBuilder().build().target(BASE_URI);
	SendInquiryClient senderClient = target.proxy(SendInquiryClient.class);
	String result = senderClient.sendInquiry(contractDetails);
	return result;
}
 
開發者ID:derursm,項目名稱:bvis,代碼行數:20,代碼來源:SendInquiry.java

示例9: main

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    // Client client = ClientBuilder.newClient();
    // Client client = ClientBuilder.newBuilder().build();
    // WebTarget target = client.target("http://localhost:8082/rest/hello/v1/echo?name=netboy");
    // Response response = target.request().get();
    // String value = response.readEntity(String.class);
    // response.close();

    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target = client.target("http://localhost:8082/rest/hello/v1/echo?name=netboy");
    Response response = target.request().get();
    String value = response.readEntity(String.class);
    System.out.println(value);
    response.close();

}
 
開發者ID:netboynb,項目名稱:coco,代碼行數:17,代碼來源:RestClientDemo.java

示例10: testSinglePOST

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
@Test
public void testSinglePOST() {
	ResteasyClient client = new ResteasyClientBuilder().build();
	ResteasyWebTarget target = client.target(buildUrl("hello/login"));
	UserLogin userLogin = new UserLogin("003","xyz");
	Response response = target.request().post(Entity.entity(userLogin,MediaType.APPLICATION_JSON));
	String userToken = response.readEntity(String.class);
	System.out.println(userToken);
	response.close();
	
	Article article = new Article(2,"NAME");
	
	ResteasyClient client2 = new ResteasyClientBuilder().build();
	ResteasyWebTarget target2 = client2.target(buildUrl("hello/singlesave"));
	Response response2 = target2.request().header("UserToken",userToken).post(Entity.entity(article,MediaType.APPLICATION_JSON));
	Article rtv = response2.readEntity(Article.class);
	response2.close();
	assertNotNull(rtv);
	assertTrue(rtv.getId().equals(2));
	assertTrue(rtv.getName().equals("NAME"));
}
 
開發者ID:tangaiyun,項目名稱:Netty-Resteasy-Spring,代碼行數:22,代碼來源:testHomeController.java

示例11: testPOSTbyList

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
@Test
public void testPOSTbyList() {
	
	ResteasyClient client = new ResteasyClientBuilder().build();
	ResteasyWebTarget target = client.target(buildUrl("hello/login"));
	UserLogin userLogin = new UserLogin("002","abc");
	Response response = target.request().post(Entity.entity(userLogin,MediaType.APPLICATION_JSON));
	String userToken = response.readEntity(String.class);
	System.out.println(userToken);
	response.close();
	
	Article article = new Article(2,"NAME");
	
	ResteasyClient client2 = new ResteasyClientBuilder().build();
	ResteasyWebTarget target2 = client2.target(buildUrl("hello/multisave?multi=true"));
	Response response2 = target2.request().header("UserToken",userToken).post(Entity.entity(Collections.singletonList(article),MediaType.APPLICATION_JSON));
	GenericType<List<Article>> ArticleListType = new GenericType<List<Article>>() {};

	List<Article> list = response2.readEntity(ArticleListType);
	assertEquals(1, list.size());
	response2.close();
}
 
開發者ID:tangaiyun,項目名稱:Netty-Resteasy-Spring,代碼行數:23,代碼來源:testHomeController.java

示例12: testPOSTbyList2

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
@Test
public void testPOSTbyList2() {
	ResteasyClient client = new ResteasyClientBuilder().build();
	ResteasyWebTarget target = client.target(buildUrl("hello/login"));
	UserLogin userLogin = new UserLogin("002","abc");
	Response response = target.request().post(Entity.entity(userLogin,MediaType.APPLICATION_JSON));
	String userToken = response.readEntity(String.class);
	System.out.println(userToken);
	response.close();
	
	List<Article> list = new ArrayList<Article>();
	list.add(new Article(1,"book1"));
	list.add(new Article(2,"book2"));
	
	
	ResteasyClient client2 = new ResteasyClientBuilder().build();
	ResteasyWebTarget target2 = client2.target(buildUrl("hello/multisave?multi=true"));
	Response response2 = target2.request().header("UserToken",userToken).post(Entity.entity(list,MediaType.APPLICATION_JSON));
	GenericType<List<Article>> ArticleListType = new GenericType<List<Article>>() {};

	List<Article> list2 = response2.readEntity(ArticleListType);
	assertEquals(2, list2.size());
	response2.close();
}
 
開發者ID:tangaiyun,項目名稱:Netty-Resteasy-Spring,代碼行數:25,代碼來源:testHomeController.java

示例13: testSinglePOST

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
@Test
public void testSinglePOST() throws JsonProcessingException {
	ResteasyClient client = new ResteasyClientBuilder().build();
	ResteasyWebTarget target = client.target(buildUrl("hello/loginecho"));
	String userName = "abc";
	String password = "efg";
	UserLogin userLogin = new UserLogin(userName,password);
	String accessRandomStr = RandomStringUtils.randomAlphanumeric(8);
	Long time = System.currentTimeMillis();
	ObjectMapper mapper = new ObjectMapper();  
       
       // Convert object to JSON string  
       String Json =  mapper.writeValueAsString(userLogin);
	String signature = Coder.genSignature(Json);
	
	Response response = target.request().header("ACCESS_RANDOM_STR", accessRandomStr).header("ACCESS_TIME", time).header("ACCESS_SIGNATURE",signature).post(Entity.entity(userLogin,MediaType.APPLICATION_JSON));
	GenericType<SafeResponse<UserLogin>> SafeResponseType = new GenericType<SafeResponse<UserLogin>>() {};
	SafeResponse<UserLogin> sr = response.readEntity(SafeResponseType);
	System.out.println(sr.getContent());
	System.out.println(sr.getSignature());
	String returnJson = mapper.writeValueAsString(sr.getContent());
	String returnSinature = Coder.genSignature(returnJson);
	assertTrue(sr.getSignature().equals(returnSinature));
	response.close();
}
 
開發者ID:tangaiyun,項目名稱:Netty-Resteasy-Spring,代碼行數:26,代碼來源:TestAntiDefacement.java

示例14: start

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
@Override
public void start(StartContext startContext) throws StartException {

    Consul.Builder builder = Consul.builder();


    // pool because of multiple threads.
    ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();
    clientBuilder = clientBuilder.connectionPoolSize(20);

    builder.withClientBuilder(clientBuilder);
    builder.withUrl(this.url);

    try {
        this.consul = builder.build();
    } catch (Exception e) {
        throw new StartException("Failed to connect consul at " + url, e);
    }
}
 
開發者ID:wildfly-swarm-archive,項目名稱:wildfly-swarm-topology-consul,代碼行數:20,代碼來源:ConsulService.java

示例15: DawPurchasesClient

import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; //導入依賴的package包/類
public DawPurchasesClient(boolean useHttps, String hostname, int port) {
    checkNotNull(hostname, "hostname");
    checkArgument(port > 0, "Invalid port %s", port);
    String apiHostUrl = String.format("%s://%s:%d", useHttps ? "https" : "http", hostname, port);

    ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();
    clientBuilder.establishConnectionTimeout(GLOBAL_TIMEOUT, TimeUnit.MILLISECONDS);
    clientBuilder.socketTimeout(GLOBAL_TIMEOUT, TimeUnit.MILLISECONDS);
    clientBuilder.maxPooledPerRoute(GLOBAL_MAX_CONNS);
    clientBuilder.connectionPoolSize(GLOBAL_MAX_CONNS);
    clientBuilder.connectionTTL(CONNECTION_TTL, TimeUnit.MILLISECONDS);
    clientBuilder.connectionCheckoutTimeout(GET_CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);

    jaxRsClient = clientBuilder.build();
    ResteasyWebTarget target = jaxRsClient.target(apiHostUrl);

    // TODO: potential improvements here:
    //   - Avoid "useHttps" boolean parameter - enum instead

    apiClientProxy = target.proxy(ApiSpec.class);
}
 
開發者ID:MiguelGL,項目名稱:popular-purchases-demo,代碼行數:22,代碼來源:DawPurchasesClient.java


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