@@ -21,16 +21,15 @@ import java.net.{HttpURLConnection, URL}
2121import javax .servlet .http .{HttpServletRequest , HttpServletResponse }
2222
2323import org .apache .commons .io .{FileUtils , IOUtils }
24- import org .json4s ._
25- import org .json4s .jackson .JsonMethods
2624import org .mockito .Mockito .when
2725import org .scalatest .{BeforeAndAfter , FunSuite , Matchers }
2826import org .scalatest .mock .MockitoSugar
2927
30- import org .apache .spark .{SecurityManager , SparkConf }
28+ import org .apache .spark .{JsonTestUtils , SecurityManager , SparkConf }
3129import org .apache .spark .ui .SparkUI
3230
33- class HistoryServerSuite extends FunSuite with BeforeAndAfter with Matchers with MockitoSugar {
31+ class HistoryServerSuite extends FunSuite with BeforeAndAfter with Matchers with MockitoSugar
32+ with JsonTestUtils {
3433
3534 private val logDir = new File (" src/test/resources/spark-events" )
3635 private val expRoot = new File (" src/test/resources/HistoryServerExpectations/" )
@@ -102,7 +101,7 @@ class HistoryServerSuite extends FunSuite with BeforeAndAfter with Matchers with
102101 import org .json4s .jackson .JsonMethods ._
103102 val jsonAst = parse(json)
104103 val expAst = parse(exp)
105- HistoryServerSuite . assertValidDataInJson(jsonAst, expAst)
104+ assertValidDataInJson(jsonAst, expAst)
106105 }
107106 }
108107
@@ -243,15 +242,4 @@ object HistoryServerSuite {
243242 else throw new RuntimeException (" got code: " + code + " when getting " + path + " w/ error: " + error)
244243 }
245244
246- def assertValidDataInJson (validateJson : JValue , expectedJson : JValue ) {
247- val Diff (c, a, d) = validateJson diff expectedJson
248- val validatePretty = JsonMethods .pretty(validateJson)
249- val expectedPretty = JsonMethods .pretty(expectedJson)
250- val errorMessage = s " Expected: \n $expectedPretty\n Found: \n $validatePretty"
251- import org .scalactic .TripleEquals ._
252- assert(c === JNothing , s " $errorMessage\n Changed: \n ${JsonMethods .pretty(c)}" )
253- assert(a === JNothing , s " $errorMessage\n Added: \n ${JsonMethods .pretty(a)}" )
254- assert(d === JNothing , s " $errorMessage\n Deleted: \n ${JsonMethods .pretty(d)}" )
255- }
256245}
257-
0 commit comments