use of com.linkedin.data.codec.ProtobufDataCodec in project rest.li by linkedin.
the class TestProtobufDataDecoder method testNumbers.
@Test(dataProvider = "numbersData", dataProviderClass = CodecDataProviders.class)
public void testNumbers(Object number) throws Exception {
DataMap dataMap = new DataMap();
dataMap.put("number", number);
byte[] bytes = TestUtil.dataComplexToBytes(new ProtobufDataCodec(new ProtobufCodecOptions.Builder().build()), dataMap);
assertEquals(decode(bytes, 20), dataMap);
}
use of com.linkedin.data.codec.ProtobufDataCodec in project rest.li by linkedin.
the class TestProtobufDataDecoder method testIntValues.
@Test
public void testIntValues() throws Exception {
int inc = (Integer.MAX_VALUE - Integer.MAX_VALUE / 100) / 10000;
for (int i = Integer.MAX_VALUE / 100; i <= Integer.MAX_VALUE && i > 0; i += inc) {
DataMap dataMap = new DataMap();
dataMap.put("int", i);
byte[] bytes = TestUtil.dataComplexToBytes(new ProtobufDataCodec(new ProtobufCodecOptions.Builder().build()), dataMap);
DataMap decodedMap = (DataMap) decode(bytes, 20);
assertEquals(decodedMap.getInteger("int"), Integer.valueOf(i));
}
for (int i = Integer.MIN_VALUE; i <= Integer.MIN_VALUE / 100 && i < 0; i += inc) {
DataMap dataMap = new DataMap();
dataMap.put("int", i);
byte[] bytes = TestUtil.dataComplexToBytes(new ProtobufDataCodec(new ProtobufCodecOptions.Builder().build()), dataMap);
DataMap decodedMap = (DataMap) decode(bytes, 20);
assertEquals(decodedMap.getInteger("int"), Integer.valueOf(i));
}
}
use of com.linkedin.data.codec.ProtobufDataCodec in project rest.li by linkedin.
the class TestSymbolTableSerializer method data.
@DataProvider
public static Object[][] data() {
List<Object[]> list = new ArrayList<>();
List<DataCodec> codecs = new ArrayList<>();
codecs.add(new BsonDataCodec());
codecs.add(new JacksonDataCodec());
codecs.add(new JacksonSmileDataCodec());
codecs.add(new JacksonLICORDataCodec(false));
codecs.add(new JacksonLICORDataCodec(true));
codecs.add(new ProtobufDataCodec());
for (DataCodec codec : codecs) {
list.add(new Object[] { codec, true });
list.add(new Object[] { codec, false });
}
return list.toArray(new Object[][] {});
}
use of com.linkedin.data.codec.ProtobufDataCodec in project rest.li by linkedin.
the class TestProtobufDataDecoder method testInvalidMap.
@Test
public void testInvalidMap() throws Exception {
DataList dataList = new DataList();
dataList.add(1);
dataList.add(2);
dataList.add(4);
byte[] bytes = TestUtil.dataComplexToBytes(new ProtobufDataCodec(new ProtobufCodecOptions.Builder().build()), dataList);
decode(bytes, 3);
try {
decodeMap(bytes);
fail("Parsing list as map.");
} catch (ExecutionException e) {
// Expected.
}
}
use of com.linkedin.data.codec.ProtobufDataCodec in project rest.li by linkedin.
the class TestProtobufDataDecoder method testDecoder.
@Test(dataProvider = "streamCodecData", dataProviderClass = CodecDataProviders.class)
public void testDecoder(String testName, DataComplex dataComplex, int chunkSize) throws Exception {
ProtobufDataCodec codec = new ProtobufDataCodec(new ProtobufCodecOptions.Builder().setEnableASCIIOnlyStrings(true).build());
byte[] bytes = TestUtil.dataComplexToBytes(codec, dataComplex);
DataComplex decodedDataComplex = decode(bytes, chunkSize);
assertEquals(TestUtil.dataComplexToBytes(codec, decodedDataComplex), bytes);
}
Aggregations