当前位置: 首页>>代码示例>>Java>>正文


Java WritableFilesDataUnit.addExistingFile方法代码示例

本文整理汇总了Java中eu.unifiedviews.dataunit.files.WritableFilesDataUnit.addExistingFile方法的典型用法代码示例。如果您正苦于以下问题:Java WritableFilesDataUnit.addExistingFile方法的具体用法?Java WritableFilesDataUnit.addExistingFile怎么用?Java WritableFilesDataUnit.addExistingFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eu.unifiedviews.dataunit.files.WritableFilesDataUnit的用法示例。


在下文中一共展示了WritableFilesDataUnit.addExistingFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入方法依赖的package包/类
@Test
public void execute() throws Exception {
    // Prepare config.
    File directory = Files.createTempDirectory(null).toFile();
    directory.mkdir();

    FilesUploadConfig_V1 config = new FilesUploadConfig_V1();
    config.setUri(directory.toURI().toString());

    // Prepare DPU.
    FilesUpload upload = new FilesUpload();
    upload.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());

    // Prepare test environment.
    TestEnvironment environment = new TestEnvironment();

    // Prepare data unit.
    WritableFilesDataUnit filesInput = environment.createFilesInput("input");
    environment.createFilesOutput("output");
    VirtualPathHelper virtualPathHelper = VirtualPathHelpers.create(filesInput);

    try {
        // Test data.
        filesInput.addExistingFile("test.txt", getClass().getClassLoader().getResource("test.txt").toURI().toString());
        virtualPathHelper.setVirtualPath("test.txt", "/test.txt");

        // Run.
        environment.run(upload);

        // Get file iterator.
        Iterator<Entry> inputEntries = FilesHelper.getFiles(filesInput).iterator();

        // Iterate over files.
        while (inputEntries.hasNext()) {
            Entry entry = inputEntries.next();
            byte[] inputContent = FileUtils.readFileToByteArray(new File(new URI(entry.getFileURIString())));
            byte[] outputContent = FileUtils.readFileToByteArray(new File(directory.getAbsolutePath() + virtualPathHelper.getVirtualPath(entry.getSymbolicName())));

            // Verify result.
            Assert.assertArrayEquals(inputContent, outputContent);
        }
    } finally {
        FileUtils.deleteDirectory(directory);

        // Release resources.
        environment.release();
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:49,代码来源:FilesUploadTest.java

示例2: test

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入方法依赖的package包/类
@Test
    public void test() throws Exception {
        ExecuteShellScriptConfig_V1 config = new ExecuteShellScriptConfig_V1();
        config.setConfiguration("Copy-of-");
        URL file = null;
        if (SystemUtils.IS_OS_WINDOWS) {
            file = Thread.currentThread().getContextClassLoader().getResource("pokus.bat");
        } else if (SystemUtils.IS_OS_UNIX) {
            file = Thread.currentThread().getContextClassLoader().getResource("pokus.sh");
        }
        File f = new File(file.toURI());
        config.setScriptName(f.getName());

        // Prepare test environment.
        TestEnvironment environment = new TestEnvironment();
        environment.getContext().getEnvironment().put(ExecuteShellScript.SHELL_SCRIPT_PATH, f.getParent());
        WritableFilesDataUnit filesOutput = environment.createFilesOutput("filesOutput");
        // Prepare data unit.
        WritableFilesDataUnit filesInput = environment.createFilesInput("filesInput");
        filesInput.addExistingFile("t1", Thread.currentThread().getContextClassLoader().getResource("test1.txt").toString());
        filesInput.addExistingFile("t2", Thread.currentThread().getContextClassLoader().getResource("test2.txt").toString());
        filesInput.addExistingFile("t3", Thread.currentThread().getContextClassLoader().getResource("test3.txt").toString());

        // Prepare DPU.
        ExecuteShellScript dpu = new ExecuteShellScript();
        dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());

        try {
            // Run.
            environment.run(dpu);

            FilesDataUnit.Iteration iteration = filesInput.getIteration();
            while (iteration.hasNext()) {
                File inpF = FilesDataUnitUtils.asFile(iteration.next());
//                File outF = new File(config.getOutputDir(), config.getConfiguration() + inpF.getName());
                File parentDir = new File(URI.create(filesOutput.getBaseFileURIString() + "tmp"));
                File outF = new File(parentDir.getAbsolutePath(), config.getConfiguration() + inpF.getName());
                Assert.assertTrue(outF.exists());
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            // Release resources.
            environment.release();
        }
    }
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:48,代码来源:ExecuteShellScriptTest.java

示例3: addFile

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入方法依赖的package包/类
/**
 * Add file to the DataUnit.
 * 
 * @param dataUnit
 * @param file
 *            File to add, must be under root.
 * @param symbolicName
 * @return
 * @throws eu.unifiedviews.dataunit.DataUnitException
 */
public static FilesDataUnit.Entry addFile(WritableFilesDataUnit dataUnit, File file, String symbolicName)
        throws DataUnitException {
    // Add existing file to DataUnit.
    dataUnit.addExistingFile(symbolicName, file.toURI().toString());
    // Set available metadata.
    MetadataUtils.add(dataUnit, symbolicName, FilesVocabulary.UV_VIRTUAL_PATH, symbolicName);
    // Return representing instance.
    return new InMemoryEntry(file.toURI().toString(), symbolicName);
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:20,代码来源:FilesDataUnitUtils.java


注:本文中的eu.unifiedviews.dataunit.files.WritableFilesDataUnit.addExistingFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。