Skip to content

Document how to add response assertions with Spring MVC Test for Spring HATEOAS links [SPR-9886] #14519

Closed

Description

@spring-projects-issues

Rossen Stoyanchev opened SPR-9886 and commented


Affects: 3.2 M2

This issue is a sub-task of #14493

Activity

  1. spring-projects-issues commented on Feb 5, 2013

    @spring-projects-issues
    CollaboratorAuthor

    Rossen Stoyanchev commented

    JSONPath:

    mockMvc.perform(get("/people").accept(MediaType.APPLICATION_JSON))
      .andExpect(jsonPath("$.links[?(@.rel == 'self')].href").value("http://localhost:8080/people"));

    XPath:

    Map<String, String> ns = Collections.singletonMap("ns", "http://www.w3.org/2005/Atom");
    mockMvc.perform(get("/handle").accept(MediaType.APPLICATION_XML))
      .andExpect(xpath("/person/ns:link[@rel='self']/@href", ns).string("http://localhost:8080/people"));
  2. added
    in: test
    type: task
    on Jan 11, 2019
  3. added this to the 3.2 GA milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: testtype: task

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions