当前位置: 首页>>代码示例>>Java>>正文


Java FlatXmlDataSet.write方法代码示例

本文整理汇总了Java中org.dbunit.dataset.xml.FlatXmlDataSet.write方法的典型用法代码示例。如果您正苦于以下问题:Java FlatXmlDataSet.write方法的具体用法?Java FlatXmlDataSet.write怎么用?Java FlatXmlDataSet.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dbunit.dataset.xml.FlatXmlDataSet的用法示例。


在下文中一共展示了FlatXmlDataSet.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDeletion

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
/**
 * Tests export.
 */
public void testDeletion() throws Exception {
	File resultDir = new File(testDir, "result");
	if (!resultDir.exists()) {
		resultDir.mkdir();
	}
	File result = null;
	result = new File(resultDir, "delete.sql");
	File insertResult = new File(resultDir, "insert.sql");
	
	if (doDeletion(datamodelDir, new File(testDir, "extractionmodel.csv"), result, insertResult, scope)) {
		Session statementExecutor = new Session(connectionArguments.get(0), connectionArguments.get(1), connectionArguments.get(2), connectionArguments.get(3));
		SqlScriptExecutor.executeScript(result.getCanonicalPath(), statementExecutor);
		statementExecutor.shutDown();
		
		File actualState = new File(resultDir, "remaining-state.xml");
		IDataSet depDataset = getConnection().createDataSet(getDataSet().getTableNames());
		Writer out = new FileWriter(actualState);
	    FlatXmlDataSet.write(depDataset, out, Charset.defaultCharset().name());
	    out.close();

		assertEqualDatasets(expectedResult, actualState);
	}
}
 
开发者ID:P15,项目名称:jailer,代码行数:27,代码来源:DeletionTestCase.java

示例2: writeToFileFromDataSet

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
/**
 * 把数据集写入到文件中
 * @param dataSet
 * @param destFilePath
 */
public static void writeToFileFromDataSet(IDataSet dataSet,String destFilePath) {
	File destFile = new File(destFilePath);
	try {
			String destFileName = destFile.getName();
			//转换为excel格式
			if(destFileName.endsWith(".xls")){
				XlsDataSet.write(dataSet, new FileOutputStream(destFile));
			}else if(destFileName.endsWith(".xml")){
				FlatXmlDataSet.write(dataSet, new FileOutputStream(destFile));
			}else{
				log.error("文件格式不是xls或者xml,不支持");
				return;
			}
			log.info("写入数据到文件 : "+destFile.getAbsolutePath());
	} catch (Exception e) {
			log.error("写入数据到文件失败");
			log.error(e.getMessage());
	}
}
 
开发者ID:sapientTest,项目名称:Sapient,代码行数:25,代码来源:DbUnitUtil.java

示例3: run

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
@Scheduled(cron = "0 0 3 * * *")
public void run() throws SQLException, DatabaseUnitException, IOException {
    if (enable) {
        log.info("begin backup database");

        String bak = root + "/" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());

        ITableFilter filter = new DatabaseSequenceFilter(conn);
        IDataSet dataSet = new FilteredDataSet(filter, conn.createDataSet());

        //IDataSet dataSet = conn.createDataSet();
        FlatXmlDataSet.write(dataSet, new FileOutputStream(bak + ".xml"));
        FlatDtdDataSet.write(dataSet, new FileOutputStream(bak + ".dtd"));
        log.info("end backup database");
    }


}
 
开发者ID:chonglou,项目名称:itpkg,代码行数:19,代码来源:BackupJob.java

示例4: main

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
    Class driverClass = Class.forName("org.postgresql.Driver");
    Connection jdbcConnection = DriverManager.getConnection(
            "jdbc:postgresql://localhost:5432/FormBuilder?autoReconnect=true", "fbdev", "fbdev");
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);

    // partial database export
    /*QueryDataSet partialDataSet = new QueryDataSet(connection);
    partialDataSet.addTable("FOO", "SELECT * FROM TABLE WHERE COL='VALUE'");
    partialDataSet.addTable("BAR");
    FlatXmlDataSet.write(partialDataSet, new FileOutputStream("partial.xml"));*/

    // full database export
    IDataSet fullDataSet = connection.createDataSet();
    FlatXmlDataSet.write(fullDataSet, new FileOutputStream("skips_on_table.xml"));
    
    // dependent tables database export: export table X and all tables that
    // have a PK which is a FK on X, in the right order for insertion
    /*String[] depTableNames = 
      TablesDependencyHelper.getAllDependentTables( connection, "X" );
    IDataSet depDataset = connection.createDataSet( depTableNames );
    FlatXmlDataSet.write(depDataSet, new FileOutputStream("dependents.xml"));*/          
    
}
 
开发者ID:NCIP,项目名称:edct-formbuilder,代码行数:26,代码来源:DatabaseExport.java

示例5: generateString

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
@Override
public String generateString() throws IOException, SQLException, DatabaseUnitException {
  StringWriter writer = new StringWriter();
  try {
    IDataSet modifiedDataSet = modify(dataSet);
    FlatXmlDataSet.write(modifiedDataSet, writer);
    return writer.toString();
  } finally {
    writer.close();
  }
}
 
开发者ID:frank780117,项目名称:dbunit-ext,代码行数:12,代码来源:FlatXmlDataSetGenerator.java

示例6: writeDataSetString

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
@Override
public void writeDataSetString(File file) throws IOException, SQLException, DatabaseUnitException {
  OutputStream outputStream = new FileOutputStream(file);
  try {
    IDataSet modifiedDataSet = modify(dataSet);
    FlatXmlDataSet.write(modifiedDataSet, outputStream);
  } finally {
    outputStream.close();
  }
}
 
开发者ID:frank780117,项目名称:dbunit-ext,代码行数:11,代码来源:FlatXmlDataSetGenerator.java

示例7: dumpDatabase

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
@After
@Transactional
public void dumpDatabase() throws SQLException, DatabaseUnitException, FileNotFoundException, IOException {
    // full database export
    Connection jdbcConnection = dataSource.getConnection();
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
    IDataSet fullDataSet = connection.createDataSet();
    FlatXmlDataSet.write(fullDataSet, new FileOutputStream("./target/QueryKeyRepositoryTest-dbunit.xml"));
}
 
开发者ID:jhaood,项目名称:github-job-keywords,代码行数:10,代码来源:QueryKeyRepositoryTest.java

示例8: dumpDatabase

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
@After
@Transactional
public void dumpDatabase() throws SQLException, DatabaseUnitException, FileNotFoundException, IOException {
    // full database export
    Connection jdbcConnection = dataSource.getConnection();
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);
    IDataSet fullDataSet = connection.createDataSet();
    FlatXmlDataSet.write(fullDataSet, new FileOutputStream(
        "./target/TermFrequencyResultsDataManagerTest-dbunit.xml"));
}
 
开发者ID:jhaood,项目名称:github-job-keywords,代码行数:11,代码来源:TermFrequencyResultsDataManagerTest.java

示例9: writeQueryTablesToFile

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
public void writeQueryTablesToFile(Map<String, String> queries, File output) throws Exception {
    QueryDataSet dataSet = new QueryDataSet(this.dbUnitConnection);
    for (String table : queries.keySet()) {
        dataSet.addTable(table, queries.get(table));
    }
    if (output.getName().endsWith(".xml")) {
        FlatXmlDataSet.write(dataSet, new FileOutputStream(output));
    } else if (output.getName().endsWith(".xls")) {
        XlsDataSet.write(dataSet, new FileOutputStream(output));
    } else {
        new CsvDataSetWriter(output).write(dataSet);
    }
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:14,代码来源:DBMock.java

示例10: doWork

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
public static void doWork(Connection conn, TreeMap<String, String> tableQueryMap) throws Exception
{
  IDatabaseConnection connection = new DatabaseConnection(conn);

  // partial database export
  QueryDataSet partialDataSet = new QueryDataSet(connection);
  for (String table : tableQueryMap.keySet()) {
    partialDataSet.addTable(table, tableQueryMap.get(table));
  }

  FlatXmlDataSet.write(partialDataSet, System.out);
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:13,代码来源:DatabaseExport.java

示例11: main

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Config config = new Config();
    Class.forName(config.getDbDriver());
    Connection jdbcConnection = DriverManager.getConnection(config.getDbUrl(), config.getDbUser(), config.getDbPass());
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection, "public");

    // dtd
    FlatDtdDataSet.write(connection.createDataSet(), new FileOutputStream("src/test/java/it/pronetics/acl/conf/dbunit/database-schema.dtd"));

    // export
    IDataSet fullDataSet = connection.createDataSet();
    FlatXmlDataSet.write(fullDataSet, new FileOutputStream("src/test/java/opennms/opennms/acl/conf/dbunit/full.xml"));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:14,代码来源:DbUnit.java

示例12: writeExpectedFile

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
protected void writeExpectedFile(IDatabaseConnection dbunitConnection,
		File outputFile, String tableName) throws IOException,
		DataSetException {

	QueryDataSet partialDataSet = new QueryDataSet(dbunitConnection);
	partialDataSet.addTable(tableName);

	FlatXmlDataSet.write(partialDataSet, new FileOutputStream(outputFile));
}
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:10,代码来源:DatabaseCapable.java

示例13: extract

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
/**
 * Performs the extraction. If no tables or queries are specified, data from
 * entire database will be extracted.
 * Otherwise, a partial extraction will be performed.
 * 
 * @throws Exception
 */
public void extract() throws Exception {
    Connection conn = null;
    try {
        conn = dataSource.getConnection();
        logger.info("Beginning extraction from '" + conn.toString() + "'.");
        IDatabaseConnection connection = new DatabaseConnection(conn, schema);
        configConnection((DatabaseConnection) connection);
        if (tableList != null || queryList != null) {
            // partial database export
            QueryDataSet partialDataSet = new QueryDataSet(connection);
            addTables(partialDataSet);
            addQueries(partialDataSet);
            FlatXmlDataSet.write(partialDataSet, new FileOutputStream(dataSetName));
        } else {
            // full database export
            IDataSet fullDataSet = connection.createDataSet();
            FlatXmlDataSet.write(fullDataSet, new FileOutputStream(dataSetName));

            // dependent tables database export: export table X and all
            // tables that
            // have a PK which is a FK on X, in the right order for
            // insertion
            String[] depTableNames = TablesDependencyHelper.getAllDependentTables(connection, "research");
            IDataSet depDataset = connection.createDataSet(depTableNames);

            FlatXmlWriter datasetWriter = new FlatXmlWriter(new FileOutputStream("target/dependents.xml"));
            datasetWriter.write(depDataset);

        }
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
    logger.info("Completed extraction to '" + dataSetName + "'.");
}
 
开发者ID:antoniomaria,项目名称:gazpachoquest,代码行数:44,代码来源:DBUnitDataExtractor.java

示例14: main

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
/**
 * Cambiar los datos de la conexión de acuerdo a la base de datos que se quiera usar como muestra
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception
{
    String url  = JOptionPane.showInputDialog("Escriba la URL de MySQL incluyendo driver");
    String user = JOptionPane.showInputDialog("Escriba el nombre de usuario de la BD");
    String pass = JOptionPane.showInputDialog("Escriba la clave de la BD");
    String dir  = "test/src/omoikane/repository/sampleData.xml";

    Class driverClass = Class.forName("com.mysql.jdbc.Driver");
    Connection jdbcConnection = DriverManager.getConnection(
            url, user, pass);
    IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);

    // Datos seleccionados considerando la base de datos de Omoikane 1.3.3 -> 1.4.0 alpha
    QueryDataSet partialDataSet = new QueryDataSet(connection);
    partialDataSet.addTable("articulos"        , "SELECT * FROM articulos         ORDER BY id_articulo DESC LIMIT 200");
    partialDataSet.addTable("base_para_precios", "SELECT * FROM base_para_precios ORDER BY id_articulo DESC LIMIT 200");
    partialDataSet.addTable("ventas"           , "SELECT * FROM ventas            ORDER BY id_venta DESC LIMIT 50");
    partialDataSet.addTable("ventas_detalles"  , "SELECT vd.* FROM ventas_detalles vd JOIN (SELECT id_venta FROM ventas ORDER BY id_venta DESC LIMIT 50) v ON (vd.id_venta = v.id_venta)");
    partialDataSet.addTable("cajas"            , "SELECT * FROM cajas");
    FlatXmlDataSet.write(partialDataSet, new FileOutputStream(dir));

    FlatDtdDataSet.write(connection.createDataSet(), new FileOutputStream("test/src/omoikane/repository/sampleBDSchema.dtd"));

    System.out.println("{}");
    JOptionPane.showMessageDialog(null, "Proceso completado. BD importada en "+dir);

}
 
开发者ID:ZooMMX,项目名称:Omoikane,代码行数:33,代码来源:CreateFixturesFromDB.java

示例15: writeBackupFile

import org.dbunit.dataset.xml.FlatXmlDataSet; //导入方法依赖的package包/类
private void writeBackupFile(IDataSet ds) throws IOException, DataSetException {
	tempFile = File.createTempFile("back","xml");
	FlatXmlDataSet.write(ds, new FileWriter(tempFile));
}
 
开发者ID:SoftwareKing,项目名称:SpringCloud,代码行数:5,代码来源:AbstractDbUnitTestCase.java


注:本文中的org.dbunit.dataset.xml.FlatXmlDataSet.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。