xmlDataSet = new XmlDataSet(fileInInputStreamFormat); xmlDataSetToRun = xmlDataSet;
/** * {@inheritDoc} */ @Override protected IDataSet fromResource(Resource resource, DataSetFormatOptions options) throws DataSetException, IOException { return new XmlDataSet(resource.getInputStream()); } },
@Override protected IDataSet createDataSet(Resource resource) throws Exception { InputStream inputStream = resource.getInputStream(); try { return new XmlDataSet(inputStream); } finally { inputStream.close(); } }
@Override protected IDataSet createDataSet(Resource resource) throws Exception { InputStream inputStream = resource.getInputStream(); try { return new XmlDataSet(inputStream); } finally { inputStream.close(); } }
protected static IDataSet getDataSet() throws Exception { URL url = MyTest.class.getClassLoader().getResource("MyDataSet.xml"); return new XmlDataSet(new FileInputStream(url.getPath()));
private IDataSet getDataSetObject(String path) throws Exception { if (getDataSetStrategy().equals(DataSetStrategy.Xml)) { return new XmlDataSet(Dbunit.class.getResourceAsStream(path)); } else if (getDataSetStrategy().equals(DataSetStrategy.FlatXml)) { boolean enableColumnSensing = true; InputStreamReader inReader = new InputStreamReader(Dbunit.class .getResourceAsStream(path), "UTF-8"); // FlatXmlDataSet fxset = new FlatXmlDataSet(inReader, true, // enableColumnSensing, false); // return fxset; return new CachedDataSet(new FlatXmlProducer(new InputSource( inReader), true, enableColumnSensing, false)); } else { return new XmlDataSet(Dbunit.class.getResourceAsStream(path)); } }
public void loadXmlDataSet(InputStream inputStream) { try { IDataSet dataSet = new XmlDataSet(inputStream); executeArbitrarySql("SET REFERENTIAL_INTEGRITY FALSE"); DatabaseOperation.REFRESH.execute(getIDatabaseConnection(), dataSet); executeArbitrarySql("SET REFERENTIAL_INTEGRITY TRUE"); } catch (DatabaseUnitException e) { throw new RuntimeException(e); } catch (SQLException e) { throw new RuntimeException(e); } }
dataSet = new XmlDataSet(is);
public void loadXmlDataSet(InputStream inputStream) { IDatabaseConnection databaseConnection = null; try { databaseConnection = getIDatabaseConnection(); IDataSet dataSet = new XmlDataSet(inputStream); DatabaseOperation.REFRESH.execute(databaseConnection, dataSet); } catch (DatabaseUnitException e) { throw new RuntimeException(e); } catch (SQLException e) { throw new RuntimeException(e); } finally { if (databaseConnection != null) { try { databaseConnection.close(); } catch (SQLException ignore) { } } } }
/******************************************************************************************************************* * * Populates the database from the given XML file. * * @param transactionManager the Spring transaction manager * @param xmlFile the file with the data to populate the database with * ******************************************************************************************************************/ public static void populate (final @Nonnull JpaTransactionManager transactionManager, final @Nonnull File xmlFile) throws SQLException, DatabaseUnitException, IOException { log.info("******** populate(.., {})", xmlFile); final @Cleanup IDatabaseConnection connection = createConnection(transactionManager); final @Cleanup Reader r = new FileReader(xmlFile); DatabaseOperation.INSERT.execute(connection, new XmlDataSet(r)); r.close(); connection.close(); }
public static void assertDatabaseContentsEquals(Database database, InputStream inputStream, Map<String, String[]> ignoreMap) { Map<ITableFilter, IColumnFilter> filterMap = createFilterMap(ignoreMap); try { IDataSet databaseDataSet = database.getIDatabaseConnection().createDataSet(); IDataSet actualDataSet = removeIgnoredColumns(databaseDataSet, filterMap); IDataSet xmlDataSet = new XmlDataSet(inputStream); IDataSet expectedDataSet = removeIgnoredColumns(xmlDataSet, filterMap); String[] expectedTableNames = expectedDataSet.getTableNames(); for (String expectedTableName : expectedTableNames) { Assertion.assertEquals(new SortedTable(expectedDataSet.getTable(expectedTableName)), new SortedTable(actualDataSet.getTable(expectedTableName), expectedDataSet.getTable(expectedTableName).getTableMetaData())); } } catch (SQLException e) { throw new RuntimeException(e); } catch (DataSetException e) { throw new RuntimeException(e); } catch (DatabaseUnitException e) { throw new AssertionFailedError(e.getMessage()); } }