Skip to content

Commit 65a0693

Browse files
committed
Adding failing test for #163
1 parent 26c5b56 commit 65a0693

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/MultipleRootValuesTest.java renamed to yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/MultipleDocumentsReadTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import com.fasterxml.jackson.databind.MappingIterator;
99

10-
public class MultipleRootValuesTest extends ModuleTestBase
10+
public class MultipleDocumentsReadTest extends ModuleTestBase
1111
{
12-
private final YAMLMapper MAPPER = new YAMLMapper();
12+
private final YAMLMapper MAPPER = newObjectMapper();
1313

1414
private final YAMLFactory YAML_F = MAPPER.getFactory();
1515

yaml/src/test/java/com/fasterxml/jackson/dataformat/yaml/failing/CollectionReadTest.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import com.fasterxml.jackson.databind.ObjectMapper;
66
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
7-
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
87

98
// for [dataformat-yaml#26]: not sure if it's an actual bug, but adding for now.
109
public class CollectionReadTest extends ModuleTestBase
@@ -15,7 +14,7 @@ static class SetBean {
1514

1615
public void testSet26() throws Exception
1716
{
18-
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
17+
ObjectMapper mapper = newObjectMapper();
1918
final String YAML = "---\n"
2019
+"sets: !!set\n"
2120
+" ? a\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.fasterxml.jackson.dataformat.yaml.failing;
2+
3+
import java.io.StringWriter;
4+
import java.util.Collections;
5+
6+
import com.fasterxml.jackson.databind.*;
7+
8+
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
9+
10+
// for [dataformats-text#163]
11+
public class MultipleDocumentsWriteTest extends ModuleTestBase
12+
{
13+
static class POJO163 {
14+
public int value;
15+
16+
public POJO163(int v) { value = v; }
17+
}
18+
19+
public void testWriteMultipleDocsBeans() throws Exception
20+
{
21+
ObjectMapper mapper = newObjectMapper();
22+
StringWriter w = new StringWriter();
23+
try (SequenceWriter seqW = mapper.writer().writeValues(w)) {
24+
seqW.write(new POJO163(42));
25+
seqW.write(new POJO163(28));
26+
}
27+
w.close();
28+
29+
String yaml = w.toString();
30+
31+
// !!! TODO: actual expected multi-doc contents:
32+
assertEquals("foo", yaml);
33+
}
34+
35+
public void testWriteMultipleDocsLists() throws Exception
36+
{
37+
ObjectMapper mapper = newObjectMapper();
38+
StringWriter w = new StringWriter();
39+
try (SequenceWriter seqW = mapper.writer().writeValues(w)) {
40+
seqW.write(Collections.singleton(42));
41+
seqW.write(Collections.singleton(28));
42+
}
43+
w.close();
44+
45+
String yaml = w.toString();
46+
47+
// !!! TODO: actual expected multi-doc contents:
48+
assertEquals("foo", yaml);
49+
}
50+
}

0 commit comments

Comments
 (0)