1
我已經編寫了一個使用會話變量的servlet。我正在爲此流創建Junit測試用例。但是如何在Junit測試用例中設置這些會話變量。我用下面的代碼調用在JUnit測試用例在servlet,如何在Java中設置會話變量Junit TestCase
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPostReq = new HttpPost(/url);
List<NameValuePair> reqParams = new ArrayList<NameValuePair>();
nvpsReqParams.add(); // paramters to add
httpPostReq.setEntity(new UrlEncodedFormEntity(reqParams, HTTP.UTF_8));
HttpResponse response = httpClient.execute(httpPostReq);
在它們之間隔設定參數後,我想添加了按實際用例需要會話變量。有人可以幫助我如何在這裏添加會話變量。任何幫助將非常感激。