Skip to content

Instantly share code, notes, and snippets.

@jwalgemoed
Last active December 28, 2017 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwalgemoed/1cb523fea9cb91d245ede6565f3f8cb2 to your computer and use it in GitHub Desktop.
Save jwalgemoed/1cb523fea9cb91d245ede6565f3f8cb2 to your computer and use it in GitHub Desktop.
@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class DslDemoApplicationTests {
@Autowired
private lateinit var testRestTemplate: TestRestTemplate
@Test
fun `Test 'Hello' endpoint using a valid name`() {
val headers = HttpHeaders()
headers.put("Accept", listOf("application/json"))
val entity = HttpEntity<Any>(headers)
val response = testRestTemplate.exchange(
"/api/hello/Jarno", HttpMethod.GET, entity, String::class.java)
assertEquals(HttpStatus.OK, response.statusCode)
assertJsonEquals("{ \"message\": \"Hi, Jarno!\" }", response.body)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment