package testcases;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.util.*;
import java.io.File;
import imageorg.*;
import imageviewer.*;

/**
 * <code>AbstractFixture</code> is an abstract test case that simply
 * defines <code>setUp</code> and <code>tearDown</code> methods for
 * your test cases to use. You should extend this class in order to
 * write you own test methods.
 *
 * @author Mark Hall
 * @version 1.0
 */
public abstract class AbstractFixture extends TestCase {

  // will hold the concrete implementation
  protected ImageOrganizer m_imageOrg;
  
  /**
   * SetUp method. Makes sure that any artifacts left over from
   * running any previous tests are removed.
   */
  protected void setUp() throws Exception {
    File repositoryHome = new File(System.getProperties().
				   getProperty("user.home")
				   + File.separator
				   + "image_org_home");
    Runtime rt = Runtime.getRuntime();
    if (repositoryHome.exists()) {
      // remove the entire repository on disk
      rt.exec("rm -rf "+repositoryHome.getAbsolutePath()).waitFor();
    }
    m_imageOrg = ImageOrganizer.create();
  }

  /**
   * TearDown method. Frees memory.
   */
  protected void tearDown() throws Exception {
    m_imageOrg = null;
  }
}
