@Test
public void testWriteBufferToAllChannelsReferenceCounting() throws Exception {

	Buffer buffer = EventSerializer.toBuffer(EndOfPartitionEvent.INSTANCE);
	ResultPartition partition = new ResultPartition(
		"TestTask",
		mock(TaskActions.class),
		new JobID(),
		new ResultPartitionID(),
		ResultPartitionType.PIPELINED,
		2,
		2,
		mock(ResultPartitionManager.class),
		mock(ResultPartitionConsumableNotifier.class),
		mock(IOManager.class),
		false);
	ResultPartitionWriter partitionWriter =
		new ResultPartitionWriter(
			partition);
	partitionWriter.writeBufferToAllChannels(buffer);
	// Verify added to all queues, i.e. two buffers in total
	assertEquals(2, partition.getTotalNumberOfBuffers());
	// release the buffers in the partition
	partition.release();
	assertTrue(buffer.isRecycled());
}