Пример #1
0
  private void testStore(StorageProvider provider, int size) throws IOException {
    byte[] data = createData(size);
    Assert.assertEquals(size, data.length);

    Storage storage = provider.store(new ByteArrayInputStream(data));

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ContentUtil.copy(storage.getInputStream(), baos);
    verifyData(data, baos.toByteArray());
  }
Пример #2
0
  private void testDelete(StorageProvider provider) throws IOException {
    Storage storage = provider.store(new ByteArrayInputStream(createData(512)));

    storage.delete();

    // getInputStream has to throw an IllegalStateException
    try {
      storage.getInputStream();
      Assert.fail();
    } catch (IllegalStateException expected) {
    }

    // invoking delete a second time should not have any effect
    storage.delete();
  }