söndag 13 september 2009 20:44:17 skrev mr.gaffo@xxxxxxxxx: > From: mike.gaffney <mike.gaffney@xxxxxxxxxxxxxx> > > --- > .../org/spearce/jgit/lib/ObjectDirectoryTest.java | 80 ++++++++++++++++++++ > 1 files changed, 80 insertions(+), 0 deletions(-) > create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java > > diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java > new file mode 100644 > index 0000000..fe019af > --- /dev/null > +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java > @@ -0,0 +1,80 @@ > +package org.spearce.jgit.lib; > + > +import java.io.File; > +import java.util.UUID; > + > +import junit.framework.TestCase; > + > +public class ObjectDirectoryTest extends TestCase { > + > + private File testDir; > + > + @Override > + protected void setUp() throws Exception { > + testDir = new File(new File(System.getProperty("java.io.tmpdir")), UUID.randomUUID().toString()); > + } Good. Now that we're on Java5 we might use this more. > + public void testGettingObjectFile() throws Exception { > + ObjectDirectory od = new ObjectDirectory(testDir); > + assertEquals(new File(testDir, "02/829ae153935095e4223f30cfc98c835de71bee"), > + od.fileFor(ObjectId.fromString("02829ae153935095e4223f30cfc98c835de71bee"))); > + assertEquals(new File(testDir, "b0/52a1272310d8df34de72f60204dee7e28a43d0"), > + od.fileFor(ObjectId.fromString("b052a1272310d8df34de72f60204dee7e28a43d0"))); > + } > + > + public boolean deleteDir(File dir) { RepositoryTestcase already contains a recursive delete, including a static one that you can use even without inheritance since you are within the same package. It is rather standalone so it could perhaps move to JGitTestUtil. > + if (dir.isDirectory()) { > + String[] children = dir.list(); > + for (int i=0; i<children.length; i++) { > + boolean success = deleteDir(new File(dir, children[i])); > + if (!success) { > + return false; > + } > + } > + } > + > + // The directory is now empty so delete it > + return dir.delete(); > + } > + > + private void createTestDir(){ > + testDir.mkdir(); No error checking. If mkdirfails the test probably fails for mysterious reasons, > + } > + > +} -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html