@Test public void testGetBody() throws AuthFailureError { final Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); request = new UploadBitmapRfcCompliantListenableRequest(Request.Method.GET, "http: bitmap, "filename"); final byte[] body = request.getBody(); final ByteArrayInputStream bais = new ByteArrayInputStream(body); final Bitmap decodedBitmap = BitmapFactory.decodeStream(bais); assertEquals(bitmap.getWidth(), decodedBitmap.getWidth()); assertEquals(bitmap.getHeight(), decodedBitmap.getHeight()); }
@SuppressWarnings("checkstyle:magicnumber") @SuppressFBWarnings(value = { "DM_DEFAULT_ENCODING", "MDM_STRING_BYTES_ENCODING", "VA_FORMAT_STRING_USES_NEWLINE" }, justification = "The encoding will be sent with the headers automatically." + " The protocol requires \\r\\n, independently on the platform") @Override public byte[] getBody() throws AuthFailureError { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { bos.write(String.format(MULTIPART_HEAD, filename).getBytes()); bitmap.compress(CompressFormat.JPEG, 100, bos); bos.write(MULTIPART_TAIL.getBytes()); } catch (final IOException e) { Log.wtf("UploadBitmapRfcCompliantListenableRequest", "Unexpected error building multipart body.", e); } return bos.toByteArray(); }
UploadBitmapRfcCompliantListenableRequest extends
				RfcCompliantListenableRequest<String> { @SuppressWarnings("checkstyle:magicnumber") @SuppressFBWarnings(value = { "DM_DEFAULT_ENCODING", "MDM_STRING_BYTES_ENCODING", "VA_FORMAT_STRING_USES_NEWLINE" }, justification = "The encoding will be sent with the headers automatically." + " The protocol requires \\r\\n, independently on the platform") @Override public byte[] getBody() throws AuthFailureError { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { bos.write(String.format(MULTIPART_HEAD, filename).getBytes()); bitmap.compress(CompressFormat.JPEG, 100, bos); bos.write(MULTIPART_TAIL.getBytes()); } catch (final IOException e) { Log.wtf("UploadBitmapRfcCompliantListenableRequest", "Unexpected error building multipart body.", e); } return bos.toByteArray(); } }
UploadBitmapRfcCompliantListenableRequest extends
				RfcCompliantListenableRequest<String> { @SuppressWarnings("checkstyle:magicnumber") @SuppressFBWarnings(value = { "DM_DEFAULT_ENCODING", "MDM_STRING_BYTES_ENCODING", "VA_FORMAT_STRING_USES_NEWLINE" }, justification = "The encoding will be sent with the headers automatically." + " The protocol requires \\r\\n, independently on the platform") @Override public byte[] getBody() throws AuthFailureError { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { bos.write(String.format(MULTIPART_HEAD, filename).getBytes()); bitmap.compress(CompressFormat.JPEG, 100, bos); bos.write(MULTIPART_TAIL.getBytes()); } catch (final IOException e) { Log.wtf("UploadBitmapRfcCompliantListenableRequest", "Unexpected error building multipart body.", e); } return bos.toByteArray(); } @SuppressWarnings("checkstyle:magicnumber")  UploadBitmapRfcCompliantListenableRequest(final int method, @NonNull final String url,
						@Nullable final Listener<String> listener,
						@Nullable final ErrorListener errListener,
						@Nullable final CancelListener cancelListener,
						@NonNull final Bitmap bmp, @NonNull final String filename);  UploadBitmapRfcCompliantListenableRequest(final int method, @NonNull final String url,
					@Nullable final Listener<String> listener,
					@Nullable final ErrorListener errListener,
					@NonNull final Bitmap bmp, @NonNull final String filename); }
UploadBitmapRfcCompliantListenableRequest extends
				RfcCompliantListenableRequest<String> { @SuppressWarnings("checkstyle:magicnumber") @SuppressFBWarnings(value = { "DM_DEFAULT_ENCODING", "MDM_STRING_BYTES_ENCODING", "VA_FORMAT_STRING_USES_NEWLINE" }, justification = "The encoding will be sent with the headers automatically." + " The protocol requires \\r\\n, independently on the platform") @Override public byte[] getBody() throws AuthFailureError { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { bos.write(String.format(MULTIPART_HEAD, filename).getBytes()); bitmap.compress(CompressFormat.JPEG, 100, bos); bos.write(MULTIPART_TAIL.getBytes()); } catch (final IOException e) { Log.wtf("UploadBitmapRfcCompliantListenableRequest", "Unexpected error building multipart body.", e); } return bos.toByteArray(); } @SuppressWarnings("checkstyle:magicnumber")  UploadBitmapRfcCompliantListenableRequest(final int method, @NonNull final String url,
						@Nullable final Listener<String> listener,
						@Nullable final ErrorListener errListener,
						@Nullable final CancelListener cancelListener,
						@NonNull final Bitmap bmp, @NonNull final String filename);  UploadBitmapRfcCompliantListenableRequest(final int method, @NonNull final String url,
					@Nullable final Listener<String> listener,
					@Nullable final ErrorListener errListener,
					@NonNull final Bitmap bmp, @NonNull final String filename); @Override String getBodyContentType(); @SuppressWarnings("checkstyle:magicnumber") @SuppressFBWarnings(value = { "DM_DEFAULT_ENCODING", "MDM_STRING_BYTES_ENCODING", "VA_FORMAT_STRING_USES_NEWLINE" }, justification = "The encoding will be sent with the headers automatically." + " The protocol requires \\r\\n, independently on the platform") @Override byte[] getBody(); @Override String toString(); }
UploadBitmapRfcCompliantListenableRequest extends
				RfcCompliantListenableRequest<String> { @SuppressWarnings("checkstyle:magicnumber") @SuppressFBWarnings(value = { "DM_DEFAULT_ENCODING", "MDM_STRING_BYTES_ENCODING", "VA_FORMAT_STRING_USES_NEWLINE" }, justification = "The encoding will be sent with the headers automatically." + " The protocol requires \\r\\n, independently on the platform") @Override public byte[] getBody() throws AuthFailureError { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { bos.write(String.format(MULTIPART_HEAD, filename).getBytes()); bitmap.compress(CompressFormat.JPEG, 100, bos); bos.write(MULTIPART_TAIL.getBytes()); } catch (final IOException e) { Log.wtf("UploadBitmapRfcCompliantListenableRequest", "Unexpected error building multipart body.", e); } return bos.toByteArray(); } @SuppressWarnings("checkstyle:magicnumber")  UploadBitmapRfcCompliantListenableRequest(final int method, @NonNull final String url,
						@Nullable final Listener<String> listener,
						@Nullable final ErrorListener errListener,
						@Nullable final CancelListener cancelListener,
						@NonNull final Bitmap bmp, @NonNull final String filename);  UploadBitmapRfcCompliantListenableRequest(final int method, @NonNull final String url,
					@Nullable final Listener<String> listener,
					@Nullable final ErrorListener errListener,
					@NonNull final Bitmap bmp, @NonNull final String filename); @Override String getBodyContentType(); @SuppressWarnings("checkstyle:magicnumber") @SuppressFBWarnings(value = { "DM_DEFAULT_ENCODING", "MDM_STRING_BYTES_ENCODING", "VA_FORMAT_STRING_USES_NEWLINE" }, justification = "The encoding will be sent with the headers automatically." + " The protocol requires \\r\\n, independently on the platform") @Override byte[] getBody(); @Override String toString();  }