Skip to content

Introduce sessionAttributeDoesNotExist in RequestResultMatchers#23756

Closed
drumonii wants to merge 1 commit into
spring-projects:masterfrom
drumonii:sessionAttributeDoesNotExist
Closed

Introduce sessionAttributeDoesNotExist in RequestResultMatchers#23756
drumonii wants to merge 1 commit into
spring-projects:masterfrom
drumonii:sessionAttributeDoesNotExist

Conversation

@drumonii

@drumonii drumonii commented Oct 4, 2019

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

3 participants