Package org.nutz.mvc.testapp.upload

Source Code of org.nutz.mvc.testapp.upload.UploadTest

package org.nutz.mvc.testapp.upload;

import java.io.File;
import java.io.FileWriter;

import static org.junit.Assert.*;

import org.junit.Test;
import org.nutz.http.Request;
import org.nutz.http.Request.METHOD;
import org.nutz.http.Response;
import org.nutz.http.sender.FilePostSender;
import org.nutz.mvc.testapp.BaseWebappTest;

public class UploadTest extends BaseWebappTest {

    @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());
    }
   
}
TOP

Related Classes of org.nutz.mvc.testapp.upload.UploadTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.