-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ArraySeq deserialization issue (#589)
- Loading branch information
Showing
4 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/scala-2.13/com/fasterxml/jackson/module/scala/deser/ArraySeqDeserializerTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.fasterxml.jackson.module.scala.deser | ||
|
||
import com.fasterxml.jackson.core.`type`.TypeReference | ||
import com.fasterxml.jackson.databind.json.JsonMapper | ||
import com.fasterxml.jackson.module.scala.{DefaultScalaModule, JacksonModule} | ||
|
||
import java.nio.charset.StandardCharsets | ||
import scala.collection.immutable | ||
import scala.collection.mutable | ||
|
||
class ArraySeqSerializerTest extends DeserializerTest { | ||
|
||
lazy val module: JacksonModule = DefaultScalaModule | ||
val arraySize = 1000 | ||
val obj = (1 to arraySize).map(i => ((i * 1498724053) & 0x1) == 0).toArray | ||
val jsonString = obj.mkString("[", ",", "]") | ||
val jsonBytes = jsonString.getBytes(StandardCharsets.UTF_8) | ||
|
||
"An ObjectMapper with the SeqDeserializer" should "handle immutable ArraySeq of booleans" in { | ||
val mapper = JsonMapper.builder().addModule(DefaultScalaModule).build() | ||
val seq = mapper.readValue(jsonBytes, new TypeReference[immutable.ArraySeq[Boolean]] {}) | ||
seq should have size arraySize | ||
} | ||
|
||
it should "handle mutable ArraySeq of booleans" in { | ||
val mapper = JsonMapper.builder().addModule(DefaultScalaModule).build() | ||
val seq = mapper.readValue(jsonBytes, new TypeReference[mutable.ArraySeq[Boolean]] {}) | ||
seq should have size arraySize | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/scala-3.0/com/fasterxml/jackson/module/scala/deser/ArraySeqDeserializerTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.fasterxml.jackson.module.scala.deser | ||
|
||
import com.fasterxml.jackson.core.`type`.TypeReference | ||
import com.fasterxml.jackson.databind.json.JsonMapper | ||
import com.fasterxml.jackson.module.scala.{DefaultScalaModule, JacksonModule} | ||
|
||
import java.nio.charset.StandardCharsets | ||
import scala.collection.immutable | ||
import scala.collection.mutable | ||
|
||
class ArraySeqSerializerTest extends DeserializerTest { | ||
|
||
lazy val module: JacksonModule = DefaultScalaModule | ||
val arraySize = 1000 | ||
val obj = (1 to arraySize).map(i => ((i * 1498724053) & 0x1) == 0).toArray | ||
val jsonString = obj.mkString("[", ",", "]") | ||
val jsonBytes = jsonString.getBytes(StandardCharsets.UTF_8) | ||
|
||
"An ObjectMapper with the SeqDeserializer" should "handle immutable ArraySeq of booleans" in { | ||
val mapper = JsonMapper.builder().addModule(DefaultScalaModule).build() | ||
val seq = mapper.readValue(jsonBytes, new TypeReference[immutable.ArraySeq[Boolean]] {}) | ||
seq should have size arraySize | ||
} | ||
|
||
it should "handle mutable ArraySeq of booleans" in { | ||
val mapper = JsonMapper.builder().addModule(DefaultScalaModule).build() | ||
val seq = mapper.readValue(jsonBytes, new TypeReference[mutable.ArraySeq[Boolean]] {}) | ||
seq should have size arraySize | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters