### Question:
RangeBitmap extends AbstractBitMap { @Override public void writeBytes(OutputStream output) { try { output.write(toBytes()); } catch (IOException e) { SwiftLoggers.getLogger().error(e); } finally { IoUtil.close(output); } } RangeBitmap(int start, int end); static ImmutableBitMap of(int start, int end); @Override ImmutableBitMap getAnd(ImmutableBitMap index); @Override ImmutableBitMap getOr(ImmutableBitMap index); @Override ImmutableBitMap getAndNot(ImmutableBitMap index); @Override ImmutableBitMap getNot(int bound); @Override boolean contains(int index); @Override ImmutableBitMap clone(); @Override BitMapType getType(); @Override byte[] toBytes(); @Override void writeBytes(OutputStream output); @Override void traversal(TraversalAction action); @Override boolean breakableTraversal(BreakTraversalAction action); @Override int getCardinality(); @Override String toString(); @Override IntIterator intIterator();  }### Answer:
@Test public void writeBytes() throws Exception { OutputStream output = mock(OutputStream.class); mockStatic(IoUtil.class); RangeBitmap.of(1, 2).writeBytes(output); ByteBuffer buf = ByteBuffer.allocate(9) .order(ByteOrder.LITTLE_ENDIAN) .put(BitMapType.RANGE.getHead()) .putInt(1).putInt(2); verify(output).write(buf.array()); doThrow(new IOException()).when(output).write(any(byte[].class)); RangeBitmap.of(1, 2).writeBytes(output); verifyStatic(IoUtil.class, times(2)); IoUtil.close(output); }