From 3ce8c91e759ee1a9fca1d7b3cb2646b76388de6c Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 2 Oct 2009 18:54:20 -0700 Subject: [PATCH] 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 --- .../eclipse/jgit/lib/ReflogReaderTest.java | 22 +++++++++++++++++++ .../eclipse/jgit/lib/RepositoryTestCase.java | 19 ---------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogReaderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogReaderTest.java index dae7cb895..1f2f25d5e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogReaderTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ReflogReaderTest.java @@ -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(); + } + } + } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java index 2870e4126..ac8881b1f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryTestCase.java +++ b/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.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(); - } - } - }