我在我的数据库中断言我的Json响应值,但我得到了断言错误。
这是groovy脚本:
16/08/04 15:35:05 ERROR yarn.ApplicationMaster: User class threw exception: java.lang.RuntimeException: Multiple sources found for json (org.apache.spark.sql.execution.datasources.json.JsonFileFormat, org.apache.spark.sql.execution.datasources.json.DefaultSource), please specify the fully qualified class name.
java.lang.RuntimeException: Multiple sources found for json (org.apache.spark.sql.execution.datasources.json.JsonFileFormat, org.apache.spark.sql.execution.datasources.json.DefaultSource), please specify the fully qualified class name.
at scala.sys.package$.error(package.scala:27)
at org.apache.spark.sql.execution.datasources.DataSource.lookupDataSource(DataSource.scala:167)
at org.apache.spark.sql.execution.datasources.DataSource.providingClass$lzycompute(DataSource.scala:78)
at org.apache.spark.sql.execution.datasources.DataSource.providingClass(DataSource.scala:78)
at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:310)
at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:149)
at org.apache.spark.sql.DataFrameReader.json(DataFrameReader.scala:287)
at org.apache.spark.sql.DataFrameReader.json(DataFrameReader.scala:249)
错误日志:
import groovy.json.JsonSlurper
// DataBase Properties
def DBcaseID = context.expand('${DataSource#CaseID}')
def DBDescription = context.expand('${DataSource#Description}' )
def row = testRunner.testCase.testSteps["DataSource"].currentRow
def CasesResponse = context.expand( '${Cases#Response}' )
def json = new JsonSlurper().parseText(CasesResponse)
//Response Values
def CaseID = json.Root[row-1].CaseID
def Description = json.Root[row-1].Description
assert CaseID == DBcaseID, "DB value: ${DBcaseID} is not equals to JSONResp value: ${CaseID}"
assert Description == DBDescription, "DB value: ${DBDescription} is not equals to JSONResp value: ${Description}"
甚至CaseID字段值在数据库和json响应中都是相同的