Search in sources :

Example 1 with FilePostSender

use of org.nutz.http.sender.FilePostSender in project nutz by nutzam.

the class UploadTest method test_upload.

@Test
public void test_upload() throws Throwable {
    Request req = Request.create(getBaseURL() + "/upload/image", METHOD.POST);
    File f = File.createTempFile("nutz", "data");
    FileWriter fw = new FileWriter(f);
    fw.write("abc");
    fw.flush();
    fw.close();
    req.getParams().put("file", f);
    FilePostSender sender = new FilePostSender(req);
    Response resp = sender.send();
    assertEquals("image&3", resp.getContent());
}
Also used : Response(org.nutz.http.Response) FileWriter(java.io.FileWriter) Request(org.nutz.http.Request) FilePostSender(org.nutz.http.sender.FilePostSender) File(java.io.File) BaseWebappTest(org.nutz.mvc.testapp.BaseWebappTest) Test(org.junit.Test)

Aggregations

File (java.io.File)1 FileWriter (java.io.FileWriter)1 Test (org.junit.Test)1 Request (org.nutz.http.Request)1 Response (org.nutz.http.Response)1 FilePostSender (org.nutz.http.sender.FilePostSender)1 BaseWebappTest (org.nutz.mvc.testapp.BaseWebappTest)1