mercredi 3 août 2016

In Spring MockMVC tests, how to chain visit of several webpages?

I have a web application that requires Login. Upon login success, many session attributes are loaded, which will be needed by subsequent navigation of other web pages.

This is the code I login with user name and password using MockMVC

How do I chain a second page visit action after the login page visit? Something like:

mockMvc.perform(post("/login").session(session).param("username", "Jack").param("password","Jack'sPassword"))
               .perform(get("/anotherPage")).andExpect(/*some session attribute are successfully loaded*/)

Aucun commentaire:

Enregistrer un commentaire