package org.jerrymouse.gaes.test;

import java.io.IOException;
import java.util.Properties;

import junit.framework.TestCase;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.Before;

/**
 * local service test
 */
public class BaseTest extends TestCase {
	static String JPA = "JPA";
	static String JDO = "JDO";
	static String GAE = "GAE";
	static String NORMAL = "NORMAL";
	static String HADOOP = "HADOOP";

	protected String pBottomLayer;

	Log log = LogFactory.getLog(BaseTest.class);

	@Before
	public void setUp() throws Exception {
		log.debug("test env:" + pBottomLayer);
		if (GAE.equalsIgnoreCase(pBottomLayer)) {
			GaeDataStoreTest.setupEnv();

		}
	}

	@After
	public void tearDown() throws Exception {
		if (GAE.equalsIgnoreCase(pBottomLayer)) {
			GaeDataStoreTest.tearDownEnv();
		}
	}

	public BaseTest() {
		Properties properties = new Properties();
		try {
			properties.load(this.getClass().getResourceAsStream(
					"/gaes.properties"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		pBottomLayer = (String) properties.get("bottomLayer");
	}
}