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


Java Greet類代碼示例

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


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

示例1: testOAuthService

import org.rvslab.chapter2.Greet; //導入依賴的package包/類
@Test
public void testOAuthService() {	
       ResourceOwnerPasswordResourceDetails resource = new ResourceOwnerPasswordResourceDetails();
       resource.setUsername("guest");
       resource.setPassword("guest123");
       resource.setAccessTokenUri("http://localhost:8080/oauth/token");
       resource.setClientId("trustedclient");
       resource.setClientSecret("trustedclient123");
       resource.setGrantType("password");
 
       DefaultOAuth2ClientContext clientContext = new DefaultOAuth2ClientContext();
       OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(resource, clientContext);

       Greet greet = restTemplate.getForObject("http://localhost:8080", Greet.class);

       Assert.assertEquals("Hello World!", greet.getMessage());
}
 
開發者ID:PacktPublishing,項目名稱:Microservices-Building-Scalable-Software,代碼行數:18,代碼來源:ApplicationTests.java

示例2: testSecureService

import org.rvslab.chapter2.Greet; //導入依賴的package包/類
@Test
public void testSecureService() {	
	String plainCreds = "guest:guest123";
	HttpHeaders headers = new HttpHeaders();
	headers.add("Authorization", "Basic " + new String(Base64.encode(plainCreds.getBytes())));
	HttpEntity<String> request = new HttpEntity<String>(headers);
	RestTemplate restTemplate = new RestTemplate();
	
	ResponseEntity<Greet> response = restTemplate.exchange("http://localhost:8080", HttpMethod.GET, request, Greet.class);
	Assert.assertEquals("Hello World!", response.getBody().getMessage());
}
 
開發者ID:rajeshrv,項目名稱:SpringMicroservice,代碼行數:12,代碼來源:ApplicationTests.java

示例3: testVanillaService

import org.rvslab.chapter2.Greet; //導入依賴的package包/類
@Test
public void testVanillaService() {
	RestTemplate restTemplate = new RestTemplate();
    Greet greet = restTemplate.getForObject("http://localhost:8080", Greet.class);
    Assert.assertEquals("Hello World!", greet.getMessage());
}
 
開發者ID:rajeshrv,項目名稱:SpringMicroservice,代碼行數:7,代碼來源:ApplicationTests.java


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