mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Violette Roche-Montane
27.17.2014 6f5e10b0dc596c8e7625de7ddf523b6d5bc220c7
opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java
@@ -25,7 +25,12 @@
 */
package com.forgerock.opendj.cli;
import java.io.File;
import java.io.IOException;
import org.testng.annotations.Test;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
public class UtilsTestCase extends CliTestCase {
@@ -44,4 +49,21 @@
    public void testValidJavaVersion() throws ClientException {
        Utils.checkJavaVersion();
    }
    @Test()
    public void testCanWriteOnNewFile() throws ClientException, IOException {
        final File f = File.createTempFile("tempFile", ".txt");
        f.deleteOnExit();
        assertTrue(f.exists());
        assertTrue(Utils.canWrite(f.getPath()));
    }
    @Test()
    public void testCannotWriteOnNewFile() throws ClientException, IOException {
        final File f = File.createTempFile("tempFile", ".txt");
        f.setReadOnly();
        f.deleteOnExit();
        assertTrue(f.exists());
        assertFalse(Utils.canWrite(f.getPath()));
    }
}