isOk = checkForDedOverlaps(createPositionSortedDescriptorList());
isOk = checkForDedOverlaps( createPositionSortedDescriptorList() );
/** * Verify that the overlap check returns true when there are no overlaps. */ public void testCheckForDedOverlaps_noOverlap() { // SETUP IndexedDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName("testCheckForDedOverlaps_noOverlap"); cattr.setDiskPath("target/test-sandbox/UnitTest"); IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>(cattr); int numDescriptors = 5; int pos = 0; IndexedDiskElementDescriptor[] sortedDescriptors = new IndexedDiskElementDescriptor[numDescriptors]; for (int i = 0; i < numDescriptors; i++) { IndexedDiskElementDescriptor descriptor = new IndexedDiskElementDescriptor(pos, i * 2); pos = pos + (i * 2) + IndexedDisk.HEADER_SIZE_BYTES; sortedDescriptors[i] = descriptor; } // DO WORK boolean result = disk.checkForDedOverlaps(sortedDescriptors); // VERIFY assertTrue("There should be no overlap. it should be ok", result); }
/** * Verify that the overlap check returns true when there are no overlaps. */ public void testCheckForDedOverlaps_noOverlap() { // SETUP IndexedDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName( "testCheckForDedOverlaps_noOverlap" ); cattr.setDiskPath( "target/test-sandbox/UnitTest" ); IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>( cattr ); int numDescriptors = 5; int pos = 0; IndexedDiskElementDescriptor[] sortedDescriptors = new IndexedDiskElementDescriptor[numDescriptors]; for ( int i = 0; i < numDescriptors; i++ ) { IndexedDiskElementDescriptor descriptor = new IndexedDiskElementDescriptor( pos, i * 2 ); pos = pos + ( i * 2 ) + IndexedDisk.HEADER_SIZE_BYTES; sortedDescriptors[i] = descriptor; } // DO WORK boolean result = disk.checkForDedOverlaps( sortedDescriptors ); // VERIFY assertTrue( "There should be no overlap. it should be ok", result ); }
/** * Verify that the overlap check returns false when there are overlaps. */ public void testCheckForDedOverlaps_overlaps() { // SETUP IndexedDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName("testCheckForDedOverlaps_overlaps"); cattr.setDiskPath("target/test-sandbox/UnitTest"); IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>(cattr); int numDescriptors = 5; int pos = 0; IndexedDiskElementDescriptor[] sortedDescriptors = new IndexedDiskElementDescriptor[numDescriptors]; for (int i = 0; i < numDescriptors; i++) { IndexedDiskElementDescriptor descriptor = new IndexedDiskElementDescriptor(pos, i * 2); // don't add the header + IndexedDisk.RECORD_HEADER; pos = pos + (i * 2); sortedDescriptors[i] = descriptor; } // DO WORK boolean result = disk.checkForDedOverlaps(sortedDescriptors); // VERIFY assertFalse("There should be overlaps. it should be not ok", result); }
/** * Verify that the overlap check returns false when there are overlaps. */ public void testCheckForDedOverlaps_overlaps() { // SETUP IndexedDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName( "testCheckForDedOverlaps_overlaps" ); cattr.setDiskPath( "target/test-sandbox/UnitTest" ); IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>( cattr ); int numDescriptors = 5; int pos = 0; IndexedDiskElementDescriptor[] sortedDescriptors = new IndexedDiskElementDescriptor[numDescriptors]; for ( int i = 0; i < numDescriptors; i++ ) { IndexedDiskElementDescriptor descriptor = new IndexedDiskElementDescriptor( pos, i * 2 ); // don't add the header + IndexedDisk.RECORD_HEADER; pos = pos + ( i * 2 ); sortedDescriptors[i] = descriptor; } // DO WORK boolean result = disk.checkForDedOverlaps( sortedDescriptors ); // VERIFY assertFalse( "There should be overlaps. it should be not ok", result ); }