@Test public void testwriteObjects() { final byte[][] expected = {{(byte)0, (byte)1}, {(byte)2, (byte)3}, {(byte)4, (byte)5}}; List<Streamable> objects = new ArrayList<Streamable>() { { add(StreamableObject.instance(expected[0])); add(StreamableObject.instance(expected[1])); add(StreamableObject.instance(expected[2])); } }; ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { getSut().writeObjects(objects, baos); } catch (IOException e) { fail(); } byte[] actual = baos.toByteArray(); int index = 0; for (byte[] anExpected : expected) { for (byte anAnExpected : anExpected) { assertTrue("" + index, actual[index] == anAnExpected); index++; } } }
protected <S extends Streamable> void writeObjects(Collection<S> objects, OutputStream os) throws IOException { if (objects != null) { Iterator<S> it = objects.iterator(); while (it.hasNext()) { Streamable s = it.next(); s.writeToStream(os); it.remove(); } } }
AbstractAFPObject implements Streamable { protected <S extends Streamable> void writeObjects(Collection<S> objects, OutputStream os) throws IOException { if (objects != null) { Iterator<S> it = objects.iterator(); while (it.hasNext()) { Streamable s = it.next(); s.writeToStream(os); it.remove(); } } } }
AbstractAFPObject implements Streamable { protected <S extends Streamable> void writeObjects(Collection<S> objects, OutputStream os) throws IOException { if (objects != null) { Iterator<S> it = objects.iterator(); while (it.hasNext()) { Streamable s = it.next(); s.writeToStream(os); it.remove(); } } }  }
AbstractAFPObject implements Streamable { protected <S extends Streamable> void writeObjects(Collection<S> objects, OutputStream os) throws IOException { if (objects != null) { Iterator<S> it = objects.iterator(); while (it.hasNext()) { Streamable s = it.next(); s.writeToStream(os); it.remove(); } } }   }
AbstractAFPObject implements Streamable { protected <S extends Streamable> void writeObjects(Collection<S> objects, OutputStream os) throws IOException { if (objects != null) { Iterator<S> it = objects.iterator(); while (it.hasNext()) { Streamable s = it.next(); s.writeToStream(os); it.remove(); } } }    }