@Test
public void multipleThreadsShouldReadTheSameFile() throws Exception {

    final String textBase = "The quick brown fox jumps over the lazy dog";
    StringBuilder builder = new StringBuilder();
    Random rand = new Random();
    while (builder.length() <= MIN_BINARY_SIZE) {
        builder.append(textBase.substring(0, rand.nextInt(textBase.length())));
    }
    final String text = builder.toString();
    final Binary storedValue = store.storeValue(new ByteArrayInputStream(text.getBytes()), false);
    ExecutorService executor = Executors.newFixedThreadPool(3);
    try {
        Callable<String> readingTask = () -> {
            File tempFile = File.createTempFile("test-binary-store", "bin");
            try {
                FileOutputStream fos = new FileOutputStream(tempFile);
                InputStream is = storedValue.getStream();
                byte[] buff = new byte[100];
                int available;
                while ((available = is.read(buff)) != -1) {
                    fos.write(buff, 0, available);
                }
                fos.close();

                return IoUtil.read(tempFile);
            } finally {
                tempFile.delete();
            }
        };
        List<Callable<String>> tasks = Arrays.asList(readingTask, readingTask, readingTask);
        List<Future<String>> futures = executor.invokeAll(tasks, 5, TimeUnit.SECONDS);
        for (Future<String> future : futures) {
            assertEquals(text, future.get());
        }
    } finally {
        executor.shutdownNow();
    }
}