@Component
public class DataBaseTablePrinter
extends java.lang.Object
#writeDbUnitDataSetFile(String[])
method.Modifier and Type | Field and Description |
---|---|
protected javax.sql.DataSource |
dataSource |
protected static Logger |
logger |
Constructor and Description |
---|
DataBaseTablePrinter() |
Modifier and Type | Method and Description |
---|---|
protected org.dbunit.database.IDatabaseConnection |
getConnection() |
void |
printDataSet(java.io.OutputStream out)
Prints the data set to an output stream, using the
FlatXmlDataSet . |
void |
printDataSet(java.io.OutputStream out,
java.lang.Boolean excludeTermLoadingTables,
org.dbunit.dataset.filter.ITableFilterSimple excludeFilterOrig,
java.lang.String[] includeTableNames,
boolean withNull) |
void |
printDataSet(java.io.OutputStream out,
org.dbunit.dataset.filter.ITableFilterSimple filter)
Prints the named tables to an output stream, using dbunit's
FlatXmlWriter . |
void |
printDataSet(java.io.OutputStream out,
java.lang.String[] includeTableNames)
Prints the named tables to an output stream, using dbunit's
FlatXmlDataSet . |
void |
printDataSetWithNull(java.io.OutputStream out)
Prints the data set to an output stream, using the
FlatFullXmlWriter . |
void |
printDataSetWithNull(java.io.OutputStream out,
java.lang.Boolean excludeTermLoadingTables,
org.dbunit.dataset.filter.ITableFilterSimple excludeFilterOrig,
java.lang.String[] includeTableNames) |
void |
printDataSetWithNull(java.io.OutputStream out,
java.lang.String[] includeTableNames)
Prints the data set to an output stream, using the
FlatFullXmlWriter . |
void |
printDtd(java.io.OutputStream out)
Prints a dtd to an output stream, using dbunit's
FlatDtdDataSet . |
void |
printTableNames(java.io.OutputStream out,
java.lang.String formatString) |
java.lang.String |
transformSourceToString(javax.xml.transform.Source source)
Transforms a javax.xml.transform.Source to a java.lang.String (useful for comparison in
XmlUnit tests etc).
|
void |
writeDbUnitDataSetFile(java.lang.String[] includeTableNames,
java.lang.Class<?> testClass)
WARNING read this doc before using this method.
|
void |
writeDbUnitDataSetFile(java.lang.String[] includeTableNames,
java.lang.Class<?> testClass,
java.lang.String methodName,
boolean withNullValues)
Extension of method mentioned in "see also" where you can specify an appendix for the
generated DbUnit
DataSet file. |
protected static final Logger logger
@Autowired protected javax.sql.DataSource dataSource
protected org.dbunit.database.IDatabaseConnection getConnection()
public void printDataSet(java.io.OutputStream out)
FlatXmlDataSet
.
printDataSetWithNull(OutputStream)
method instead.
Remember, if you've just called save() or
update(), the data isn't written to the database until the
transaction is committed, and that isn't until after the
method exits. Consequently, if you want to test writing to
the database, either use the @ExpectedDataSet
annotation (that executes after the test is run), or use
CdmTransactionalIntegrationTest
.
out
- The OutputStream to write to.FlatFullXmlWriter
public void printDataSetWithNull(java.io.OutputStream out, java.lang.String[] includeTableNames)
FlatFullXmlWriter
.
which is a variant of the FlatXmlWriter
. It
inserts '[null]' place holders for null values instead of skipping them.
This was necessary to make this xml database export compatible to the
MultiSchemaXmlDataSetReader
which is used in Unitils since version 3.x
out
- out The OutputStream to write to.includeTableNames
- public void printDataSetWithNull(java.io.OutputStream out)
FlatFullXmlWriter
.
which is a variant of the FlatXmlWriter
. It
inserts '[null]' place holders for null values instead of skipping them.
This was necessary to make this xml database export compatible to the
MultiSchemaXmlDataSetReader
which is used in Unitils since version 3.x
Remember, if you've just called save() or
update(), the data isn't written to the database until the
transaction is committed, and that isn't until after the
method exits. Consequently, if you want to test writing to
the database, either use the @ExpectedDataSet
annotation (that executes after the test is run), or use
CdmTransactionalIntegrationTest
.
out
- The OutputStream to write to.FlatFullXmlWriter
public void printDataSetWithNull(java.io.OutputStream out, java.lang.Boolean excludeTermLoadingTables, org.dbunit.dataset.filter.ITableFilterSimple excludeFilterOrig, java.lang.String[] includeTableNames)
out
- excludeTermLoadingTables
- excludeFilter
- the tables to be excludedpublic void printDataSet(java.io.OutputStream out, java.lang.Boolean excludeTermLoadingTables, org.dbunit.dataset.filter.ITableFilterSimple excludeFilterOrig, java.lang.String[] includeTableNames, boolean withNull)
public void printTableNames(java.io.OutputStream out, java.lang.String formatString)
out
- formatString
- can be null, otherwise a format string like eg. "< %1$s />" see also String.format(String, Object...)
public void printDataSet(java.io.OutputStream out, java.lang.String[] includeTableNames)
FlatXmlDataSet
.
printDataSetWithNull(OutputStream)
method instead.
Remember, if you've just called save() or
update(), the data isn't written to the database until the
transaction is committed, and that isn't until after the
method exits. Consequently, if you want to test writing to
the database, either use the @ExpectedDataSet
annotation (that executes after the test is run), or use
CdmTransactionalIntegrationTest
.
out
- the OutputStream to write the XML toincludeTableNames
- the names of tables to print (should be in upper case letters)#printDataSet(OutputStream)}
,
FlatFullXmlWriter
public void printDataSet(java.io.OutputStream out, org.dbunit.dataset.filter.ITableFilterSimple filter)
FlatXmlWriter
.
printDataSetWithNull(OutputStream)
method instead.
Remember, if you've just called save() or
update(), the data isn't written to the database until the
transaction is committed, and that isn't until after the
method exits. Consequently, if you want to test writing to
the database, either use the @ExpectedDataSet
annotation (that executes after the test is run), or use
CdmTransactionalIntegrationTest
.
out
- filter
- #printDataSet(OutputStream)}
,
FlatFullXmlWriter
public void printDtd(java.io.OutputStream out)
FlatDtdDataSet
.out
- The OutputStream to write to.FlatDtdDataSet
public void writeDbUnitDataSetFile(java.lang.String[] includeTableNames, java.lang.Class<?> testClass) throws java.io.FileNotFoundException
This is the recommended method to create DbUnit data set for integration tests.
This method will create the DbUnit data set file for the specific test class
it has been called from. This happens in full compliance with the DbUnit conventions,
so that the test class will immediately be able to use the
newly created file during the next run.
This also means that using writeDbUnitDataSetFile()
in a test class will overwrite the existing data set file. This is not
considered to be harmful since we expect that any development always is
backed up by a VCS like git, svn and therefore recovery of overwritten
data source files should not cause any problems.
Writes a DbUnit DataSet
file from the current data base connection using the
FlatFullXmlWriter
which is a variant of the
FlatXmlWriter
. It
inserts '[null]'
place holders for null values instead of skipping them.
java.io.FileNotFoundException
public void writeDbUnitDataSetFile(java.lang.String[] includeTableNames, java.lang.Class<?> testClass, java.lang.String methodName, boolean withNullValues) throws java.io.FileNotFoundException
DataSet
file.methodName
- the appendix of the generated DbUnit dataset filejava.io.FileNotFoundException
#writeDbUnitDataSetFile(String[], Class)}
public java.lang.String transformSourceToString(javax.xml.transform.Source source) throws javax.xml.transform.TransformerException
source
- javax.xml.transform.TransformerException
Copyright © 2007-2020 EDIT. All Rights Reserved.