final byte[] buf = new byte[128];
try {
server = new BlobServer();
InetSocketAddress blobSocketAddress = new InetSocketAddress(server.getServerPort());
BlobClient bc = new BlobClient(blobSocketAddress);
keys.add(bc.put(buf));
buf[0] += 1;
keys.add(bc.put(buf));
libraryCacheManager = new BlobLibraryCacheManager(server, GlobalConfiguration.getConfiguration());
libraryCacheManager.registerJob(jid, keys);
List<File> files = new ArrayList<File>();
for (BlobKey key: keys){
files.add(libraryCacheManager.getFile(key));
}
assertEquals(2, files.size());
files.clear();
libraryCacheManager.unregisterJob(jid);
Thread.sleep(1500);
int caughtExceptions = 0;
for (BlobKey key : keys) {
// the blob cache should no longer contain the files
try {
files.add(libraryCacheManager.getFile(key));
} catch (IOException ioe) {
caughtExceptions++;
}
}
assertEquals(2, caughtExceptions);
bc.close();
}
catch(Exception e){
e.printStackTrace();
fail(e.getMessage());
}