use of aQute.lib.io.IO.getFile in project bnd by bndtools.
the class FileRepoTest method testDownloadListenerCallback.
public void testDownloadListenerCallback() throws Exception {
try {
FileRepo repo = new FileRepo("tmp", tmp, true);
File srcBundle = IO.getFile("testresources/test.jar");
PutResult r = repo.put(IO.stream(IO.getFile("testresources/test.jar")), null);
assertNotNull(r);
assertNotNull(r.artifact);
// file repo, so should match
File f = new File(r.artifact);
SHA1 sha1 = SHA1.digest(srcBundle);
sha1.equals(SHA1.digest(f));
DownloadListener mock = Mockito.mock(DownloadListener.class);
f = repo.get("test", new Version("0"), null, mock);
Mockito.verify(mock).success(f);
Mockito.verifyNoMoreInteractions(mock);
Mockito.reset(mock);
f = repo.get("XXXXXXXXXXXXXXXXX", new Version("0"), null, mock);
assertNull(f);
Mockito.verifyZeroInteractions(mock);
} finally {
IO.delete(tmp);
}
}
use of aQute.lib.io.IO.getFile in project bnd by bndtools.
the class FileRepoTest method setUp.
@Override
protected void setUp() throws Exception {
File testRepoDir = IO.getFile("src/test/repo");
assertTrue(testRepoDir.isDirectory());
testRepo = createRepo(testRepoDir);
File nonExistentDir = IO.getFile("invalidrepo");
nonExistentDir.mkdir();
nonExistentDir.setReadOnly();
nonExistentRepo = createRepo(nonExistentDir);
tmp = IO.getFile("tmp" + getName());
tmp.mkdir();
indexedRepo = createRepo(tmp, MAP.$("index", "true"));
}
use of aQute.lib.io.IO.getFile in project bnd by bndtools.
the class FileRepoTest method testBundleNotModifiedOnPut.
public void testBundleNotModifiedOnPut() throws Exception {
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
File dstBundle = null;
try {
File srcBundle = IO.getFile("testresources/test.jar");
byte[] srcSha = calculateHash(sha1, srcBundle);
PutOptions options = new RepositoryPlugin.PutOptions();
options.digest = srcSha;
PutResult r = testRepo.put(new BufferedInputStream(new FileInputStream(srcBundle)), options);
dstBundle = new File(r.artifact);
assertEquals(hashToString(srcSha), hashToString(r.digest));
assertTrue(MessageDigest.isEqual(srcSha, r.digest));
} finally {
if (dstBundle != null) {
delete(dstBundle.getParentFile());
}
}
}
Aggregations