Skip to content

Commit

Permalink
Adding failing test for #163
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 11, 2019
1 parent 26c5b56 commit 65a0693
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
Expand Up @@ -7,9 +7,9 @@

import com.fasterxml.jackson.databind.MappingIterator;

public class MultipleRootValuesTest extends ModuleTestBase
public class MultipleDocumentsReadTest extends ModuleTestBase
{
private final YAMLMapper MAPPER = new YAMLMapper();
private final YAMLMapper MAPPER = newObjectMapper();

private final YAMLFactory YAML_F = MAPPER.getFactory();

Expand Down
Expand Up @@ -4,7 +4,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

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

public void testSet26() throws Exception
{
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
ObjectMapper mapper = newObjectMapper();
final String YAML = "---\n"
+"sets: !!set\n"
+" ? a\n"
Expand Down
@@ -0,0 +1,50 @@
package com.fasterxml.jackson.dataformat.yaml.failing;

import java.io.StringWriter;
import java.util.Collections;

import com.fasterxml.jackson.databind.*;

import com.fasterxml.jackson.dataformat.yaml.ModuleTestBase;

// for [dataformats-text#163]
public class MultipleDocumentsWriteTest extends ModuleTestBase
{
static class POJO163 {
public int value;

public POJO163(int v) { value = v; }
}

public void testWriteMultipleDocsBeans() throws Exception
{
ObjectMapper mapper = newObjectMapper();
StringWriter w = new StringWriter();
try (SequenceWriter seqW = mapper.writer().writeValues(w)) {

This comment has been minimized.

Copy link
@piyushkumar13

piyushkumar13 Dec 12, 2019

@cowtowncoder You can try adding sequenceWriter.init(true); here. Exception might resolve, since I was also getting some exception without this.

seqW.write(new POJO163(42));
seqW.write(new POJO163(28));
}
w.close();

String yaml = w.toString();

// !!! TODO: actual expected multi-doc contents:
assertEquals("foo", yaml);
}

public void testWriteMultipleDocsLists() throws Exception
{
ObjectMapper mapper = newObjectMapper();
StringWriter w = new StringWriter();
try (SequenceWriter seqW = mapper.writer().writeValues(w)) {

This comment has been minimized.

Copy link
@piyushkumar13

piyushkumar13 Dec 12, 2019

Try adding sequenceWriter.init(true); here as well

seqW.write(Collections.singleton(42));
seqW.write(Collections.singleton(28));
}
w.close();

String yaml = w.toString();

// !!! TODO: actual expected multi-doc contents:
assertEquals("foo", yaml);
}
}

0 comments on commit 65a0693

Please sign in to comment.