Skip to content

Commit 35fed9f

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

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.fasterxml.jackson.module.scala.ser
2+
3+
import com.fasterxml.jackson.annotation.{JsonProperty, 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+
val x = 42
13+
@transient
14+
val value = 3
15+
def getValue = value
16+
}
17+
18+
class IgnoredTransient {
19+
@transient
20+
val value = 3
21+
val x = 42
22+
}
23+
}
24+
25+
@RunWith(classOf[JUnitRunner])
26+
class TransientFieldTest extends SerializerTest {
27+
import TransientFieldTest._
28+
29+
val module = DefaultScalaModule
30+
31+
"DefaultScalaModule" should "normally ignore @transient annotations" in {
32+
serialize(new ClassyTransient) shouldBe """{"x":42,"value":3}"""
33+
}
34+
35+
it should "respect @transient annotation when feature enabled" in {
36+
serialize(new ClassyTransient, newMapper.enable(MapperFeature.PROPAGATE_TRANSIENT_MARKER)) shouldBe """{"x":42}"""
37+
}
38+
39+
it should "normally ignore @transient fields without getters" in {
40+
serialize(new IgnoredTransient) shouldBe """{"x":42}"""
41+
}
42+
}

0 commit comments

Comments
 (0)