Search in sources :

Example 1 with FlatDtdWriter

use of org.dbunit.dataset.xml.FlatDtdWriter 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 2 with FlatDtdWriter

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

the class GenerateDTD method generateDTD.

@Test
public void generateDTD() throws Exception {
    IDatabaseConnection connection = new DatabaseConnection(dsLocator.getDataSource().getConnection());
    // write DTD file
    IDataSet dataSet = connection.createDataSet();
    Writer out = new OutputStreamWriter(new FileOutputStream(dtdFile));
    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 3 with FlatDtdWriter

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

the class GenerateDTD 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 4 with FlatDtdWriter

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

the class GenerateDTDForUserSchema method generateDTD.

@Test
public void generateDTD() throws Exception {
    IDatabaseConnection connection = new DatabaseConnection(dsLocator.getDataSource().getConnection());
    // write DTD file
    IDataSet dataSet = connection.createDataSet();
    Writer out = new OutputStreamWriter(new FileOutputStream(dtdFile));
    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 5 with FlatDtdWriter

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

the class GenerateUserDTD method generateUserDTD.

/**
 * This method should be executed every times the db schema change.
 * The schema is defined in main/resources/db.migration/*.sql.
 * The generated file user.dtd should go
 * @throws Exception
 */
@Test
public void generateUserDTD() throws Exception {
    IDatabaseConnection connection = new DatabaseConnection(dsLocator.getUserDataSource().getConnection(), "np_users");
    // write DTD file
    IDataSet dataSet = connection.createDataSet();
    Writer out = new OutputStreamWriter(new FileOutputStream(dtdFile));
    FlatDtdWriter datasetWriter = new FlatDtdWriter(out);
    datasetWriter.setContentModel(FlatDtdWriter.CHOICE);
    datasetWriter.write(dataSet);
}
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) Writer(java.io.Writer) FlatDtdWriter(org.dbunit.dataset.xml.FlatDtdWriter) OutputStreamWriter(java.io.OutputStreamWriter) UserResourceBaseTest(org.nextprot.api.user.dao.test.base.UserResourceBaseTest) Test(org.junit.Test)

Aggregations

FileOutputStream (java.io.FileOutputStream)5 OutputStreamWriter (java.io.OutputStreamWriter)5 Writer (java.io.Writer)5 DatabaseConnection (org.dbunit.database.DatabaseConnection)5 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)5 IDataSet (org.dbunit.dataset.IDataSet)5 FlatDtdWriter (org.dbunit.dataset.xml.FlatDtdWriter)5 Test (org.junit.Test)5 File (java.io.File)4 UserResourceBaseTest (org.nextprot.api.user.dao.test.base.UserResourceBaseTest)1