cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus/src/test/java/org/cloudbus/cloudsim/resources/HarddriveStorageTest.java
@Test
    public void testReserveSpaceNotReservedFile1() {
        final int fileSize = FILE_SIZE;
        final long capacity = fileSize * 2;
        final long available = (long)fileSize;
        final HarddriveStorage instance = createHardDrive(capacity);
        assertEquals(0, instance.getAllocatedResource());

        int fileNumber = 0;
        File file = createNumberedFile(++fileNumber, fileSize);
        assertTrue(instance.addFile(file) > 0.0);
        assertEquals(available, instance.getAvailableResource());

        //a null file cannot be added
        assertEquals(0, instance.addReservedFile(null), 0.0);

        //file larger than the available capacity
        assertEquals(0, instance.addFile(new File("too-big-file.txt", FILE_SIZE*10)), 0.0);

        //accordingly, reserves space previously and then adds the reserved file
        assertTrue(instance.reserveSpace(fileSize));
        file = createNumberedFile(++fileNumber, fileSize);
        assertTrue(instance.addReservedFile(file) > 0);
        assertEquals(0, instance.getAvailableResource());
    }
/**
     * Try to add a reserved file which the space was not previously reserved.
     * An exception must be thrown in that case.
     */
Try to add a reserved file which the space was not previously reserved.
An exception must be thrown in that case.
Try to add a reserved file which the space was not previously reserved . An exception must be thrown in that case .
@Test
    public void testReserveSpaceNotReservedFile1() {
        final int fileSize = FILE_SIZE;
        final long capacity = fileSize * 2;
        final long available = (long)fileSize;
        final HarddriveStorage instance = createHardDrive(capacity);
        assertEquals(0, instance.getAllocatedResource());
        int fileNumber = 0;
        File file = createNumberedFile(++fileNumber, fileSize);
        assertTrue(instance.addFile(file) > 0.0);
        assertEquals(available, instance.getAvailableResource());
        assertEquals(0, instance.addReservedFile(null), 0.0);
        assertEquals(0, instance.addFile(new File("too-big-file.txt", FILE_SIZE*10)), 0.0);
        assertTrue(instance.reserveSpace(fileSize));
        file = createNumberedFile(++fileNumber, fileSize);
        assertTrue(instance.addReservedFile(file) > 0);
        assertEquals(0, instance.getAvailableResource());
    }
@ Test public void testReserveSpaceNotReservedFile1 ( ) { final int fileSize = FILE_SIZE ; final long capacity = fileSize * 2 ; final long available = ( long ) fileSize ; final HarddriveStorage instance = createHardDrive ( capacity ) ; assertEquals ( 0 , instance . getAllocatedResource ( ) ) ; int fileNumber = 0 ; File file = createNumberedFile ( ++ fileNumber , fileSize ) ; assertTrue ( instance . addFile ( file ) > 0.0 ) ; assertEquals ( available , instance . getAvailableResource ( ) ) ; assertEquals ( 0 , instance . addReservedFile ( null ) , 0.0 ) ; assertEquals ( 0 , instance . addFile ( new File ( "too-big-file.txt" , FILE_SIZE * 10 ) ) , 0.0 ) ; assertTrue ( instance . reserveSpace ( fileSize ) ) ; file = createNumberedFile ( ++ fileNumber , fileSize ) ; assertTrue ( instance . addReservedFile ( file ) > 0 ) ; assertEquals ( 0 , instance . getAvailableResource ( ) ) ; }
Try to add a reserved file which the space was not previously reserved.
Try to add a reserved file which the space was not previously reserved .
//a null file cannot be added //file larger than the available capacity //accordingly, reserves space previously and then adds the reserved file