cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot cast object 'jxl.read.biff.SheetImpl@f55c22' with class 'jxl.read.biff.SheetImpl' to class 'j

Highlighted
Contributor

Cannot cast object 'jxl.read.biff.SheetImpl@f55c22' with class 'jxl.read.biff.SheetImpl' to class 'j

Hi,

 

I'm trying to update the overall status of my tests to an excel which contains a list of services. I want to write the status against the corresponding service name. I'm comparing the data received from the inputFile with the response received from soapUI.I'm writing the status to ServiceFile. I have used the below code but I'm getting cannot cast error at line 25

 

Code:

import static java.nio.charset.StandardCharsets.*;
import java.lang.*;
import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus
import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep
import com.eviware.soapui.support.XmlHolder
import jxl.*
import jxl.write.*
import org.skyscreamer.jsonassert.JSONAssert
import org.skyscreamer.jsonassert.JSONCompareMode
import groovy.json.JsonSlurper
def i=1,k=1,pass_count=0,fail_count=0
def inputFileName,Service_File
def inputFile = testRunner.testCase.testSuite.getPropertyValue("inputFileName")
def ServiceFile = testRunner.testCase.testSuite.getPropertyValue("Service_File")

Workbook inputWB = Workbook.getWorkbook(new File(inputFile))
Sheet inputSheet = inputWB.getSheet(0)
no_of_rows= inputSheet.getRows().toInteger()

Workbook list_file = Workbook.getWorkbook(new File(ServiceFile))
Sheet listSheet = list_file.getSheet(0)
no_of_services= listSheet.getRows().toInteger()
WritableSheet sheet_writable = list_file.getSheet(0)

testCaseName=testRunner.testCase.name
(0..context.testCase.testStepCount-1).each{
def step1 = context.testCase.testStepList[it]
if ( step1 instanceof RestTestRequestStep) {
for(j=1;j<no_of_rows;j++){
Cell f=inputSheet.getCell(0,j)
step_name=f.getContents()
Cell f1=inputSheet.getCell(3,j)
def String step_response=f1.getContents()
step_response=step_response.replaceAll(" ","")
def String response = context.expand(step1.getPropertyValue('Response'))
response=response.replaceAll(" ","")
if(step1.name==step_name&step1.name!=null){
try{
JSONAssert.assertEquals(step_response,response,false)
pass_count=pass_count+1
}catch(AssertionError e){
fail_count=fail_count+1
}
k=k+1
}

}
}
}
def status=testRunner.testCase.testSuite.getPropertyValue("overall_status")
if(status=="Passed")
{
if(fail_count>0)
{
testRunner.testCase.testSuite.setPropertyValue("overall_status","Failed")
}
}
def overall_status=testRunner.testCase.testSuite.getPropertyValue("overall_status")
def ProjectName= testRunner.testCase.testSuite.project.getName()
for(i=1;i<no_of_services;i++)
{
Cell f=listSheet.getCell(0,i)
service_name=f.getContents()
log.info service_name
if(service_name==ProjectName)
{
jxl.write.Label final_status = new jxl.write.Label(2,i ,overall_status)
sheet_writable.addCell(final_status)
}
}
inputWB.close()
list_file.close()

 

Error:

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'jxl.read.biff.SheetImpl@f55c22' with class 'jxl.read.biff.SheetImpl' to class 'jxl.write.WritableSheet' error at line: 25