Groovy(conncet DB, generate xml, get response xml, compare two xml)

Groovy(conncet DB, generate xml, get response xml, compare two xml),第1张

概述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

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();        }    

总结

以上是内存溢出为你收集整理的Groovy(conncet DB, generate xml, get response xml, compare two xml)全部内容,希望文章能够帮你解决Groovy(conncet DB, generate xml, get response xml, compare two xml)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1271010.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存