Skip to content

Commit

Permalink
Merge branch 'rpcCrash' of github.com:siroky/Payola into rpcCrash
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiri Helmich committed Apr 10, 2012
2 parents aa5ed97 + 4934b53 commit b1e1b8e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ tmp/
payola/lib/s2js-adapters_2.9.1-0.2.jar
payola/lib/s2js-compiler_2.9.1-0.2.jar
payola/web/server/public/javascripts/compiled/
payola/web/server/public/javascripts/runtime/
payola/web/server/public/javascripts/runtime-shared/
payola/web/server/public/javascripts/runtime-client/
payola/web/server/public/javascripts/common/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class JSONSerializer
&& !obj.isInstanceOf[Array[_]]) {
// Must be AnyRef, otherwise it wouldn't get into the processedObjects array
result = serializePlainObject(obj.asInstanceOf[AnyRef], serializeObjectAsReference, objectID, processedObjects)
} else if (serializationClass.isDefined) {
} else if (serializationClass.isDefined && !serializationClass.get._2.isInstanceOf[CustomValueSerializationRule[_]]) {
val rule = serializationClass.get._2
result = rule match {
case basic: BasicSerializationRule => serializeWithRule(obj.asInstanceOf[AnyRef], basic, objectID, processedObjects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class Group(val name: String)
val thisIsNotInTrait = null
}

class Exception1(val message: String = "", val cause: Exception = null) extends RuntimeException
class Exception2(override val message: String = "", cause: Exception = null) extends Exception1(message, cause)

class Scala2JSONTest extends FlatSpec with ShouldMatchers {
"JSONSerializer" should "handle cyclic dependencies and a BasicSerializationRule." in {
val u: User = new User("Franta")
Expand Down Expand Up @@ -70,4 +73,14 @@ class Scala2JSONTest extends FlatSpec with ShouldMatchers {
JSONUtilities.escapeString("\"jame\"go\"\"to hess\"\"") should equal ("\"\\\"jame\\\"go\\\"\\\"to hess\\\"\\\"\"")
}

"exception" should "have a message field serialized" in {
val serializer: JSONSerializer = new JSONSerializer()
val exc = new Exception2("Hello")

val rule = new CustomValueSerializationRule[Exception2]("message", { (_, exc) => exc.message })
serializer.addSerializationRule(new SimpleSerializationClass(classOf[Exception2]), rule)

assume(serializer.serialize(exc).contains("Hello"))
}

}

0 comments on commit b1e1b8e

Please sign in to comment.