Skip to content

Print cookies in human-readable form in Spring MVC Test [SPR-13168] #17759

@spring-projects-issues

Description

@spring-projects-issues

Sam Brannen opened SPR-13168 and commented

Status Quo

When rendering cookies via andDo(print()) in Spring MVC Test, the output for the MockHttpServletResponse looks something like the following:

Cookies = [javax.servlet.http.Cookie@3ccd3277]

The reason is that Cookie in javax.servlet-api-3.0.1.jar does not implement toString(). Consequently, nothing about the cookie's name, value, etc., is displayed, thereby making the debug output for cookies next to useless.


Deliverables

  1. Implement custom toString() logic in PrintingResultHandler for Cookies.
Before
MockHttpServletResponse:
   ...
   Cookies = [javax.servlet.http.Cookie@25084a1e]
After
MockHttpServletResponse:
   ...
   Cookies = [[Cookie@47faa49c name = 'enigma', value = '42', comment = [null], domain = [null], maxAge = -1, path = [null], secure = false, version = 0, httpOnly = false]]

Affects: 3.2 GA

Issue Links:

Referenced from: commits 895d43a

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions