Search in sources :

Example 1 with LocalCarbonFile

use of org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile in project carbondata by apache.

the class CarbonUtilTest method testToDeleteFoldersAndFilesForValidFolder.

@Test
public void testToDeleteFoldersAndFilesForValidFolder() throws InterruptedException, IOException {
    String folderPath = "../core/src/test/resources/testDir/carbonDir";
    new File(folderPath).mkdirs();
    LocalCarbonFile testDir = new LocalCarbonFile(folderPath);
    CarbonUtil.deleteFoldersAndFiles(testDir);
    assertTrue(!testDir.exists());
}
Also used : LocalCarbonFile(org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile) File(java.io.File) LocalCarbonFile(org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile) Test(org.junit.Test)

Example 2 with LocalCarbonFile

use of org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile in project carbondata by apache.

the class CarbonUtilTest method testToDeleteFoldersAndFilesWithInterruptedException.

@Test(expected = InterruptedException.class)
public void testToDeleteFoldersAndFilesWithInterruptedException() throws InterruptedException, IOException {
    LocalCarbonFile testDir = new LocalCarbonFile("../core/src/test/resources/testDir/carbonDir");
    new MockUp<UserGroupInformation>() {

        @SuppressWarnings("unused")
        @Mock
        public UserGroupInformation getLoginUser() throws InterruptedException {
            throw new InterruptedException();
        }
    };
    CarbonUtil.deleteFoldersAndFiles(testDir);
}
Also used : LocalCarbonFile(org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 3 with LocalCarbonFile

use of org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile in project carbondata by apache.

the class CarbonUtilTest method testToDeleteFoldersAndFilesWithIOException.

@Test(expected = IOException.class)
public void testToDeleteFoldersAndFilesWithIOException() throws InterruptedException, IOException {
    LocalCarbonFile testDir = new LocalCarbonFile("../core/src/test/resources/testDir/carbonDir");
    new MockUp<UserGroupInformation>() {

        @SuppressWarnings("unused")
        @Mock
        public UserGroupInformation getLoginUser() throws IOException {
            throw new IOException();
        }
    };
    CarbonUtil.deleteFoldersAndFiles(testDir);
}
Also used : LocalCarbonFile(org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile) MockUp(mockit.MockUp) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with LocalCarbonFile

use of org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile in project carbondata by apache.

the class CarbonUtilTest method testToDeleteFoldersAndFilesSintlyWithIOException.

@Test(expected = IOException.class)
public void testToDeleteFoldersAndFilesSintlyWithIOException() throws IOException, InterruptedException {
    new MockUp<UserGroupInformation>() {

        @SuppressWarnings("unused")
        @Mock
        public UserGroupInformation getLoginUser() throws IOException {
            throw new IOException();
        }
    };
    LocalCarbonFile testDir = new LocalCarbonFile("../unibi-solutions/system/carbon/badRecords/badLogPath");
    CarbonUtil.deleteFoldersAndFilesSilent(testDir);
}
Also used : LocalCarbonFile(org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile) MockUp(mockit.MockUp) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with LocalCarbonFile

use of org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile in project carbondata by apache.

the class CarbonUtilTest method testToDeleteFoldersAndFilesSintlyWithInterruptedException.

@Test(expected = InterruptedException.class)
public void testToDeleteFoldersAndFilesSintlyWithInterruptedException() throws IOException, InterruptedException {
    new MockUp<UserGroupInformation>() {

        @SuppressWarnings("unused")
        @Mock
        public UserGroupInformation getLoginUser() throws InterruptedException {
            throw new InterruptedException();
        }
    };
    LocalCarbonFile testDir = new LocalCarbonFile("../unibi-solutions/system/carbon/badRecords/badLogPath");
    CarbonUtil.deleteFoldersAndFilesSilent(testDir);
}
Also used : LocalCarbonFile(org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile) MockUp(mockit.MockUp) Test(org.junit.Test)

Aggregations

LocalCarbonFile (org.apache.carbondata.core.datastore.filesystem.LocalCarbonFile)7 Test (org.junit.Test)7 MockUp (mockit.MockUp)4 IOException (java.io.IOException)2 File (java.io.File)1