Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce sessionAttributeDoesNotExist in RequestResultMatchers #23756

Closed

Conversation

drumonii
Copy link
Contributor

@drumonii drumonii commented Oct 4, 2019

Given the matcher attributeDoesNotExist of ModelResultMatchers, it makes sense for a session attribute ResultMatcher equivalent – sessionAttributeDoesNotExist which asserts that the given session attributes are null in the HttpSession.

Similar to attributeDoesNotExist of ModelResultMatchers, sessionAttributeDoesNotExist asserts that the given attributes are null in the HttpSession.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 4, 2019
@sbrannen sbrannen added the in: test Issues in the test module label Oct 4, 2019
@sbrannen sbrannen self-assigned this Oct 4, 2019
@sbrannen sbrannen added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 4, 2019
@sbrannen sbrannen added this to the 5.2.1 milestone Oct 4, 2019
@sbrannen sbrannen changed the title Add sessionAttributeDoesNotExist ResultMatcher Introduce sessionAttributeDoesNotExist in RequestResultMatchers Oct 22, 2019
@sbrannen
Copy link
Member

For anyone interested in achieving the same goal prior to Spring Framework 5.2.1, please note that this is already possible for a single attribute name using a Hamcrest Matcher as follows.

this.mockMvc.perform(get("/"))
	.andExpect(request().sessionAttribute("bogus", is(nullValue())))

@sbrannen sbrannen closed this in e73344f Oct 23, 2019
sbrannen added a commit that referenced this pull request Oct 23, 2019
sbrannen added a commit that referenced this pull request Oct 23, 2019
The new sessionAttributeDoesNotExist() method introduced in commit
e73344f declares an unused type
parameter <T>.

This commit removes that unused type parameter from the method
signature.

See gh-23756
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants