本文整理汇总了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();
}
示例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);
}
}
示例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 ;
}
示例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());
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例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");
}
示例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());
}
示例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;
}
示例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());
}