Exemple #1
0
 private VersionedObject versioningRoundTripSerailization(
     VersionedObject obj, SchemaVersion ver, String encoding) throws Exception {
   ByteArrayOutputStream os = new ByteArrayOutputStream();
   switch (encoding) {
     case "binary":
       Serializer.newBinaryWriter(ver, os).write(obj);
       return Serializer.newBinaryReader(ver, new ByteArrayInputStream(os.toByteArray()))
           .read((VersionedObject) null);
     case "json":
       Serializer.newJsonWriter(ver, os).write(obj);
       return Serializer.newJsonReader(ver, new ByteArrayInputStream(os.toByteArray()))
           .read((VersionedObject) null);
     default:
       throw new AssertionError("Unexpected encoding.");
   }
 }
Exemple #2
0
  @Test
  public void testJsonSerializationNoDefinition() throws Exception {
    thrown.expect(TeslaSerializationException.class);
    thrown.expectMessage(
        "Type 'com.expedia.tesla.compiler.test.passcompile.full.referencetest.ObjectReference' is not defined in current schema.");

    ObjectReference obj = new ObjectReference();
    ObjectWriter writer =
        Serializer.newJsonWriter(
            Serializer.VERSION_TESLACOMPILER_ALL_TYPES_V1_0, new ByteArrayOutputStream());
    writer.write(obj);
  }
Exemple #3
0
  @Test
  public void testJsonDeserializationNoDefinition() throws Exception {
    thrown.expect(TeslaDeserializationException.class);
    thrown.expectMessage(
        "Type 'com.expedia.tesla.compiler.test.passcompile.full.referencetest.ObjectReference' is not defined in current schema.");

    ObjectReference obj = new ObjectReference();
    InputStream is = new ByteArrayInputStream("{}".getBytes());
    ObjectReader reader =
        Serializer.newJsonReader(Serializer.VERSION_TESLACOMPILER_ALL_TYPES_V1_0, is);
    reader.read(obj);
  }