Java 类org.junit.rules.TemporaryFolder 实例源码

项目:mycore    文件:MCRTestCaseHelper.java   
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();
}
项目:svg-stockpile    文件:GradleBuildFileBehaviour.java   
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);
        }
    };
}
项目:aml    文件:Swagger2RamlTest.java   
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();
    }
}
项目:binaryprefs    文件:PreferencesCreator.java   
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);
    }
}
项目:platypus-kb-lucene    文件:FakeWikidataLuceneIndexFactory.java   
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();
    }
}
项目:beam    文件:TextIOReadTest.java   
/**
 * 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;
}
项目:flink    文件:PartitionedStateCheckpointingITCase.java   
@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);
}
项目:Gaffer    文件:RestApiTestClient.java   
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();
}
项目:digdag    文件:TestUtils.java   
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());
    }
}
项目:l10n-maven-plugin    文件:ValidateMojoIT.java   
@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();
}
项目:activemq-artemis    文件:EmbeddedBrokerTestSupport.java   
@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();
}
项目:swift-explorer    文件:TestUtils.java   
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 ;
}
项目:jarup    文件:WorkingCopyRule.java   
@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);
}
项目:oai-harvest-manager    文件:TestHelper.java   
/**
 * <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;
}
项目:xodus    文件:JMHPersistItTokyoCabinetBenchmarkBase.java   
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();

}
项目:questdb    文件:QueryHandlerTest.java   
private static String downloadStr(String queryUrl, int limitFrom, int limitTo, boolean noMeta, boolean count, TemporaryFolder temp) throws Exception {
    File f = temp.newFile();
    String url = "http://localhost:9000/js?query=" + URLEncoder.encode(queryUrl, "UTF-8");
    if (limitFrom >= 0) {
        url += "&limit=" + limitFrom;
    }
    if (limitTo >= 0) {
        url += "," + limitTo;
    }

    if (noMeta) {
        url += "&nm=true";
    }

    if (count) {
        url += "&count=true";
    }

    HttpTestUtils.download(HttpTestUtils.clientBuilder(false), url, f);
    return Files.readStringFromFile(f);
}
项目:incubator-twill    文件:YarnTestUtils.java   
public static final boolean initOnce() throws IOException {
  if (once.compareAndSet(false, true)) {
    final TemporaryFolder tmpFolder = new TemporaryFolder();
    tmpFolder.create();
    init(tmpFolder.newFolder());

    // add shutdown hook because we want to initialized/cleanup once
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
      @Override
      public void run() {
        try {
          finish();
        } finally {
          tmpFolder.delete();
        }
      }
    }));
    return true;
  }
  return false;
}
项目:parquet-mr    文件:AvroTestUtil.java   
@SuppressWarnings("unchecked")
public static <D> File write(TemporaryFolder temp, GenericData model, Schema schema, D... data) throws IOException {
  File file = temp.newFile();
  Assert.assertTrue(file.delete());
  ParquetWriter<D> writer = AvroParquetWriter
      .<D>builder(new Path(file.toString()))
      .withDataModel(model)
      .withSchema(schema)
      .build();

  try {
    for (D datum : data) {
      writer.write(datum);
    }
  } finally {
    writer.close();
  }

  return file;
}
项目:mod-neo4j-persistor    文件:Neo4jPersistorTest.java   
@Override
public void start() {
    super.start();
    tmpFolder = new TemporaryFolder();
    try {
        tmpFolder.create();
    } catch (IOException e) {
        e.printStackTrace();
        return;
    }
    JsonObject config = new JsonObject();
    config.putString("address", TEST_PERSISTOR);
    config.putString("datastore-path", tmpFolder.getRoot().getAbsolutePath());
    container.deployModule(System.getProperty("vertx.modulename"), config, 1,
            new AsyncResultHandler<String>() {
        public void handle(AsyncResult<String> ar) {
            if (ar.succeeded()) {
                Neo4jPersistorTest.super.start();
            } else {
                ar.cause().printStackTrace();
            }
        }
    });
}
项目:gocd    文件:HgTestRepo.java   
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());
    }
}
项目:gocd    文件:P4TestRepo.java   
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);
    }
}
项目:buck    文件:RuleKeyLoggerListenerTest.java   
@Before
public void setUp() throws InterruptedException, IOException {
  TemporaryFolder tempDirectory = new TemporaryFolder();
  tempDirectory.create();
  projectFilesystem =
      TestProjectFilesystems.createProjectFilesystem(tempDirectory.getRoot().toPath());
  outputExecutor =
      MostExecutors.newSingleThreadExecutor(new CommandThreadFactory(getClass().getName()));
  info =
      InvocationInfo.of(
          new BuildId(),
          false,
          false,
          "topspin",
          ImmutableList.of(),
          ImmutableList.of(),
          tempDirectory.getRoot().toPath());
  durationTracker = new BuildRuleDurationTracker();
}
项目:camunda-bpm-platform    文件:JerseySpecifics.java   
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      TomcatServerBootstrap bootstrap = new JerseyTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
项目:camunda-bpm-platform    文件:WinkSpecifics.java   
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      WinkTomcatServerBootstrap bootstrap = new WinkTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
项目:camunda-bpm-platform    文件:JerseySpecifics.java   
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      TomcatServerBootstrap bootstrap = new JerseyTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
项目:camunda-bpm-platform    文件:CXFSpecifics.java   
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      TomcatServerBootstrap bootstrap = new CXFTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
项目:camunda-bpm-platform    文件:ResteasySpecifics.java   
public TestRule createTestRule() {
  final TemporaryFolder tempFolder = new TemporaryFolder();

  return RuleChain
    .outerRule(tempFolder)
    .around(new ExternalResource() {

      ResteasyTomcatServerBootstrap bootstrap = new ResteasyTomcatServerBootstrap(webXmlResource);

      protected void before() throws Throwable {
        bootstrap.setWorkingDir(tempFolder.getRoot().getAbsolutePath());
        bootstrap.start();
      }

      protected void after() {
        bootstrap.stop();
      }
    });
}
项目:gradle-circle-style    文件:TestCommon.java   
public static File copyTestFile(String source, TemporaryFolder root, String target) {
    File targetFile = new File(root.getRoot(), target);
    targetFile.getParentFile().mkdirs();
    try (OutputStream stream = new FileOutputStream(targetFile)) {
        Resources.copy(WhoCalled.$.getCallingClass().getResource(source), stream);
        return targetFile;
    } catch (IOException e) {
        throw new AssertionError(e);
    }
}
项目:r8    文件:ToolHelper.java   
public static TemporaryFolder getTemporaryFolderForTest() {
  String tmpDir = System.getProperty("test_dir");
  if (tmpDir == null) {
    return new TemporaryFolder(ToolHelper.isLinux() ? null : Paths.get("build", "tmp").toFile());
  } else {
    return new RetainedTemporaryFolder(new java.io.File(tmpDir));
  }
}
项目:cf-java-client-sap    文件:SampleProjects.java   
public static File appWithScmMetaData(TemporaryFolder temporaryFolder) throws IOException {
    File appDirectory = new File(TEST_APP_DIR + "/app-with-scm-metadata");
    File tmpAppDirectory = copyAppToTempDir(temporaryFolder, appDirectory);
    addExampleGitRepo(tmpAppDirectory);

    // For the scenario of having a repo in a subdirectory
    File subProject = new File(tmpAppDirectory, "sub-project");
    subProject.mkdir();
    addExampleGitRepo(subProject);

    return tmpAppDirectory;
}
项目:cf-java-client-sap    文件:SampleProjects.java   
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;
}
项目:cf-java-client-sap    文件:SampleProjects.java   
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;
}
项目:xenon-utils    文件:TestGatewayHost.java   
public void startSynchronously(GatewayHost.Arguments args) throws Throwable {
    // Create a temp folder that will be used as the sandbox
    // directory for the app.
    if (this.folder == null) {
        this.folder = new TemporaryFolder();
        this.folder.create();
    }

    // Update the arguments with the sandbox temp directory.
    if (this.arguments == null) {
        args.sandbox = this.folder.getRoot().toPath();
        this.arguments = args;
    }

    final TestContext ctx = TestContext.create(1,
            TimeUnit.SECONDS.toMicros(this.timeoutSeconds));
    start(args, (t) -> {
        if (t != null) {
            ctx.failIteration(t);
            return;
        }
        ctx.completeIteration();
    });
    ctx.await();

    if (this.ngManager == null) {
        this.ngManager = new TestNodeGroupManager();
        this.ngManager.addHost(this.configHost);
    }

    if (this.peerGateways == null) {
        this.peerGateways = new ArrayList<>();
    }
}
项目:directory-mavibot    文件:PageReclaimerTest.java   
@Before
public void setup() throws Exception
{
    tmpDir = new TemporaryFolder();
    tmpDir.create();

    dbFile = tmpDir.newFile( "spacereclaimer.db" );

    //System.out.println(dbFile.getAbsolutePath());
    rm = new RecordManager( dbFile.getAbsolutePath() );
    rm.setPageReclaimerThreshold( 10 );

    uidTree = ( PersistedBTree<Integer, String> ) rm.addBTree( TREE_NAME, IntSerializer.INSTANCE, StringSerializer.INSTANCE, false );
}
项目:gretl    文件:TestUtil.java   
public static File createFile(TemporaryFolder folder, String stm, String fileName) throws IOException {
    File sqlFile =  folder.newFile(fileName);
    BufferedWriter writer = new BufferedWriter(new FileWriter(sqlFile));
    writer.write(stm);
    writer.close();

    return sqlFile;
}
项目:gradle-dependency-metadata-plugin    文件:GradleTestHelper.java   
public static BuildResult executeBuild(TemporaryFolder testProjectDir, String... tasks) {
    return GradleRunner.create()
            .withProjectDir(testProjectDir.getRoot())
            .withArguments(tasks)
            .forwardOutput()
            .withPluginClasspath()
            .build();
}
项目:Lagerta    文件:EmbeddedKafkaRule.java   
public EmbeddedKafkaRule(TemporaryFolder folder, String resourceName, int numberOfKafkaBrokers, int zookeeperPort,
    int kafkaPort) {
    super(resourceName);
    this.folder = folder;
    this.numberOfKafkaBrokers = numberOfKafkaBrokers;
    this.zookeeperPort = zookeeperPort;
    this.kafkaPort = kafkaPort;
}
项目:monarch    文件:SerializableTemporaryFolderTest.java   
@Test
public void fieldsCanBeRead() throws Exception {
  File parentFolder = this.temporaryFolder.getRoot();

  SerializableTemporaryFolder instance = new SerializableTemporaryFolder(parentFolder);
  instance.create();

  assertThat(readField(TemporaryFolder.class, instance, FIELD_PARENT_FOLDER))
      .isEqualTo(parentFolder);
  assertThat(readField(TemporaryFolder.class, instance, FIELD_FOLDER))
      .isEqualTo(instance.getRoot());
}
项目:monarch    文件:SerializableTemporaryFolderTest.java   
@Test
public void canBeSerialized() throws Exception {
  File parentFolder = this.temporaryFolder.getRoot();

  SerializableTemporaryFolder instance = new SerializableTemporaryFolder(parentFolder);
  instance.create();

  SerializableTemporaryFolder cloned =
      (SerializableTemporaryFolder) SerializationUtils.clone(instance);

  assertThat(readField(TemporaryFolder.class, cloned, FIELD_PARENT_FOLDER))
      .isEqualTo(parentFolder);
  assertThat(readField(TemporaryFolder.class, cloned, FIELD_FOLDER)).isEqualTo(cloned.getRoot());
}
项目:kafka-0.11.0.0-src-with-comment    文件:KafkaEmbedded.java   
/**
 * 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());
}