????1??HttpClient??????????????????

 

/*
Map<String??String>param=newHashMap<String??String>();
param.put("businesstype"??"1006");
param.put("trade_no"??"123123123");
param.put("orderid"??"123456");
GetMethodmethod=getMethod(URL??param);
client.executeMethod(method);
if(method.getStatusCode()!=200){
fail("δ??????");
return;
}
Stringresponse=method.getResponseBodyAsString();
System.err.println(response);
PayStatusResponsepayStatus=newPayStatusResponse();
payStatus.setBusinessType(1006);
payStatus.setOrderId("");
payStatus.setResultStatus(1);
StringpayStatusJson=JsonUtil.toJson(payStatus);
System.err.println(payStatusJson);
assertEquals(payStatusJson??response);
*/

    json?????????????jackson???
 

????2??springmvc???????mockMvc
????staticimports:

 

MockMvcBuilders.*??MockMvcRequestBuilders.*??MockMvcResultMatchers.*
WebApplicationContextwac=...;
MockMvcmockMvc=webAppContextSetup(wac).configureWarRootDir("src/main/webapp"??false).build()
mockMvc.perform(get("/form"))
.andExpect(status().isOk())
.andExpect(content().mimeType("text/html"))
.andExpect(forwardedUrl("/WEB-INF/layouts/main.jsp"));