public void testPojoWithArray2D() throws Exception { Schema<PojoWithArray2D> schema = RuntimeSchema .getSchema(PojoWithArray2D.class); Pipe.Schema<PojoWithArray2D> pipeSchema = ((RuntimeSchema<PojoWithArray2D>) schema).getPipeSchema(); PojoWithArray2D p = new PojoWithArray2D().fill(); byte[] data = toByteArray(p, schema); PojoWithArray2D pFromByteArray = new PojoWithArray2D(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithArray2D pFromStream = new PojoWithArray2D(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithMap() throws Exception { Schema<PojoWithMap> schema = RuntimeSchema.getSchema(PojoWithMap.class); Pipe.Schema<PojoWithMap> pipeSchema = ((RuntimeSchema<PojoWithMap>) schema).getPipeSchema(); PojoWithMap p = new PojoWithMap().fill(); byte[] data = toByteArray(p, schema); PojoWithMap pFromByteArray = new PojoWithMap(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithMap pFromStream = new PojoWithMap(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testBat() throws Exception { Schema<WrapsBat> schema = RuntimeSchema.getSchema(WrapsBat.class); Pipe.Schema<WrapsBat> pipeSchema = ((RuntimeSchema<WrapsBat>) schema).getPipeSchema(); WrapsBat p = new WrapsBat().fill(); byte[] data = toByteArray(p, schema); WrapsBat pFromByteArray = new WrapsBat(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); WrapsBat pFromStream = new WrapsBat(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojo() throws Exception { Schema<Pojo> schema = RuntimeSchema.getSchema(Pojo.class); Pipe.Schema<Pojo> pipeSchema = ((RuntimeSchema<Pojo>) schema).getPipeSchema(); Pojo p = new Pojo().fill(); byte[] data = toByteArray(p, schema); Pojo pFromByteArray = new Pojo(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); Pojo pFromStream = new Pojo(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithSingletonMapNullKV() throws Exception { Schema<PojoWithSingletonMapNullKV> schema = RuntimeSchema .getSchema(PojoWithSingletonMapNullKV.class); Pipe.Schema<PojoWithSingletonMapNullKV> pipeSchema = ((RuntimeSchema<PojoWithSingletonMapNullKV>) schema) .getPipeSchema(); PojoWithSingletonMapNullKV p = new PojoWithSingletonMapNullKV().fill(); byte[] data = toByteArray(p, schema); PojoWithSingletonMapNullKV pFromByteArray = new PojoWithSingletonMapNullKV(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithSingletonMapNullKV pFromStream = new PojoWithSingletonMapNullKV(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithCustomArrayListAndHashMapAndHashMap() throws Exception { Schema<PojoWithCustomArrayListAndHashMap> schema = RuntimeSchema .getSchema(PojoWithCustomArrayListAndHashMap.class); Pipe.Schema<PojoWithCustomArrayListAndHashMap> pipeSchema = ((RuntimeSchema<PojoWithCustomArrayListAndHashMap>) schema) .getPipeSchema(); PojoWithCustomArrayListAndHashMap p = new PojoWithCustomArrayListAndHashMap() .fill(); byte[] data = toByteArray(p, schema); PojoWithCustomArrayListAndHashMap pFromByteArray = new PojoWithCustomArrayListAndHashMap(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithCustomArrayListAndHashMap pFromStream = new PojoWithCustomArrayListAndHashMap(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithCollection() throws Exception { Schema<PojoWithCollection> schema = RuntimeSchema .getSchema(PojoWithCollection.class); Pipe.Schema<PojoWithCollection> pipeSchema = ((RuntimeSchema<PojoWithCollection>) schema).getPipeSchema(); PojoWithCollection p = new PojoWithCollection().fill(); byte[] data = toByteArray(p, schema); PojoWithCollection pFromByteArray = new PojoWithCollection(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithCollection pFromStream = new PojoWithCollection(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithThrowable() throws Exception { Schema<PojoWithThrowable> schema = RuntimeSchema .getSchema(PojoWithThrowable.class); Pipe.Schema<PojoWithThrowable> pipeSchema = ((RuntimeSchema<PojoWithThrowable>) schema).getPipeSchema(); PojoWithThrowable p = new PojoWithThrowable().fill(); byte[] data = toByteArray(p, schema); PojoWithThrowable pFromByteArray = new PojoWithThrowable(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithThrowable pFromStream = new PojoWithThrowable(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithArray() throws Exception { Schema<PojoWithArray> schema = RuntimeSchema .getSchema(PojoWithArray.class); Pipe.Schema<PojoWithArray> pipeSchema = ((RuntimeSchema<PojoWithArray>) schema).getPipeSchema(); PojoWithArray p = new PojoWithArray().fill(); byte[] data = toByteArray(p, schema); PojoWithArray pFromByteArray = new PojoWithArray(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithArray pFromStream = new PojoWithArray(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithClassFields() throws Exception { Schema<PojoWithClassFields> schema = RuntimeSchema .getSchema(PojoWithClassFields.class); Pipe.Schema<PojoWithClassFields> pipeSchema = ((RuntimeSchema<PojoWithClassFields>) schema).getPipeSchema(); PojoWithClassFields p = new PojoWithClassFields().fill(); byte[] data = toByteArray(p, schema); PojoWithClassFields pFromByteArray = new PojoWithClassFields(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithClassFields pFromStream = new PojoWithClassFields(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithThrowableArray() throws Exception { Schema<PojoWithThrowableArray> schema = RuntimeSchema .getSchema(PojoWithThrowableArray.class); Pipe.Schema<PojoWithThrowableArray> pipeSchema = ((RuntimeSchema<PojoWithThrowableArray>) schema) .getPipeSchema(); PojoWithThrowableArray p = new PojoWithThrowableArray().fill(); byte[] data = toByteArray(p, schema); PojoWithThrowableArray pFromByteArray = new PojoWithThrowableArray(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithThrowableArray pFromStream = new PojoWithThrowableArray(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithObjectCollectionNullKV() throws Exception { Schema<PojoWithObjectCollectionNullKV> schema = RuntimeSchema .getSchema(PojoWithObjectCollectionNullKV.class); Pipe.Schema<PojoWithObjectCollectionNullKV> pipeSchema = ((RuntimeSchema<PojoWithObjectCollectionNullKV>) schema) .getPipeSchema(); PojoWithObjectCollectionNullKV p = new PojoWithObjectCollectionNullKV() .fill(); byte[] data = toByteArray(p, schema); PojoWithObjectCollectionNullKV pFromByteArray = new PojoWithObjectCollectionNullKV(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithObjectCollectionNullKV pFromStream = new PojoWithObjectCollectionNullKV(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithObjectMapFields() throws Exception { Schema<PojoWithObjectMapFields> schema = RuntimeSchema .getSchema(PojoWithObjectMapFields.class); Pipe.Schema<PojoWithObjectMapFields> pipeSchema = ((RuntimeSchema<PojoWithObjectMapFields>) schema) .getPipeSchema(); PojoWithObjectMapFields p = new PojoWithObjectMapFields().fill(); byte[] data = toByteArray(p, schema); PojoWithObjectMapFields pFromByteArray = new PojoWithObjectMapFields(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithObjectMapFields pFromStream = new PojoWithObjectMapFields(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); PojoWithObjectMapFields.verify(pFromByteArray, pFromStream); }
public void testPojoWithObjectCollectionFields() throws Exception { Schema<PojoWithObjectCollectionFields> schema = RuntimeSchema .getSchema(PojoWithObjectCollectionFields.class); Pipe.Schema<PojoWithObjectCollectionFields> pipeSchema = ((RuntimeSchema<PojoWithObjectCollectionFields>) schema) .getPipeSchema(); PojoWithObjectCollectionFields p = new PojoWithObjectCollectionFields() .fill(); byte[] data = toByteArray(p, schema); PojoWithObjectCollectionFields pFromByteArray = new PojoWithObjectCollectionFields(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithObjectCollectionFields pFromStream = new PojoWithObjectCollectionFields(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); PojoWithObjectCollectionFields.verify(pFromByteArray, pFromStream); }
public void testPojoWithSingletonAsDelegate() throws Exception { if (RuntimeEnv.ID_STRATEGY instanceof DefaultIdStrategy) { ((DefaultIdStrategy) RuntimeEnv.ID_STRATEGY) .registerDelegate(SINGLETON_DELEGATE); } Schema<PojoWithSingletonAsDelegate> schema = RuntimeSchema .getSchema(PojoWithSingletonAsDelegate.class); Pipe.Schema<PojoWithSingletonAsDelegate> pipeSchema = ((RuntimeSchema<PojoWithSingletonAsDelegate>) schema) .getPipeSchema(); PojoWithSingletonAsDelegate p = new PojoWithSingletonAsDelegate() .fill(); byte[] data = toByteArray(p, schema); PojoWithSingletonAsDelegate pFromByteArray = new PojoWithSingletonAsDelegate(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithSingletonAsDelegate pFromStream = new PojoWithSingletonAsDelegate(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithImmutableListAsDelegate() throws Exception { ImmutableListAsDelegate delegate = null; if (RuntimeEnv.ID_STRATEGY instanceof DefaultIdStrategy) { if (!((DefaultIdStrategy) RuntimeEnv.ID_STRATEGY) .registerDelegate(ImmutableList.class.getName(), delegate = new ImmutableListAsDelegate(new CollectionSchemaForBaz()))) { // couldn't register delegate = null; } } Schema<PojoWithImmutableListAsDelegate> schema = RuntimeSchema .getSchema(PojoWithImmutableListAsDelegate.class); Pipe.Schema<PojoWithImmutableListAsDelegate> pipeSchema = ((RuntimeSchema<PojoWithImmutableListAsDelegate>) schema) .getPipeSchema(); PojoWithImmutableListAsDelegate p = new PojoWithImmutableListAsDelegate().fill(); byte[] data = toByteArray(p, schema); PojoWithImmutableListAsDelegate pFromByteArray = new PojoWithImmutableListAsDelegate(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithImmutableListAsDelegate pFromStream = new PojoWithImmutableListAsDelegate(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }
public void testPojoWithHashMapInnerKeySetAsDelegate() throws Exception { HashMapInnerKeySetDelegate delegate = null; if (RuntimeEnv.ID_STRATEGY instanceof DefaultIdStrategy) { if (!((DefaultIdStrategy) RuntimeEnv.ID_STRATEGY) .registerDelegate("java.util.HashMap$KeySet", delegate = new HashMapInnerKeySetDelegate(new CollectionSchemaForString()))) { // couldn't register delegate = null; } } Schema<PojoWithHashMapInnerKeySetAsDelegate> schema = RuntimeSchema .getSchema(PojoWithHashMapInnerKeySetAsDelegate.class); Pipe.Schema<PojoWithHashMapInnerKeySetAsDelegate> pipeSchema = ((RuntimeSchema<PojoWithHashMapInnerKeySetAsDelegate>) schema) .getPipeSchema(); PojoWithHashMapInnerKeySetAsDelegate p = new PojoWithHashMapInnerKeySetAsDelegate().fill(); byte[] data = toByteArray(p, schema); PojoWithHashMapInnerKeySetAsDelegate pFromByteArray = new PojoWithHashMapInnerKeySetAsDelegate(); mergeFrom(data, 0, data.length, pFromByteArray, schema); assertEquals(p, pFromByteArray); PojoWithHashMapInnerKeySetAsDelegate pFromStream = new PojoWithHashMapInnerKeySetAsDelegate(); ByteArrayInputStream in = new ByteArrayInputStream(data); mergeFrom(in, pFromStream, schema); assertEquals(p, pFromStream); roundTrip(p, schema, pipeSchema); }