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


Java WritableFilesDataUnit类代码示例

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


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

示例1: execute

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入依赖的package包/类
@Test
public void execute() throws Exception {
    GzipperConfig_V1 config = new GzipperConfig_V1();

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

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

    // Prepare data unit.
    WritableFilesDataUnit filesOutput = environment.createFilesOutput("filesOutput");
    WritableFilesDataUnit filesInput = environment.createFilesInput("filesInput");

    File inputFile = new File(URI.create(filesInput.addNewFile("LICENSE")));
    try (FileOutputStream fout = new FileOutputStream(inputFile)) {
        IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream("LICENSE"), fout);
    }
    try {
        // Run.
        environment.run(dpu);

        // Get file iterator.
        Set<FilesDataUnit.Entry> outputFiles = FilesHelper.getFiles(filesOutput);
        Assert.assertEquals(1, outputFiles.size());

        FilesDataUnit.Entry entry = outputFiles.iterator().next();

        byte[] outputContent = IOUtils.toByteArray(new GZIPInputStream(new FileInputStream(new File(new URI(entry.getFileURIString())))));
        byte[] expectedContent = IOUtils.toByteArray(Thread.currentThread().getContextClassLoader().getResourceAsStream("LICENSE"));

        Assert.assertArrayEquals(expectedContent, outputContent);
        
        Assert.assertEquals("LICENSE.gz", VirtualPathHelpers.getVirtualPath(filesOutput, "LICENSE"));
    } finally {
        // Release resources.
        environment.release();
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:41,代码来源:GzipperTest.java

示例2: testSmallFile

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入依赖的package包/类
@Test
public void testSmallFile() throws Exception {
    GunzipperConfig_V1 config = new GunzipperConfig_V1();
    
    // Prepare DPU.
    Gunzipper dpu = new Gunzipper();
    dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());

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

    // Prepare data unit.
    WritableFilesDataUnit filesOutput = environment.createFilesOutput("filesOutput");
    WritableFilesDataUnit filesInput = environment.createFilesInput("filesInput");
    
    File inputFile = new File(URI.create(filesInput.addNewFile("LICENSE.gz")));
    try (FileOutputStream fout = new FileOutputStream(inputFile)) {
        IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream("LICENSE.gz"), fout);
    }
    try {
        // Run.
        environment.run(dpu);

        // Get file iterator.
        Set<FilesDataUnit.Entry> outputFiles = FilesHelper.getFiles(filesOutput);
        Assert.assertEquals(1, outputFiles.size());
        
        FilesDataUnit.Entry entry = outputFiles.iterator().next();
        String outputContent = IOUtils.toString(new URI(entry.getFileURIString()), "US-ASCII");
        String expectedContent = IOUtils.toString(Thread.currentThread().getContextClassLoader().getResourceAsStream("LICENSE"), "US-ASCII");
        
        Assert.assertEquals(expectedContent, outputContent);
        Assert.assertEquals("LICENSE", VirtualPathHelpers.getVirtualPath(filesOutput, "LICENSE.gz"));
    } finally {
        // Release resources.
        environment.release();
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:39,代码来源:GunzipperTest.java

示例3: assertOutputContainsFile

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入依赖的package包/类
private void assertOutputContainsFile(WritableFilesDataUnit output, String symbolicName) throws DataUnitException{
    List<FilesDataUnit.Entry> outputList = new ArrayList<FilesDataUnit.Entry>(FilesHelper.getFiles(output));
    boolean contains = false;
    for(Entry entry : outputList) {
        if(entry.getFileURIString().endsWith(symbolicName)){
            contains = true;
        }
    }
    assertEquals("Should return true.", true, contains);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:11,代码来源:FilterValidXmlTest.java

示例4: execute

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入依赖的package包/类
@Test
public void execute() throws Exception {
    // Prepare config.
    FilesDownloadConfig_V1 config = new FilesDownloadConfig_V1();
    config.getVfsFiles().add(new VfsFile());
    config.getVfsFiles().get(0).setUri(getClass().getClassLoader().getResource("test").toURI().toString());

    // Prepare DPU.
    FilesDownload download = new FilesDownload();
    download.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());

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

    // Prepare data unit.
    WritableFilesDataUnit filesOutput = environment.createFilesOutput("output");

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

        // Get file iterator.
        Iterator<Entry> outputEntries = FilesHelper.getFiles(filesOutput).iterator();

        // Iterate over files.
        while (outputEntries.hasNext()) {
            byte[] outputContent = FileUtils.readFileToByteArray(new File(new URI(outputEntries.next().getFileURIString())));

            // Verify result.
            Assert.assertEquals(5, outputContent.length);
        }
    } finally {
        // Release resources.
        environment.release();
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:37,代码来源:FilesDownloadTest.java

示例5: executeSelfSigned

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入依赖的package包/类
@Test
public void executeSelfSigned() throws Exception {
    // Prepare config.
    String uri = "https://www.isvz.cz/";
    FilesDownloadConfig_V1 config = new FilesDownloadConfig_V1();
    config.getVfsFiles().add(new VfsFile());
    config.getVfsFiles().get(0).setUri(uri);
    config.setDefaultTimeout(60000);
    config.setIgnoreTlsErrors(true);

    // Prepare DPU.
    FilesDownload download = new FilesDownload();
    download.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());

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

    // Prepare data unit.
    WritableFilesDataUnit filesOutput = environment.createFilesOutput("output");

    try {
        // Run.
        environment.run(download);
    } finally {
        // Release resources.
        environment.release();
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:29,代码来源:FilesDownloadTest.java

示例6: testNoInputFiles

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入依赖的package包/类
@Test
public void testNoInputFiles() throws Exception {
    ExecuteShellScriptConfig_V1 config = new ExecuteShellScriptConfig_V1();
    config.setConfiguration("adam eva had");
    URL file = null;
    if (SystemUtils.IS_OS_WINDOWS) {
        file = Thread.currentThread().getContextClassLoader().getResource("pokusNoInput.bat");
    } else if (SystemUtils.IS_OS_UNIX) {
        file = Thread.currentThread().getContextClassLoader().getResource("pokusNoInput.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 DPU.
    ExecuteShellScript dpu = new ExecuteShellScript();
    dpu.configure((new ConfigurationBuilder()).setDpuConfiguration(config).toString());

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

        String[] items = config.getConfiguration().split(" ");
        List<String> itemList = Arrays.asList(items);
        for (String newFile : itemList) {
            File parentDir = new File(URI.create(filesOutput.getBaseFileURIString() + "tmp"));
            File outF = new File(parentDir.getAbsolutePath(), newFile);
            Assert.assertTrue(outF.exists());
        }

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

示例7: 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

示例8: 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

示例9: 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

示例10: createFile

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入依赖的package包/类
/**
 * Create file of under given path and return {@link File} to it. Also add {@link VirtualPathHelper#PREDICATE_VIRTUAL_PATH} metadata to the new file.
 * As this function create new connection is should not be used for greater number of files.
 * 
 * @param dataUnit
 * @param symbolicName
 * @return
 * @throws DataUnitException
 */
public static FilesDataUnit.Entry createFile(WritableFilesDataUnit dataUnit, String symbolicName)
        throws DataUnitException {
    final String fileUri = dataUnit.addNewFile(symbolicName);
    MetadataUtils.add(dataUnit, symbolicName, FilesVocabulary.UV_VIRTUAL_PATH, symbolicName);
    return new InMemoryEntry(fileUri, symbolicName);
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:16,代码来源:FilesDataUnitUtils.java

示例11: createFile

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入依赖的package包/类
/**
 * Creates new empty file in the {@link eu.unifiedviews.dataunit.files.WritableFilesDataUnit} with the symbolicName metadata equal to
 * filename.
 * The physical name of the created file is generated and the file is physically stored in the working directory of the given pipeline execution.
 * It also automatically adds {@link eu.unifiedviews.helpers.dataunit.virtualpath.VirtualPathHelper#PREDICATE_VIRTUAL_PATH} metadata to
 * the new file, which is equal to filename.
 * Note: This function creates new connection to the RDF working store (where metadata of entries are held) anytime it is called
 * 
 * @param filesDataUnit
 *            data unit in which the file should be created
 * @param filename
 * @return Files entry pointing to the create file.
 * @throws DataUnitException
 */
public static FilesDataUnit.Entry createFile(WritableFilesDataUnit filesDataUnit, final String filename) throws DataUnitException {
    return FilesDataUnitUtils.createFile(filesDataUnit, filename);
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:18,代码来源:FilesHelper.java

示例12: addFile

import eu.unifiedviews.dataunit.files.WritableFilesDataUnit; //导入依赖的package包/类
/**
 * Adds existing file to the {@link eu.unifiedviews.dataunit.files.WritableFilesDataUnit}.
 * It automatically creates new entry in the output data unit with the symbolicName and virtualPath metadata equal to filename.
 * The real location and the physical name of the file is as it was when it was created before calling this method. Be careful that the file
 * is not created in the working space of the given pipeline execution.
 * It also automatically adds {@link eu.unifiedviews.helpers.dataunit.virtualpath.VirtualPathHelper#PREDICATE_VIRTUAL_PATH} metadata to
 * the new file, which is equal to filename.
 * Note: This function creates new connection to the RDF working store (where metadata of entries are held) anytime it is called
 * 
 * @param filesDataUnit
 *            data unit to which the file should be added
 * @param file
 *            File to be added
 * @param filename
 *            The name under which the file should be added
 * @throws DPUException
 */
public static FilesDataUnit.Entry addFile(WritableFilesDataUnit filesDataUnit, final File file, final String filename) throws DataUnitException {
    return FilesDataUnitUtils.addFile(filesDataUnit, file, filename);
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:21,代码来源:FilesHelper.java


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