use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.
the class TestSerializedString method testFailedAccess.
public void testFailedAccess() throws IOException {
final String INPUT = "Bit longer text";
SerializableString sstr = new SerializedString(INPUT);
final byte[] buffer = new byte[INPUT.length() - 2];
final char[] ch = new char[INPUT.length() - 2];
final ByteBuffer bbuf = ByteBuffer.allocate(INPUT.length() - 2);
assertEquals(-1, sstr.appendQuotedUTF8(buffer, 0));
assertEquals(-1, sstr.appendQuoted(ch, 0));
assertEquals(-1, sstr.putQuotedUTF8(bbuf));
bbuf.rewind();
assertEquals(-1, sstr.appendUnquotedUTF8(buffer, 0));
assertEquals(-1, sstr.appendUnquoted(ch, 0));
assertEquals(-1, sstr.putUnquotedUTF8(bbuf));
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.
the class NextXxxAccessTest method _testIssue38.
private void _testIssue38(int mode) throws Exception {
final String DOC = "{\"field\" :\"value\"}";
SerializableString fieldName = new SerializedString("field");
JsonParser parser = createParser(mode, DOC);
assertEquals(JsonToken.START_OBJECT, parser.nextToken());
assertTrue(parser.nextFieldName(fieldName));
assertEquals(JsonToken.VALUE_STRING, parser.nextToken());
assertEquals("value", parser.getText());
assertEquals(JsonToken.END_OBJECT, parser.nextToken());
if (mode != MODE_DATA_INPUT) {
assertNull(parser.nextToken());
}
parser.close();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.
the class NextXxxAccessTest method _testIsNextTokenName4.
private void _testIsNextTokenName4(int mode) throws Exception {
final String DOC = "{\"name\":-123,\"name2\":99}";
JsonParser p = createParser(mode, DOC);
assertToken(JsonToken.START_OBJECT, p.nextToken());
assertTrue(p.nextFieldName(new SerializedString("name")));
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(-123, p.getIntValue());
assertTrue(p.nextFieldName(new SerializedString("name2")));
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(99, p.getIntValue());
assertToken(JsonToken.END_OBJECT, p.nextToken());
if (mode != MODE_DATA_INPUT) {
assertNull(p.nextToken());
}
p.close();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-core by FasterXML.
the class NextXxxAccessTest method _testNextNameWithLong.
private void _testNextNameWithLong(int mode) throws Exception {
// do 5 meg thingy
final int SIZE = 5 * 1024 * 1024;
StringBuilder sb = new StringBuilder(SIZE + 20);
sb.append("{");
Random rnd = new Random(1);
int count = 0;
while (sb.length() < SIZE) {
++count;
if (sb.length() > 1) {
sb.append(", ");
}
int val = rnd.nextInt();
sb.append('"');
sb.append("f" + val);
sb.append("\":");
sb.append(String.valueOf(val % 1000));
}
sb.append("}");
final String DOC = sb.toString();
JsonParser parser = createParser(mode, DOC);
assertToken(JsonToken.START_OBJECT, parser.nextToken());
rnd = new Random(1);
for (int i = 0; i < count; ++i) {
int exp = rnd.nextInt();
SerializableString expName = new SerializedString("f" + exp);
assertTrue(parser.nextFieldName(expName));
assertToken(JsonToken.VALUE_NUMBER_INT, parser.nextToken());
assertEquals(exp % 1000, parser.getIntValue());
}
assertToken(JsonToken.END_OBJECT, parser.nextToken());
parser.close();
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.io.SerializedString in project jackson-databind by FasterXML.
the class TestJsonNode method testRawValue.
// [databind#743]
public void testRawValue() throws Exception {
ObjectNode root = MAPPER.createObjectNode();
root.putRawValue("a", new RawValue(new SerializedString("[1, 2, 3]")));
assertEquals("{\"a\":[1, 2, 3]}", MAPPER.writeValueAsString(root));
}
Aggregations