Skip to content

Commit 1dd3b23

Browse files
committed
Write regression test for FasterXML#109. No further changes needed beyond the databind changes.
1 parent 1029739 commit 1dd3b23

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fasterxml.jackson.module.scala.ser
2+
3+
import com.fasterxml.jackson.annotation.JsonPropertyOrder
4+
import com.fasterxml.jackson.databind.MapperFeature
5+
import com.fasterxml.jackson.module.scala.DefaultScalaModule
6+
import org.junit.runner.RunWith
7+
import org.scalatest.junit.JUnitRunner
8+
9+
object TransientFieldTest {
10+
@JsonPropertyOrder(Array("x"))
11+
class ClassyTransient {
12+
@transient
13+
val value = 3
14+
def getValue = value
15+
def getX = 42
16+
}
17+
}
18+
19+
@RunWith(classOf[JUnitRunner])
20+
class TransientFieldTest extends SerializerTest {
21+
import TransientFieldTest._
22+
23+
val module = DefaultScalaModule
24+
25+
"DefaultScalaModule" should "normally ignore @transient annotations" in {
26+
serialize(new ClassyTransient) shouldBe """{"x":42,"value":3}"""
27+
}
28+
29+
it should "respect @transient annotation when feature enabled" in {
30+
serialize(new ClassyTransient, newMapper.enable(MapperFeature.PROPAGATE_TRANSIENT_MARKER)) shouldBe """{"x":42}"""
31+
}
32+
}

0 commit comments

Comments
 (0)