zrlw commented on issue #15520:
URL: https://github.com/apache/dubbo/issues/15520#issuecomment-3026122546

   Investigation Examples refer to 
https://github.com/apache/dubbo-samples/tree/master/2-advanced/dubbo-samples-triple-rest/dubbo-samples-triple-rest-basic
   1. adjust testing server
   ```
   @DubboService
   public class DemoServiceImpl implements DemoService {
   
       private static final StringBuffer finalString = new StringBuffer();
   
       static {
           IntStream.range(0, 20000).forEach(i -> 
finalString.append(i).append("Hello"));
       }
   
       @Override
       public String hello(String name) {
           return finalString + "Hello " + name;
       }
   
       @Override
       public String hello(User user, int count) {
           return finalString + "Hello " + user.getTitle() + ". " + 
user.getName() + ", " + count;
       }
   
       @Override
       public String helloUser(User user) {
           return finalString + "Hello " + user.getTitle() + ". " + 
user.getName();
       }
   }
   ```
   2. adjust test cases
   ```
   @EnableDubbo
   @RunWith(SpringRunner.class)
   public class ConsumerIT {
   
       private static final String HOST = System.getProperty("dubbo.address", 
"localhost");
   
       private static final StringBuffer finalString = new StringBuffer();
   
       static {
           IntStream.range(0, 20000).forEach(i -> 
finalString.append(i).append("Hello"));
       }
   
       private final RestClient restClient = RestClient.create();
   
       @DubboReference(url = "tri://${dubbo.address:localhost}:50052")
       private DemoService demoService;
   
       private static String toUri(String path) {
           return "http://"; + HOST + 
":50052/org.apache.dubbo.rest.demo.DemoService" + path;
       }
   
       @Test
       public void helloWithRpc() {
           String result = demoService.hello("world");
           Assert.assertEquals(finalString + "Hello world", result);
       }
   
       @Test
       public void helloWithRest() {
           String result = 
restClient.get().uri(toUri("/hello?name=world")).retrieve().body(String.class);
           Assert.assertEquals(finalString + "\"Hello world\"", result);
       }
   
       @Test
       public void helloWithRestAdvance() {
           MultiValueMap<String, String> data = new LinkedMultiValueMap<>();
           data.add("name", "Yang");
   
           String result = restClient.post()
                   .uri(toUri("/hi.txt?title=Mr"))
                   .body(data)
                   .header("c", "3")
                   .retrieve()
                   .body(String.class);
           Assert.assertEquals(finalString + "Hello Mr. Yang, 3", result);
       }
   
       @Test
       public void helloWithBody() {
           User user = new User();
           user.setTitle("Mr");
           user.setName("Yang");
   
           String result = restClient.post()
                   .uri(toUri("/helloUser"))
                   .contentType(MediaType.APPLICATION_JSON)
                   .body(user)
                   .retrieve()
                   .body(String.class);
           Assert.assertEquals(finalString + "\"Hello Mr. Yang\"", result);
       }
   }
   ```
   3. start BasicRestApplication
   4. run test cases of ConsumerIT


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to