public IDataSet createDbUnitDataset() throws SQLException { return createDbUnitDataset("IA_%"); }
/** * Creates a schema and initialize the database */ public void createSchema() throws IntactTransactionException { createSchema(true); }
IntactUnit iu = new IntactUnit(); loadDataset = true; } else { iu.createSchema(); iu.createSchema(false); getDataContext().beginTransaction(); iu.importTestDataset((DbUnitTestDataset) testDataset); } else { throw new IntactTestException("Cannot import TestDatasets of type: " + testDataset.getClass().getName()); iu.createSchema();
/** * Import a testDataset into the database * @param testDataset the dataset to use */ public void importTestDataset(DbUnitTestDataset testDataset) { if (testDataset == null) { throw new NullPointerException("testDataset"); } try { IDataSet dbUnitDataSet = convertTestDatasetToDbUnit(testDataset); DatabaseOperation.INSERT.execute(getDatabaseConnection(), dbUnitDataSet); } catch (Exception e) { throw new IntactException("Exception importing dataset: "+testDataset.getId(), e); } // reset institution List<Institution> institutions = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().getInstitutionDao().getAll(); if (!institutions.isEmpty()) { IntactContext.getCurrentInstance().getConfig().setInstitution(institutions.get(0)); } }
public IDataSet createDbUnitDataset(String tablePrefix) throws SQLException { Connection con = IntactContext.getCurrentInstance().getDataContext().getDaoFactory().connection(); ResultSet tables = con.getMetaData().getTables(null, null, tablePrefix, new String[]{"TABLE"}); QueryDataSet allTablesDataSet = new QueryDataSet(getDatabaseConnection()); while (tables.next()) { String tableName = tables.getString(3); allTablesDataSet.addTable(tableName); } return allTablesDataSet; }