예제 #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));
 }
예제 #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));
 }
예제 #3
0
 @Test
 public void testgetSizeOfLocker() {
   int size = 0;
   for (FileInfo f : testlocker.files) {
     size += f.getSize();
   }
   Assert.assertEquals(size, testlocker.getSizeOfLocker());
 }
예제 #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);
  }
예제 #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"));
 }
예제 #6
0
 @Test
 public void tetGetProgress() {
   Assert.assertEquals(testlocker.getProgress(), testlocker.progress);
 }
예제 #7
0
 @Test(expected = FileNotFoundException.class)
 public void testDynamicBlockInsert() {
   testlocker.dynamicBlockInsert("nosuchfile");
 }