Skip to content

Commit

Permalink
Polish contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Oct 23, 2019
1 parent e73344f commit 82f64f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public <T> ResultMatcher sessionAttribute(String name, Object value) {

/**
* Assert the given session attributes do not exist.
* @since 5.2.1
*/
public <T> ResultMatcher sessionAttributeDoesNotExist(String... names) {
return result -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
Expand Down Expand Up @@ -68,7 +69,13 @@ public void testSessionAttributeMatcher() throws Exception {
@Test
public void testSessionAttributeDoesNotExist() throws Exception {
this.mockMvc.perform(get("/"))
.andExpect(request().sessionAttributeDoesNotExist("myAttr1", "myAttr2"));
.andExpect(request().sessionAttributeDoesNotExist("bogus", "enigma"));

assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() ->
this.mockMvc.perform(get("/"))
.andExpect(request().sessionAttributeDoesNotExist("locale")))
.withMessage("Session attribute 'locale' exists");
}


Expand Down

0 comments on commit 82f64f6

Please sign in to comment.