com.agimatec.database.DataSet Maven / Gradle / Ivy
package com.agimatec.database;
import com.agimatec.commons.config.ConfigManager;
import org.dbunit.dataset.DataSetException;
import org.dbunit.dataset.IDataSet;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Description:
* User: roman.stumm
* Date: 01.06.2007
* Time: 14:12:17
* Copyright: Agimatec GmbH
*/
public abstract class DataSet {
protected String dataFile;
public abstract IDataSet load(InputStream in) throws DataSetException, IOException;
public abstract void write(IDataSet set, OutputStream out)
throws DataSetException, IOException;
protected DataSet(String dataFile) {
this.dataFile = dataFile;
}
public String getDataFile() {
return dataFile;
}
public void setDataFile(String dataFile) {
this.dataFile = dataFile;
}
/**
* load from file ("./data.xml") or from classpath ("data.xml")
*
* @return
* @throws IOException
* @throws DataSetException
*/
public IDataSet load() throws IOException, DataSetException {
IDataSet testDataSet;
InputStream in = ConfigManager.toURL(dataFile).openStream();
try {
testDataSet = load(in);
} finally {
in.close();
}
return testDataSet;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy