List of usage examples for org.apache.commons.io FileUtils touch
public static void touch(File file) throws IOException
From source file:playRepository.GitRepositoryTest.java
@Test public void isFile() throws Exception { // Given/*from w w w . j a v a2s . co m*/ String userName = "yobi"; String projectName = "mytest"; String wcPath = GitRepository.getRepoPrefix() + userName + "/" + projectName; String repoPath = wcPath + "/.git"; String dirName = "dir"; String fileName = "file"; Repository repository = new RepositoryBuilder().setGitDir(new File(repoPath)).build(); repository.create(false); Git git = new Git(repository); FileUtils.forceMkdir(new File(wcPath + "/" + dirName)); FileUtils.touch(new File(wcPath + "/" + fileName)); git.add().addFilepattern(dirName).call(); git.add().addFilepattern(fileName).call(); git.commit().setMessage("test").call(); repository.close(); // When GitRepository gitRepository = new GitRepository(userName, projectName + "/"); // Then assertThat(gitRepository.isFile(dirName)).isEqualTo(false); assertThat(gitRepository.isFile(fileName)).isEqualTo(true); assertThat(gitRepository.isFile("not_exist_file")).isEqualTo(false); assertThat(gitRepository.isFile(fileName, "not_exist_branch")).isEqualTo(false); }
From source file:playRepository.GitRepositoryTest.java
@Test public void testGetAllBranches() throws IOException, GitAPIException { FakeApplication app = support.Helpers.makeTestApplication(); Helpers.start(app);/*from ww w.j av a2 s . c om*/ // Given String userName = "wansoon"; String projectName = "test"; Project project = createProject(userName, projectName); project.save(); String email = "test@email.com"; String wcPath = GitRepository.getRepoPrefix() + userName + "/" + "clone-" + projectName + ".git"; String repoPath = wcPath + "/.git"; String dirName = "dir"; String fileName = "file"; GitRepository gitRepository = new GitRepository(userName, projectName); gitRepository.create(); Repository repository = new RepositoryBuilder().setGitDir(new File(repoPath)).build(); repository.create(false); Git git = new Git(repository); FileUtils.forceMkdir(new File(wcPath + "/" + dirName)); FileUtils.touch(new File(wcPath + "/" + fileName)); git.add().addFilepattern(dirName).call(); git.add().addFilepattern(fileName).call(); git.commit().setMessage("test").setAuthor(userName, email).call(); String branchName = "testBranch"; git.branchCreate().setName(branchName).setForce(true).call(); git.push().setRemote(GitRepository.getGitDirectoryURL(project)) .setRefSpecs(new RefSpec(branchName + ":" + branchName)).setForce(true).call(); repository.close(); // When List<GitBranch> gitBranches = gitRepository.getBranches(); gitRepository.close(); // Then assertThat(gitBranches.size()).isEqualTo(1); assertThat(gitBranches.get(0).getShortName()).isEqualTo(branchName); Helpers.stop(app); }
From source file:stroom.streamstore.server.fs.TestFileSystemUtil.java
@Test public void testCreateChildStreamFile() throws IOException { final Stream md = Stream.createStreamForTesting(StreamType.RAW_EVENTS, Feed.createStub(1), null, DateUtil.parseNormalDateTimeString("2010-01-01T12:00:00.000Z")); md.setId(1001001L);/*w w w.j av a2 s.c o m*/ final File rootFile = FileSystemStreamTypeUtil.createRootStreamFile(buildTestVolume(), md, StreamType.RAW_EVENTS); FileUtils.touch(rootFile); final File child1 = FileSystemStreamTypeUtil.createChildStreamFile(rootFile, StreamType.CONTEXT); FileUtils.touch(child1); assertPathEndsWith(child1, "EVENTS/2010/01/01/001/001/1=001001001.revt.ctx.bgz"); final File child2 = FileSystemStreamTypeUtil.createChildStreamFile(rootFile, StreamType.SEGMENT_INDEX); FileUtils.touch(child2); assertPathEndsWith(child2, "EVENTS/2010/01/01/001/001/1=001001001.revt.seg.dat"); final File child1_1 = FileSystemStreamTypeUtil.createChildStreamFile(child1, StreamType.SEGMENT_INDEX); FileUtils.touch(child1_1); assertPathEndsWith(child1_1, "EVENTS/2010/01/01/001/001/1=001001001.revt.ctx.seg.dat"); final List<File> kids = FileSystemStreamTypeUtil.findAllDescendantStreamFileList(rootFile); Assert.assertEquals("should match 3 kids", 3, kids.size()); for (final File kid : kids) { FileUtil.deleteFile(kid); } FileUtil.deleteFile(rootFile); }
From source file:tayler.TailerTest.java
protected void createFile(File file) throws IOException { FileUtils.deleteQuietly(file); FileUtils.touch(file); }