Browse Source

Move setupReflog test function to only test that cares

Only one test class actually needs this function, so instead of
us inheriting it down into every test, move it to that one class.

Change-Id: I5700ca48df4177153f2b3861dec7c538c621e775
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
stable-0.7
Shawn O. Pearce 15 years ago
parent
commit
3ce8c91e75
  1. 22
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogReaderTest.java
  2. 19
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java

22
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogReaderTest.java

@ -44,6 +44,10 @@
package org.eclipse.jgit.lib; package org.eclipse.jgit.lib;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
@ -173,4 +177,22 @@ public class ReflogReaderTest extends RepositoryTestCase {
assertEquals(0, db.getReflogReader("master").getReverseEntries().size()); assertEquals(0, db.getReflogReader("master").getReverseEntries().size());
assertNull(db.getReflogReader("master").getLastEntry()); assertNull(db.getReflogReader("master").getLastEntry());
} }
private void setupReflog(String logName, byte[] data)
throws FileNotFoundException, IOException {
File logfile = new File(db.getDirectory(), logName);
if (!logfile.getParentFile().mkdirs()
&& !logfile.getParentFile().isDirectory()) {
throw new IOException(
"oops, cannot create the directory for the test reflog file"
+ logfile);
}
FileOutputStream fileOutputStream = new FileOutputStream(logfile);
try {
fileOutputStream.write(data);
} finally {
fileOutputStream.close();
}
}
} }

19
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java

@ -46,7 +46,6 @@ package org.eclipse.jgit.lib;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -326,22 +325,4 @@ public abstract class RepositoryTestCase extends TestCase {
repositoriesToClose.add(newRepo); repositoriesToClose.add(newRepo);
return newRepo; return newRepo;
} }
protected void setupReflog(String logName, byte[] data)
throws FileNotFoundException, IOException {
File logfile = new File(db.getDirectory(), logName);
if (!logfile.getParentFile().mkdirs()
&& !logfile.getParentFile().isDirectory()) {
throw new IOException(
"oops, cannot create the directory for the test reflog file"
+ logfile);
}
FileOutputStream fileOutputStream = new FileOutputStream(logfile);
try {
fileOutputStream.write(data);
} finally {
fileOutputStream.close();
}
}
} }

Loading…
Cancel
Save