2010-01-28 47 views

回答

0

我認爲這是可能的。你有沒有爲控制器寫過一個jUnit測試?嘲笑請求和迴應將是這樣做的一種方式。
另一種方法是使用HttpClient和模擬瀏覽器:

GetMethod get = new GetMethod("http://httpcomponents.apache.org"); 
    // execute method and handle any error responses. 
    ... 
    InputStream in = get.getResponseBodyAsStream(); 
    // Process the data from the input stream. 
    get.releaseConnection(); 

這段代碼是從這個page

相關問題