import groovy.sql.Sql
import groovy.xml.MarkupBuilder
import org.custommonkey.xmlunit.*
//Conect to DB and get the nessecery data to generate the expected Xml.
Sql sql=context.dbConnection;
def writer = new StringWriter();
def xml = new groovy.xml.MarkupBuilder(writer)
xml.RetailerGroups(){
RetailerGroup(Name:"Checkout",Id:"CO")
{
Retailers(){
Retailer(Name:"Acme",Id:"Acm")
Retailer(Name:"Acme2",Id:"Acm2")
def res = sql.firstRow("select scdprj.user3 as 'Brand',"
+ "schedwin.unix_date_conv (scdslg.air_start) as 'StartDate',"
+ "schedwin.unix_date_conv (scdslg.air_end) as 'EndDate',"
+ "scdprj.cl_id as AdvertiserId,clnt.name + ' ' + '-'+ ' ' + user3 as CampaignName,clnt.name as AdvertiserName "
+ "From schedwin.PROJECTS scdprj "
+ "Inner join schedwin.SLGUSAGE scdslg "
+ "ON scdprj.prj_id=scdslg.prj_id "
+ "Join schedwin.CLNT clnt "
+ "ON clnt.cl_id=scdprj.cl_id "
+ "Where scdprj.cl_id=1228 and (scdprj.stat=1) and scdprj.formid=0 "
+ "AND (DATEDIFF(dd,schedwin.unix_date_conv(scdslg.AIR_END),'20090707') < =0) "
+ "AND (DATEDIFF(dd,schedwin.unix_date_conv(scdslg.AIR_START),'20090707') >= 0) ")
}
}
RetailerGroup(Name:"Checkout",Id:"CO")
}
def expectedResult = writer.toString()
log.info writer.toString()
XMLUnit.setIgnoreWhitespace(true)
//Get the actual result
def step = testRunner.testCase.testSteps["retailer"]
def result = step.testRequest.response.contentAsString
log.info result
//Check the actual result by expected result,and output the test result.def xmlDiff = new Diff(result,expectedResult)def s = xmlDiff.toString();File f = new File("c:/","d.txt"); if( !f.exists()){ f.createNewFile(); }try { FileWriter fileWriter = new FileWriter(f,true); if (s == "org.custommonkey.xmlunit.Diff[identical]"){ fileWriter.write("API: '"+ step.name + "' DV Result is "+ "Passed/r/n"); } else{ fileWriter.write("API: '"+ step.name + "' DV Result is "+ "Failed/r/n"); } fileWriter.close(); } catch (IOException e) { e.printStackTrace(); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。