Package org.junit.rules

Examples of org.junit.rules.TemporaryFolder


  @Rule
  public TemporaryFolder temporaryProfileDirectory;

  @Before
  public void beforeEach() throws IOException {
    existingProfileDirectory = new TemporaryFolder();
    temporaryProfileDirectory = new TemporaryFolder();
    existingProfileDirectory.create();
    temporaryProfileDirectory.create();
    existingProfile = existingProfileDirectory.getRoot();
    temporaryProfile = temporaryProfileDirectory.getRoot();
View Full Code Here


  @Rule
  public TemporaryFolder temporaryFolder;

  @Before
  public void beforeEach() throws IOException {
    temporaryFolder = new TemporaryFolder();
    temporaryFolder.create();

    switch (currentProduct()) {
      case DESKTOP:
        iniFile = temporaryFolder.newFile("operaprefs.ini");
View Full Code Here

        tmpFolder.delete();
    }

    @BeforeClass
    public static void bootstrap() throws IOException {
        tmpFolder = new TemporaryFolder();
        tmpFolder.create();
        fedoraHomeFixture = fakeFedoraHome();
    }
View Full Code Here

  private static List<Mutation> recover(Map<String,KeyValue[]> logs, KeyExtent extent) throws IOException {
    return recover(logs, new HashSet<String>(), extent);
  }

  private static List<Mutation> recover(Map<String,KeyValue[]> logs, Set<String> files, KeyExtent extent) throws IOException {
    TemporaryFolder root = new TemporaryFolder(new File(System.getProperty("user.dir") + "/target"));
    root.create();
    final String workdir = root.getRoot().getAbsolutePath() + "/workdir";
    VolumeManager fs = VolumeManagerImpl.getLocal(workdir);
    final Path workdirPath = new Path("file://" + workdir);
    fs.deleteRecursively(workdirPath);
    ArrayList<Path> dirs = new ArrayList<Path>();
    try {
      for (Entry<String,KeyValue[]> entry : logs.entrySet()) {
        String path = workdir + "/" + entry.getKey();
        FileSystem ns = fs.getVolumeByPath(new Path(path)).getFileSystem();
        @SuppressWarnings("deprecation")
        Writer map = new MapFile.Writer(ns.getConf(), ns, path + "/log1", LogFileKey.class, LogFileValue.class);
        for (KeyValue lfe : entry.getValue()) {
          map.append(lfe.key, lfe.value);
        }
        map.close();
        ns.create(new Path(path, "finished")).close();
        dirs.add(new Path(path));
      }
      // Recover
      SortedLogRecovery recovery = new SortedLogRecovery(fs);
      CaptureMutations capture = new CaptureMutations();
      recovery.recover(extent, dirs, files, capture);
      return capture.result;
    } finally {
      root.delete();
    }
  }
View Full Code Here

public class GeogigPy4JEntryPointTest {

    @Before
    public void setUpDirectories() throws IOException {
        tempFolder = new TemporaryFolder();
        tempFolder.create();
        File homeDirectory = tempFolder.newFolder("fakeHomeDir").getCanonicalFile();
        File currentDirectory = tempFolder.newFolder("testrepo").getCanonicalFile();
        GlobalState.platform = new TestPlatform(currentDirectory, homeDirectory);
        GlobalContextBuilder.builder = new CLITestContextBuilder(platform);
View Full Code Here

    private static final String LINE_SEPARATOR = System.getProperty("line.separator");

    @cucumber.annotation.Before
    public void before() throws Exception {
        tempFolder = new TemporaryFolder();
        tempFolder.create();
        setupFeatures();
    }
View Full Code Here

  private volatile File sourceLocalDirectory;

  private volatile File targetLocalDirectory;

  public TestSftpServer() {
    this.sftpFolder = new TemporaryFolder() {

      @Override
      public void create() throws IOException {
        super.create();
        sftpRootFolder = this.newFolder("test");
        sourceSftpDirectory = new File(sftpRootFolder, "sftpSource");
        sourceSftpDirectory.mkdir();
        File file = new File(sourceSftpDirectory, "sftpSource1.txt");
        file.createNewFile();
        FileOutputStream fos = new FileOutputStream(file);
        fos.write("source1".getBytes());
        fos.close();
        file = new File(sourceSftpDirectory, "sftpSource2.text");
        file.createNewFile();
        fos = new FileOutputStream(file);
        fos.write("source2".getBytes());
        fos.close();

        File subSourceFtpDirectory = new File(sourceSftpDirectory, "subSftpSource");
        subSourceFtpDirectory.mkdir();
        file = new File(subSourceFtpDirectory, "subSftpSource1.txt");
        file.createNewFile();
        fos = new FileOutputStream(file);
        fos.write("subSource1".getBytes());
        fos.close();

        targetSftpDirectory = new File(sftpRootFolder, "sftpTarget");
        targetSftpDirectory.mkdir();
      }
    };
    this.localFolder = new TemporaryFolder() {

      @Override
      public void create() throws IOException {
        super.create();
        File rootFolder = this.newFolder("test");
View Full Code Here

  private volatile File targetLocalDirectory;

  private volatile FtpServer server;

  public TestFtpServer(final String root) {
    this.ftpFolder = new TemporaryFolder() {

      @Override
      public void create() throws IOException {
        super.create();
        ftpRootFolder = this.newFolder(root);
        sourceFtpDirectory = new File(ftpRootFolder, "ftpSource");
        sourceFtpDirectory.mkdir();
        File file = new File(sourceFtpDirectory, "ftpSource1.txt");
        file.createNewFile();
        FileOutputStream fos = new FileOutputStream(file);
        fos.write("source1".getBytes());
        fos.close();
        file = new File(sourceFtpDirectory, "ftpSource2.txt");
        file.createNewFile();
        fos = new FileOutputStream(file);
        fos.write("source2".getBytes());
        fos.close();

        File subSourceFtpDirectory = new File(sourceFtpDirectory, "subFtpSource");
        subSourceFtpDirectory.mkdir();
        file = new File(subSourceFtpDirectory, "subFtpSource1.txt");
        file.createNewFile();
        fos = new FileOutputStream(file);
        fos.write("subSource1".getBytes());
        fos.close();

        targetFtpDirectory = new File(ftpRootFolder, "ftpTarget");
        targetFtpDirectory.mkdir();
      }
    };
    this.localFolder = new TemporaryFolder() {

      @Override
      public void create() throws IOException {
        super.create();
        File rootFolder = this.newFolder(root);
View Full Code Here

    }
  }

  @Test
  public void recursiveDeleteFolderWithOneElement() throws IOException {
    TemporaryFolder folder= new TemporaryFolder();
    folder.create();
    File file= folder.newFile("a");
    folder.delete();
    assertFalse(file.exists());
    assertFalse(folder.getRoot().exists());
  }
View Full Code Here

    assertFalse(folder.getRoot().exists());
  }

  @Test
  public void recursiveDeleteFolderWithOneRandomElement() throws IOException {
    TemporaryFolder folder= new TemporaryFolder();
    folder.create();
    File file= folder.newFile();
    folder.delete();
    assertFalse(file.exists());
    assertFalse(folder.getRoot().exists());
  }
View Full Code Here

TOP

Related Classes of org.junit.rules.TemporaryFolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.