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>tags/v0.7.0
@@ -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 class ReflogReaderTest extends RepositoryTestCase { | |||
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(); | |||
} | |||
} | |||
} |
@@ -46,7 +46,6 @@ package org.eclipse.jgit.lib; | |||
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 abstract class RepositoryTestCase extends TestCase { | |||
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(); | |||
} | |||
} | |||
} |