The integration test for the preceding method is very simple. Take a look at the following test method:
@Test public void welcomeWithParameter() throws Exception { ResponseEntity<String> response = template.getForEntity( createURL("/welcome-with-parameter/name/Buddy"), String.class); assertThat(response.getBody(), containsString("Hello World, Buddy")); }
A few important things to note are as follows:
- createURL("/welcome-with-parameter/name/Buddy"): This matches against the variable template in the URI. We are passing in the name, Buddy.
- assertThat(response.getBody(), containsString("Hello World, Buddy”)): We expect the response to contain the message with the name.
In this section, we looked at the basics of creating ...