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


Java ResteasyClient.target方法代碼示例

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


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

示例1: testAddSkill

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的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: testGetSkill

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的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

示例3: main

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的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

示例4: testSinglePOST

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的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

示例5: testPOSTbyList

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的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

示例6: testPOSTbyList2

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的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

示例7: testSinglePOST

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的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

示例8: getProducts

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的package包/類
public static List<String> getProducts()
{
   ResteasyClient client = new ResteasyClientBuilder()
              .disableTrustManager() // shouldn't really do this, but I'm being lazy
              .build();

   Form form = new Form().param("grant_type", "client_credentials");
   ResteasyWebTarget target = client.target("https://localhost:8443/auth-server/j_oauth_token_grant");
   // this is resteasy specific, check spec to make sure it hasn't added a way to do basic auth
   target.register(new BasicAuthentication("[email protected]", "password"));
   AccessTokenResponse res = target
           .request()
           .post(Entity.form(form), AccessTokenResponse.class);
   try
   {
      Response response = client.target("https://localhost:8443/database/products").request()
              .header(HttpHeaders.AUTHORIZATION, "Bearer " + res.getToken()).get();
      return response.readEntity(new GenericType<List<String>>(){});
   }
   finally
   {
      client.close();
   }
}
 
開發者ID:resteasy,項目名稱:resteasy-examples,代碼行數:25,代碼來源:ProductDatabaseClient.java

示例9: findByIdTest

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的package包/類
/**
 * Find by id test.
 *
 * @throws Exception the exception
 */
@Test
@InSequence(4)
@RunAsClient
public void findByIdTest() throws Exception {
  try {
    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target =
        client.target(deploymentUrl.toString() + RESOURCE_PREFIX + "/courses/1");
    Response response = target.request().get();

    Assert.assertEquals(200, response.getStatus());
    System.out.println("GET /courses/1\n" + response.readEntity(String.class));
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:yntelectual,項目名稱:nlighten,代碼行數:22,代碼來源:CourseEndpointTest.java

示例10: deleteTest

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的package包/類
/**
 * Delete test.
 *
 * @throws Exception the exception
 */
@Test
@InSequence(5)
@RunAsClient
public void deleteTest() throws Exception {
  try {
    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target =
        client.target(deploymentUrl.toString() + RESOURCE_PREFIX + "/questions/1");
    Response response = target.request().delete();

    Assert.assertEquals(200, response.getStatus());
    System.out.println("DELETE /questions/1\n" + response.readEntity(String.class));
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:yntelectual,項目名稱:nlighten,代碼行數:22,代碼來源:QuestionEndpointTest.java

示例11: createTest

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的package包/類
/**
 * Creates the test.
 *
 * @throws Exception the exception
 */
@Test
@InSequence(1)
@RunAsClient
public void createTest() throws Exception {
  try {
    Lesson lesson = new Lesson();
    lesson.setTitle("title_test");
    lesson.setDescription("description_test");
    lesson.setOrder(1);

    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target =
        client.target(deploymentUrl.toString() + RESOURCE_PREFIX + "/lessons");
    Response response = target.request().post(Entity.entity(lesson, MediaType.APPLICATION_JSON));

    Assert.assertEquals(200, response.getStatus());
    System.out.println("POST /lessons\n" + response.readEntity(String.class));
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:yntelectual,項目名稱:nlighten,代碼行數:27,代碼來源:LessonEndpointTest.java

示例12: findByIdTest

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的package包/類
/**
 * Find by id test.
 *
 * @throws Exception the exception
 */
@Test
@InSequence(4)
@RunAsClient
public void findByIdTest() throws Exception {
  try {
    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target =
        client.target(deploymentUrl.toString() + RESOURCE_PREFIX + "/comments/1");
    Response response = target.request().get();

    Assert.assertEquals(200, response.getStatus());
    System.out.println("GET /comments/1\n" + response.readEntity(String.class));
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:yntelectual,項目名稱:nlighten,代碼行數:22,代碼來源:CommentEndpointTest.java

示例13: createTest

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的package包/類
/**
 * Creates the test.
 *
 * @throws Exception the exception
 */
@Test
@InSequence(1)
@RunAsClient
public void createTest() throws Exception {
  try {
    Question question = new Question();
    question.setAuthor("author_test");
    question.setText("text_test");

    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target =
        client.target(deploymentUrl.toString() + RESOURCE_PREFIX + "/questions");
    Response response =
        target.request().post(Entity.entity(question, MediaType.APPLICATION_JSON));

    Assert.assertEquals(200, response.getStatus());
    System.out.println("POST /questions\n" + response.readEntity(String.class));
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:yntelectual,項目名稱:nlighten,代碼行數:27,代碼來源:QuestionEndpointTest.java

示例14: findAllTest

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的package包/類
/**
 * Find all test.
 *
 * @throws Exception the exception
 */
@Test
@InSequence(3)
@RunAsClient
public void findAllTest() throws Exception {
  try {
    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target =
        client.target(deploymentUrl.toString() + RESOURCE_PREFIX + "/lessons");
    Response response = target.request().get();

    Assert.assertEquals(200, response.getStatus());
    System.out.println("GET /lessons\n" + response.readEntity(String.class));
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:yntelectual,項目名稱:nlighten,代碼行數:22,代碼來源:LessonEndpointTest.java

示例15: deleteTest

import org.jboss.resteasy.client.jaxrs.ResteasyClient; //導入方法依賴的package包/類
/**
 * Delete test.
 *
 * @throws Exception the exception
 */
@Test
@InSequence(5)
@RunAsClient
public void deleteTest() throws Exception {
  try {
    ResteasyClient client = new ResteasyClientBuilder().build();
    ResteasyWebTarget target =
        client.target(deploymentUrl.toString() + RESOURCE_PREFIX + "/answers/1");
    Response response = target.request().delete();

    Assert.assertEquals(200, response.getStatus());
    System.out.println("DELETE /answers/1\n" + response.readEntity(String.class));
  } catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:yntelectual,項目名稱:nlighten,代碼行數:22,代碼來源:AnswerEndpointTest.java


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