本文整理汇总了Java中com.google.common.io.Files.createTempDir方法的典型用法代码示例。如果您正苦于以下问题:Java Files.createTempDir方法的具体用法?Java Files.createTempDir怎么用?Java Files.createTempDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.io.Files
的用法示例。
在下文中一共展示了Files.createTempDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupCommonConfig
import com.google.common.io.Files; //导入方法依赖的package包/类
protected Configuration setupCommonConfig() {
tmpOivImgDir = Files.createTempDir();
Configuration conf = new Configuration();
conf.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_CHECK_PERIOD_KEY, 1);
conf.setInt(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_TXNS_KEY, 5);
conf.setInt(DFSConfigKeys.DFS_HA_TAILEDITS_PERIOD_KEY, 1);
conf.set(DFSConfigKeys.DFS_NAMENODE_LEGACY_OIV_IMAGE_DIR_KEY,
tmpOivImgDir.getAbsolutePath());
conf.setBoolean(DFSConfigKeys.DFS_IMAGE_COMPRESS_KEY, true);
conf.set(DFSConfigKeys.DFS_IMAGE_COMPRESSION_CODEC_KEY,
SlowCodec.class.getCanonicalName());
CompressionCodecFactory.setCodecClasses(conf,
ImmutableList.<Class>of(SlowCodec.class));
return conf;
}
示例2: createBrokerService
import com.google.common.io.Files; //导入方法依赖的package包/类
private BrokerService createBrokerService(final String name) {
final BrokerService broker = new BrokerService();
broker.setPersistent(persistent);
broker.setBrokerName(name);
broker.setStartAsync(false);
tempDir = Files.createTempDir();
broker.setDataDirectoryFile(tempDir);
try {
broker.addConnector(createVmTransportServer(createVmTransportUri(name)));
} catch (Exception e) {
throw new IllegalStateException("Could not create VM Transport URI", e);
}
broker.setUseJmx(false);
return broker;
}
示例3: testComponentFields
import com.google.common.io.Files; //导入方法依赖的package包/类
@Test
public void testComponentFields() throws IOException {
File outputDir = Files.createTempDir();
System.out.println("Generating into " + outputDir.getAbsolutePath());
assertAbout(javaSources())
.that(Arrays.asList(componentClassBadField))
.processedWith(new VerifiedSpringConfiguration())
.failsToCompile()
.withErrorContaining("@Component classes my only have static final constant fields or final private fields")
.in(componentClassBadField)
.onLine(15)
.and()
.withErrorContaining("@Component classes my only have static final constant fields or final private fields")
.in(componentClassBadField)
.onLine(15);
}
示例4: getMetadataInternal
import com.google.common.io.Files; //导入方法依赖的package包/类
private EnumMap<SysProp, String> getMetadataInternal(File jdkPath) {
JavaExecAction exec = factory.newJavaExecAction();
exec.executable(javaExe(jdkPath, "java"));
File workingDir = Files.createTempDir();
exec.setWorkingDir(workingDir);
exec.setClasspath(new SimpleFileCollection(workingDir));
try {
writeProbe(workingDir);
exec.setMain(JavaProbe.CLASSNAME);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exec.setStandardOutput(baos);
ByteArrayOutputStream errorOutput = new ByteArrayOutputStream();
exec.setErrorOutput(errorOutput);
exec.setIgnoreExitValue(true);
ExecResult result = exec.execute();
int exitValue = result.getExitValue();
if (exitValue == 0) {
return parseExecOutput(baos.toString());
}
return error("Command returned unexpected result code: " + exitValue + "\nError output:\n" + errorOutput);
} catch (ExecException ex) {
return error(ex.getMessage());
} finally {
try {
FileUtils.deleteDirectory(workingDir);
} catch (IOException e) {
throw new GradleException("Unable to delete temp directory", e);
}
}
}
示例5: setUp
import com.google.common.io.Files; //导入方法依赖的package包/类
@Before
public void setUp() {
javac = ToolProvider.getSystemJavaCompiler();
diagnosticCollector = new DiagnosticCollector<>();
fileManager = javac.getStandardFileManager(diagnosticCollector, null, null);
tmpDir = Files.createTempDir();
}
示例6: testComponentImportTwoConstructorsNoAutowired
import com.google.common.io.Files; //导入方法依赖的package包/类
@Test
public void testComponentImportTwoConstructorsNoAutowired() throws IOException {
File outputDir = Files.createTempDir();
System.out.println("Generating into " + outputDir.getAbsolutePath());
assertAbout(javaSources())
.that(Arrays.asList(definitionClass, componentClassTwoConstructorsBusted))
.processedWith(new VerifiedSpringConfiguration())
.failsToCompile()
.withErrorContaining("No single default constructor or single @Autowired constructor")
.in(componentClassTwoConstructorsBusted)
.onLine(9);
}
示例7: setup
import com.google.common.io.Files; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
baseDir = Files.createTempDir();
keyStorePasswordFile = new File(baseDir, "keyStorePasswordFile");
Files.write("keyStorePassword", keyStorePasswordFile, Charsets.UTF_8);
keyAliasPassword = Maps.newHashMap();
keyStoreFile = new File(baseDir, "keyStoreFile");
Assert.assertTrue(keyStoreFile.createNewFile());
}
示例8: convertToStandardIds
import com.google.common.io.Files; //导入方法依赖的package包/类
static final ValidateSystemOutput.Preprocessor convertToStandardIds(
final LinkingStoreSource linkingStoreSource, final SystemOutputLayout outputLayout) {
return new ValidateSystemOutput.Preprocessor() {
@Override
public File preprocess(final File uncompressedSubmissionDir) throws IOException {
final File outputDir = Files.createTempDir();
ImportForeignIDs.importForeignIDs(uncompressedSubmissionDir, outputDir, linkingStoreSource,
outputLayout);
return outputDir;
}
};
}
示例9: prepareTestResources
import com.google.common.io.Files; //导入方法依赖的package包/类
private void prepareTestResources() throws IOException {
testResourcesDirectory = Files.createTempDir();
chromedriverFile = extractResource("chromedriver", testResourcesDirectory);
if (!chromedriverFile.setExecutable(true)) {
throw new IllegalStateException("Cannot set chrome driver file to executable");
}
configurationFile = extractResource(resourceConfigurationPath, ".brm", testResourcesDirectory);
measurementsFile = createTempFile("measurements.csv");
log4j2ConfigurationFile = extractResource("log4j2.xml", testResourcesDirectory);
Logger.getRootLogger().getLoggerRepository().resetConfiguration();
PropertyConfigurator.configure(log4j2ConfigurationFile.getAbsolutePath());
}
示例10: FileUploadTest
import com.google.common.io.Files; //导入方法依赖的package包/类
/**
*
*/
public FileUploadTest () {
try {
source = File.createTempFile("fut", "-source");
repo = Files.createTempDir();
}
catch ( IOException e ) {
e.printStackTrace();
}
}
示例11: init
import com.google.common.io.Files; //导入方法依赖的package包/类
@BeforeClass
void init() throws IOException
{
InputStream is=ProcessingManager.class.getResourceAsStream("size-test.zip");
File tmp_folder = Files.createTempDir();
File output = new File (tmp_folder, "size-test.zip");
FileUtils.copyInputStreamToFile(is, output);
is.close();
sample = output;
}
示例12: setup
import com.google.common.io.Files; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
fileID = 1;
transactionID = 1L;
dataDir = Files.createTempDir();
dataFile = new File(dataDir, String.valueOf(fileID));
Assert.assertTrue(dataDir.isDirectory());
logFileWriter = LogFileFactory.getWriter(dataFile, fileID,
Integer.MAX_VALUE, null, null, null, Long.MAX_VALUE, true, 0);
}
示例13: testLegacyOivImage
import com.google.common.io.Files; //导入方法依赖的package包/类
@Test
public void testLegacyOivImage() throws Exception {
MiniDFSCluster cluster = null;
SecondaryNameNode secondary = null;
File tmpDir = Files.createTempDir();
Configuration conf = new HdfsConfiguration();
conf.set(DFSConfigKeys.DFS_NAMENODE_LEGACY_OIV_IMAGE_DIR_KEY,
tmpDir.getAbsolutePath());
conf.set(DFSConfigKeys.DFS_NAMENODE_NUM_CHECKPOINTS_RETAINED_KEY,
"2");
try {
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0)
.format(true).build();
secondary = startSecondaryNameNode(conf);
// Checkpoint once
secondary.doCheckpoint();
String files1[] = tmpDir.list();
assertEquals("Only one file is expected", 1, files1.length);
// Perform more checkpointngs and check whether retention management
// is working.
secondary.doCheckpoint();
secondary.doCheckpoint();
String files2[] = tmpDir.list();
assertEquals("Two files are expected", 2, files2.length);
// Verify that the first file is deleted.
for (String fName : files2) {
assertFalse(fName.equals(files1[0]));
}
} finally {
cleanup(secondary);
cleanup(cluster);
tmpDir.delete();
}
}
示例14: setup
import com.google.common.io.Files; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
baseDir = Files.createTempDir();
tmpDir = new File(baseDir, "tmp");
dataDir = new File(baseDir, "data");
Assert.assertTrue(tmpDir.mkdir());
passwordFile = new File(baseDir, "password");
Files.write(PASSWORD.getBytes(Charsets.UTF_8), passwordFile);
broker = new BrokerService();
broker.addConnector(BROKER_BIND_URL);
broker.setTmpDataDirectory(tmpDir);
broker.setDataDirectoryFile(dataDir);
List<AuthenticationUser> users = Lists.newArrayList();
users.add(new AuthenticationUser(USERNAME, PASSWORD, ""));
SimpleAuthenticationPlugin authentication = new SimpleAuthenticationPlugin(users);
broker.setPlugins(new BrokerPlugin[]{authentication});
broker.start();
context = new Context();
context.put(JMSSourceConfiguration.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
context.put(JMSSourceConfiguration.PROVIDER_URL, BROKER_BIND_URL);
context.put(JMSSourceConfiguration.DESTINATION_NAME, DESTINATION_NAME);
context.put(JMSSourceConfiguration.USERNAME, USERNAME);
context.put(JMSSourceConfiguration.PASSWORD_FILE, passwordFile.getAbsolutePath());
events = Lists.newArrayList();
source = new JMSSource();
source.setName("JMSSource-" + UUID.randomUUID());
ChannelProcessor channelProcessor = mock(ChannelProcessor.class);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
events.addAll((List<Event>)invocation.getArguments()[0]);
return null;
}
}).when(channelProcessor).processEventBatch(any(List.class));
source.setChannelProcessor(channelProcessor);
}
示例15: setUp
import com.google.common.io.Files; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
/* Create 3 temp dirs, each used as value within agentProps */
final File sinkOutputDir = Files.createTempDir();
tempResources.add(sinkOutputDir);
final String sinkOutputDirPath = sinkOutputDir.getCanonicalPath();
LOGGER.info("Created rolling file sink's output dir: " + sinkOutputDirPath);
final File channelCheckpointDir = Files.createTempDir();
tempResources.add(channelCheckpointDir);
final String channelCheckpointDirPath = channelCheckpointDir.getCanonicalPath();
LOGGER.info("Created file channel's checkpoint dir: " + channelCheckpointDirPath);
final File channelDataDir = Files.createTempDir();
tempResources.add(channelDataDir);
final String channelDataDirPath = channelDataDir.getCanonicalPath();
LOGGER.info("Created file channel's data dir: " + channelDataDirPath);
/* Build props to pass to flume agent */
Properties agentProps = new Properties();
// Active sets
agentProps.put("a1.channels", "c1");
agentProps.put("a1.sources", "r1");
agentProps.put("a1.sinks", "k1");
// c1
agentProps.put("a1.channels.c1.type", "FILE");
agentProps.put("a1.channels.c1.checkpointDir", channelCheckpointDirPath);
agentProps.put("a1.channels.c1.dataDirs", channelDataDirPath);
// r1
agentProps.put("a1.sources.r1.channels", "c1");
agentProps.put("a1.sources.r1.type", "EXEC");
agentProps.put("a1.sources.r1.command", "seq 1 100");
// k1
agentProps.put("a1.sinks.k1.channel", "c1");
agentProps.put("a1.sinks.k1.type", "FILE_ROLL");
agentProps.put("a1.sinks.k1.sink.directory", sinkOutputDirPath);
agentProps.put("a1.sinks.k1.sink.rollInterval", "0");
this.agentProps = agentProps;
this.sinkOutputDir = sinkOutputDir;
}