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); }
return false; else if (!isEquals((byte[][]) expectByteArray2D, (byte[][]) other.expectByteArray2D)) return false; return false; else if (!isEquals((int[][]) expectPrimitiveIntArray2D, (int[][]) other.expectPrimitiveIntArray2D)) return false; return false; else if (!isEquals((Object[][]) expectDateArray2D, (Object[][]) other.expectDateArray2D)) return false;
PojoWithHashMapInnerKeySetAsDelegate fill() { Map<String, String> map1 = newMap(); map1.put("hello", "world"); map1.put("oh", "hi"); Map<String, String> map2 = newMap(); map2.put("abc", "123"); map2.put("good", "cool"); Map<String, String> map3 = newMap(); map3.put("yummy", "cake"); list = newList(map1.keySet()); set = map2.keySet(); map = newMap(); map.put("key", map3.keySet()); return this; }
PojoWithCollection fill() { someCollectionObjectV = newList(new Object[] { "foo", 1, 1.1f, 100.001d, System.currentTimeMillis(), new Date(), Size.LARGE, new Pojo().fill(), new BassGuitar(4, true) }); Collection<Object> collectionWildcardV = newList(new Object[] { "bar", Size.SMALL, new AcousticGuitar(GuitarPickup.MICROPHONE) }); someCollectionWildcardV = collectionWildcardV; someListObjectV = newList(new Object[] { "baz", 2, 2.2f, 200.002d, Size.MEDIUM, new BassGuitar(6, true) }); List<Object> listWildcardV = newList(new Object[] { "gg", 3, 30.03f, 300.003d, 300000l, new BassGuitar(5, false) }); someListWildcardV = listWildcardV; return this; }
PojoWithMap fill() someMapStringKObjectV = newMap(); someMapStringKObjectV.put("1", new Pojo().fill()); someMapStringKObjectV.put(null, Size.SMALL); someMapStringKObjectV.put("3", 3); Map<Guitar, Object> mapGuitarKWildcardV = newMap(); mapGuitarKWildcardV.put(new BassGuitar(4, false), "passive 4 string"); someMapObjectKIntegerV = newMap(); someMapObjectKIntegerV.put(1, 1); someMapObjectKIntegerV.put(null, 2); someMapObjectKIntegerV.put("3", null); Map<Object, Size> mapWildcardKEnumV = newMap(); mapWildcardKEnumV.put("1", Size.SMALL); mapWildcardKEnumV.put(null, Size.MEDIUM); someMapObjectKObjectV = newMap(); someMapObjectKObjectV.put("foo", "bar"); someMapObjectKObjectV.put(1, Size.SMALL); someMapObjectKObjectV.put(null, null); Map<Object, Object> mapWildcardKWildcardV = newMap(); mapWildcardKWildcardV.put(null, null); mapWildcardKWildcardV.put("foo", 1);
PojoWithImmutableListAsDelegate fill() { List<Baz> bazList = newList( new Baz(567, "baz", 202020202), new Baz(999, "buzz", 10101010) ); list = new ImmutableList(bazList); return this; }
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); }
PojoWithSingletonAsDelegate fill() { s2 = s1 = Singleton.INSTANCE; l3 = l1 = newList(Singleton.INSTANCE); l2 = newList(); l2.add(Singleton.INSTANCE); l4 = l2; m1 = newMap(); m1.put("s1", s1); m2 = newMap(); m2.put("s1", s1); m3 = newMap(); m3.put(s1, s1); m4 = newMap(); m4.put(s1, "s1"); m5 = m1; m6 = m2; m7 = m3; m8 = m4; return this; }
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); }
PojoWithShortArrayAsDelegate fill() { short[] s = new short[] { 0x7f7f, 0x7e7e }; s2 = s1 = s; l3 = l1 = newList(s); l2 = newList(); l2.add(s); l4 = l2; m1 = newMap(); m1.put("s1", s1); m2 = newMap(); m2.put("s1", s1); m3 = newMap(); m3.put(s1, s1); m4 = newMap(); m4.put(s1, "s1"); m5 = m1; m6 = m2; m7 = m3; m8 = m4; return this; }
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); }
PojoWithThrowable fill() { t1 = new Throwable("t1"); t2 = new Exception("t2", t1); o1 = t1; o2 = t2; e1 = new Exception("e1"); e2 = new RuntimeException("e2", e1); re1 = new RuntimeException("re1"); re2 = new RuntimeException("re2", re1); l1 = newList(t1, e1, re1); l2 = newList(o2, e2, re2); l3 = l1; l4 = l2; m1 = newMap(); m1.put("t1", t1); m2 = newMap(); m2.put("e1", e1); m3 = newMap(); m3.put(e2, re2); m4 = m1; m5 = m2; m6 = m3; return this; }
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); }
expectCollectionStringV = newList(new String[] { "bar", "baz" }); expectCollectionEnumV = newList(new Size[] { Size.SMALL, Size.MEDIUM, Size.LARGE }); expectCollectionGuitarV = newList(new Guitar[] { new AcousticGuitar(GuitarPickup.MICROPHONE), new BassGuitar(5, true) }); List<Integer> intFirst = newList(new Integer[] { 1, 2, 3, 4 }); List<Integer> intSecond = newList(new Integer[] { 4, 5, 6, 7 }); expectCollectionIntegerCollectionV = newList(new List[] { intFirst, intSecond }); List<Size> enumFirst = newList(new Size[] { Size.SMALL }); List<Size> enumSecond = newList(new Size[] { Size.MEDIUM }); List<Size> enumThird = newList(new Size[] { Size.LARGE }); expectCollectionEnumCollectionV = newList(new List[] { enumFirst, enumSecond, enumThird }); List<Guitar> guitarFirst = newList(new Guitar[] { new AcousticGuitar(GuitarPickup.MICROPHONE), new BassGuitar(5, true) }); List<Guitar> guitarSecond = newList(new Guitar[] { new AcousticGuitar(GuitarPickup.CONTACT),
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); }
HashMap<String, Boolean> empty = newMap(); unmodifiableList = Collections.unmodifiableList(ll); unmodifiableRandomAccessList = Collections .unmodifiableList(newList("six")); synchronizedList = Collections.synchronizedList(ll); synchronizedRandomAccessList = Collections .synchronizedList(newList("seven")); checkedCollection = Collections.checkedCollection(newList("eight"), String.class); // no equals impl checkedSet = Collections.checkedSet(es, Size.class); checkedSortedSet = Collections.checkedSortedSet(ts, String.class); checkedList = Collections.checkedList(ll, String.class); checkedRandomAccessList = Collections.checkedList(newList("nine"), String.class);
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); }
newList(new String[] { "foo", "bar", "baz" }), newList(new String[] { "1", "2" }), newList(new String[] { "3" }) }; expectListPojoVArray = new List[] { newList(new Pojo[] { new Pojo() .fill() }) }; newList(new Guitar[] { new BassGuitar(6, true), new AcousticGuitar(GuitarPickup.UNDER_THE_SADDLE) }), newList(new Guitar[] { new BassGuitar(5, false), }) }; expectListObjectVArray = new List[] { newList(new Object[] { new Pojo().fill(), new AcousticGuitar(GuitarPickup.CONTACT), new BassGuitar(4, true) }) }; Map<Size, String> mapEnumKStringVFirst = newMap(); mapEnumKStringVFirst.put(Size.SMALL, "s"); mapEnumKStringVFirst.put(Size.MEDIUM, null); Map<Size, String> mapEnumKStringVSecond = newMap(); mapEnumKStringVSecond.put(Size.LARGE, "l"); mapEnumKStringVSecond.put(null, "m"); Map<Guitar, Pojo> mapGuitarKPojoVFirst = newMap(); mapGuitarKPojoVFirst.put( new AcousticGuitar(GuitarPickup.SOUNDHOLE), null); Map<Guitar, Pojo> mapGuitarKPojoVSecond = newMap();
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); }