Skip to content

Commit

Permalink
more tests.....92% line coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tdas committed Jun 4, 2015
1 parent 7e2fdcf commit 26b5179
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private[spark] object SerializationDebugger extends Logging {
*
* It does not yet handle writeObject override, but that shouldn't be too hard to do either.
*/
def find(obj: Any): List[String] = {
private[serializer] def find(obj: Any): List[String] = {
new SerializationDebugger().visit(obj, List.empty)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.spark.serializer

import java.io.{IOException, ObjectOutputStream, ObjectOutput, ObjectInput}
import java.io._

import org.scalatest.BeforeAndAfterEach

Expand Down Expand Up @@ -141,7 +141,7 @@ class SerializationDebuggerSuite extends SparkFunSuite with BeforeAndAfterEach {
}

test("crazy nested objects") {

def findAndAssert(shouldSerialize: Boolean, obj: Any): Unit = {
val s = find(obj)
if (shouldSerialize) {
Expand All @@ -168,6 +168,31 @@ class SerializationDebuggerSuite extends SparkFunSuite with BeforeAndAfterEach {
)))
)
}

test("improveException") {
val e = SerializationDebugger.improveException(
new SerializableClass2(new NotSerializable), new NotSerializableException("someClass"))
assert(e.getMessage.contains("someClass")) // original exception message should be present
assert(e.getMessage.contains("SerializableClass2")) // found debug trace should be present
}

test("improveException with error in debugger") {
// Object that throws exception in the SerializationDebugger
val o = new SerializableClass1 {
private def writeReplace(): Object = {
throw new Exception()
}
}
withClue("requirement: SerializationDebugger should fail trying debug this object") {
intercept[Exception] {
SerializationDebugger.find(o)
}
}

val originalException = new NotSerializableException("someClass")
// verify thaht original exception is returned on failure
assert(SerializationDebugger.improveException(o, originalException).eq(originalException))
}
}


Expand Down

0 comments on commit 26b5179

Please sign in to comment.