Skip to content

Instantly share code, notes, and snippets.

@knoguchi
Created May 14, 2017 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knoguchi/da4125b66ca20e3b0d1f26f35ac2d6ea to your computer and use it in GitHub Desktop.
Save knoguchi/da4125b66ca20e3b0d1f26f35ac2d6ea to your computer and use it in GitHub Desktop.
package com.fasterxml.jackson.dataformat.protobuf.schema;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.dataformat.protobuf.ProtobufMapper;
import com.fasterxml.jackson.dataformat.protobuf.ProtobufTestBase;
import java.io.IOException;
import java.io.InputStream;
public class DeserializeTest extends ProtobufTestBase
{
private final ProtobufMapper MAPPER = new ProtobufMapper();
public void testDeserialize() throws IOException
{
// Prepare schema
InputStream in = this.getClass().getResourceAsStream("/descriptor.proto");
ProtobufSchema schema = ProtobufSchemaLoader.std.load(in);
// System.out.println(schema.toString());
// Deserialize the descriptor PB
InputStream pb = this.getClass().getResourceAsStream("/unittest_proto3.desc");
JsonNode t = MAPPER.readerFor(JsonNode.class).with(schema).readValue(pb);
assertNotNull(t);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment