Java Code Examples for org.eclipse.jgit.util.FileUtils#delete()
The following examples show how to use
org.eclipse.jgit.util.FileUtils#delete() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitCloneTest.java From orion.server with Eclipse Public License 1.0 | 6 votes |
@Test public void testCloneNotGitRepository() throws Exception { createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME); String workspaceId = getWorkspaceId(workspaceLocation); JSONObject project = createProjectOrLink(workspaceLocation, getMethodName().concat("Project"), null); IPath clonePath = new Path("file").append(workspaceId).append(project.getString(ProtocolConstants.KEY_NAME)).makeAbsolute(); // clone File notAGitRepository = createTempDir().toFile(); assertTrue(notAGitRepository.isDirectory()); assertTrue(notAGitRepository.list().length == 0); WebRequest request = getPostGitCloneRequest(notAGitRepository.toURI().toString(), clonePath); WebResponse response = webConversation.getResponse(request); ServerStatus status = waitForTask(response); assertFalse(status.toString(), status.isOK()); assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, status.getHttpCode()); assertEquals("Error cloning git repository", status.getMessage()); assertNotNull(status.getJsonData()); assertEquals(status.toString(), "Invalid remote: origin", status.getException().getMessage()); // cleanup the tempDir FileUtils.delete(notAGitRepository, FileUtils.RECURSIVE); }
Example 2
Source File: ConfigServerTestUtils.java From spring-cloud-config with Apache License 2.0 | 5 votes |
public static String prepareLocalSvnRepo(String sourceDir, String checkoutDir) throws Exception { File sourceDirFile = new File(sourceDir); sourceDirFile.mkdirs(); File local = new File(checkoutDir); if (local.exists()) { FileUtils.delete(local, FileUtils.RECURSIVE); } local.mkdirs(); FileSystemUtils.copyRecursively(sourceDirFile, local); return StringUtils.cleanPath("file:///" + local.getAbsolutePath()); }
Example 3
Source File: JGitEnvironmentRepositoryIntegrationTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Before public void init() throws Exception { if (this.basedir.exists()) { FileUtils.delete(this.basedir, FileUtils.RECURSIVE); } ConfigServerTestUtils.deleteLocalRepo(""); }
Example 4
Source File: GitPersistenceResourceTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@After public void deleteDirectoriesAndFiles() throws Exception { if (repository != null) { repository.close(); } FileUtils.delete(root.toFile(), FileUtils.RECURSIVE | FileUtils.RETRY); }
Example 5
Source File: AbstractGitRepositoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected void closeRepository() throws Exception{ if (repository != null) { repository.close(); } if (Files.exists(getDotGitDir())) { FileUtils.delete(getDotGitDir().toFile(), FileUtils.RECURSIVE | FileUtils.RETRY); } if(Files.exists(getDotGitIgnore())) { FileUtils.delete(getDotGitIgnore().toFile(), FileUtils.RECURSIVE | FileUtils.RETRY); } }
Example 6
Source File: AbstractParallelGitTest.java From ParallelGit with Apache License 2.0 | 5 votes |
@After public void closeRepository() throws IOException { if(repo != null) repo.close(); if(repoDir != null && repoDir.exists()) FileUtils.delete(repoDir, FileUtils.RECURSIVE); }
Example 7
Source File: AbstractParallelGitTest.java From ParallelGit with Apache License 2.0 | 5 votes |
@After public void closeRepository() throws IOException { if(repo != null) repo.close(); if(repoDir != null && repoDir.exists()) FileUtils.delete(repoDir, FileUtils.RECURSIVE); }
Example 8
Source File: TestUtils.java From spring-cloud-release-tools with Apache License 2.0 | 5 votes |
private static void prepareLocalRepo(String buildDir, String repoPath) throws IOException { File dotGit = new File(buildDir + repoPath + "/.git"); File git = new File(buildDir + repoPath + "/git"); if (git.exists()) { if (dotGit.exists()) { FileUtils.delete(dotGit, FileUtils.RECURSIVE); } } git.renameTo(dotGit); }
Example 9
Source File: ConfigServerTestUtils.java From spring-cloud-config with Apache License 2.0 | 5 votes |
public static String prepareLocalRepo(String baseDir, String buildDir, String repoPath, String checkoutDir) throws IOException { buildDir = baseDir + buildDir; new File(buildDir).mkdirs(); if (!repoPath.startsWith("/")) { repoPath = "/" + repoPath; } if (!repoPath.endsWith("/")) { repoPath = repoPath + "/"; } File source = new File(baseDir + "src/test/resources" + repoPath); File dest = new File(buildDir + repoPath); if (dest.exists()) { FileUtils.delete(dest, FileUtils.RECURSIVE | FileUtils.RETRY); } FileSystemUtils.copyRecursively(source, dest); File dotGit = new File(buildDir + repoPath + ".git"); File git = new File(buildDir + repoPath + "git"); if (git.exists()) { if (dotGit.exists()) { FileUtils.delete(dotGit, FileUtils.RECURSIVE); } } git.renameTo(dotGit); File local = new File(checkoutDir); if (local.exists()) { FileUtils.delete(local, FileUtils.RECURSIVE); } if (!buildDir.startsWith("/")) { buildDir = "./" + buildDir; } return "file:" + buildDir + repoPath; }
Example 10
Source File: MultipleJGitEnvironmentRepositoryIntegrationTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Before public void init() throws Exception { if (this.basedir.exists()) { FileUtils.delete(this.basedir, FileUtils.RECURSIVE); } ConfigServerTestUtils.deleteLocalRepo("config-copy"); }
Example 11
Source File: GitUriTest.java From orion.server with Eclipse Public License 1.0 | 5 votes |
@Test public void testGitUrisForFile() throws Exception { createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME); File dir = createTempDir().toFile(); dir.mkdir(); File file = new File(dir, "test.txt"); file.createNewFile(); ServletTestingSupport.allowedPrefixes = dir.toString(); String projectName = getMethodName().concat("Project"); JSONObject project = createProjectOrLink(workspaceLocation, projectName, dir.toString()); String location = project.getString(ProtocolConstants.KEY_CONTENT_LOCATION); WebRequest request = getGetRequest(location); WebResponse response = webConversation.getResponse(request); assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode()); JSONObject files = new JSONObject(response.getText()); assertNull(files.optString(GitConstants.KEY_STATUS, null)); assertNull(files.optString(GitConstants.KEY_DIFF, null)); assertNull(files.optString(GitConstants.KEY_DIFF, null)); assertNull(files.optString(GitConstants.KEY_COMMIT, null)); assertNull(files.optString(GitConstants.KEY_REMOTE, null)); assertNull(files.optString(GitConstants.KEY_TAG, null)); assertNull(files.optString(GitConstants.KEY_CLONE, null)); FileUtils.delete(dir, FileUtils.RECURSIVE); }
Example 12
Source File: SVNKitEnvironmentRepositoryTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Before public void init() throws Exception { String uri = ConfigServerTestUtils.prepareLocalSvnRepo( "src/test/resources/" + REPOSITORY_NAME, "target/repos/" + REPOSITORY_NAME); this.repository.setUri(uri); if (this.basedir.exists()) { FileUtils.delete(this.basedir, FileUtils.RECURSIVE | FileUtils.RETRY); } }
Example 13
Source File: TestUtils.java From spring-cloud-release-tools with Apache License 2.0 | 5 votes |
private static void prepareLocalRepo(String buildDir, String repoPath) throws IOException { File dotGit = new File(buildDir + repoPath + "/.git"); File git = new File(buildDir + repoPath + "/git"); if (git.exists()) { if (dotGit.exists()) { FileUtils.delete(dotGit, FileUtils.RECURSIVE); } } git.renameTo(dotGit); }
Example 14
Source File: GitRepo.java From spring-cloud-release-tools with Apache License 2.0 | 5 votes |
private void deleteBaseDirIfExists() { if (this.basedir.exists()) { try { FileUtils.delete(this.basedir, FileUtils.RECURSIVE); } catch (IOException e) { throw new IllegalStateException("Failed to initialize base directory", e); } } }
Example 15
Source File: TestUtils.java From spring-cloud-release-tools with Apache License 2.0 | 5 votes |
private static void prepareLocalRepo(String buildDir, String repoPath) throws IOException { File dotGit = new File(buildDir + repoPath + "/.git"); File git = new File(buildDir + repoPath + "/git"); if (git.exists()) { if (dotGit.exists()) { FileUtils.delete(dotGit, FileUtils.RECURSIVE); } } git.renameTo(dotGit); }
Example 16
Source File: JGitEnvironmentRepositoryConcurrencyTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Before public void init() throws Exception { if (this.basedir.exists()) { FileUtils.delete(this.basedir, FileUtils.RECURSIVE); } ConfigServerTestUtils.deleteLocalRepo("config-copy"); }
Example 17
Source File: RepositoryUtilsOpenRepositoryTest.java From ParallelGit with Apache License 2.0 | 4 votes |
@After public void tearDown() throws IOException { if(repo != null) repo.close(); FileUtils.delete(dir, FileUtils.RECURSIVE); }
Example 18
Source File: RepositoryUtilsOpenRepositoryTest.java From ParallelGit with Apache License 2.0 | 4 votes |
@After public void tearDown() throws IOException { if(repo != null) repo.close(); FileUtils.delete(dir, FileUtils.RECURSIVE); }
Example 19
Source File: RemoteGitRepositoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void closeRemoteRepository() throws Exception{ if (remoteRepository != null) { remoteRepository.close(); } FileUtils.delete(remoteRoot.toFile(), FileUtils.RECURSIVE | FileUtils.RETRY); }
Example 20
Source File: AbstractGitRepositoryTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected void closeEmptyRemoteRepository() throws Exception { if (emptyRemoteRepository != null) { emptyRemoteRepository.close(); } FileUtils.delete(emptyRemoteRoot.toFile(), FileUtils.RECURSIVE | FileUtils.RETRY); }