@Test public void testGetData() throws IOException { byte[] bytes = new byte[(int) tempFile.length()]; int index = 0; int read = 0; InputStream data = fileDataPacket.getData(); try { while ((read = data.read(bytes, index, bytes.length - index)) != -1 && index < bytes.length) { index += read; } } finally { data.close(); } assertEquals(new String(SOME_TEST_DATA, Charset.defaultCharset()), new String(bytes, Charset.defaultCharset())); }
@Override public InputStream getData() { try { return new FileInputStream(file); } catch (FileNotFoundException e) { throw new DataPacketGetDataException(e); } }
FileDataPacket implements DataPacket { @Override public InputStream getData() { try { return new FileInputStream(file); } catch (FileNotFoundException e) { throw new DataPacketGetDataException(e); } } }
FileDataPacket implements DataPacket { @Override public InputStream getData() { try { return new FileInputStream(file); } catch (FileNotFoundException e) { throw new DataPacketGetDataException(e); } } FileDataPacket(File file); }
FileDataPacket implements DataPacket { @Override public InputStream getData() { try { return new FileInputStream(file); } catch (FileNotFoundException e) { throw new DataPacketGetDataException(e); } } FileDataPacket(File file); @Override Map<String, String> getAttributes(); @Override InputStream getData(); @Override long getSize(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); }
FileDataPacket implements DataPacket { @Override public InputStream getData() { try { return new FileInputStream(file); } catch (FileNotFoundException e) { throw new DataPacketGetDataException(e); } } FileDataPacket(File file); @Override Map<String, String> getAttributes(); @Override InputStream getData(); @Override long getSize(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final Creator<FileDataPacket> CREATOR; }