-
Notifications
You must be signed in to change notification settings - Fork 624
/
JaxbElementTest.kt
29 lines (23 loc) · 1004 Bytes
/
JaxbElementTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.sksamuel.kotest
import io.kotest.assertions.shouldFail
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.equality.shouldBeEqualToComparingFields
import io.kotest.matchers.string.shouldContain
import javax.xml.bind.JAXBElement
import javax.xml.namespace.QName
class JaxbElementTest : FunSpec({
context("Comparing JAXBElement reflectively works as expected") {
val jaxbElement = JAXBElement(QName.valueOf("name"), Int::class.java, 123)
val otherJaxbElement = JAXBElement(QName.valueOf("name"), Int::class.java, 124)
test("!should pass when comparing equal elements") {
jaxbElement.shouldBeEqualToComparingFields(jaxbElement)
}
test("!should fail when comparing different elements") {
shouldFail {
jaxbElement.shouldBeEqualToComparingFields(otherJaxbElement)
}.message.shouldContain(
"""Value differ at:\s+1\) value:\s+expected:<124> but was:<123>""".toRegex()
)
}
}
})