After I upgraded my spring framework version from 4.1.6 to 4.2.4, I am getting "java.lang.NoSuchFieldError: BEFORE_CLASS" while unit testing with jUnit, which worked fine before updated. Can anyone tell me what is wrong with this and how to solve this?
Here are my snippet code.
HttpMethodUnitTest
public MockMvc mockMvc;
private MediaType contentType = new MediaType(MediaType.APPLICATION_JSON.getType(),
MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
public void testGetMethod(String url, String locale, String empKey, String accessToken) throws Exception {
mockMvc.perform(get(url).param("locale", locale).param("empKey", empKey).param("accessToken", accessToken))
.andDo(print())
.andExpect(status().isOk());
}
LoginContollerTest
@Mock private LoginService loginService;
@InjectMocks private LoginController loginController;
@Value("${locale}") public String locale;
@Value("${empKey}") public String empKey;
@Value("${accessToken}") public String accessToken;
//@Qualifier LoginController loginController = new LoginController();
@Before
public void /*setUp*/init() throws Exception {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.standaloneSetup(loginController).build();
}
@Test
public void TestCaseMain () throws Exception {
testGetMethod("/certificate/valid", locale, empKey, accessToken);
}
Aucun commentaire:
Enregistrer un commentaire