Package org.nutz.mock.servlet.multipart

Examples of org.nutz.mock.servlet.multipart.MultipartInputStream


        File txt = Files.findFile("org/nutz/mvc/upload/files/quick/abc.zdoc");
        File red = Files.findFile("org/nutz/mvc/upload/files/quick/red.png");
        File blue = Files.findFile("org/nutz/mvc/upload/files/quick/blue.png");
        File green = Files.findFile("org/nutz/mvc/upload/files/quick/green.png");

        MultipartInputStream ins = Mock.servlet.insmulti(charset);
        ins.append("abc", txt);
        ins.append("red", red);
        ins.append("blue", blue);
        ins.append("green", green);
        req.setInputStream(ins);
        req.init();

        Uploading up = UploadUnit.TYPE.born();
        Map<String, Object> map = up.parse(req, UploadingContext.create(tmps));
View Full Code Here


    public void test_upload_queryString() throws UploadException {
        MockHttpServletRequest req = Mock.servlet.request();
        req.setParameter("id", "1");
        req.setParameter("name", "nutz");
        Uploading up = UploadUnit.TYPE.born();
        MultipartInputStream ins = Mock.servlet.insmulti(charset);
        ins.append("age", "1");
        req.setInputStream(ins);
        req.init();
        Map<String, Object> map = up.parse(req, UploadingContext.create(tmps));
        assertEquals("1", map.get("id"));
        assertEquals("nutz", map.get("name"));
View Full Code Here

    public void test_upload_onlyQueryString() throws UploadException {
        MockHttpServletRequest req = Mock.servlet.request();
        req.setParameter("id", "1");
        req.setParameter("name", "nutz");
        Uploading up = UploadUnit.TYPE.born();
        MultipartInputStream ins = Mock.servlet.insmulti(charset);
        req.setInputStream(ins);
        req.init();
        Map<String, Object> map = up.parse(req, UploadingContext.create(tmps));
        assertEquals("1", map.get("id"));
        assertEquals("nutz", map.get("name"));
View Full Code Here

        public static ServletInputStream ins(String path) {
            return ins(Streams.fileIn(path));
        }

        public static MultipartInputStream insmulti(String charset, String boundary) {
            return new MultipartInputStream(charset, boundary);
        }
View Full Code Here

                            "------NutzMockHTTPBoundary@"
                                    + Long.toHexString(System.currentTimeMillis()));
        }

        public static MultipartInputStream insmulti(String charset, File... files) {
            MultipartInputStream ins = insmulti(charset);
            for (int i = 0; i < files.length; i++) {
                if (files[i].isFile())
                    ins.append("F" + i, files[i]);
            }
            return ins;
        }
View Full Code Here

TOP

Related Classes of org.nutz.mock.servlet.multipart.MultipartInputStream

Copyright © 2018 www.massapicom. 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.