@Override
    protected Storage toStorage0() throws IOException {
      if (tail == null)
        return new MemoryStorageProvider.MemoryStorage(head.buffer(), head.length());

      return new ThresholdStorage(head.buffer(), head.length(), tail.toStorage());
    }
  private void testCreateStorageOutputStream(StorageProvider provider, int size)
      throws IOException {
    byte[] data = createData(size);
    Assert.assertEquals(size, data.length);

    StorageOutputStream out = provider.createStorageOutputStream();
    ContentUtil.copy(new ByteArrayInputStream(data), out);
    Storage storage = out.toStorage();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ContentUtil.copy(storage.getInputStream(), baos);
    verifyData(data, baos.toByteArray());
  }