rename org.spearce.egit -> org.eclipse.egit and bump version to 0.5.0
[egit/imyousuf.git] / org.eclipse.egit.core.test / src / org / eclipse / egit / core / test / GitTestCase.java
blob59051fdfc7d82740e293abed2781f5d7e135682d
1 /*******************************************************************************
2 * Copyright (C) 2007, Robin Rosenberg <robin.rosenberg@dewire.com>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * See LICENSE for the full license text, also available.
7 *******************************************************************************/
8 package org.eclipse.egit.core.test;
10 import java.io.File;
11 import java.io.IOException;
13 import junit.framework.TestCase;
15 public abstract class GitTestCase extends TestCase {
17 protected TestProject project;
19 protected File gitDir;
21 protected void setUp() throws Exception {
22 super.setUp();
23 project = new TestProject();
24 gitDir = new File(project.getProject().getWorkspace().getRoot()
25 .getRawLocation().toFile(), ".git");
26 rmrf(gitDir);
29 protected void tearDown() throws Exception {
30 super.tearDown();
31 project.dispose();
32 rmrf(gitDir);
35 private void rmrf(File d) throws IOException {
36 if (!d.exists())
37 return;
39 File[] files = d.listFiles();
40 if (files != null) {
41 for (int i = 0; i < files.length; ++i) {
42 if (files[i].isDirectory())
43 rmrf(files[i]);
44 else if (!files[i].delete())
45 throw new IOException(files[i] + " in use or undeletable");
48 if (!d.delete())
49 throw new IOException(d + " in use or undeletable");
50 assert !d.exists();