BlobUtils { static File initStorageDirectory(String storageDirectory) { File baseDir; if (storageDirectory == null || storageDirectory.trim().isEmpty()) { baseDir = new File(System.getProperty("java.io.tmpdir")); } else { baseDir = new File(storageDirectory); } File storageDir; final int MAX_ATTEMPTS = 10; int attempt; for(attempt = 0; attempt < MAX_ATTEMPTS; attempt++) { storageDir = new File(baseDir, String.format( "blobStore-%s", UUID.randomUUID().toString())); if (!storageDir.exists() && storageDir.mkdirs()) { return storageDir; } } throw new RuntimeException("Could not create storage directory for BLOB store in '" + baseDir + "'."); } private  BlobUtils();   }
@Test(expected = Exception.class) public void testExceptionOnCreateStorageDirectoryFailure() { BlobUtils.initStorageDirectory(new File(blobUtilsTestDirectory, CANNOT_CREATE_THIS).getAbsolutePath()); }