Skip to content

Commit

Permalink
update spring-boot 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
qihaiyan committed Nov 24, 2023
1 parent 9a7539b commit 5fa6c92
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
set('springBootVersion', "3.1.2")
set('springBootVersion', "3.2.0")
}
repositories {
maven { url "https://plugins.gradle.org/m2/" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

Expand All @@ -18,14 +17,14 @@ public class DemoController {
private RestTemplate restTemplate;

@GetMapping("/demo/get")
public Object demoGet(String arg) {
return restTemplate.postForObject("http://someservice/foo", new BodyRequest("test"), BodyRequest.class);
public BodyRequest demoGet(@RequestParam(value = "arg") String arg) {
return restTemplate.postForObject("http://someservice/foo", new BodyRequest(arg), BodyRequest.class);
}

@Data
@AllArgsConstructor
@NoArgsConstructor
static class BodyRequest {
private String arg1;
public static class BodyRequest {
private String code;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ public HttpStatusCode getStatusCode() throws IOException {
return this.response.getStatusCode();
}

@NonNull
public int getRawStatusCode() throws IOException {
return this.response.getStatusCode().value();
}

@NonNull
public String getStatusText() throws IOException {
return this.response.getStatusText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,13 @@ public void before() {
mockRestServiceServer = MockRestServiceServer.bindTo(restTemplate).ignoreExpectOrder(true).build();

this.mockRestServiceServer.expect(manyTimes(), MockRestRequestMatchers.requestTo(Matchers.startsWithIgnoringCase("http://someservice/foo")))
.andRespond(withSuccess("{\"code\": 200}", MediaType.APPLICATION_JSON));
.andRespond(withSuccess("{\"code\": \"200\"}", MediaType.APPLICATION_JSON));

}

@Test
public void testGet() {
String resp = testRestTemplate.getForObject("/demo/get?arg=test", String.class);
log.info("rest: {}", resp);
// .andDo(print()).andExpect(status().isOk());
// this.mockMvc.perform(post("/demo/post/form")
// .content(new ObjectMapper().writeValueAsString(new DemoController.BodyRequest("test")))
// .contentType(MediaType.APPLICATION_FORM_URLENCODED))
// .andDo(print()).andExpect(status().isOk());
// this.mockMvc.perform(post("/demo/post/body")
// .content(new ObjectMapper().writeValueAsString(new DemoController.BodyRequest("test")))
// .contentType(MediaType.APPLICATION_JSON))
// .andDo(print()).andExpect(status().isOk());
}
}

0 comments on commit 5fa6c92

Please sign in to comment.