Update of /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant
In directory usw-pr-cvs1:/tmp/cvs-serv20206/dbunit/src/java/org/dbunit/ant
Modified Files:
Export.java
Log Message:
Ant Task - Close output stream after dataset export.
Index: Export.java
===================================================================
RCS file: /cvsroot/dbunit/dbunit/src/java/org/dbunit/ant/Export.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Export.java 15 Jul 2002 01:00:30 -0000 1.3
--- Export.java 3 Aug 2002 14:49:49 -0000 1.4
***************
*** 24,36 ****
import org.dbunit.DatabaseUnitException;
- import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
! import org.dbunit.dataset.xml.FlatXmlDataSet;
! import org.dbunit.dataset.xml.FlatDtdDataSet;
! import org.dbunit.dataset.xml.XmlDataSet;
import java.io.*;
- import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
--- 24,32 ----
import org.dbunit.DatabaseUnitException;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
! import org.dbunit.dataset.xml.*;
import java.io.*;
import java.sql.SQLException;
import java.util.ArrayList;
***************
*** 39,44 ****
/**
* The <code>Export</code> class is the step that facilitates exporting
! * the contents of the database and/or it's corresponding dtd to a file.
! * The export can be performed on a full dataset or a partial one if
* specific table names are identified.
*
--- 35,40 ----
/**
* The <code>Export</code> class is the step that facilitates exporting
! * the contents of the database and/or it's corresponding dtd to a file.
! * The export can be performed on a full dataset or a partial one if
* specific table names are identified.
*
***************
*** 58,65 ****
}
! private String getAbsolutePath(File filename)
! {
return filename != null ? filename.getAbsolutePath() : "null";
! }
public File getDest()
--- 54,61 ----
}
! private String getAbsolutePath(File filename)
! {
return filename != null ? filename.getAbsolutePath() : "null";
! }
public File getDest()
***************
*** 85,98 ****
public void setFormat(String format)
{
! if (format.equalsIgnoreCase("flat")
! || format.equalsIgnoreCase("xml")
! || format.equalsIgnoreCase("dtd"))
! {
! this.format = format;
! }
! else
! {
! throw new IllegalArgumentException("Type must be one of: 'flat'(default), 'xml', or 'dtd' but was: " + format);
! }
}
--- 81,94 ----
public void setFormat(String format)
{
! if (format.equalsIgnoreCase("flat")
! || format.equalsIgnoreCase("xml")
! || format.equalsIgnoreCase("dtd"))
! {
! this.format = format;
! }
! else
! {
! throw new IllegalArgumentException("Type must be one of: 'flat'(default), 'xml', or 'dtd' but was: " + format);
! }
}
***************
*** 115,137 ****
dataset = connection.createDataSet(getTableArray());
}
! if (dest == null)
{
! throw new DatabaseUnitException ("'dest' is a required attribute of the <export> step.");
! }
! else
! {
! if (format.equalsIgnoreCase("flat"))
! {
! FlatXmlDataSet.write(dataset, new FileOutputStream(dest));
}
! else if (format.equalsIgnoreCase("xml"))
{
! XmlDataSet.write(dataset, new FileOutputStream(dest));
}
! else if (format.equalsIgnoreCase("dtd"))
! {
! FlatDtdDataSet.write(dataset, new FileOutputStream(dest));
! }
! }
}
--- 111,141 ----
dataset = connection.createDataSet(getTableArray());
}
! if (dest == null)
{
! throw new DatabaseUnitException("'dest' is a required attribute of the <export> step.");
! }
! else
! {
! OutputStream out = new FileOutputStream(dest);
! try
! {
! if (format.equalsIgnoreCase("flat"))
! {
! FlatXmlDataSet.write(dataset, out);
! }
! else if (format.equalsIgnoreCase("xml"))
! {
! XmlDataSet.write(dataset, out);
! }
! else if (format.equalsIgnoreCase("dtd"))
! {
! FlatDtdDataSet.write(dataset, out);
! }
}
! finally
{
! out.close();
}
! }
}
***************
*** 160,165 ****
{
return "Executing export: "
! + "\n in format: " + format
! + " to datafile: " + getAbsolutePath(dest);
}
--- 164,169 ----
{
return "Executing export: "
! + "\n in format: " + format
! + " to datafile: " + getAbsolutePath(dest);
}
|