Examples of TempFile


Examples of org.apache.tools.ant.taskdefs.TempFile

     */
    public void transform() throws BuildException {
        checkOptions();
        Project project = task.getProject();

        TempFile tempFileTask = new TempFile();
        tempFileTask.bindToOwner(task);

        XSLTProcess xsltTask = new XSLTProcess();
        xsltTask.bindToOwner(task);

        xsltTask.setXslResource(getStylesheet());

        // acrobatic cast.
        xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile());
        File outputFile = null;
        if (format.equals(FRAMES)) {
            String tempFileProperty = getClass().getName() + String.valueOf(counter++);
            File tmp = FILE_UTILS.resolveFile(project.getBaseDir(), project
                    .getProperty("java.io.tmpdir"));
            tempFileTask.setDestDir(tmp);
            tempFileTask.setProperty(tempFileProperty);
            tempFileTask.execute();
            outputFile = new File(project.getProperty(tempFileProperty));
        } else {
            outputFile = new File(toDir, "junit-noframes.html");
        }
        xsltTask.setOut(outputFile);
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.TempFile

     */
    public void transform() throws BuildException {
        checkOptions();
        Project project = task.getProject();

        TempFile tempFileTask = new TempFile();
        tempFileTask.bindToOwner(task);

        XSLTProcess xsltTask = new XSLTProcess();
        xsltTask.bindToOwner(task);

        xsltTask.setXslResource(getStylesheet());

        // acrobatic cast.
        xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile());
        File outputFile = null;
        if (format.equals(FRAMES)) {
            String tempFileProperty = getClass().getName() + String.valueOf(counter++);
            File tmp = FILE_UTILS.resolveFile(project.getBaseDir(), project
                    .getProperty("java.io.tmpdir"));
            tempFileTask.setDestDir(tmp);
            tempFileTask.setProperty(tempFileProperty);
            tempFileTask.execute();
            outputFile = new File(project.getProperty(tempFileProperty));
        } else {
            outputFile = new File(toDir, "junit-noframes.html");
        }
        xsltTask.setOut(outputFile);
View Full Code Here

Examples of org.jets3t.service.io.TempFile

        }

        String actionText = "";

        // Create a temporary file to hold data transformed from the original file.
        final File tempUploadFile = new TempFile(File.createTempFile("JetS3t",".tmp"));       
        tempUploadFile.deleteOnExit();
       
        // Transform data from original file, gzipping or encrypting as specified in user's options.
        OutputStream outputStream = null;
        InputStream inputStream = null;
       
        try {
            inputStream = new BufferedInputStream(new FileInputStream(dataFile));      
            outputStream = new BufferedOutputStream(new FileOutputStream(tempUploadFile));
           
            String contentEncoding = null;       
            if (gzipFile) {
                inputStream = new GZipDeflatingInputStream(inputStream);
                contentEncoding = "gzip";
                s3Object.addMetadata(Constants.METADATA_JETS3T_COMPRESSED, "gzip");
                actionText += "Compressing";               
            }
            if (encryptionUtil != null) {
                inputStream = encryptionUtil.encrypt(inputStream);
                contentEncoding = null;
                s3Object.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM);
                s3Object.addMetadata(Constants.METADATA_JETS3T_CRYPTO_ALGORITHM,
                    encryptionUtil.getAlgorithm());
                s3Object.addMetadata(Constants.METADATA_JETS3T_CRYPTO_VERSION,
                    EncryptionUtil.DEFAULT_VERSION);
                actionText += (actionText.length() == 0? "Encrypting" : " and encrypting");               
            }
            if (contentEncoding != null) {
                s3Object.addMetadata("Content-Encoding", contentEncoding);
            }
           
            if (log.isDebugEnabled()) {
              log.debug("Transforming upload file '" + dataFile + "' to temporary file '"
                  + tempUploadFile.getAbsolutePath() + "': " + actionText);
            }
           
            if (progressWatcher != null) {
                inputStream = new ProgressMonitoredInputStream(inputStream, progressWatcher);
            }
View Full Code Here

Examples of org.jets3t.service.io.TempFile

        }

        String actionText = "";

        // Create a temporary file to hold data transformed from the original file.
        final File tempUploadFile = new TempFile(File.createTempFile("JetS3t",".tmp"));
        tempUploadFile.deleteOnExit();

        // Transform data from original file, gzipping or encrypting as specified in user's options.
        OutputStream outputStream = null;
        InputStream inputStream = null;

        try {
            inputStream = new BufferedInputStream(new FileInputStream(dataFile));
            outputStream = new BufferedOutputStream(new FileOutputStream(tempUploadFile));

            String contentEncoding = null;
            if (gzipFile) {
                inputStream = new GZipDeflatingInputStream(inputStream);
                contentEncoding = "gzip";
                s3Object.addMetadata(Constants.METADATA_JETS3T_COMPRESSED, "gzip");
                actionText += "Compressing";
            }
            if (encryptionUtil != null) {
                inputStream = encryptionUtil.encrypt(inputStream);
                contentEncoding = null;
                s3Object.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM);
                s3Object.addMetadata(Constants.METADATA_JETS3T_CRYPTO_ALGORITHM,
                    encryptionUtil.getAlgorithm());
                s3Object.addMetadata(Constants.METADATA_JETS3T_CRYPTO_VERSION,
                    EncryptionUtil.DEFAULT_VERSION);
                actionText += (actionText.length() == 0? "Encrypting" : " and encrypting");
            }
            if (contentEncoding != null) {
                s3Object.addMetadata("Content-Encoding", contentEncoding);
            }

            if (log.isDebugEnabled()) {
                log.debug("Transforming upload file '" + dataFile + "' to temporary file '"
                    + tempUploadFile.getAbsolutePath() + "': " + actionText);
            }

            if (progressWatcher != null) {
                inputStream = new ProgressMonitoredInputStream(inputStream, progressWatcher);
            }
View Full Code Here

Examples of org.nutz.mvc.upload.TempFile

         * 默认不忽略空文件
         */
        Uploading up = UploadUnit.TYPE.born();
        Map<String, Object> map = up.parse(req, UploadingContext.create(tmps));
        assertEquals(2, map.size());
        TempFile txt2 = (TempFile) map.get("abc");
        TempFile empty2 = (TempFile) map.get("empty");

        assertEquals("abc.zdoc", txt2.getMeta().getFileLocalName());
        assertTrue(Files.equals(txt, txt2.getFile()));

        assertEquals("empty.txt", empty2.getMeta().getFileLocalName());
        assertTrue(Files.equals(empty, empty2.getFile()));

        /*
         * 设置忽略空文件
         */
        ins = Mock.servlet.insmulti(charset);
View Full Code Here

Examples of org.nutz.mvc.upload.TempFile

        /*
         * 如果模拟上传时request使用 GBK 编码,用 GBK 来解码,应该会生成正确的文件名
         */
        req.setInputStream(Mock.servlet.insmulti("GBK", txt)).init();
        Uploading up = UploadUnit.TYPE.born();
        TempFile txt2 = (TempFile) up.parse(req, UploadingContext.create(tmps).setCharset("GBK"))
                                        .get("F0");
        // 测试本地的默认编码是否是GBK,即模拟中文环境,本人环境为中文Windows XP
        // 在JVM参数中增加-Dfile.encoding=GBK即可设置好
        // assertEquals("GBK", Charset.defaultCharset().name());
        //
        // zzh: JUnit 测试必须在多数常用环境下可以比较方便的测试通过,经过这次修改,相信
        // 即可以达到这个目的,又可以测试出中文文件名的编码问题。如果没有其他的问题,在
        // 1.a.30 发布前,这段注释将被删除
        assertEquals("中文.txt", txt2.getMeta().getFileLocalName());

        /*
         * 为了验证上传是否是真的可以解码,再次准备模拟 GBK 的输入流,但是这次将用 UTF-8 来解码
         */
        req.setInputStream(Mock.servlet.insmulti("GBK", txt)).init();
        up = UploadUnit.TYPE.born();
        txt2 = (TempFile) up.parse(req, UploadingContext.create(tmps)).get("F0");
        assertFalse("中文.txt".equals(txt2.getMeta().getFileLocalName()));
    }
View Full Code Here

Examples of org.nutz.mvc.upload.TempFile

        req.init();

        Uploading up = UploadUnit.TYPE.born();
        Map<String, Object> map = up.parse(req, UploadingContext.create(tmps));
        assertEquals(4, map.size());
        TempFile txt2 = (TempFile) map.get("abc");
        TempFile red2 = (TempFile) map.get("red");
        TempFile blue2 = (TempFile) map.get("blue");
        TempFile green2 = (TempFile) map.get("green");

        assertEquals("abc.zdoc", txt2.getMeta().getFileLocalName());
        assertTrue(Files.equals(txt, txt2.getFile()));

        assertEquals("red.png", red2.getMeta().getFileLocalName());
        assertTrue(Files.equals(red, red2.getFile()));

        assertEquals("blue.png", blue2.getMeta().getFileLocalName());
        assertTrue(Files.equals(blue, blue2.getFile()));

        assertEquals("green.png", green2.getMeta().getFileLocalName());
        assertTrue(Files.equals(green, green2.getFile()));

    }
View Full Code Here

Examples of org.nutz.mvc.upload.TempFile

         * 默认不忽略空文件
         */
        Uploading up = UploadUnit.TYPE.born();
        Map<String, Object> map = up.parse(req, UploadingContext.create(tmps));
        assertEquals(1, map.size());
        TempFile tf = (TempFile) map.get("theF");

        assertEquals("_r_n.txt", tf.getMeta().getFileLocalName());
        assertTrue(Files.equals(f, tf.getFile()));
    }
View Full Code Here

Examples of org.nutz.mvc.upload.TempFile

         * 默认不忽略空文件
         */
        Uploading up = UploadUnit.TYPE.born();
        Map<String, Object> map = up.parse(req, UploadingContext.create(tmps));
        assertEquals(2, map.size());
        TempFile txt2 = (TempFile) map.get("abc");
        TempFile empty2 = (TempFile) map.get("empty");

        assertEquals("abc.zdoc", txt2.getMeta().getFileLocalName());
        assertTrue(Files.equals(txt, txt2.getFile()));

        assertEquals("empty.txt", empty2.getMeta().getFileLocalName());
        assertTrue(Files.equals(empty, empty2.getFile()));

        /*
         * 设置忽略空文件
         */
        ins = Mock.servlet.insmulti(charset);
View Full Code Here

Examples of org.nutz.mvc.upload.TempFile

        /*
         * 如果模拟上传时request使用 GBK 编码,用 GBK 来解码,应该会生成正确的文件名
         */
        req.setInputStream(Mock.servlet.insmulti("GBK", txt)).init();
        Uploading up = UploadUnit.TYPE.born();
        TempFile txt2 = (TempFile) up.parse(req,
                                            UploadingContext.create(tmps)
                                                            .setCharset("GBK"))
                                     .get("F0");
        // 测试本地的默认编码是否是GBK,即模拟中文环境,本人环境为中文Windows XP
        // 在JVM参数中增加-Dfile.encoding=GBK即可设置好
        // assertEquals("GBK", Charset.defaultCharset().name());
        //
        // zzh: JUnit 测试必须在多数常用环境下可以比较方便的测试通过,经过这次修改,相信
        // 即可以达到这个目的,又可以测试出中文文件名的编码问题。如果没有其他的问题,在
        // 1.a.30 发布前,这段注释将被删除
        assertEquals("中文.txt", txt2.getMeta().getFileLocalName());

        /*
         * 为了验证上传是否是真的可以解码,再次准备模拟 GBK 的输入流,但是这次将用 UTF-8 来解码
         */
        req.setInputStream(Mock.servlet.insmulti("GBK", txt)).init();
        up = UploadUnit.TYPE.born();
        txt2 = (TempFile) up.parse(req, UploadingContext.create(tmps))
                            .get("F0");
        assertFalse("中文.txt".equals(txt2.getMeta().getFileLocalName()));
    }
View Full Code Here
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.