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>
This commit is contained in:
Shawn O. Pearce 2009-10-02 18:54:20 -07:00
parent 1640812b89
commit 3ce8c91e75
2 changed files with 22 additions and 19 deletions

View File

@ -44,6 +44,10 @@
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.util.List;
@ -173,4 +177,22 @@ public void testNoLog() throws Exception {
assertEquals(0, db.getReflogReader("master").getReverseEntries().size());
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();
}
}
}

View File

@ -46,7 +46,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
@ -326,22 +325,4 @@ public void run() {
repositoriesToClose.add(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();
}
}
}