New to groovy and seeking some help. I have a requirement where I need to compare XML files with similar names from two folders and I have to compare certain tags alone. Can anyone help me with this,
Ex : folder1 has xmls with name abc.xml, xyz.xml.
folder2 has xmls with name abc.xml, xyz.xml.
I need to check if folder1 and folder2 has file with similar name, if yes then go ahead and compare the XML's and print the difference (using groovy scripting in SOAPUI)**
Please see: Working on SOAP UI free version.
Was able to fetch the xml filenames from folder1 and folder 2 so far
def fileList1 = []
File folder1 = new File("Path of basefiles")
folder1.eachFileRecurse FileType.FILES, { f ->
if (f.isFile() && f.name.endsWith('.xml')) {
def filename1 = f.name[0..-1]
fileList1.add(filename1)
log.info filename1
}
}
if (fileList1.size() < 1) {
testRunner.fail("No request files")
}
def fileList2 = []
File folder2 = new File("Path of response files")
folder2.eachFileRecurse FileType.FILES, { f ->
if (f.isFile() && f.name.endsWith('.xml')) {
def filename2 = f.name[0..-1]
fileList2.add(filename2)
log.info filename2
}
}
if (fileList2.size() < 1) {
testRunner.fail("No request files")
}
if(fileList1==fileList2)
log.info true
else
log.info false
Now, I want to ensure if there is any xml file with similar name in folder 1 and folder 2, I should compare those two xml's and print the difference.