Hey nmrao
so I updated the script assertion as follows:
def ns = context.expand('${REST Request#namespace}')
def ds = context.expand('${REST Request#dataset}')
def value = "attachment; filename=${ns}_${ds}.csv" as String
log.info value
//def expectedHTTPResponse = ['attachment; filename=context.expand( '${REST Request#namespace}' )_context.expand( '${REST Request#dataset}' ).csv']
//def headers = messageExchange.response.responseHeaders
//def actualHTTPResponse = headers['Content-Disposition']
//assert expectedHTTPResponse == actualHTTPResponse
and it generated the following:
Thu Feb 21 11:17:37 GMT 2019: INFO: attachment; filename=certification-nomenclature_certificates.csv
so I thought about your code and tried the following:
def ns = context.expand('${REST Request#namespace}')
def ds = context.expand('${REST Request#dataset}')
//def value = "attachment; filename=${ns}_${ds}.csv" as String
//log.info value
def expectedHTTPResponse = "attachment; filename=${ns}_${ds}.csv" as String
def headers = messageExchange.response.responseHeaders
def actualHTTPResponse = headers['Content-Disposition']
assert expectedHTTPResponse == actualHTTPResponse
and got the result
assert expectedHTTPResponse == actualHTTPResponse | | | | | [attachment; filename=certification-nomenclature_certificates.csv] | false attachment; filename=certification-nomenclature_certificates.cs
so I removed the 'as String' and wrapped the value in square brackets as
def ns = context.expand('${REST Request#namespace}')
def ds = context.expand('${REST Request#dataset}')
def expectedHTTPResponse = ["attachment; filename=${ns}_${ds}.csv"]
def headers = messageExchange.response.responseHeaders
def actualHTTPResponse = headers['Content-Disposition']
assert expectedHTTPResponse == actualHTTPResponse
and it worked! YAY!
thanks a lot man - that was doing my head in.
For my education - can you clarify why I have to declare those variables (ns and ds) rather than use the original script?
Again - thanks so much - you're saving my life here!
richie
\zz\