Package org.dbunit.dataset.xml

Examples of org.dbunit.dataset.xml.FlatXmlDataSetBuilder


                .getConnection(
                "jdbc:mysql://localhost:3306/adi_test",
                "root", "adi");
        connection = new DatabaseConnection(jdbcConnection);

        FlatXmlDataSetBuilder flatXmlDataSetBuilder = new FlatXmlDataSetBuilder();
        flatXmlDataSetBuilder.setColumnSensing(true);
        dataset = flatXmlDataSetBuilder.build(Thread.currentThread()
                .getContextClassLoader()
                .getResourceAsStream("db/test-daos-dataset.xml"));
    }
View Full Code Here


*/
public class FlatXmlDataSetLoader extends AbstractDataSetLoader {

  @Override
  protected IDataSet createDataSet(Resource resource) throws Exception {
    FlatXmlDataSetBuilder builder = new FlatXmlDataSetBuilder();
    builder.setColumnSensing(true);
    InputStream inputStream = resource.getInputStream();
    try {
      return builder.build(inputStream);
    } finally {
      inputStream.close();
    }
  }
View Full Code Here

               .getConnection(
                     "jdbc:mysql://localhost:3306/muevete_test",
                     "root", "adi");
        connection = new DatabaseConnection(jdbcConnection);

        FlatXmlDataSetBuilder flatXmlDataSetBuilder = new FlatXmlDataSetBuilder();
        flatXmlDataSetBuilder.setColumnSensing(true);
        dataset = flatXmlDataSetBuilder.build(Thread.currentThread()
                .getContextClassLoader()
                .getResourceAsStream("db/test-daos-dataset.xml"));
    }
View Full Code Here

        openConnection();
        // Initializes DBUnit
        String dateFile = this.getClass().getSimpleName() + "-dataset.xml";
        URL file = ClassLoader.getSystemResource(dateFile);
        if (file != null) {
            IDataSet dataset = new FlatXmlDataSetBuilder().build(file);

            LOGGER.info("Dataset File: {}", dateFile);
            DatabaseOperation.CLEAN_INSERT.execute(connection, dataset);
            LOGGER.info("Dataset inserted.");
            connection.getConnection().commit();
View Full Code Here

     * @throws IOException
     *             si il y a une erreur au niveau de la lecture du fichier
     */
    protected IDataSet getXmlDataSet(File file) throws DataSetException,
            IOException {
        return new FlatXmlDataSetBuilder().build(file);
    }
View Full Code Here

     * Imports DB data from the specified XML
     * @param xmlUrl URL to XML file location
     */
    public ImportBuilder from(URL xmlUrl) {
      try {
        flatXmlDataSet = new FlatXmlDataSetBuilder()
          .setColumnSensing(true)
          .setCaseSensitiveTableNames(false)
          .build(xmlUrl);
        this.dataSetUrl = xmlUrl;
        return this;
View Full Code Here

     * @return This builder to allow for chaining
     */
    public AssertBuilder expected(URL xmlUrl) {
      try {
        this.dataSetUrl = xmlUrl;
        flatXmlDataSet = new FlatXmlDataSetBuilder().build(xmlUrl);
        return this;
      } catch (Exception ex) {
        throw new JuDbException("Couldn't import data from XML: xmlUrl", ex);
      }
    }
View Full Code Here

     * @throws IOException
     *             si il y a une erreur au niveau de la lecture du fichier
     */
    private IDataSet getXmlDataSet(File file) {
        try {
            return new FlatXmlDataSetBuilder().build(file);
        } catch (MalformedURLException ex) {
            Assert.assertNotNull("Error on File DataSet. " + ex);
        } catch (DataSetException ex) {
            Assert.fail("Error on execute dataset. " + ex);
        }
View Full Code Here

            // Load the base dataset file
            InputStream input =
                    Thread.currentThread().getContextClassLoader()
                            .getResourceAsStream(dataSetLocation);
            try {
                FlatXmlDataSetBuilder dataSetBuilder =
                        new FlatXmlDataSetBuilder();
                dataSetBuilder.setColumnSensing(true);

                InputStream dtdInput = null;
                if (dtdLocation != null) {
                    dtdInput =
                            Thread.currentThread().getContextClassLoader()
                                    .getResourceAsStream(dtdLocation);
                }
                if (dtdInput == null) {
                    this.dataSet =
                            new ReplacementDataSet(dataSetBuilder.build(input));
                } else {
                    dataSetBuilder.setMetaDataSetFromDtd(dtdInput);
                    this.dataSet =
                            new ReplacementDataSet(dataSetBuilder.build(input));
                }
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
            this.operation = operation;
View Full Code Here

            // Load the base dataset file
            InputStream input =
                    Thread.currentThread().getContextClassLoader()
                            .getResourceAsStream(dataSetLocation);
            try {
                FlatXmlDataSetBuilder dataSetBuilder =
                        new FlatXmlDataSetBuilder();
                dataSetBuilder.setColumnSensing(true);

                InputStream dtdInput = null;
                if (dtdLocation != null) {
                    dtdInput =
                            Thread.currentThread().getContextClassLoader()
                                    .getResourceAsStream(dtdLocation);
                }
                if (dtdInput == null) {
                    this.dataSet =
                            new ReplacementDataSet(dataSetBuilder.build(input));
                } else {
                    dataSetBuilder.setMetaDataSetFromDtd(dtdInput);
                    this.dataSet =
                            new ReplacementDataSet(dataSetBuilder.build(input));
                }
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
            this.operation = operation;
View Full Code Here

TOP

Related Classes of org.dbunit.dataset.xml.FlatXmlDataSetBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.