To Write the "status response" from a REST" in a file,status different to "HTTP/1.0 200 OK".
Hi
I have a script that writes me in an Excel Sheet the "status" response from a REST, for correct cases, but not the status different to "HTTP/1.0 200 OK".
I would like to write this errors. What will I do?
import com.eviware.soapui.support.GroovyUtils.*;
import org.apache.poi.ss.usermodel.*
import org.apache.poi.hssf.usermodel.*
import org.apache.poi.xssf.usermodel.*
import org.apache.poi.ss.util.*
import groovy.json.JsonSlurper.*
int fil = testRunner.testCase.getPropertyValue("Fila").toInteger();
int cel = testRunner.testCase.getPropertyValue("Col").toInteger();
cel++;
def httpResponseHeaders = context.testCase.testSteps["PuntoVenta"].testRequest.response.responseHeaders
def httpStatus = httpResponseHeaders["#status#"]
log.info httpStatus
def fs=new FileInputStream ("D:\\prueba\\Salida.xlsx")
Workbook wb = WorkbookFactory.create(fs)
def fil1 = wb.getSheet("Hoja1").getLastRowNum()+1
def hora = new Date().format("yyyy-MM-dd'T'HH:mm:ss SSS")
log.info hora
def row = wb.getSheet("Hoja1").createRow(fil1)
row.createCell(0).setCellValue(new Date().toString())
row.createCell(1).setCellValue(httpStatus)
fs.close();
def fo = new FileOutputStream ("D:\\prueba\\Salida.xlsx");
wb.write(fo);
fo.close();
if(fil<5)
{
fil++;
testRunner.testCase.setPropertyValue("Fila",fil.toString());
testRunner.gotoStepByName("Script");
// Se realiza el bucle para que vaya al script fila.
}
else
{
fil=0;
cel=0;
testRunner.testCase.setPropertyValue("Fila",fil.toString());
testRunner.testCase.setPropertyValue("Col",cel.toString());
}
- Hey alfonsolftc,
Is there a reason you're not using a Datasink step to do this? If you just need the status headers value i think a couple of lines of groovy in either a script assertion (or separate groovy step), which youve written already for the most part, along with a Datasink step will do this?
Also i'm not understanding the purpose of youre assignment of the hora variable. I can see youre specifying the datetime as the hora variable but you dont appear to use it at all in the script after assignment? Am i missing something important here?
Cheers fella,
Rich