Server|sqlserver
Package com.sourceware.test;
/*******************************************************************************
* Copyright (c), Zhongke Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common public License v1.0
* Which accompanies this distribution, and are available at
* http://www.source-ware.com/
*
* Contributors:
* Zhongke corporation-initial API and implementation
*******************************************************************************/
Import Java.io.InputStream;
Import java.sql.Connection;
Import Org.dbunit.DatabaseTestCase;
Import Org.dbunit.database.DatabaseConfig;
Import org.dbunit.database.DatabaseConnection;
Import org.dbunit.database.IDatabaseConnection;
Import Org.dbunit.dataset.IDataSet;
Import Org.dbunit.dataset.xml.FlatXmlDataSet;
Import org.dbunit.operation.DatabaseOperation;
Import Com.sourceware.sms.platform.dao.SMSDAO;
Import Org.springframework.context.support.ClassPathXmlApplicationContext;
Import Org.springframework.context.ApplicationContext;
Import Javax.sql.DataSource;
/**
*
* <p> title: Message Service </p>
*
* <p> Description: Message Service Platform </p>
*
* <p> Copyright: Ningbo Zhongke Information Industry Co., Ltd. Copyright (c) 2004</p>
*
* <p> Company: Ningbo Zhongke Information Industry Co., Ltd. </p>
*
* @author Wu Fengbin (woowind@sina.com)
* @version 1.0
*/
public class Basedatabasetestcase
Extends Databasetestcase {
Static ApplicationContext Appcontext;
Private final static String BatchId =
"Http://www.dbunit.org/features/batchedStatements";
Static DataSource ds;
static {
Appcontext =
New Classpathxmlapplicationcontext ("Xml/sms-platform-context.xml");
ds = (DataSource) appcontext.getbean ("DataSource");
}
protected void SetUp () throws Exception {
Super.setup ();
}
protected void teardown () throws Exception {
Super.teardown ();
This.getconnection (). Close ();
}
/* (Non-javadoc)
* @see org.dbunit.databasetestcase#getconnection ()
*/
Protected Idatabaseconnection getconnection () throws Exception {
Idatabaseconnection idatabaseconnection = new DatabaseConnection (ds.
Getconnection ());
Databaseconfig config = Idatabaseconnection.getconfig ();
Enable batched statements
if (!config.getfeature (BatchId)) {
Config.setfeature (BatchId, true);
}
return idatabaseconnection;
}
/* (Non-javadoc)
* @see Org.dbunit.databasetestcase#getdataset ()
*/
Protected Idataset GetDataSet () throws Exception {
InputStream is = This.getclass (). getClassLoader (). getResourceAsStream (
"Dataset/fmsdomain.xml");
Return to New Flatxmldataset (IS);
}
Protected Databaseoperation getsetupoperation () throws Exception {
return Org.dbunit.ext.mssql.InsertIdentityOperation.INSERT;
}
Protected Databaseoperation getteardownoperation () throws Exception {
return Org.dbunit.ext.mssql.InsertIdentityOperation.CLEAN_INSERT;
}
}