Forum Discussion
nmrao, sorry, seem to be crossing over posts again, we must of been replying at the same time...
My questions was really in response to seeing the error:
"java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean"
From what I can see, the script shown can not throw this error, so my thinking was that the error originates somewhere else, I was guessing that some other bit of code was trying to convert a string to a boolean value. Sorry if that didn't come across.
Unfortunately the only error message I'm getting from the logs so far is only this one:
TestCase failed [java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean:java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean], time taken = 2447
nmrao Thank you for your input, however the issue is not in the clearing properties itself, but with assigning value to them.
If I put values manually (any number, basically) in the properties - test case is running absolutely ok. Every time I use my script that first clears all properties and then assigns "1" to those two properties - test case fails on the very first step with the exception (screenshot attached).
My guess was that it's connected to the types of properties, because as far as I know, you cannot store int or booleans in properties, only converting them to String helps. But i's just a pure guessing, unfortunately I'm not very familiar with SoapUI yet, just started to work with it, so please exuse me for any stupid questions that might come up.
- nmrao8 years agoCommunity Hero
Re-iterating my request for the following:
1. Would you mind sharing clean log from error log tab?
2. Full script of 1 step.
Otherwise it is difficult to offer any help.- Radford8 years agoSuper Contributor
Excuse me if I am explaining things you aready know, but you mentioned you were new to SoapUI. The "error log" can be found at the bottom of the screen, see the highlighted area 5 on the following page:
https://www.soapui.org/getting-started/soapui-interface/main-window.html
To get the log nmrao requested, open the error log, clear it (should be a right click menu option), then run your test again, then copy and paste the log contetents here.
- Akuratere8 years agoNew Contributor
Radford, nmrao sorry, found the exception text in SoapUI log window, error log is absolutely empty:
- Wed May 17 13:38:55 CEST 2017:ERROR:Exception during Test Execution
- java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
- at com.ubs.soapuiengine.ExtendedError.afterStep(ExtendedError.java:20)
- at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:222)
- at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:47)
- at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:138)
- at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:46)
- at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:129)
- at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
- at java.util.concurrent.FutureTask.run(Unknown Source)
- at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
- at java.lang.Thread.run(Unknown Source)
Please find the full script of step 1 below:
import com.eviware.soapui.support.XmlHolder
import jxl.*
import jxl.write.*
def myTestCase = context.testCase // creating instance of testCase
propTestStep = myTestCase.getTestStepByName("Properties") // read the properties
// CAPTURE PROJECT CUSTOM PROPERTIES - OUTPUT FOLDER AND INPUT FILE
output = testRunner.testCase.testSuite.project.getPropertyValue("OutputFolder")
xlsFile = testRunner.testCase.testSuite.project.getPropertyValue("InputFile")
log.info xlsFile
propTestStep.setPropertyValue("Datasheet", "flattenPdfForm")
Workbook workbook1 = Workbook.getWorkbook(new File(xlsFile)) //reading file containing the data
Sheet sheet1 = workbook1.getSheet(0) // reading 1st sheet in the excel
size = sheet1.getRows().toInteger() // getting number of rows
propTestStep.setPropertyValue("Total", size.toString()) // save number of rows to the "Total" property
counter = propTestStep.getPropertyValue("Count").toString() // create variable for iteration number
counter = counter.toInteger()
next = (counter+1) //set the next value
//// READING EXCEL
Cell a = sheet1.getCell(1,counter)
Cell b = sheet1.getCell(2,counter)
Cell c = sheet1.getCell(3,counter)
Cell d = sheet1.getCell(4,counter)
Cell e = sheet1.getCell(5,counter)
Cell f = sheet1.getCell(6,counter)
Cell g = sheet1.getCell(7,counter)
workbook1.close() //close the file
// SAVING VALUES IN THE PROPERTIES
propTestStep.setPropertyValue("Form Name", a.getContents())
propTestStep.setPropertyValue("PDF", b.getContents())
propTestStep.setPropertyValue("Rendering Engine", c.getContents())
propTestStep.setPropertyValue("make PDFa", d.getContents())
propTestStep.setPropertyValue("PDF type", e.getContents())
propTestStep.setPropertyValue("Md5Digest", f.getContents())
propTestStep.setPropertyValue("responseFile", g.getContents())
// CAPTURING PDF FILE NAME FROM EXCEL AND ASSIGNING FULL PATH TO VARIABLE "PATH"
String p1 = testRunner.testCase.testSuite.project.getPropertyValue("InputFolder")
String p2 = "Input_PDF"
p3 = propTestStep.getPropertyValue( "PDF" )
p4 = p1 + "\\" + p2 + "\\" + p3
propTestStep.setPropertyValue("Path",p4)
path = propTestStep.getPropertyValue ("Path")
// ENCODING PDF FILE INTO BASE64 FORMAT
def inputFile = new File(path).getText('UTF-8')
String encoded = inputFile.bytes.encodeBase64().toString()
propTestStep.setPropertyValue("PDFcontent", encoded)
propTestStep.setPropertyValue("Count", next.toString()) // increase Count value
next++ // increase next value
propTestStep.setPropertyValue("Next", next.toString()) // save Next value in properties
// SETTING STOP VALUE
if (counter == size-1)
{
propTestStep.setPropertyValue("Stop", "T")
}
else if (counter==0)
{
def runner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testRunner.testCase, null)
propTestStep.setPropertyValue("Stop", "F")
}
else
{
propTestStep.setPropertyValue("Stop", "F")
}