Add doesExist() to HeaderAssertions for WebTestClient
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,6 +37,7 @@ import static org.mockito.Mockito.*;
|
||||
* Unit tests for {@link HeaderAssertions}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sam Brannen
|
||||
* @since 5.0
|
||||
*/
|
||||
public class HeaderAssertionTests {
|
||||
@@ -124,6 +125,26 @@ public class HeaderAssertionTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesExist() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
HeaderAssertions assertions = headerAssertions(headers);
|
||||
|
||||
// Success
|
||||
assertions.doesExist("Content-Type");
|
||||
|
||||
try {
|
||||
assertions.doesExist("Framework");
|
||||
fail("Header should not exist");
|
||||
}
|
||||
catch (AssertionError error) {
|
||||
Throwable cause = error.getCause();
|
||||
assertNotNull(cause);
|
||||
assertEquals("Response header 'Framework' does not exist", cause.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotExist() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
Reference in New Issue
Block a user