Search in sources :

Example 26 with IDataSet

use of org.dbunit.dataset.IDataSet in project api-core by ca-cwds.

the class ClientDaoTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    cleanAllAndInsert("/dbunit/Client/update/Client_before_update.xml");
    executeInTransaction(sessionFactory, (sessionFactory) -> {
        NameType nameType = nameTypeDao.find((short) 1314);
        assertNotNull(nameType);
        assertEquals("Maiden", nameType.getShortDescription().trim());
        assertTrue(nameType.getSystemId().equals((short) 1314));
        Client c = dao.find("AaiU7IW0Rt");
        assertEquals(0, c.getBirthStateCode());
        // NAME_TPC
        c.setNameType(nameType);
        dao.update(c);
    });
    IDataSet expectedDataSet = readXmlDataSet("/dbunit/Client/update/Client_after_update.xml");
    ITable expectedTable = expectedDataSet.getTable("CLIENT_T");
    IDataSet actualDataSet = dbUnitConnection.createDataSet(new String[] { "CLIENT_T" });
    ITable actualTable = actualDataSet.getTable("CLIENT_T");
    assertTableEquals(expectedTable, actualTable);
}
Also used : NameType(gov.ca.cwds.data.legacy.cms.entity.syscodes.NameType) ITable(org.dbunit.dataset.ITable) ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Client(gov.ca.cwds.data.legacy.cms.entity.Client) IDataSet(org.dbunit.dataset.IDataSet) Test(org.junit.Test) BaseCwsCmsInMemoryPersistenceTest(gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest)

Example 27 with IDataSet

use of org.dbunit.dataset.IDataSet in project nextprot-api by calipho-sib.

the class GenerateDTDForUserSchema method generateUserDTD.

@Test
public void generateUserDTD() throws Exception {
    IDatabaseConnection connection = new DatabaseConnection(dsLocator.getUserDataSource().getConnection());
    // write DTD file
    IDataSet dataSet = connection.createDataSet();
    Writer out = new OutputStreamWriter(new FileOutputStream("user.dtd"));
    FlatDtdWriter datasetWriter = new FlatDtdWriter(out);
    datasetWriter.setContentModel(FlatDtdWriter.CHOICE);
    // You could also use the sequence model which is the default
    // datasetWriter.setContentModel(FlatDtdWriter.SEQUENCE);
    datasetWriter.write(dataSet);
    // delete file after the test
    new File(dtdFile).delete();
}
Also used : FileOutputStream(java.io.FileOutputStream) FlatDtdWriter(org.dbunit.dataset.xml.FlatDtdWriter) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) DatabaseConnection(org.dbunit.database.DatabaseConnection) OutputStreamWriter(java.io.OutputStreamWriter) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) IDataSet(org.dbunit.dataset.IDataSet) File(java.io.File) FlatDtdWriter(org.dbunit.dataset.xml.FlatDtdWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) Test(org.junit.Test)

Example 28 with IDataSet

use of org.dbunit.dataset.IDataSet in project SSM by Intel-bigdata.

the class TestTableAggregator method testAggregate.

@Test
public void testAggregate() throws Exception {
    createTables(databaseTester.getConnection());
    IDataSet dataSet = new XmlDataSet(getClass().getClassLoader().getResourceAsStream("accessCountTable.xml"));
    databaseTester.setDataSet(dataSet);
    databaseTester.onSetup();
    MetaStore metaStore = new MetaStore(druidPool);
    prepareFiles(metaStore);
    AccessCountTable result = new AccessCountTable("actual", 0L, 0L, false);
    AccessCountTable table1 = new AccessCountTable("table1", 0L, 0L, false);
    AccessCountTable table2 = new AccessCountTable("table2", 0L, 0L, false);
    AccessCountTable table3 = new AccessCountTable("table3", 0L, 0L, false);
    metaStore.aggregateTables(result, Lists.newArrayList(table1, table2, table3));
    ITable actual = databaseTester.getConnection().createTable(result.getTableName());
    ITable expect = databaseTester.getDataSet().getTable("expect");
    Assertion.assertEquals(expect, actual);
}
Also used : MetaStore(org.smartdata.metastore.MetaStore) ITable(org.dbunit.dataset.ITable) IDataSet(org.dbunit.dataset.IDataSet) XmlDataSet(org.dbunit.dataset.xml.XmlDataSet) DBTest(org.smartdata.metastore.DBTest) Test(org.junit.Test)

Example 29 with IDataSet

use of org.dbunit.dataset.IDataSet in project head by mifos.

the class CollectionSheetEntryTest method verifyCollectionSheetData.

// one of the dependent methods throws Exception
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
private void verifyCollectionSheetData(String filename) throws Exception {
    IDataSet expectedDataSet = dbUnitUtilities.getDataSetFromDataSetDirectoryFile(filename);
    IDataSet databaseDataSet = dbUnitUtilities.getDataSetForTables(dataSource, new String[] { ACCOUNT_TRXN, LOAN_TRXN_DETAIL, ACCOUNT_PAYMENT, LOAN_SUMMARY, LOAN_SCHEDULE, LOAN_ACTIVITY_DETAILS, ACCOUNT_STATUS_CHANGE_HISTORY, FINANCIAL_TRXN, CUSTOMER_ACCOUNT_ACTIVITY, CUSTOMER_ATTENDANCE });
    verifyTablesWithoutSorting(expectedDataSet, databaseDataSet);
    verifyTransactionsAfterSortingTables(expectedDataSet, databaseDataSet);
}
Also used : IDataSet(org.dbunit.dataset.IDataSet)

Example 30 with IDataSet

use of org.dbunit.dataset.IDataSet in project head by mifos.

the class DatasetVersionTest method verifyDatabaseVersion.

@SuppressWarnings("PMD.SignatureDeclareThrowsException")
private void verifyDatabaseVersion(String acceptanceDataSetFile) throws Exception {
    String[] tablesToValidate = { "APPLIED_UPGRADES" };
    IDataSet acceptanceDataSet = dbUnitUtilities.getDataSetFromDataSetDirectoryFile(acceptanceDataSetFile);
    IDataSet databaseDataSet = dbUnitUtilities.getDataSetForTables(dataSource, tablesToValidate);
    //compare acceptance data set version to db version on running application
    dbUnitUtilities.verifyTables(tablesToValidate, acceptanceDataSet, databaseDataSet);
}
Also used : IDataSet(org.dbunit.dataset.IDataSet)

Aggregations

IDataSet (org.dbunit.dataset.IDataSet)54 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)21 DatabaseConnection (org.dbunit.database.DatabaseConnection)16 Test (org.junit.Test)15 ITable (org.dbunit.dataset.ITable)13 Connection (java.sql.Connection)12 FileOutputStream (java.io.FileOutputStream)11 File (java.io.File)10 FlatXmlDataSet (org.dbunit.dataset.xml.FlatXmlDataSet)8 XmlDataSet (org.dbunit.dataset.xml.XmlDataSet)8 InputStream (java.io.InputStream)7 InputStreamReader (java.io.InputStreamReader)7 FlatXmlDataSetBuilder (org.dbunit.dataset.xml.FlatXmlDataSetBuilder)7 OutputStreamWriter (java.io.OutputStreamWriter)5 Writer (java.io.Writer)5 IDatabaseTester (org.dbunit.IDatabaseTester)5 FileInputStream (java.io.FileInputStream)4 FlatDtdWriter (org.dbunit.dataset.xml.FlatDtdWriter)4 BaseCwsCmsInMemoryPersistenceTest (gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest)3 DatabaseEnvironment (io.shardingjdbc.core.common.env.DatabaseEnvironment)3