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


Java TemporaryFolder类代码示例

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


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

示例1: beforeClass

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
public static void beforeClass(TemporaryFolder junitFolder) throws IOException {
    if (System.getProperties().getProperty("MCR.Home") == null) {
        File baseDir = junitFolder.newFolder("mcrhome");
        System.out.println("Setting MCR.Home=" + baseDir.getAbsolutePath());
        System.getProperties().setProperty("MCR.Home", baseDir.getAbsolutePath());
    }
    if (System.getProperties().getProperty("MCR.AppName") == null) {
        String currentComponentName = getCurrentComponentName();
        System.out.println("Setting MCR.AppName=" + currentComponentName);
        System.getProperties().setProperty("MCR.AppName", getCurrentComponentName());
    }
    File configDir = new File(System.getProperties().getProperty("MCR.Home"),
        System.getProperties().getProperty("MCR.AppName"));
    System.out.println("Creating config directory: " + configDir);
    configDir.mkdirs();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:17,代码来源:MCRTestCaseHelper.java

示例2: gradleFile

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
static BiConsumer<TemporaryFolder, File> gradleFile(String name) {
	return (folder, buildFile) -> {
		Path path = Paths.get(String.format(BUILD_FILE_PATH_FORMAT, name));

		try (BufferedWriter writer = Files.newBufferedWriter(buildFile.toPath())) {
			List<String> input = Files.readAllLines(path);

			for (String line : input) {
				writer.write(line);
				writer.newLine();
			}
		} catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	};
}
 
开发者ID:michaelbull,项目名称:svg-stockpile,代码行数:17,代码来源:GradleBuildFileBehaviour.java

示例3: test0

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
public void test0(){
	if (System.getenv().get("SKIP_HEAVY")!=null){
		return;
	}
	TemporaryFolder tempSwaggerApis=new TemporaryFolder();
	TemporaryFolder tempRAMLApis=new TemporaryFolder();
	try{
	File fs=File.createTempFile("ddd", "tmp");		
	FileUtils.copyInputStreamToFile(RegistryManager.getInstance().getClass().getResourceAsStream("/azure-specs.zip"), fs);
	tempSwaggerApis.create();
	tempRAMLApis.create();
	extractFolder(fs.getAbsolutePath(), tempSwaggerApis.getRoot().getAbsolutePath());
	WriteApis.write(tempSwaggerApis.getRoot().getAbsolutePath(), tempRAMLApis.getRoot().getAbsolutePath());
	tempSwaggerApis.delete();
	tempRAMLApis.delete();
	}catch (Exception e) {
		throw new IllegalStateException();
	}
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:20,代码来源:Swagger2RamlTest.java

示例4: create

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
public Preferences create(String name, TemporaryFolder folder) {
    try {
        final File srcDir = folder.newFolder();
        final File backupDir = folder.newFolder();
        final File lockDir = folder.newFolder();
        DirectoryProvider directoryProvider = new DirectoryProvider() {
            @Override
            public File getStoreDirectory() {
                return srcDir;
            }

            @Override
            public File getBackupDirectory() {
                return backupDir;
            }

            @Override
            public File getLockDirectory() {
                return lockDir;
            }
        };
        return create(name, directoryProvider);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:iamironz,项目名称:binaryprefs,代码行数:27,代码来源:PreferencesCreator.java

示例5: FakeWikidataLuceneIndexFactory

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
public FakeWikidataLuceneIndexFactory() throws IOException {
    TemporaryFolder temporaryFolder = new TemporaryFolder();
    temporaryFolder.create();

    File fakeDumpFile = temporaryFolder.newFile("wikidata-20160829-all.json.gz");
    compressFileToGzip(new File(FakeWikidataLuceneIndexFactory.class.getResource("/wikidata-20160829-all.json").getPath()), fakeDumpFile);
    MwLocalDumpFile fakeDump = new MwLocalDumpFile(fakeDumpFile.getPath());

    File dbFile = temporaryFolder.newFile();
    dbFile.delete();
    try (WikidataTypeHierarchy typeHierarchy = new WikidataTypeHierarchy(dbFile.toPath())) {
        index = new LuceneIndex(temporaryFolder.newFolder().toPath());
        DumpProcessingController dumpProcessingController = new DumpProcessingController("wikidatawiki");
        dumpProcessingController.setDownloadDirectory(temporaryFolder.newFolder().toString());
        dumpProcessingController.registerEntityDocumentProcessor(typeHierarchy.getUpdateProcessor(), null, true);
        dumpProcessingController.processDump(fakeDump);

        dumpProcessingController.registerEntityDocumentProcessor(
                new WikidataResourceProcessor(new LuceneLoader(index), dumpProcessingController.getSitesInformation(), typeHierarchy),
                null,
                true
        );
        dumpProcessingController.processDump(fakeDump);
        index.refreshReaders();
    }
}
 
开发者ID:askplatypus,项目名称:platypus-kb-lucene,代码行数:27,代码来源:FakeWikidataLuceneIndexFactory.java

示例6: createZipFile

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
/**
 * Create a zip file with the given lines.
 *
 * @param expected A list of expected lines, populated in the zip file.
 * @param folder A temporary folder used to create files.
 * @param filename Optionally zip file name (can be null).
 * @param fieldsEntries Fields to write in zip entries.
 * @return The zip filename.
 * @throws Exception In case of a failure during zip file creation.
 */
private static File createZipFile(
    List<String> expected, TemporaryFolder folder, String filename, String[]... fieldsEntries)
    throws Exception {
  File tmpFile = folder.getRoot().toPath().resolve(filename).toFile();

  ZipOutputStream out = new ZipOutputStream(new FileOutputStream(tmpFile));
  PrintStream writer = new PrintStream(out, true /* auto-flush on write */);

  int index = 0;
  for (String[] entry : fieldsEntries) {
    out.putNextEntry(new ZipEntry(Integer.toString(index)));
    for (String field : entry) {
      writer.println(field);
      expected.add(field);
    }
    out.closeEntry();
    index++;
  }

  writer.close();
  out.close();

  return tmpFile;
}
 
开发者ID:apache,项目名称:beam,代码行数:35,代码来源:TextIOReadTest.java

示例7: parameters

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
@Parameterized.Parameters
public static Collection<AbstractStateBackend> parameters() throws IOException {
	TemporaryFolder tempFolder = new TemporaryFolder();
	tempFolder.create();

	MemoryStateBackend syncMemBackend = new MemoryStateBackend(MAX_MEM_STATE_SIZE, false);
	MemoryStateBackend asyncMemBackend = new MemoryStateBackend(MAX_MEM_STATE_SIZE, true);

	FsStateBackend syncFsBackend = new FsStateBackend("file://" + tempFolder.newFolder().getAbsolutePath(), false);
	FsStateBackend asyncFsBackend = new FsStateBackend("file://" + tempFolder.newFolder().getAbsolutePath(), true);

	RocksDBStateBackend fullRocksDbBackend = new RocksDBStateBackend(new MemoryStateBackend(MAX_MEM_STATE_SIZE), false);
	fullRocksDbBackend.setDbStoragePath(tempFolder.newFolder().getAbsolutePath());

	RocksDBStateBackend incRocksDbBackend = new RocksDBStateBackend(new MemoryStateBackend(MAX_MEM_STATE_SIZE), true);
	incRocksDbBackend.setDbStoragePath(tempFolder.newFolder().getAbsolutePath());

	return Arrays.asList(
		syncMemBackend,
		asyncMemBackend,
		syncFsBackend,
		asyncFsBackend,
		fullRocksDbBackend,
		incRocksDbBackend);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:PartitionedStateCheckpointingITCase.java

示例8: reinitialiseGraph

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
public void reinitialiseGraph(final TemporaryFolder testFolder, final Schema schema, final StoreProperties storeProperties) throws IOException {
    FileUtils.writeByteArrayToFile(testFolder.newFile("schema.json"), schema
            .toJson(true));

    try (OutputStream out = new FileOutputStream(testFolder.newFile("store.properties"))) {
        storeProperties.getProperties()
                       .store(out, "This is an optional header comment string");
    }

    // set properties for REST service
    System.setProperty(SystemProperty.STORE_PROPERTIES_PATH, testFolder.getRoot() + "/store.properties");
    System.setProperty(SystemProperty.SCHEMA_PATHS, testFolder.getRoot() + "/schema.json");
    System.setProperty(SystemProperty.GRAPH_ID, "graphId");

    reinitialiseGraph();
}
 
开发者ID:gchq,项目名称:Gaffer,代码行数:17,代码来源:RestApiTestClient.java

示例9: runWorkflow

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
public static void runWorkflow(TemporaryFolder folder, String resource, Map<String, String> params, Map<String, String> config, int expectedStatus)
        throws IOException
{
    Path workflow = Paths.get(resource);
    Path tempdir = folder.newFolder().toPath();
    Path file = tempdir.resolve(workflow.getFileName());
    Path configFile = folder.newFolder().toPath().resolve("config");
    List<String> configLines = config.entrySet().stream()
            .map(e -> e.getKey() + " = " + e.getValue())
            .collect(Collectors.toList());
    Files.write(configFile, configLines);
    List<String> runCommand = new ArrayList<>(asList("run",
            "-c", configFile.toAbsolutePath().normalize().toString(),
            "-o", tempdir.toString(),
            "--project", tempdir.toString(),
            workflow.getFileName().toString()));
    params.forEach((k, v) -> runCommand.addAll(asList("-p", k + "=" + v)));
    try {
        copyResource(resource, file);
        CommandStatus status = main(runCommand);
        assertThat(status.errUtf8(), status.code(), is(expectedStatus));
    }
    finally {
        FileUtils.deleteQuietly(tempdir.toFile());
    }
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:27,代码来源:TestUtils.java

示例10: setUpBefore

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
@Before
public void setUpBefore() throws IOException {
  super.setUp();

  plugin = new ValidateMojo();
  plugin.setLog(log);

  plugin.setPropertyDir(getFile(""));

  // Use XHTML5 as it is much faster
  plugin.setXhtmlSchema(HtmlValidator.XHTML5);

  File dictionaryDir = new File(this.getClass().getClassLoader().getResource("").getFile());
  plugin.setDictionaryDir(dictionaryDir);

  CustomPattern listPattern = new CustomPattern("List", "([A-Z](:[A-Z])+)?", ".list.");
  CustomPattern anotherPattern = new CustomPattern("List", "([A-Z](:[A-Z])+)?", new String[] { ".pattern1.",
      ".pattern2." });
  plugin.setCustomPatterns(new CustomPattern[] { listPattern, anotherPattern });

  // Junit bug can't use tmpFolder
  plugin.setReportsDir(new TemporaryFolder().newFolder());

  // Use default configuration for the rest
  plugin.initialize();
}
 
开发者ID:rquinio,项目名称:l10n-maven-plugin,代码行数:27,代码来源:ValidateMojoIT.java

示例11: setUp

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
   BrokerService.disableWrapper = disableWrapper;
   File tmpRoot = new File("./target/tmp");
   tmpRoot.mkdirs();
   temporaryFolder = new TemporaryFolder(tmpRoot);
   temporaryFolder.create();

   if (artemisBroker == null) {
      artemisBroker = createArtemisBroker();
   }
   startBroker();

   connectionFactory = createConnectionFactory();

   destination = createDestination();

   template = createJmsTemplate();
   template.setDefaultDestination(destination);
   template.setPubSubDomain(useTopic);
   template.afterPropertiesSet();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:23,代码来源:EmbeddedBrokerTestSupport.java

示例12: getTestDirectoryWithFiles

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
public static  File getTestDirectoryWithFiles (TemporaryFolder tmpFolder, String directoryName, String fileNamePrefix, int numberOfFiles) throws IOException
{
	assert (numberOfFiles >= 0) ;
	
    File folder = tmpFolder.newFolder(directoryName) ;
    
    if (numberOfFiles == 0)
    	return folder ;
    
    StringBuilder fileNameBase = new StringBuilder () ;
    fileNameBase.append(directoryName) ;
    fileNameBase.append(File.separator) ;
    fileNameBase.append(fileNamePrefix) ;
    fileNameBase.append("_") ;
    
    File [] fileList = new File [numberOfFiles] ;
    for (int i = 0 ; i < numberOfFiles ; ++i)
    {
    	final String fileName = fileNameBase.toString() + i ;
    	fileList[i] = getTestFile (tmpFolder, fileName, (long) (Math.random() * 1000 + 1)) ;
    }
    
    return folder ;
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:25,代码来源:TestUtils.java

示例13: apply

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
@Override
public Statement apply(final Statement statement, Description description) {
    final TemporaryFolder tmp = new TemporaryFolder();
    return tmp.apply(new Statement() {
        @Override
        public void evaluate() throws Throwable {
            try {
                wc = WorkingCopy.prepareFor(getJarUnderTest(tmp, jar));
                statement.evaluate();
            } finally {
                if (wc != null) {
                    wc.close();
                }
            }
        }
    }, description);
}
 
开发者ID:xhanin,项目名称:jarup,代码行数:18,代码来源:WorkingCopyRule.java

示例14: copyToTemporary

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
/**
 * <br> Copy a file to a temporary folder <br><br>
 *
 * Note: by creating a copy of a file in the resources folder, tests can
 * change the contents of a file without consequences.
 *
 * Note: there might be easier ways to copy a file. By creating a copy
 * of the overview by invoking the save method on an overview object, the
 * helper method is a test in itself.
 *
 * @param temporaryFolder folder in which to create the new file
 * @param originalFile the original file
 * @param newFileName file name, no path
 * @return the new file as a file type object
 */
static File copyToTemporary (TemporaryFolder temporaryFolder,
                             File originalFile, String newFileName) {

    // get the overview from an existing test XML overview file
    final XMLOverview xmlOverview = new XMLOverview(originalFile);

    // try to save the overview under another, new name
    File newFile = null;
    try {
        // create a new temporary file
        newFile = temporaryFolder.newFile(newFileName);

        // save the overview in the temporary file, creating a copy
        xmlOverview.save(newFile);
    } catch (IOException e) {
        fail();
        e.printStackTrace();
    }

    return newFile;
}
 
开发者ID:clarin-eric,项目名称:oai-harvest-manager,代码行数:37,代码来源:TestHelper.java

示例15: createEnvironment

import org.junit.rules.TemporaryFolder; //导入依赖的package包/类
private void createEnvironment() throws IOException, PersistitException {
    closeDb();
    temporaryFolder = new TemporaryFolder();
    temporaryFolder.create();
    persistit = new Persistit();
    persistit.setPersistitLogger(new Slf4jAdapter(LoggerFactory.getLogger("PERSISTIT")));
    Properties props = new Properties();
    props.setProperty("datapath", temporaryFolder.getRoot().getAbsolutePath());
    props.setProperty("logpath", "${datapath}/log");
    props.setProperty("logfile", "${logpath}/persistit_${timestamp}.log");
    props.setProperty("buffer.count.8192", "5000");
    props.setProperty("journalpath", "${datapath}/journal");
    props.setProperty("tmpvoldir", "${datapath}");
    props.setProperty("volume.1", "${datapath}/persistit,create,pageSize:8192,initialPages:10,extensionPages:100,maximumPages:25000");
    props.setProperty("jmx", "false");
    persistit.setProperties(props);
    persistit.initialize();
    volume = persistit.createTemporaryVolume();

}
 
开发者ID:JetBrains,项目名称:xodus,代码行数:21,代码来源:JMHPersistItTokyoCabinetBenchmarkBase.java


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