try {
Files.touch(file);
Files.write("My test file contents".getBytes(), file);
final NodePath nodePath = new NodePath("myuser/" + filename);
final StoredFile storedFile = new StoredFile(new BufferedInputStream(new FileInputStream(file)));
storageService.put(nodePath, storedFile);
final StoredFile obtainedFile = storageService.get(nodePath);
assertNotNull(obtainedFile, "Obtained file must not be NULL at path " + nodePath);
final File tempDestFile = File.createTempFile("unit-test", null);
final FileOutputStream fos = new FileOutputStream(tempDestFile);
InputStream inputStream = obtainedFile.getInputStream();
ByteStreams.copy(inputStream, fos);
fos.flush();
final boolean filesAreTheSame = Files.equal(file, tempDestFile);
assertTrue(filesAreTheSame, "Source file and obtained file must have the same contents");