Polish
This commit is contained in:
parent
81ca1f7c2b
commit
49f1aa78eb
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -90,6 +90,15 @@ public class HeaderResultMatchers {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assert that the named response header does exist.
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
public ResultMatcher doesExist(final String name) {
|
||||||
|
return result -> assertTrue("Response should contain header '" + name + "'",
|
||||||
|
result.getResponse().containsHeader(name));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert that the named response header does not exist.
|
* Assert that the named response header does not exist.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
|
@ -99,15 +108,6 @@ public class HeaderResultMatchers {
|
||||||
!result.getResponse().containsHeader(name));
|
!result.getResponse().containsHeader(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Assert that the named response header does exist.
|
|
||||||
* @since 4.3
|
|
||||||
*/
|
|
||||||
public ResultMatcher doesExist(final String name) {
|
|
||||||
return result -> assertTrue("Response should contain header '" + name + "'",
|
|
||||||
result.getResponse().containsHeader(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert the primary value of the named response header as a {@code long}.
|
* Assert the primary value of the named response header as a {@code long}.
|
||||||
* <p>The {@link ResultMatcher} returned by this method throws an
|
* <p>The {@link ResultMatcher} returned by this method throws an
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ public class HeaderAssertionTests {
|
||||||
this.mockMvc.perform(get("/persons/1")).andExpect(header().doesExist(LAST_MODIFIED));
|
this.mockMvc.perform(get("/persons/1")).andExpect(header().doesExist(LAST_MODIFIED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = AssertionError.class) // SPR-10771
|
@Test(expected = AssertionError.class)
|
||||||
public void doesExistFail() throws Exception {
|
public void doesExistFail() throws Exception {
|
||||||
this.mockMvc.perform(get("/persons/1")).andExpect(header().doesExist("X-Custom-Header"));
|
this.mockMvc.perform(get("/persons/1")).andExpect(header().doesExist("X-Custom-Header"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue