#902 - EJsonWriter.write(Object object, Writer writer) ... closes the writer but should not

This commit is contained in:
Rob Bygrave
2016-11-28 21:27:14 +13:00
parent 7ba86f7cf2
commit 588d5c5cfa
2 changed files with 28 additions and 3 deletions
@@ -6,10 +6,16 @@ import com.avaje.ebeaninternal.server.type.ModifyAwareOwner;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.nio.file.Files;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -18,6 +24,8 @@ import static org.junit.Assert.*;
public class EJsonTests {
private static final Logger log = LoggerFactory.getLogger(EJsonTests.class);
@Test
public void test_map_simple() throws IOException {
@@ -38,6 +46,21 @@ public class EJsonTests {
assertEquals(jsonInput, jsonOutput);
}
@Test
public void write_withWriter_expect_writerNotClosed() throws IOException {
File temp = Files.createTempFile("some", ".json").toFile();
FileWriter writer = new FileWriter(temp);
Map<String,Object> map = new LinkedHashMap<>();
map.put("foo", "bar");
EJson.write(map, writer);
writer.write("The end.");
writer.flush();
writer.close();
log.info("write to file {}", temp.getAbsolutePath());
}
@Test
public void test_parseObject() throws IOException {