use of com.linkedin.data.ChunkedByteStringWriter in project rest.li by linkedin.
the class TestJacksonJsonDataEncoder method testStringInternDisabledByDefault.
/**
* Test to make sure that field names are not interned by default.
*/
@Test
public void testStringInternDisabledByDefault() throws Exception {
final String keyName = "testKey";
DataMap dataMap = new DataMap();
dataMap.put(keyName, 1);
JacksonJsonDataEncoder encoder = new JacksonJsonDataEncoder(dataMap, 3);
// make sure intern field names is disabled by default
assertFalse(encoder._jsonFactory.isEnabled(JsonFactory.Feature.INTERN_FIELD_NAMES));
EntityStream<ByteString> entityStream = EntityStreams.newEntityStream(encoder);
CollectingReader<ByteString, ?, ChunkedByteStringCollector.Result> reader = new CollectingReader<>(new ChunkedByteStringCollector());
entityStream.setReader(reader);
byte[] encoded = reader.getResult().toCompletableFuture().get().data;
JacksonJsonDataMapDecoder decoder = new JacksonJsonDataMapDecoder();
// make sure intern field names is disabled
assertFalse(decoder._jsonFactory.isEnabled(JsonFactory.Feature.INTERN_FIELD_NAMES));
Writer<ByteString> writer = new ChunkedByteStringWriter(encoded, 3);
entityStream = EntityStreams.newEntityStream(writer);
entityStream.setReader(decoder);
DataMap map = decoder.getResult().toCompletableFuture().get();
final String key = map.keySet().iterator().next();
assertEquals(key, keyName);
assertNotSame(key, keyName);
}
use of com.linkedin.data.ChunkedByteStringWriter in project rest.li by linkedin.
the class FeedDownloadResourceReactive method get.
@Override
public void get(Long key, @CallbackParam Callback<UnstructuredDataReactiveResult> callback) {
ChunkedByteStringWriter writer = new ChunkedByteStringWriter(CONTENT, 2);
callback.onSuccess(new UnstructuredDataReactiveResult(EntityStreams.newEntityStream(writer), CONTENT_TYPE));
}
Aggregations