Source:
<code>private void doMultipartDecodeTest(int expectedRequestSize, InMemoryFile[] files, String digestAlgorithm) throws Exception { HttpHeaders httpHeaders = new DefaultHttpHeaders(); httpHeaders.set(RestUtils.Headers.BLOB_SIZE, expectedRequestSize); NettyMultipartRequest request = createRequest(httpHeaders, files); assertEquals("Request size does not match", expectedRequestSize, request.getSize()); request.prepare(); CopyingAsyncWritableChannel asyncWritableChannel; byte[] readOutput; Map<String, Object> args = request.getArgs(); ByteBuffer blobData = ByteBuffer.allocate(0); byte[] wholeDigest = null; if (files != null) { for (InMemoryFile file : files) { if (file.name.equals(RestUtils.MultipartPost.BLOB_PART)) { blobData = file.content; if (digestAlgorithm != null && !digestAlgorithm.isEmpty()) { MessageDigest digest = MessageDigest.getInstance(digestAlgorithm); digest.update(blobData); wholeDigest = digest.digest(); blobData.rewind(); request.setDigestAlgorithm(digestAlgorithm); } } else { Object value = args.get(file.name); assertNotNull("Request does not contain " + file, value); assertTrue("Argument value is not ByteBuffer", value instanceof ByteBuffer); readOutput = new byte[((ByteBuffer) value).remaining()]; ((ByteBuffer) value).get(readOutput); assertArrayEquals(file.name + " content does not match", file.content.array(), readOutput); } } } asyncWritableChannel = new CopyingAsyncWritableChannel(expectedRequestSize); request.readInto(asyncWritableChannel, null).get(); readOutput = asyncWritableChannel.getData(); assertArrayEquals(RestUtils.MultipartPost.BLOB_PART + " content does not match", blobData.array(), readOutput); byte[] partByPartDigest = request.getDigest(); <START> if (partByPartDigest != null) { <END> assertArrayEquals("Part by part digest should match digest of whole", wholeDigest, partByPartDigest); } closeRequestAndValidate(request); }</code><technical_language>this check is required. if partByPartDigest is null, wholeDigest be? Right? assertArrayEquals handles null (and considers nulls equal)</technical_language>

Target:
private void doMultipartDecodeTest(int expectedRequestSize, InMemoryFile[] files, String digestAlgorithm) throws Exception { HttpHeaders httpHeaders = new DefaultHttpHeaders(); httpHeaders.set(RestUtils.Headers.BLOB_SIZE, expectedRequestSize); NettyMultipartRequest request = createRequest(httpHeaders, files); assertEquals("Request size does not match", expectedRequestSize, request.getSize()); request.prepare(); CopyingAsyncWritableChannel asyncWritableChannel; byte[] readOutput; Map<String, Object> args = request.getArgs(); ByteBuffer blobData = ByteBuffer.allocate(0); byte[] wholeDigest = null; if (files != null) { for (InMemoryFile file : files) { if (file.name.equals(RestUtils.MultipartPost.BLOB_PART)) { blobData = file.content; if (digestAlgorithm != null && !digestAlgorithm.isEmpty()) { MessageDigest digest = MessageDigest.getInstance(digestAlgorithm); digest.update(blobData); wholeDigest = digest.digest(); blobData.rewind(); request.setDigestAlgorithm(digestAlgorithm); } } else { Object value = args.get(file.name); assertNotNull("Request does not contain " + file, value); assertTrue("Argument value is not ByteBuffer", value instanceof ByteBuffer); readOutput = new byte[((ByteBuffer) value).remaining()]; ((ByteBuffer) value).get(readOutput); assertArrayEquals(file.name + " content does not match", file.content.array(), readOutput); } } } asyncWritableChannel = new CopyingAsyncWritableChannel(expectedRequestSize); request.readInto(asyncWritableChannel, null).get(); readOutput = asyncWritableChannel.getData(); assertArrayEquals(RestUtils.MultipartPost.BLOB_PART + " content does not match", blobData.array(), readOutput); assertArrayEquals("Part by part digest should match digest of whole", wholeDigest, request.getDigest()); closeRequestAndValidate(request); }