-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encode Boolean values without XMLEncoder
- Loading branch information
Martijn Dirkse
committed
Sep 23, 2024
1 parent
34c4da8
commit a910caa
Showing
2 changed files
with
52 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
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,43 @@ | ||
package nl.nn.testtool; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
public class MessageEncoderTest { | ||
@Test | ||
public void encode_and_decode_boolean_true() { | ||
MessageEncoder instance = new MessageEncoderImpl(); | ||
MessageEncoder.ToStringResult encoded = instance.toString(true, null); | ||
assertEquals("true", encoded.getString()); | ||
assertEquals("java.lang.Boolean", encoded.getMessageClassName()); | ||
Checkpoint checkpoint = new Checkpoint(); | ||
checkpoint.setMessage(encoded.getString()); | ||
checkpoint.setEncoding(encoded.getEncoding()); | ||
checkpoint.setMessageClassName(encoded.getMessageClassName()); | ||
Object back = instance.toObject(checkpoint); | ||
if(! (back instanceof Boolean)) { | ||
fail("Expected to get back Boolean"); | ||
} | ||
assertTrue((Boolean) back); | ||
} | ||
|
||
@Test | ||
public void encode_decode_boolean_false() { | ||
MessageEncoder instance = new MessageEncoderImpl(); | ||
MessageEncoder.ToStringResult encoded = instance.toString(false, null); | ||
assertEquals("false", encoded.getString()); | ||
assertEquals("java.lang.Boolean", encoded.getMessageClassName()); | ||
Checkpoint checkpoint = new Checkpoint(); | ||
checkpoint.setMessage(encoded.getString()); | ||
checkpoint.setEncoding(encoded.getEncoding()); | ||
checkpoint.setMessageClassName(encoded.getMessageClassName()); | ||
Object back = instance.toObject(checkpoint); | ||
if(! (back instanceof Boolean)) { | ||
fail("Expected to get back Boolean"); | ||
} | ||
assertFalse((Boolean) back); | ||
} | ||
} |