Forum Discussion
Awesome
16 years agoFrequent Contributor
SOLUTION: store attachment stream in a reader; pass reader object to OpenCSV to parse; store each line in a List[]
// READ .CSV attachment from SOAP RESPONSE
log.info " Attachment Name: " + testRunner.testCase.getTestStepByName( "runReport_1").testStep.testRequest.response.attachments[0].getName();
log.info " Attachment ContentType: " + testRunner.testCase.getTestStepByName( "runReport_1").testStep.testRequest.response.attachments[0].getContentType();
def attachment_stream = testRunner.testCase.getTestStepByName( "runReport_1").testStep.testRequest.response.attachments[0].getInputStream();
def rdr = new InputStreamReader(attachment_stream);
// OpenCSV read into List
CSVReader reader = new CSVReader(rdr);
def List theList = reader.readAll();
log.info " Number of Lines in List: " + theList.size()
// READ .CSV attachment from SOAP RESPONSE
log.info " Attachment Name: " + testRunner.testCase.getTestStepByName( "runReport_1").testStep.testRequest.response.attachments[0].getName();
log.info " Attachment ContentType: " + testRunner.testCase.getTestStepByName( "runReport_1").testStep.testRequest.response.attachments[0].getContentType();
def attachment_stream = testRunner.testCase.getTestStepByName( "runReport_1").testStep.testRequest.response.attachments[0].getInputStream();
def rdr = new InputStreamReader(attachment_stream);
// OpenCSV read into List
CSVReader reader = new CSVReader(rdr);
def List theList = reader.readAll();
log.info " Number of Lines in List: " + theList.size()