-
-
Notifications
You must be signed in to change notification settings - Fork 797
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First sort-of working version of #549
- Loading branch information
1 parent
2b19c0b
commit 56c4371
Showing
7 changed files
with
131 additions
and
10 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
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
62 changes: 62 additions & 0 deletions
62
src/test/java/com/fasterxml/jackson/core/json/CustomQuoteCharTest.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,62 @@ | ||
package com.fasterxml.jackson.core.json; | ||
|
||
import java.io.*; | ||
|
||
import com.fasterxml.jackson.core.*; | ||
|
||
// For [core#549], ability to use alternate quote characters | ||
public class CustomQuoteCharTest | ||
extends com.fasterxml.jackson.core.BaseTest | ||
{ | ||
final JsonFactory JSON_F = streamFactoryBuilder() | ||
.quoteChar('\'') | ||
.build(); | ||
|
||
public void testBasicAposWithCharBased() throws Exception | ||
{ | ||
StringWriter w; | ||
JsonGenerator g; | ||
|
||
// with Object | ||
w = new StringWriter(); | ||
g = createGenerator(JSON_F, w); | ||
g.writeStartObject(); | ||
g.writeStringField("question", "answer"); | ||
g.writeEndObject(); | ||
g.close(); | ||
assertEquals("{'question':'answer'}", w.toString()); | ||
|
||
// with Array | ||
w = new StringWriter(); | ||
g = createGenerator(JSON_F, w); | ||
g.writeStartArray(); | ||
g.writeString("hello world"); | ||
g.writeEndArray(); | ||
g.close(); | ||
assertEquals("['hello world']", w.toString()); | ||
} | ||
|
||
public void testBasicAposWithByteBased() throws Exception | ||
{ | ||
ByteArrayOutputStream out; | ||
JsonGenerator g; | ||
|
||
// with Object | ||
out = new ByteArrayOutputStream(); | ||
g = createGenerator(JSON_F, out); | ||
g.writeStartObject(); | ||
g.writeStringField("question", "answer"); | ||
g.writeEndObject(); | ||
g.close(); | ||
assertEquals("{'question':'answer'}", out.toString("UTF-8")); | ||
|
||
// with Array | ||
out = new ByteArrayOutputStream(); | ||
g = createGenerator(JSON_F, out); | ||
g.writeStartArray(); | ||
g.writeString("hello world"); | ||
g.writeEndArray(); | ||
g.close(); | ||
assertEquals("['hello world']", out.toString("UTF-8")); | ||
} | ||
} |
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