當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。