Exemplo n.º 1
0
 @Test
 public void testAddToDictionary() throws UnsupportedEncodingException, NoSuchAlgorithmException {
   byte[] chunk1 = new byte[1024];
   String hash = testlocker.md5ToString(testlocker.md5(chunk1));
   testlocker.addToDictionary(hash, chunk1);
   Assert.assertTrue(testlocker.dictionary.contains(chunk1));
   Assert.assertTrue(testlocker.dictionary.containsKey(hash));
 }
Exemplo n.º 2
0
 @Test
 public void testcontentsMatch() throws UnsupportedEncodingException, NoSuchAlgorithmException {
   byte[] chunk2 = new byte[1024];
   String hash = testlocker.md5ToString(testlocker.md5(chunk2));
   String hash2 = hash + "false";
   testlocker.addToDictionary(hash, chunk2);
   Assert.assertTrue(testlocker.contentsMatch(hash, chunk2));
   Assert.assertFalse(testlocker.contentsMatch(hash2, chunk2));
 }
Exemplo n.º 3
0
 @Test
 public void testgetSizeOfLocker() {
   int size = 0;
   for (FileInfo f : testlocker.files) {
     size += f.getSize();
   }
   Assert.assertEquals(size, testlocker.getSizeOfLocker());
 }
Exemplo n.º 4
0
  @Test
  public void testgetSizeOfDB() throws IOException {

    RandomAccessFile locker1 = new RandomAccessFile("locker.txt", "r");
    FileChannel l = locker1.getChannel();
    long dbSize = l.size();
    Assert.assertEquals(testlocker.getSizeOfDB(), dbSize);
  }
Exemplo n.º 5
0
 @Test
 public void testHashExists() {
   byte[] chunk1 = new byte[1024];
   testlocker.dictionary.put("1", chunk1);
   Assert.assertEquals(testlocker.hashExists("1"), testlocker.dictionary.containsKey("1"));
 }
Exemplo n.º 6
0
 @Test
 public void tetGetProgress() {
   Assert.assertEquals(testlocker.getProgress(), testlocker.progress);
 }
Exemplo n.º 7
0
 @Test(expected = FileNotFoundException.class)
 public void testDynamicBlockInsert() {
   testlocker.dynamicBlockInsert("nosuchfile");
 }