Search code examples
springspring-securityspring-security-test

missing dependencies in latest spring security test


I need to resolve certain methods (status, jsonPath, content) mentioned in code shown below -

mockMvc.perform(MockMvcRequestBuilders.get("/api/token")
            .with(getAuthentication(getOauthTestAuthentication()))
            .sessionAttr("scopedTarget.oauth2ClientContext", getOauth2ClientContext()))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$.username").value("cominventor"))
            .andExpect(jsonPath("$.token").value("my-fun-token"));

When I searched for related projects containing these methods, many of them are importing the following

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

The problem is that I am unable to find a counterpart in package spring-security-test with version 4.2.2.RELEASE

The closest options that could have worked but haven't are

import static org.springframework.test.web.servlet.ResultMatcher.*;
import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.*;

The above don't contain the methods I am looking for. Any idea where should I look for these methods or their newer counterparts.


Solution

  • Everything worked out once I set the spring-security-test version to 4.0.2.RELEASE