我已经为我的申请写了一个代码。
def "Test for file type #FileFormat"() {
given:
HttpURLConnection connection = getHandlerURL('endpoint')
connection.setDoOutput(true)
connection.setRequestMethod("POST")
connection.setRequestProperty(HttpHeaders.CONTENT_TYPE, "RdfFormat."+RDFFileFormat+".toMIME()")
rdfStatement = ModelFactory.createDefaultModel().read(new ByteArrayInputStream(readRDFfromfile(Filename).bytes), null, "RdfFormat."+RDFFileFormat.toString()).listStatements().nextStatement()
when:
connection.getOutputStream().write(readRDFfromfile(Filename).bytes)
then:
connection.getResponseCode() == HTTP_CREATED
where:
FileFormat | Filename | RDFFileFormat
'N-TRIPLES' | 'n-triples.nt' | "NTRIPLES"
}当我运行我的代码时,我在给定子句的最后一行中得到了错误:SampleTest.Test for file type #FileFormat:37 » Riot。
如果我使用RdfFormat.NTRIPLES.toString()而不是使用从Where子句传递的参数RDFFileFormat,测试就会通过。
尝试分配def format1 = "RdfFormat."+RDFFileFormat+".toString()"和使用format1,但得到了相同的错误。
有什么办法可以让它起作用吗?
发布于 2016-10-25 07:45:30
我想你可能想:
connection.setRequestProperty(HttpHeaders.CONTENT_TYPE, RdfFormat."$RDFFileFormat".toMIME())https://stackoverflow.com/questions/40230996
复制相似问题