-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d95b5c3
commit 3bb1792
Showing
15 changed files
with
222 additions
and
146 deletions.
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
52 changes: 0 additions & 52 deletions
52
yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/EventsTest.java
This file was deleted.
Oops, something went wrong.
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
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
4 changes: 3 additions & 1 deletion
4
...ckson/dataformat/yaml/UTF8ReaderTest.java → ...dataformat/yaml/deser/UTF8ReaderTest.java
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
29 changes: 29 additions & 0 deletions
29
yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/BinaryWriteTest.java
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,29 @@ | ||
package com.fasterxml.jackson.dataformat.yaml.ser; | ||
|
||
import org.junit.Assert; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.databind.node.JsonNodeType; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase; | ||
|
||
public class BinaryWriteTest extends ModuleTestBase | ||
{ | ||
private final ObjectMapper MAPPER = newObjectMapper(); | ||
|
||
public void testBinaryViaTree() throws Exception | ||
{ | ||
byte[] srcPayload = new byte[] { 1, 2, 3, 4, 5 }; | ||
ObjectNode root = MAPPER.createObjectNode(); | ||
root.put("payload", srcPayload); | ||
String doc = MAPPER.writeValueAsString(root); | ||
|
||
// and read back | ||
final JsonNode bean = MAPPER.readTree(doc); | ||
final JsonNode data = bean.get("payload"); | ||
assertNotNull(data); | ||
assertEquals(JsonNodeType.BINARY, data.getNodeType()); | ||
final byte[] b = data.binaryValue(); | ||
Assert.assertArrayEquals(srcPayload, b); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/ser/DatabindWriteTest.java
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,77 @@ | ||
package com.fasterxml.jackson.dataformat.yaml.ser; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
import java.util.TreeSet; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase; | ||
|
||
public class DatabindWriteTest extends ModuleTestBase | ||
{ | ||
public void testBasicPOJO() throws Exception | ||
{ | ||
ObjectMapper mapper = newObjectMapper(); | ||
FiveMinuteUser user = new FiveMinuteUser("Bob", "Dabolito", false, | ||
FiveMinuteUser.Gender.MALE, new byte[] { 1, 3, 13, 79 }); | ||
String yaml = mapper.writeValueAsString(user).trim(); | ||
String[] parts = yaml.split("\n"); | ||
// unify ordering, need to use TreeSets to get alphabetic ordering | ||
TreeSet<String> exp = new TreeSet<String>(); | ||
for (String part : parts) { | ||
exp.add(part.trim()); | ||
} | ||
Iterator<String> it = exp.iterator(); | ||
assertEquals("---", it.next()); | ||
assertEquals("AQMNTw==", it.next()); | ||
assertEquals("firstName: \"Bob\"", it.next()); | ||
assertEquals("gender: \"MALE\"", it.next()); | ||
assertEquals("lastName: \"Dabolito\"", it.next()); | ||
assertEquals("userImage: !!binary |", it.next()); | ||
assertEquals("verified: false", it.next()); | ||
assertFalse(it.hasNext()); | ||
} | ||
|
||
public void testWithFile() throws Exception | ||
{ | ||
File f = File.createTempFile("test", ".yml"); | ||
f.deleteOnExit(); | ||
ObjectMapper mapper = newObjectMapper(); | ||
Map<String,Integer> map = new HashMap<String,Integer>(); | ||
map.put("a", 3); | ||
mapper.writeValue(f, map); | ||
assertTrue(f.canRead()); | ||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream( | ||
f), "UTF-8")); | ||
String doc = br.readLine(); | ||
String str = br.readLine(); | ||
if (str != null) { | ||
doc += "\n" + str; | ||
} | ||
doc = trimDocMarker(doc); | ||
assertEquals("a: 3", doc); | ||
br.close(); | ||
f.delete(); | ||
} | ||
|
||
public void testWithFile2() throws Exception | ||
{ | ||
File f = File.createTempFile("test", ".yml"); | ||
f.deleteOnExit(); | ||
ObjectMapper mapper = newObjectMapper(); | ||
ObjectNode root = mapper.createObjectNode(); | ||
root.put("name", "Foobar"); | ||
mapper.writeValue(f, root); | ||
|
||
// and get it back | ||
Map<?,?> result = mapper.readValue(f, Map.class); | ||
assertEquals(1, result.size()); | ||
assertEquals("Foobar", result.get("name")); | ||
} | ||
} |
7 changes: 6 additions & 1 deletion
7
...taformat/yaml/GeneratorFeature34Test.java → ...rmat/yaml/ser/GeneratorFeature34Test.java
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
Oops, something went wrong.