Examples of JacksonDataCodec


Examples of com.linkedin.data.codec.JacksonDataCodec

        @Override
        public void onSuccess(RestResponse result)
        {
          try
          {
            DataMap data = new JacksonDataCodec().readMap(result.getEntity().asInputStream());
            Assert.assertEquals(data.get(QueryParamMockCollection.VALUE_KEY), testValue);
            Assert.assertEquals(QueryParamMockCollection._lastQueryParamValue, testValue);
          }
          catch (IOException e)
          {
View Full Code Here

Examples of com.linkedin.data.codec.JacksonDataCodec

  public static DataMap dataSchemaToDataMap(NamedDataSchema schema)
  {
    String inputSchemaAsString = schema.toString();
    try
    {
      JacksonDataCodec codec = new JacksonDataCodec();
      DataMap schemaAsDataMap = codec.stringToMap(inputSchemaAsString);
      return schemaAsDataMap;
    }
    catch (IOException e)
    {
      // This should never occur.
View Full Code Here

Examples of com.linkedin.data.codec.JacksonDataCodec

   */
  public static DataSchema dataMapToDataSchema(DataMap map, SchemaParser parser)
  {
    // Convert DataMap into DataSchema
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    JacksonDataCodec codec = new JacksonDataCodec();
    try
    {
      codec.writeMap(map, outputStream);
    }
    catch (IOException e)
    {
      // This should never occur
      throw new IllegalStateException(UNEXPECTED_IOEXCEPTION + map, e);
View Full Code Here

Examples of com.linkedin.data.codec.JacksonDataCodec

  }

  @Test
  public void testJacksonDataCodec() throws IOException
  {
    JacksonDataCodec codec = new JacksonDataCodec();
    testDataCodec(codec, referenceDataMap1);

    DataList list1 = codec.bytesToList("[7,27,279]".getBytes());
    assertEquals(list1, new DataList(Arrays.asList(7, 27, 279)));

    DataList list2 = new DataList(Arrays.asList(321, 21, 1));
    assertEquals(codec.listToBytes(list2), "[321,21,1]".getBytes());

    DataMap map3 = getMapFromJson(codec, "{ \"a\" : null }");
    // out.println(map3.getError());
    assertSame(map3.get("a"), Data.NULL);

    DataMap map4 = getMapFromJson(codec, "{ \"b\" : 123456789012345678901234567890 }");
    // out.println(map4.getError());
    assertTrue(map4.getError().indexOf(" value: 123456789012345678901234567890, token: VALUE_NUMBER_INT, number type: BIG_INTEGER not parsed.") != -1);

    DataMap map5 = getMapFromJson(codec, "{ \"a\" : null, \"b\" : 123456789012345678901234567890 }");
    // out.println(map5.getError());
    assertTrue(map5.getError().indexOf(" value: 123456789012345678901234567890, token: VALUE_NUMBER_INT, number type: BIG_INTEGER not parsed.") != -1);

    // Test comments
    codec.setAllowComments(true);
    DataMap map6 = getMapFromJson(codec, "/* abc */ { \"a\" : \"b\" }");
    assertEquals(map6.get("a"), "b");

    // Test getStringEncoding
    String encoding = codec.getStringEncoding();
    assertEquals(encoding, "UTF-8");
    assertEquals(encoding, JsonEncoding.UTF8.getJavaName());
  }
View Full Code Here

Examples of com.linkedin.data.codec.JacksonDataCodec

  }

  @Test
  public void testJacksonCodecNumbers() throws IOException
  {
    JacksonDataCodec codec = new JacksonDataCodec();
    testCodecNumbers(codec);
  }
View Full Code Here

Examples of com.linkedin.data.codec.JacksonDataCodec

  }

  @Test(expectedExceptions = IOException.class)
  public void testJacksonDataCodecErrorEmptyInput() throws IOException
  {
    final JacksonDataCodec codec = new JacksonDataCodec();
    final ByteArrayInputStream in = new ByteArrayInputStream(new byte[0]);
    codec.readMap(in);
  }
View Full Code Here

Examples of com.linkedin.data.codec.JacksonDataCodec

  }

  @Test(expectedExceptions = DataDecodingException.class)
  public void testJacksonDataCodecErrorToList() throws IOException
  {
    final JacksonDataCodec codec = new JacksonDataCodec();
    codec.bytesToList("{\"A\": 1}".getBytes());
  }
View Full Code Here

Examples of com.linkedin.data.codec.JacksonDataCodec

  }

  @Test(expectedExceptions = DataDecodingException.class)
  public void testJacksonDataCodecErrorToMap() throws IOException
  {
    final JacksonDataCodec codec = new JacksonDataCodec();
    codec.bytesToMap("[1, 2, 3]".getBytes());
  }
View Full Code Here

Examples of com.linkedin.data.codec.JacksonDataCodec

  }

  private void perfTest(int count, DataMap map) throws IOException
  {
    List<DataCodec> codecs = new ArrayList<DataCodec>();
    codecs.add(new JacksonDataCodec());
    //codecs.add(new Bson4JacksonDataCodec());
    codecs.add(new BsonDataCodec());

    for (DataCodec codec : codecs)
    {
View Full Code Here

Examples of com.linkedin.data.codec.JacksonDataCodec

{
  protected boolean debug = false;

  public Object jsonToObject(String s) throws IOException
  {
    JacksonDataCodec codec = new JacksonDataCodec();
    String input = "{ \"key\" : " + s + " }";
    DataMap map = TestUtil.dataMapFromString(input);
    return map.get("key");
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.