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


Java TemporaryFolder.newFolder方法代码示例

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


在下文中一共展示了TemporaryFolder.newFolder方法的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: 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

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

示例4: HgTestRepo

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
public HgTestRepo(String workingCopyName, TemporaryFolder temporaryFolder) throws IOException {
    super(temporaryFolder);
    File tempFolder = temporaryFolder.newFolder();

    remoteRepo = new File(tempFolder, "remote-repo");
    remoteRepo.mkdirs();
    //Copy file to work around bug in hg
    File bundleToExtract = new File(tempFolder, "repo.bundle");
    FileUtils.copyFile(new File(HG_BUNDLE_FILE), bundleToExtract);
    setUpServerRepoFromHgBundle(remoteRepo, bundleToExtract);

    File workingCopy = new File(tempFolder, workingCopyName);
    hgCommand = new HgCommand(null, workingCopy, "default", remoteRepo.getAbsolutePath(), null);
    InMemoryStreamConsumer output = inMemoryConsumer();
    if (hgCommand.clone(output, new UrlArgument(remoteRepo.getAbsolutePath())) != 0) {
        fail("Error creating repository\n" + output.getAllOutput());
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:19,代码来源:HgTestRepo.java

示例5: P4TestRepo

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
private P4TestRepo(int port, String repoPrototype, String user, String password, String clientName,
                   boolean useTickets, TemporaryFolder temporaryFolder, File clientFolder) throws IOException {
    super(temporaryFolder);
    this.port = port;
    this.user = user;
    this.password = password;
    this.clientName = clientName;
    this.useTickets = useTickets;
    tempRepo = temporaryFolder.newFolder();
    this.clientFolder = clientFolder;
    try {
        copyDirectory(new File(repoPrototype), tempRepo);
    } catch (IOException e) {
        bomb(e);
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:17,代码来源:P4TestRepo.java

示例6: copyAppToTempDir

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
private static File copyAppToTempDir(TemporaryFolder temporaryFolder, File file) throws IOException {
    File tmpDir = temporaryFolder.newFolder(file.getName());
    if (tmpDir.exists()) {
        FileUtils.forceDelete(tmpDir);
    }
    tmpDir.mkdirs();
    FileUtils.copyDirectory(file, tmpDir);
    return tmpDir;
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:10,代码来源:SampleProjects.java

示例7: explodeTestApp

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
private static File explodeTestApp(File file, TemporaryFolder temporaryFolder) throws IOException {
    File unpackDir = temporaryFolder.newFolder(file.getName());
    if (unpackDir.exists()) {
        FileUtils.forceDelete(unpackDir);
    }
    unpackDir.mkdir();
    ZipFile zipFile = new ZipFile(file);
    try {
        unpackZip(zipFile, unpackDir);
    } finally {
        zipFile.close();
    }
    return unpackDir;
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:15,代码来源:SampleProjects.java

示例8: KafkaEmbedded

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded Kafka broker.
 *
 * @param config Broker configuration settings.  Used to modify, for example, on which port the
 *               broker should listen to.  Note that you cannot change the `log.dirs` setting
 *               currently.
 */
public KafkaEmbedded(final Properties config, final MockTime time) throws IOException {
    tmpFolder = new TemporaryFolder();
    tmpFolder.create();
    logDir = tmpFolder.newFolder();
    effectiveConfig = effectiveConfigFrom(config);
    final boolean loggingEnabled = true;
    final KafkaConfig kafkaConfig = new KafkaConfig(effectiveConfig, loggingEnabled);
    log.debug("Starting embedded Kafka broker (with log.dirs={} and ZK ensemble at {}) ...",
        logDir, zookeeperConnect());
    kafka = TestUtils.createServer(kafkaConfig, time);
    log.debug("Startup of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...",
        brokerList(), zookeeperConnect());
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:21,代码来源:KafkaEmbedded.java

示例9: KafkaEmbedded

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded Kafka broker.
 *
 * @param config Broker configuration settings.  Used to modify, for example, on which port the
 *               broker should listen to.  Note that you cannot change some settings such as
 *               `log.dirs`, `port`.
 */
public KafkaEmbedded(Properties config) throws IOException {
  tmpFolder = new TemporaryFolder();
  tmpFolder.create();
  logDir = tmpFolder.newFolder();
  effectiveConfig = effectiveConfigFrom(config);
  boolean loggingEnabled = true;

  KafkaConfig kafkaConfig = new KafkaConfig(effectiveConfig, loggingEnabled);
  log.debug("Starting embedded Kafka broker (with log.dirs={} and ZK ensemble at {}) ...",
      logDir, zookeeperConnect());
  kafka = TestUtils.createServer(kafkaConfig, Time.SYSTEM);
  log.debug("Startup of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...",
      brokerList(), zookeeperConnect());
}
 
开发者ID:kaiwaehner,项目名称:kafka-streams-machine-learning-examples,代码行数:22,代码来源:KafkaEmbedded.java

示例10: setUpAppEngineWebXml

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
protected void setUpAppEngineWebXml() throws IOException {
  TemporaryFolder tempFolder = new TemporaryFolder();
  tempFolder.create();
  File webInf = tempFolder.newFolder("build", "artifact", "WEB-INF");
  new File(webInf, "appengine-web.xml").createNewFile();
  when(mavenProjectMock.getBuild()).thenReturn(mock(Build.class));
  when(mavenProjectMock.getBuild().getDirectory())
      .thenReturn(webInf.getParentFile().getParentFile().getAbsolutePath());
  when(mavenProjectMock.getBuild().getFinalName()).thenReturn("artifact");
}
 
开发者ID:GoogleCloudPlatform,项目名称:app-maven-plugin,代码行数:11,代码来源:AbstractDevServerTest.java

示例11: KafkaEmbedded

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded Kafka broker.
 *
 * @param config Broker configuration settings.  Used to modify, for example, on which port the
 *               broker should listen to.  Note that you cannot change the `log.dirs` setting
 *               currently.
 */
public KafkaEmbedded(final Properties config, final MockTime time) throws IOException {
  tmpFolder = new TemporaryFolder();
  tmpFolder.create();
  logDir = tmpFolder.newFolder();
  effectiveConfig = effectiveConfigFrom(config);
  final boolean loggingEnabled = true;
  final KafkaConfig kafkaConfig = new KafkaConfig(effectiveConfig, loggingEnabled);
  log.debug("Starting embedded Kafka broker (with log.dirs={} and ZK ensemble at {}) ...",
      logDir, zookeeperConnect());
  kafka = TestUtils.createServer(kafkaConfig, time);
  log.debug("Startup of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...",
      brokerList(), zookeeperConnect());
}
 
开发者ID:Landoop,项目名称:kafka-testkit,代码行数:21,代码来源:KafkaEmbedded.java

示例12: TestProject

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
public TestProject(TemporaryFolder tempFolder, Class<?>... classes)
		throws IOException {
	this.sourceFolder = tempFolder.newFolder();
	this.compiler = new TestCompiler(tempFolder) {
		@Override
		protected File getSourceFolder() {
			return TestProject.this.sourceFolder;
		}
	};
	Set<Class<?>> contents = new HashSet<Class<?>>(Arrays.asList(classes));
	contents.addAll(Arrays.asList(ALWAYS_INCLUDE));
	copySources(contents);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:TestProject.java

示例13: TestCompiler

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
public TestCompiler(JavaCompiler compiler, TemporaryFolder temporaryFolder)
		throws IOException {
	this.compiler = compiler;
	this.fileManager = compiler.getStandardFileManager(null, null, null);
	this.outputLocation = temporaryFolder.newFolder();
	Iterable<? extends File> temp = Arrays.asList(this.outputLocation);
	this.fileManager.setLocation(StandardLocation.CLASS_OUTPUT, temp);
	this.fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, temp);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:TestCompiler.java

示例14: makeTempDir

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
public static File makeTempDir(TemporaryFolder parentDir, String prefix, String suffix)
    throws IOException {
  File temp = parentDir.newFolder(prefix + suffix);
  assertTrue(temp.delete());
  assertTrue(temp.mkdir());

  return temp;
}
 
开发者ID:GoogleCloudPlatform,项目名称:jenkins-deployment-manager-plugin,代码行数:9,代码来源:PathUtils.java

示例15: KafkaEmbedded

import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
/**
 * Creates and starts an embedded Kafka broker.
 *
 * @param config Broker configuration settings.  Used to modify, for example, on which port the
 *               broker should listen to.  Note that you cannot change some settings such as
 *               `log.dirs`, `port`.
 */
public KafkaEmbedded(Properties config) throws IOException {
  tmpFolder = new TemporaryFolder();
  tmpFolder.create();
  logDir = tmpFolder.newFolder();
  effectiveConfig = effectiveConfigFrom(config);
  boolean loggingEnabled = true;

  KafkaConfig kafkaConfig = new KafkaConfig(effectiveConfig, loggingEnabled);
  log.debug("Starting embedded Kafka broker (with log.dirs={} and ZK ensemble at {}) ...",
      logDir, zookeeperConnect());
  kafka = TestUtils.createServer(kafkaConfig, new SystemTime());
  log.debug("Startup of embedded Kafka broker at {} completed (with ZK ensemble at {}) ...",
      brokerList(), zookeeperConnect());
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:22,代码来源:KafkaEmbedded.java


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