carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject [10/57] [abbrv] incubator-carbondata git commit: move org.apache.carbon.common in core
Date Sat, 14 Jan 2017 07:57:19 GMT
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/FileFactoryImplUnitTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/FileFactoryImplUnitTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/FileFactoryImplUnitTest.java
deleted file mode 100644
index 8277f91..0000000
--- a/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/FileFactoryImplUnitTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.carbondata.core.carbon.datastorage.filesystem.store.impl;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.carbondata.core.datastorage.store.impl.FileFactory;
-
-import mockit.Mock;
-import mockit.MockUp;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static junit.framework.TestCase.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class FileFactoryImplUnitTest {
-
-  private static String filePath;
-
-  @AfterClass
-  public static void tearDown() {
-    File file = new File(filePath);
-    if (file.exists()) {
-      file.delete();
-    }
-
-    File file1 = new File(".TestFileFactory.carbondata.crc");
-    if (file1.exists()) {
-      file1.delete();
-    }
-  }
-
-  @BeforeClass public static void setUp() {
-    filePath = "TestFileFactory.carbondata";
-  }
-
-  @Test public void testFileExistsForVIEWFSType() throws IOException {
-    FileFactory.isFileExist("fakefilePath", FileFactory.FileType.VIEWFS);
-  }
-
-  @Test public void testFileExistsForDefaultType() throws IOException {
-    FileFactory.isFileExist("fakefilePath", FileFactory.FileType.LOCAL);
-  }
-
-  @Test public void testFileExistsForDefaultTypeWithPerformFileCheck() throws IOException {
-    assertTrue(FileFactory.isFileExist(filePath, FileFactory.FileType.LOCAL, true));
-  }
-
-  @Test public void testFileExistsForDefaultTypeWithOutPerformFileCheck() throws IOException {
-    assertFalse(FileFactory.isFileExist("fakefilePath", FileFactory.FileType.LOCAL, false));
-  }
-
-  @Test public void testFileExistsForVIEWFSTypeWithPerformFileCheck() throws IOException {
-    assertTrue(FileFactory.isFileExist(filePath, FileFactory.FileType.VIEWFS, true));
-  }
-
-  @Test public void testFileExistsForVIEWFSTypeWithOutPerformFileCheck() throws IOException {
-    assertFalse(FileFactory.isFileExist("fakefilePath", FileFactory.FileType.VIEWFS, false));
-  }
-
-  @Test public void testCreateNewFileWithDefaultFileType() throws IOException {
-    tearDown();
-    assertTrue(FileFactory.createNewFile(filePath, FileFactory.FileType.LOCAL));
-  }
-
-  @Test public void testCreateNewLockFileWithDefaultFileType() throws IOException {
-    tearDown();
-    assertTrue(FileFactory.createNewLockFile(filePath, FileFactory.FileType.LOCAL));
-  }
-
-  @Test public void testCreateNewLockFileWithViewFsFileType() throws IOException {
-    tearDown();
-    assertTrue(FileFactory.createNewLockFile(filePath, FileFactory.FileType.VIEWFS));
-  }
-
-  @Test public void testCreateNewLockFileWithViewFsFileTypeWhenFileExists() throws IOException {
-    assertFalse(FileFactory.createNewLockFile(filePath, FileFactory.FileType.VIEWFS));
-  }
-
-  @Test public void testCreateNewFileWithDefaultFileTypeWhenFileExists() throws IOException {
-    assertFalse(FileFactory.createNewFile(filePath, FileFactory.FileType.LOCAL));
-  }
-
-  @Test public void testCreateNewFileWithVIEWFSFileType() throws IOException {
-    File file = new File(filePath);
-    if (file.exists()) {
-      file.delete();
-    }
-    assertTrue(FileFactory.createNewFile(filePath, FileFactory.FileType.VIEWFS));
-  }
-
-  @Test public void testCreateNewFileWithVIEWFSFileTypeWhenFileExists() throws IOException {
-    assertFalse(FileFactory.createNewFile(filePath, FileFactory.FileType.VIEWFS));
-  }
-
-  @Test public void testMkDirWithVIEWFSFileType() throws IOException {
-    new MockUp<FileSystem>() {
-      @SuppressWarnings("unused") @Mock public boolean mkdirs(Path file) throws IOException {
-        {
-          return true;
-        }
-      }
-    };
-    tearDown();
-    assertTrue(FileFactory.mkdirs(filePath, FileFactory.FileType.VIEWFS));
-  }
-
-  @Test public void testGetDataOutputStreamUsingAppendeForException() {
-    try {
-      FileFactory.getDataOutputStreamUsingAppend(filePath, FileFactory.FileType.VIEWFS);
-    } catch (Exception exception) {
-      assertEquals("Not supported", exception.getMessage());
-    }
-  }
-
-  @Test public void getDataOutputStreamForVIEWFSType() throws IOException {
-    assertNotNull(FileFactory.getDataOutputStream(filePath, FileFactory.FileType.VIEWFS));
-  }
-
-  @Test public void getDataOutputStreamForLocalType() throws IOException {
-    assertNotNull(FileFactory.getDataOutputStream(filePath, FileFactory.FileType.LOCAL));
-  }
-
-  @Test public void testGetCarbonFile() throws IOException {
-    FileFactory.getDataOutputStream(filePath, FileFactory.FileType.VIEWFS);
-    assertNotNull(FileFactory.getCarbonFile(filePath, FileFactory.FileType.HDFS));
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/FileHolderImplUnitTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/FileHolderImplUnitTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/FileHolderImplUnitTest.java
deleted file mode 100644
index c14dff9..0000000
--- a/core/src/test/java/org/apache/carbondata/core/carbon/datastorage/filesystem/store/impl/FileHolderImplUnitTest.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.carbondata.core.carbon.datastorage.filesystem.store.impl;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-
-import org.apache.carbondata.core.datastorage.store.impl.FileHolderImpl;
-
-import mockit.Mock;
-import mockit.MockUp;
-import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.pentaho.di.core.util.Assert.assertNull;
-
-public class FileHolderImplUnitTest {
-
-  private static FileHolderImpl fileHolder;
-  private static FileHolderImpl fileHolderWithCapacity;
-  private static String fileName;
-  private static String fileNameWithEmptyContent;
-  private static File file;
-  private static File fileWithEmptyContent;
-
-  @BeforeClass public static void setup() {
-    fileHolder = new FileHolderImpl();
-    fileHolderWithCapacity = new FileHolderImpl(50);
-    file = new File("Test.carbondata");
-    fileWithEmptyContent = new File("TestEXception.carbondata");
-
-    if (!file.exists()) try {
-      file.createNewFile();
-    } catch (IOException e) {
-      e.printStackTrace();
-    }
-    if (!fileWithEmptyContent.exists()) try {
-      fileWithEmptyContent.createNewFile();
-    } catch (IOException e) {
-      e.printStackTrace();
-    }
-    try {
-      FileOutputStream of = new FileOutputStream(file, true);
-      BufferedWriter br = new BufferedWriter(new OutputStreamWriter(of, "UTF-8"));
-      br.write("Hello World");
-      br.close();
-    } catch (Exception e) {
-      e.getMessage();
-    }
-    fileName = file.getAbsolutePath();
-    fileNameWithEmptyContent = fileWithEmptyContent.getAbsolutePath();
-  }
-
-  @AfterClass public static void tearDown() throws IOException {
-    file.delete();
-    fileWithEmptyContent.delete();
-    fileHolder.finish();
-  }
-
-  @Test public void testReadByteArray() throws IOException  {
-    byte[] result = fileHolder.readByteArray(fileName, 1);
-    byte[] expected_result = new byte[] { 72 };
-    assertThat(result, is(equalTo(expected_result)));
-  }
-
-  @Test public void testReadByteArrayWithFilePath() throws IOException  {
-    byte[] result = fileHolder.readByteArray(fileName, 2L, 2);
-    byte[] expected_result = { 108, 108 };
-    assertThat(result, is(equalTo(expected_result)));
-  }
-
-  @Test public void testReadLong() throws IOException  {
-    long actualResult = fileHolder.readLong(fileName, 1L);
-    long expectedResult = 7308335519855243122L;
-    assertThat(actualResult, is(equalTo(expectedResult)));
-  }
-
-  @Test public void testReadLongForIoException() throws IOException {
-    fileHolder.readLong(fileNameWithEmptyContent, 1L);
-  }
-
-  @Test public void testReadIntForIoException() throws IOException {
-    fileHolder.readInt(fileNameWithEmptyContent, 1L);
-  }
-
-  @Test public void testReadInt() throws IOException  {
-    int actualResult = fileHolder.readInt(fileName, 1L);
-    int expectedResult = 1701604463;
-    assertThat(actualResult, is(equalTo(expectedResult)));
-  }
-
-  @Test public void testReadIntWithFileName() throws IOException  {
-    int actualResult = fileHolder.readInt(fileName);
-    int expectedResult = 1701604463;
-    assertThat(actualResult, is(equalTo(expectedResult)));
-  }
-
-  @Test public void testReadIntWithFileNameForIOException() throws IOException  {
-    fileHolder.readInt(fileNameWithEmptyContent);
-
-  }
-
-  @Test public void testDouble() throws IOException  {
-    double actualResult = fileHolder.readDouble(fileName, 1L);
-    double expectedResult = 7.3083355198552433E18;
-    assertThat(actualResult, is(equalTo(expectedResult)));
-  }
-
-  @Test public void testDoubleForIoException() throws IOException {
-    fileHolder.readDouble(fileNameWithEmptyContent, 1L);
-
-  }
-
-  @Test public void testDoubleForIoExceptionwithUpdateCache() throws Exception {
-    new MockUp<FileSystem>() {
-      @SuppressWarnings("unused") @Mock public FSDataInputStream open(Path file)
-          throws IOException {
-        throw new IOException();
-      }
-
-    };
-    try {
-      fileHolder.readDouble(fileName, 1L);
-    } catch (Exception e) {
-      assertNull(e.getMessage());
-    }
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/DriverQueryStatisticsRecorderImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/DriverQueryStatisticsRecorderImplTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/DriverQueryStatisticsRecorderImplTest.java
deleted file mode 100644
index 4322817..0000000
--- a/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/DriverQueryStatisticsRecorderImplTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.carbondata.core.carbon.querystatistics;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.carbondata.core.stats.DriverQueryStatisticsRecorderImpl;
-import org.apache.carbondata.core.stats.QueryStatistic;
-import org.apache.carbondata.core.stats.QueryStatisticsConstants;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static junit.framework.TestCase.assertNotNull;
-import static org.pentaho.di.core.util.Assert.assertNull;
-
-public class DriverQueryStatisticsRecorderImplTest {
-  private static DriverQueryStatisticsRecorderImpl driverQueryStatisticsRecorderImpl = null;
-  private static QueryStatistic queryStasticsWithSQL_PARSE = null;
-  private static QueryStatistic queryStasticsWithLoadMetaData = null;
-  private static QueryStatistic queryStasticsWithLOAD_BLOCKS_DRIVER = null;
-  private static QueryStatistic queryStasticsWithBLOCK_ALLOCATION = null;
-  private static QueryStatistic queryStasticsWithBLOCK_IDENTIFICATION = null;
-
-  private static List<QueryStatistic> queryStatisticList;
-
-  @BeforeClass public static void setUp() {
-    driverQueryStatisticsRecorderImpl = DriverQueryStatisticsRecorderImpl.getInstance();
-    queryStasticsWithSQL_PARSE = new QueryStatistic();
-    queryStasticsWithLoadMetaData = new QueryStatistic();
-    queryStasticsWithLOAD_BLOCKS_DRIVER = new QueryStatistic();
-    queryStasticsWithBLOCK_ALLOCATION = new QueryStatistic();
-    queryStasticsWithBLOCK_IDENTIFICATION = new QueryStatistic();
-    queryStatisticList = new ArrayList<>();
-
-  }
-
-  @Test public void testCollectDriverStatistics() {
-    queryStasticsWithLOAD_BLOCKS_DRIVER
-        .addCountStatistic(QueryStatisticsConstants.LOAD_BLOCKS_DRIVER, 3);
-    queryStasticsWithLOAD_BLOCKS_DRIVER
-        .addStatistics(QueryStatisticsConstants.LOAD_BLOCKS_DRIVER, 5);
-    queryStasticsWithLOAD_BLOCKS_DRIVER
-        .addFixedTimeStatistic(QueryStatisticsConstants.LOAD_BLOCKS_DRIVER, 5);
-    queryStatisticList.add(queryStasticsWithLOAD_BLOCKS_DRIVER);
-    queryStasticsWithBLOCK_ALLOCATION
-        .addCountStatistic(QueryStatisticsConstants.BLOCK_ALLOCATION, 3);
-    queryStasticsWithBLOCK_ALLOCATION.addStatistics(QueryStatisticsConstants.BLOCK_ALLOCATION, 5);
-    queryStasticsWithLOAD_BLOCKS_DRIVER
-        .addFixedTimeStatistic(QueryStatisticsConstants.LOAD_BLOCKS_DRIVER, 5);
-    queryStatisticList.add(queryStasticsWithBLOCK_ALLOCATION);
-    queryStasticsWithBLOCK_IDENTIFICATION
-        .addCountStatistic(QueryStatisticsConstants.BLOCK_IDENTIFICATION, 3);
-    queryStasticsWithBLOCK_IDENTIFICATION
-        .addStatistics(QueryStatisticsConstants.BLOCK_IDENTIFICATION, 5);
-    queryStatisticList.add(queryStasticsWithBLOCK_IDENTIFICATION);
-    queryStasticsWithLoadMetaData.addCountStatistic(QueryStatisticsConstants.LOAD_META, 3);
-    queryStasticsWithLoadMetaData.addStatistics(QueryStatisticsConstants.LOAD_META, 5);
-    queryStatisticList.add(queryStasticsWithLoadMetaData);
-    queryStasticsWithSQL_PARSE.addCountStatistic(QueryStatisticsConstants.SQL_PARSE, 3);
-    queryStasticsWithSQL_PARSE.addStatistics(QueryStatisticsConstants.SQL_PARSE, 5);
-    queryStatisticList.add(queryStasticsWithSQL_PARSE);
-
-    String result =
-        driverQueryStatisticsRecorderImpl.collectDriverStatistics(queryStatisticList, "query1");
-    assertNotNull(result);
-  }
-
-  @Test public void testCollectDriverStatisticsWithBlock_Allocation() {
-    queryStatisticList.clear();
-    queryStasticsWithBLOCK_ALLOCATION
-        .addCountStatistic(QueryStatisticsConstants.BLOCK_ALLOCATION, 3);
-    queryStasticsWithBLOCK_ALLOCATION.addStatistics(QueryStatisticsConstants.BLOCK_ALLOCATION, 5);
-    queryStatisticList.add(queryStasticsWithBLOCK_ALLOCATION);
-    String result =
-        driverQueryStatisticsRecorderImpl.collectDriverStatistics(queryStatisticList, "query1");
-    assertNull(result);
-  }
-
-  @Test public void testCollectDriverStatisticsWithBlock_AllocationAndBlock_Identification() {
-    queryStatisticList.clear();
-    queryStasticsWithBLOCK_ALLOCATION
-        .addCountStatistic(QueryStatisticsConstants.BLOCK_ALLOCATION, 3);
-    queryStasticsWithBLOCK_ALLOCATION.addStatistics(QueryStatisticsConstants.BLOCK_ALLOCATION, 5);
-    queryStatisticList.add(queryStasticsWithBLOCK_ALLOCATION);
-    queryStasticsWithBLOCK_IDENTIFICATION
-        .addCountStatistic(QueryStatisticsConstants.BLOCK_IDENTIFICATION, 3);
-    queryStasticsWithBLOCK_IDENTIFICATION
-        .addStatistics(QueryStatisticsConstants.BLOCK_IDENTIFICATION, 5);
-    queryStatisticList.add(queryStasticsWithBLOCK_IDENTIFICATION);
-    String result =
-        driverQueryStatisticsRecorderImpl.collectDriverStatistics(queryStatisticList, "query1");
-    assertNotNull(result);
-  }
-
-  @Test
-  public void testCollectDriverStatisticsWithBlock_AllocationAndBlock_IdentificationForException() {
-    queryStatisticList.clear();
-
-    driverQueryStatisticsRecorderImpl = DriverQueryStatisticsRecorderImpl.getInstance();
-
-    String result =
-        driverQueryStatisticsRecorderImpl.collectDriverStatistics(queryStatisticList, "query1");
-    assertNull(result);
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/QueryStasticsRecorderImplTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/QueryStasticsRecorderImplTest.java b/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/QueryStasticsRecorderImplTest.java
deleted file mode 100644
index fe2f1ea..0000000
--- a/core/src/test/java/org/apache/carbondata/core/carbon/querystatistics/QueryStasticsRecorderImplTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.carbondata.core.carbon.querystatistics;
-
-import org.apache.carbondata.core.stats.QueryStatistic;
-import org.apache.carbondata.core.stats.QueryStatisticsConstants;
-import org.apache.carbondata.core.stats.QueryStatisticsRecorderImpl;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static junit.framework.TestCase.assertNotNull;
-
-public class QueryStasticsRecorderImplTest {
-
-  private static QueryStatisticsRecorderImpl queryStasticsRecorderImpl = null;
-  private static QueryStatistic queryStatistic = null;
-  private static QueryStatistic queryStatisticWithLOAD_BLOCKS_EXECUTOR = null;
-  private static QueryStatistic queryStatisticWithSCAN_BLOCKS_TIME = null;
-  private static QueryStatistic queryStatisticWithSCAN_BLOCKS_NUM = null;
-  private static QueryStatistic queryStatisticWithLOAD_DICTIONARY = null;
-  private static QueryStatistic queryStatisticWithRESULT_SIZE = null;
-  private static QueryStatistic queryStatisticWithEXECUTOR_PART = null;
-  private static QueryStatistic queryStatisticWithTOTAL_BLOCKLET_NUM = null;
-  private static QueryStatistic queryStatisticWithVALID_SCAN_BLOCKLET_NUM = null;
-
-  @BeforeClass public static void setUp() {
-    queryStatisticWithLOAD_BLOCKS_EXECUTOR = new QueryStatistic();
-    queryStasticsRecorderImpl = new QueryStatisticsRecorderImpl(System.nanoTime() + "");
-    queryStasticsRecorderImpl.logStatisticsAsTableDriver();
-    queryStatisticWithLOAD_BLOCKS_EXECUTOR
-        .addStatistics(QueryStatisticsConstants.LOAD_BLOCKS_EXECUTOR, 5L);
-    queryStatisticWithLOAD_BLOCKS_EXECUTOR
-        .addCountStatistic(QueryStatisticsConstants.LOAD_BLOCKS_EXECUTOR, 5L);
-    queryStatisticWithLOAD_BLOCKS_EXECUTOR
-        .addStatistics(QueryStatisticsConstants.LOAD_BLOCKS_EXECUTOR, 5L);
-    queryStasticsRecorderImpl.logStatistics();
-    queryStasticsRecorderImpl.recordStatistics(queryStatisticWithLOAD_BLOCKS_EXECUTOR);
-    queryStatisticWithSCAN_BLOCKS_TIME = new QueryStatistic();
-    queryStatisticWithSCAN_BLOCKS_TIME.addStatistics(QueryStatisticsConstants.SCAN_BLOCKS_TIME, 5L);
-    queryStatisticWithSCAN_BLOCKS_TIME
-        .addCountStatistic(QueryStatisticsConstants.SCAN_BLOCKS_TIME, 5L);
-    queryStatisticWithSCAN_BLOCKS_TIME.addStatistics(QueryStatisticsConstants.SCAN_BLOCKS_TIME, 5L);
-    queryStasticsRecorderImpl.logStatistics();
-    queryStasticsRecorderImpl.recordStatistics(queryStatisticWithSCAN_BLOCKS_TIME);
-    queryStatisticWithSCAN_BLOCKS_NUM = new QueryStatistic();
-    queryStatisticWithSCAN_BLOCKS_NUM.addStatistics(QueryStatisticsConstants.SCAN_BLOCKS_NUM, 5L);
-    queryStatisticWithSCAN_BLOCKS_NUM
-        .addCountStatistic(QueryStatisticsConstants.SCAN_BLOCKS_NUM, 5L);
-    queryStatisticWithSCAN_BLOCKS_NUM.addStatistics(QueryStatisticsConstants.SCAN_BLOCKS_NUM, 5L);
-    queryStasticsRecorderImpl.logStatistics();
-    queryStasticsRecorderImpl.recordStatistics(queryStatisticWithSCAN_BLOCKS_NUM);
-    queryStatisticWithLOAD_DICTIONARY = new QueryStatistic();
-    queryStatisticWithLOAD_DICTIONARY.addStatistics(QueryStatisticsConstants.LOAD_DICTIONARY, 5L);
-    queryStatisticWithLOAD_DICTIONARY
-        .addCountStatistic(QueryStatisticsConstants.LOAD_DICTIONARY, 5L);
-    queryStatisticWithLOAD_DICTIONARY.addStatistics(QueryStatisticsConstants.LOAD_DICTIONARY, 5L);
-    queryStasticsRecorderImpl.logStatistics();
-    queryStasticsRecorderImpl.recordStatistics(queryStatisticWithLOAD_DICTIONARY);
-    queryStatisticWithRESULT_SIZE = new QueryStatistic();
-    queryStatisticWithRESULT_SIZE.addStatistics(QueryStatisticsConstants.RESULT_SIZE, 5L);
-    queryStatisticWithRESULT_SIZE.addCountStatistic(QueryStatisticsConstants.RESULT_SIZE, 5L);
-    queryStatisticWithRESULT_SIZE.addStatistics(QueryStatisticsConstants.RESULT_SIZE, 5L);
-    queryStasticsRecorderImpl.logStatistics();
-    queryStasticsRecorderImpl.recordStatistics(queryStatisticWithRESULT_SIZE);
-    queryStatisticWithEXECUTOR_PART = new QueryStatistic();
-    queryStatisticWithEXECUTOR_PART.addStatistics(QueryStatisticsConstants.EXECUTOR_PART, 5L);
-    queryStatisticWithEXECUTOR_PART.addCountStatistic(QueryStatisticsConstants.EXECUTOR_PART, 5L);
-    queryStatisticWithEXECUTOR_PART.addStatistics(QueryStatisticsConstants.EXECUTOR_PART, 5L);
-    queryStasticsRecorderImpl.logStatistics();
-    queryStasticsRecorderImpl.recordStatistics(queryStatisticWithEXECUTOR_PART);
-    queryStatisticWithTOTAL_BLOCKLET_NUM = new QueryStatistic();
-    queryStatisticWithTOTAL_BLOCKLET_NUM
-        .addStatistics(QueryStatisticsConstants.TOTAL_BLOCKLET_NUM, 5L);
-    queryStatisticWithTOTAL_BLOCKLET_NUM
-        .addCountStatistic(QueryStatisticsConstants.TOTAL_BLOCKLET_NUM, 5L);
-    queryStatisticWithTOTAL_BLOCKLET_NUM
-        .addStatistics(QueryStatisticsConstants.TOTAL_BLOCKLET_NUM, 5L);
-    queryStasticsRecorderImpl.logStatistics();
-    queryStasticsRecorderImpl.recordStatistics(queryStatisticWithTOTAL_BLOCKLET_NUM);
-    queryStatisticWithVALID_SCAN_BLOCKLET_NUM = new QueryStatistic();
-    queryStatisticWithVALID_SCAN_BLOCKLET_NUM
-        .addStatistics(QueryStatisticsConstants.VALID_SCAN_BLOCKLET_NUM, 5L);
-    queryStatisticWithVALID_SCAN_BLOCKLET_NUM
-        .addCountStatistic(QueryStatisticsConstants.VALID_SCAN_BLOCKLET_NUM, 5L);
-    queryStatisticWithVALID_SCAN_BLOCKLET_NUM
-        .addStatistics(QueryStatisticsConstants.VALID_SCAN_BLOCKLET_NUM, 5L);
-    queryStasticsRecorderImpl.logStatistics();
-    queryStasticsRecorderImpl.recordStatistics(queryStatisticWithVALID_SCAN_BLOCKLET_NUM);
-    queryStasticsRecorderImpl.logStatisticsAsTableExecutor();
-  }
-
-  @Test public void testcollectExecutorStatistics() {
-    assertNotNull(queryStasticsRecorderImpl.collectExecutorStatistics());
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/datastorage/CompressedDataMeasureWrapperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/CompressedDataMeasureWrapperTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/CompressedDataMeasureWrapperTest.java
new file mode 100644
index 0000000..8bc6af4
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/datastorage/CompressedDataMeasureWrapperTest.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.core.datastorage;
+
+import org.apache.carbondata.core.datastorage.dataholder.CarbonReadDataHolder;
+import org.apache.carbondata.core.datastorage.impl.CompressedDataMeasureDataWrapper;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class CompressedDataMeasureWrapperTest {
+  private static CompressedDataMeasureDataWrapper compressedDataMeasureDataWrapper;
+  private static CarbonReadDataHolder carbonReadDataHolder;
+  private static CarbonReadDataHolder[] carbonReadDataHolders;
+
+  @BeforeClass public static void setUp() {
+    carbonReadDataHolder = new CarbonReadDataHolder(null);
+    carbonReadDataHolders = new CarbonReadDataHolder[] { carbonReadDataHolder };
+
+  }
+
+  @Test public void testGetValues() {
+    compressedDataMeasureDataWrapper = new CompressedDataMeasureDataWrapper(carbonReadDataHolders);
+    int expected = 1;
+    int actual = compressedDataMeasureDataWrapper.getValues().length;
+    assertEquals(expected, actual);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/datastorage/DFSFileHolderImplUnitTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/DFSFileHolderImplUnitTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/DFSFileHolderImplUnitTest.java
new file mode 100644
index 0000000..62700db
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/datastorage/DFSFileHolderImplUnitTest.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.core.datastorage;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+import org.apache.carbondata.core.datastorage.impl.DFSFileHolderImpl;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.pentaho.di.core.util.Assert.assertNull;
+
+public class DFSFileHolderImplUnitTest {
+
+  private static DFSFileHolderImpl dfsFileHolder;
+  private static String fileName;
+  private static String fileNameWithEmptyContent;
+  private static File file;
+  private static File fileWithEmptyContent;
+
+  @BeforeClass public static void setup() {
+    dfsFileHolder = new DFSFileHolderImpl();
+    file = new File("Test.carbondata");
+    fileWithEmptyContent = new File("TestEXception.carbondata");
+
+    if (!file.exists()) try {
+      file.createNewFile();
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    if (!fileWithEmptyContent.exists()) try {
+      fileWithEmptyContent.createNewFile();
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    try {
+      FileOutputStream of = new FileOutputStream(file, true);
+      BufferedWriter br = new BufferedWriter(new OutputStreamWriter(of, "UTF-8"));
+      br.write("Hello World");
+      br.close();
+    } catch (Exception e) {
+      e.getMessage();
+    }
+    fileName = file.getAbsolutePath();
+    fileNameWithEmptyContent = fileWithEmptyContent.getAbsolutePath();
+  }
+
+  @AfterClass public static void tearDown() throws IOException  {
+    file.delete();
+    fileWithEmptyContent.delete();
+    dfsFileHolder.finish();
+  }
+
+  @Test public void testReadByteArray() throws IOException  {
+    byte[] result = dfsFileHolder.readByteArray(fileName, 1);
+    byte[] expected_result = new byte[] { 72 };
+    assertThat(result, is(equalTo(expected_result)));
+  }
+
+  @Test public void testReadByteArrayWithFilePath() throws IOException  {
+    byte[] result = dfsFileHolder.readByteArray(fileName, 2L, 2);
+    byte[] expected_result = { 108, 108 };
+    assertThat(result, is(equalTo(expected_result)));
+  }
+
+  @Test public void testReadLong() throws IOException  {
+    long actualResult = dfsFileHolder.readLong(fileName, 1L);
+    long expectedResult = 7308335519855243122L;
+    assertThat(actualResult, is(equalTo(expectedResult)));
+  }
+
+  @Test(expected = IOException.class)
+  public void testReadLongForIoException() throws IOException {
+    dfsFileHolder.readLong(fileNameWithEmptyContent, 1L);
+  }
+
+  @Test(expected = IOException.class)
+  public void testReadIntForIoException() throws IOException{
+    dfsFileHolder.readInt(fileNameWithEmptyContent, 1L);
+  }
+
+  @Test public void testReadInt() throws IOException  {
+    int actualResult = dfsFileHolder.readInt(fileName, 1L);
+    int expectedResult = 1701604463;
+    assertThat(actualResult, is(equalTo(expectedResult)));
+  }
+
+  @Test public void testReadIntWithFileName() throws IOException {
+    int actualResult = dfsFileHolder.readInt(fileName);
+    int expectedResult = 1701604463;
+    assertThat(actualResult, is(equalTo(expectedResult)));
+  }
+
+  @Test(expected = IOException.class)
+  public void testReadIntWithFileNameForIOException() throws IOException {
+    dfsFileHolder.readInt(fileNameWithEmptyContent);
+  }
+
+  @Test public void testDouble() throws IOException  {
+    double actualResult = dfsFileHolder.readDouble(fileName, 1L);
+    double expectedResult = 7.3083355198552433E18;
+    assertThat(actualResult, is(equalTo(expectedResult)));
+  }
+
+  @Test(expected = IOException.class)
+  public void testDoubleForIoException() throws IOException {
+    dfsFileHolder.readDouble(fileNameWithEmptyContent, 1L);
+  }
+
+  @Test
+  public void testDoubleForIoExceptionwithUpdateCache() throws IOException {
+    new MockUp<FileSystem>() {
+      @SuppressWarnings("unused") @Mock public FSDataInputStream open(Path file)
+          throws IOException {
+        throw new IOException();
+      }
+
+    };
+    dfsFileHolder.readDouble(fileName, 1L);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/datastorage/FileFactoryImplUnitTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/FileFactoryImplUnitTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/FileFactoryImplUnitTest.java
new file mode 100644
index 0000000..51874c0
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/datastorage/FileFactoryImplUnitTest.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.core.datastorage;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.carbondata.core.datastorage.impl.FileFactory;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class FileFactoryImplUnitTest {
+
+  private static String filePath;
+
+  @AfterClass
+  public static void tearDown() {
+    File file = new File(filePath);
+    if (file.exists()) {
+      file.delete();
+    }
+
+    File file1 = new File(".TestFileFactory.carbondata.crc");
+    if (file1.exists()) {
+      file1.delete();
+    }
+  }
+
+  @BeforeClass public static void setUp() {
+    filePath = "TestFileFactory.carbondata";
+  }
+
+  @Test public void testFileExistsForVIEWFSType() throws IOException {
+    FileFactory.isFileExist("fakefilePath", FileFactory.FileType.VIEWFS);
+  }
+
+  @Test public void testFileExistsForDefaultType() throws IOException {
+    FileFactory.isFileExist("fakefilePath", FileFactory.FileType.LOCAL);
+  }
+
+  @Test public void testFileExistsForDefaultTypeWithPerformFileCheck() throws IOException {
+    assertTrue(FileFactory.isFileExist(filePath, FileFactory.FileType.LOCAL, true));
+  }
+
+  @Test public void testFileExistsForDefaultTypeWithOutPerformFileCheck() throws IOException {
+    assertFalse(FileFactory.isFileExist("fakefilePath", FileFactory.FileType.LOCAL, false));
+  }
+
+  @Test public void testFileExistsForVIEWFSTypeWithPerformFileCheck() throws IOException {
+    assertTrue(FileFactory.isFileExist(filePath, FileFactory.FileType.VIEWFS, true));
+  }
+
+  @Test public void testFileExistsForVIEWFSTypeWithOutPerformFileCheck() throws IOException {
+    assertFalse(FileFactory.isFileExist("fakefilePath", FileFactory.FileType.VIEWFS, false));
+  }
+
+  @Test public void testCreateNewFileWithDefaultFileType() throws IOException {
+    tearDown();
+    assertTrue(FileFactory.createNewFile(filePath, FileFactory.FileType.LOCAL));
+  }
+
+  @Test public void testCreateNewLockFileWithDefaultFileType() throws IOException {
+    tearDown();
+    assertTrue(FileFactory.createNewLockFile(filePath, FileFactory.FileType.LOCAL));
+  }
+
+  @Test public void testCreateNewLockFileWithViewFsFileType() throws IOException {
+    tearDown();
+    assertTrue(FileFactory.createNewLockFile(filePath, FileFactory.FileType.VIEWFS));
+  }
+
+  @Test public void testCreateNewLockFileWithViewFsFileTypeWhenFileExists() throws IOException {
+    assertFalse(FileFactory.createNewLockFile(filePath, FileFactory.FileType.VIEWFS));
+  }
+
+  @Test public void testCreateNewFileWithDefaultFileTypeWhenFileExists() throws IOException {
+    assertFalse(FileFactory.createNewFile(filePath, FileFactory.FileType.LOCAL));
+  }
+
+  @Test public void testCreateNewFileWithVIEWFSFileType() throws IOException {
+    File file = new File(filePath);
+    if (file.exists()) {
+      file.delete();
+    }
+    assertTrue(FileFactory.createNewFile(filePath, FileFactory.FileType.VIEWFS));
+  }
+
+  @Test public void testCreateNewFileWithVIEWFSFileTypeWhenFileExists() throws IOException {
+    assertFalse(FileFactory.createNewFile(filePath, FileFactory.FileType.VIEWFS));
+  }
+
+  @Test public void testMkDirWithVIEWFSFileType() throws IOException {
+    new MockUp<FileSystem>() {
+      @SuppressWarnings("unused") @Mock public boolean mkdirs(Path file) throws IOException {
+        {
+          return true;
+        }
+      }
+    };
+    tearDown();
+    assertTrue(FileFactory.mkdirs(filePath, FileFactory.FileType.VIEWFS));
+  }
+
+  @Test public void testGetDataOutputStreamUsingAppendeForException() {
+    try {
+      FileFactory.getDataOutputStreamUsingAppend(filePath, FileFactory.FileType.VIEWFS);
+    } catch (Exception exception) {
+      assertEquals("Not supported", exception.getMessage());
+    }
+  }
+
+  @Test public void getDataOutputStreamForVIEWFSType() throws IOException {
+    assertNotNull(FileFactory.getDataOutputStream(filePath, FileFactory.FileType.VIEWFS));
+  }
+
+  @Test public void getDataOutputStreamForLocalType() throws IOException {
+    assertNotNull(FileFactory.getDataOutputStream(filePath, FileFactory.FileType.LOCAL));
+  }
+
+  @Test public void testGetCarbonFile() throws IOException {
+    FileFactory.getDataOutputStream(filePath, FileFactory.FileType.VIEWFS);
+    assertNotNull(FileFactory.getCarbonFile(filePath, FileFactory.FileType.HDFS));
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/datastorage/FileHolderImplUnitTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/FileHolderImplUnitTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/FileHolderImplUnitTest.java
new file mode 100644
index 0000000..854b14d
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/datastorage/FileHolderImplUnitTest.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.core.datastorage;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+import org.apache.carbondata.core.datastorage.impl.FileHolderImpl;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.pentaho.di.core.util.Assert.assertNull;
+
+public class FileHolderImplUnitTest {
+
+  private static FileHolderImpl fileHolder;
+  private static FileHolderImpl fileHolderWithCapacity;
+  private static String fileName;
+  private static String fileNameWithEmptyContent;
+  private static File file;
+  private static File fileWithEmptyContent;
+
+  @BeforeClass public static void setup() {
+    fileHolder = new FileHolderImpl();
+    fileHolderWithCapacity = new FileHolderImpl(50);
+    file = new File("Test.carbondata");
+    fileWithEmptyContent = new File("TestEXception.carbondata");
+
+    if (!file.exists()) try {
+      file.createNewFile();
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    if (!fileWithEmptyContent.exists()) try {
+      fileWithEmptyContent.createNewFile();
+    } catch (IOException e) {
+      e.printStackTrace();
+    }
+    try {
+      FileOutputStream of = new FileOutputStream(file, true);
+      BufferedWriter br = new BufferedWriter(new OutputStreamWriter(of, "UTF-8"));
+      br.write("Hello World");
+      br.close();
+    } catch (Exception e) {
+      e.getMessage();
+    }
+    fileName = file.getAbsolutePath();
+    fileNameWithEmptyContent = fileWithEmptyContent.getAbsolutePath();
+  }
+
+  @AfterClass public static void tearDown() throws IOException {
+    file.delete();
+    fileWithEmptyContent.delete();
+    fileHolder.finish();
+  }
+
+  @Test public void testReadByteArray() throws IOException  {
+    byte[] result = fileHolder.readByteArray(fileName, 1);
+    byte[] expected_result = new byte[] { 72 };
+    assertThat(result, is(equalTo(expected_result)));
+  }
+
+  @Test public void testReadByteArrayWithFilePath() throws IOException  {
+    byte[] result = fileHolder.readByteArray(fileName, 2L, 2);
+    byte[] expected_result = { 108, 108 };
+    assertThat(result, is(equalTo(expected_result)));
+  }
+
+  @Test public void testReadLong() throws IOException  {
+    long actualResult = fileHolder.readLong(fileName, 1L);
+    long expectedResult = 7308335519855243122L;
+    assertThat(actualResult, is(equalTo(expectedResult)));
+  }
+
+  @Test public void testReadLongForIoException() throws IOException {
+    fileHolder.readLong(fileNameWithEmptyContent, 1L);
+  }
+
+  @Test public void testReadIntForIoException() throws IOException {
+    fileHolder.readInt(fileNameWithEmptyContent, 1L);
+  }
+
+  @Test public void testReadInt() throws IOException  {
+    int actualResult = fileHolder.readInt(fileName, 1L);
+    int expectedResult = 1701604463;
+    assertThat(actualResult, is(equalTo(expectedResult)));
+  }
+
+  @Test public void testReadIntWithFileName() throws IOException  {
+    int actualResult = fileHolder.readInt(fileName);
+    int expectedResult = 1701604463;
+    assertThat(actualResult, is(equalTo(expectedResult)));
+  }
+
+  @Test public void testReadIntWithFileNameForIOException() throws IOException  {
+    fileHolder.readInt(fileNameWithEmptyContent);
+
+  }
+
+  @Test public void testDouble() throws IOException  {
+    double actualResult = fileHolder.readDouble(fileName, 1L);
+    double expectedResult = 7.3083355198552433E18;
+    assertThat(actualResult, is(equalTo(expectedResult)));
+  }
+
+  @Test public void testDoubleForIoException() throws IOException {
+    fileHolder.readDouble(fileNameWithEmptyContent, 1L);
+
+  }
+
+  @Test public void testDoubleForIoExceptionwithUpdateCache() throws Exception {
+    new MockUp<FileSystem>() {
+      @SuppressWarnings("unused") @Mock public FSDataInputStream open(Path file)
+          throws IOException {
+        throw new IOException();
+      }
+
+    };
+    try {
+      fileHolder.readDouble(fileName, 1L);
+    } catch (Exception e) {
+      assertNull(e.getMessage());
+    }
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/datastorage/columnar/ColumnarKeyStoreDataHolderUnitTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/columnar/ColumnarKeyStoreDataHolderUnitTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/columnar/ColumnarKeyStoreDataHolderUnitTest.java
new file mode 100644
index 0000000..29d2eae
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/datastorage/columnar/ColumnarKeyStoreDataHolderUnitTest.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.core.datastorage.columnar;
+
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ColumnarKeyStoreDataHolderUnitTest {
+
+  private static ColumnarKeyStoreDataHolder columnarKeyStoreDataHolder;
+  private static ColumnarKeyStoreMetadata columnarKeyStoreMetadata;
+
+  @BeforeClass public static void setup() {
+    byte[] keyBlockData = new byte[] { 16, 8, 32, 40, 8, 8, 8 };
+    int eachRowSize = 2;
+    int[] reverseIndex = new int[] { 1, 5, 6, 3, 8 };
+    columnarKeyStoreMetadata = new ColumnarKeyStoreMetadata(eachRowSize);
+    columnarKeyStoreMetadata.setColumnReverseIndex(reverseIndex);
+    columnarKeyStoreDataHolder =
+        new ColumnarKeyStoreDataHolder(keyBlockData, columnarKeyStoreMetadata);
+  }
+
+  @Test public void testGetSurrogateKeyWithNullINGetColumnReverseIndex() {
+    byte[] keyBlockData = new byte[] { 16, 8, 32, 40, 8, 8, 8 };
+    int eachRowSize = 1;
+    ColumnarKeyStoreMetadata columnarKeyStoreMetadata = new ColumnarKeyStoreMetadata(eachRowSize);
+    ColumnarKeyStoreDataHolder columnarKeyStoreDataHolderNew =
+        new ColumnarKeyStoreDataHolder(keyBlockData, columnarKeyStoreMetadata);
+    int columnIndex = 5;
+    int expected_result = 8;
+    int result = columnarKeyStoreDataHolderNew.getSurrogateKey(columnIndex);
+    assertEquals(expected_result, result);
+  }
+
+  @Test public void testGetSurrogateKeyWithNullINGetColumnReverseIndexAndRowSizeTwo() {
+    byte[] keyBlockData = new byte[] { 16, 8, 32, 40, 8, 8, 8 };
+    int eachRowSize = 2;
+    ColumnarKeyStoreMetadata columnarKeyStoreMetadata = new ColumnarKeyStoreMetadata(eachRowSize);
+    ColumnarKeyStoreDataHolder columnarKeyStoreDataHolderNew =
+        new ColumnarKeyStoreDataHolder(keyBlockData, columnarKeyStoreMetadata);
+    int columnIndex = 0;
+    int expected_result = 4104;
+    int result = columnarKeyStoreDataHolderNew.getSurrogateKey(columnIndex);
+    assertEquals(expected_result, result);
+  }
+
+  @Test public void testGetSurrogateKeyWithNotNullINGetColumnReverseIndex() {
+    int columnIndex = 0;
+    int expected_result = 8232;
+    int result = columnarKeyStoreDataHolder.getSurrogateKey(columnIndex);
+    assertEquals(expected_result, result);
+  }
+
+  @Test(expected = ArrayIndexOutOfBoundsException.class)
+  public void testExceptionInGetSurrogateKey() {
+    int columnIndex = 10;
+    int expected_result = 8232;
+    int result = columnarKeyStoreDataHolder.getSurrogateKey(columnIndex);
+    assertEquals(expected_result, result);
+  }
+
+  @Test public void testGetSurrogateKeyWithListOfByteWhileCreatingObject() {
+    byte[] keyBlockData = new byte[] { 32, 64, 32, 40, 64, 8, 8 };
+    List<byte[]> noDictionaryValBasedKeyBlockData = new java.util.ArrayList<>();
+    noDictionaryValBasedKeyBlockData.add(keyBlockData);
+    new ColumnarKeyStoreDataHolder(columnarKeyStoreMetadata);
+    int columnIndex = 0;
+    int expected_result = 8232;
+    int result = columnarKeyStoreDataHolder.getSurrogateKey(columnIndex);
+    assertEquals(expected_result, result);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/AlluxioCarbonFileTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/AlluxioCarbonFileTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/AlluxioCarbonFileTest.java
new file mode 100644
index 0000000..49323d8
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/AlluxioCarbonFileTest.java
@@ -0,0 +1,292 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.core.datastorage.filesystem;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Options;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
+import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class AlluxioCarbonFileTest {
+
+    private static AlluxioCarbonFile alluxioCarbonFile;
+    private static FileStatus fileStatus;
+    private static FileStatus fileStatusWithOutDirectoryPermission;
+    private static String fileName;
+    private static File file;
+
+
+    @BeforeClass
+    static public void setUp() {
+        file = new File("Test.carbondata");
+        if (!file.exists())
+            try {
+                file.createNewFile();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        try {
+            FileOutputStream oFile = new FileOutputStream(file, true);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+
+        fileStatus = new FileStatus(12L, true, 60, 120l, 180L, new Path(file.getAbsolutePath()));
+        fileStatusWithOutDirectoryPermission = new FileStatus(12L, false, 60, 120l, 180L, new Path(file.getAbsolutePath()));
+        fileName = file.getAbsolutePath();
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+    }
+
+    @AfterClass
+    static public void cleanUp() {
+        file.delete();
+    }
+
+    @Test
+    public void testRenameForceForException() throws IOException {
+
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                throw new IOException();
+            }
+
+        };
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+        alluxioCarbonFile.renameForce(fileName);
+    }
+
+    @Test
+    public void testListFilesWithOutDirectoryPermission() {
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatusWithOutDirectoryPermission);
+        assertTrue(alluxioCarbonFile.listFiles() == null);
+    }
+
+    @Test
+    public void testConstructorWithFilePath() {
+        alluxioCarbonFile = new AlluxioCarbonFile(file.getAbsolutePath());
+        assertTrue(alluxioCarbonFile instanceof AlluxioCarbonFile);
+    }
+
+    @Test
+    public void testListFilesForNullListStatus() {
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatusWithOutDirectoryPermission);
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus[] listStatus(Path var1) throws IOException {
+
+                return null;
+            }
+
+        };
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+        assertTrue(alluxioCarbonFile.listFiles().length == 0);
+    }
+
+    @Test
+    public void testListDirectory() {
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus[] listStatus(Path var1) throws IOException {
+
+                FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))};
+                return fileStatus;
+            }
+
+        };
+
+        assertTrue(alluxioCarbonFile.listFiles().length == 1);
+    }
+
+    @Test
+    public void testListFilesForException() throws IOException {
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatusWithOutDirectoryPermission);
+
+        new MockUp<FileStatus>() {
+            @Mock
+            public Path getPath() {
+                return new Path(file.getAbsolutePath());
+            }
+
+        };
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                throw new IOException();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus[] listStatus(Path var1) throws IOException {
+
+                throw new IOException();
+            }
+
+        };
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+        alluxioCarbonFile.listFiles();
+    }
+
+    @Test
+    public void testListFilesWithCarbonFilter() {
+        CarbonFileFilter carbonFileFilter = new CarbonFileFilter() {
+
+            @Override
+            public boolean accept(CarbonFile file) {
+                return true;
+            }
+        };
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+        assertTrue(alluxioCarbonFile.listFiles(carbonFileFilter).length == 1);
+    }
+
+    @Test
+    public void testlistFilesWithoutFilter() {
+        CarbonFileFilter carbonFileFilter = new CarbonFileFilter() {
+
+            @Override
+            public boolean accept(CarbonFile file) {
+                return false;
+            }
+        };
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus[] listStatus(Path var1) throws IOException {
+
+                FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))};
+                return fileStatus;
+            }
+
+        };
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+        assertTrue(alluxioCarbonFile.listFiles(carbonFileFilter).length == 0);
+    }
+
+    @Test
+    public void testGetParentFile() {
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<Path>() {
+            @Mock
+            public Path getParent() {
+                return new Path(file.getAbsolutePath()
+                );
+            }
+
+        };
+        new MockUp<FileStatus>() {
+            @Mock
+            public Path getPath() {
+                return new Path(file.getAbsolutePath());
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus getFileStatus(Path path) throws IOException {
+
+                return new FileStatus(12L, true, 60, 120l, 180L, new Path(file.getAbsolutePath()));
+            }
+
+        };
+
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+        assertFalse(alluxioCarbonFile.getParentFile().equals(null));
+    }
+
+    @Test
+    public void testForNonDisributedSystem() {
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new WebHdfsFileSystem();
+            }
+
+        };
+        assertFalse(alluxioCarbonFile.renameForce(fileName));
+    }
+
+    @Test
+    public void testrenameForceForDisributedSystem() {
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public void rename(Path src, Path dst, final Options.Rename... options) throws IOException {
+
+            }
+
+        };
+
+        alluxioCarbonFile = new AlluxioCarbonFile(fileStatus);
+        assertTrue(alluxioCarbonFile.renameForce(fileName));
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/HDFSCarbonFileTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/HDFSCarbonFileTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/HDFSCarbonFileTest.java
new file mode 100644
index 0000000..b09e14e
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/HDFSCarbonFileTest.java
@@ -0,0 +1,400 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.core.datastorage.filesystem;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.apache.carbondata.common.logging.LogService;
+import org.apache.carbondata.common.logging.LogServiceFactory;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Options;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
+import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
+import org.apache.hadoop.util.Progressable;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+
+public class HDFSCarbonFileTest {
+
+    private static final LogService LOGGER =
+            LogServiceFactory.getLogService(HDFSCarbonFile.class.getName());
+    private static HDFSCarbonFile hdfsCarbonFile;
+    private static FileStatus fileStatus = null;
+    private static FileStatus fileStatusWithOutDirectoryPermission;
+    private static String fileName = null;
+    private static FileSystem fs = null;
+    private static Path pt;
+
+    @BeforeClass
+    static public void setUp() throws IOException {
+        Configuration config = new Configuration();
+//adding local hadoop configuration
+        config.addResource(new Path("core-site.xml"));
+        config.addResource(new Path("hdfs-site.xml"));
+        fileName = "Test.carbondata"; //this path is HDFS path
+        pt = new Path(fileName);
+        fs = FileSystem.get(new Configuration(config));
+        fs.create(pt);
+        if (fs.exists(pt)) {
+            OutputStream os = fs.create(pt,
+                    new Progressable() {
+                        public void progress() {
+                            LOGGER.info("Started Writing to File===");
+                        }
+                    });
+            BufferedWriter br = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
+            br.write("Hello World");
+            br.close();
+            fs.close();
+
+            fileStatus = new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName));
+            fileStatusWithOutDirectoryPermission = new FileStatus(12L, false, 60, 120l, 180L, new Path(fileName));
+            hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+
+        }
+    }
+
+    @AfterClass
+    static public void cleanUp() {
+        try {
+            fs.delete(pt, true);
+        } catch (IOException e) {
+            LOGGER.error("Exception Occured" + e.getMessage());
+        }
+    }
+
+    @Test
+    public void testRenameForceForException() throws IOException {
+
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                throw new IOException();
+            }
+
+        };
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+        hdfsCarbonFile.renameForce(fileName);
+    }
+
+    @Test
+    public void testListFilesWithOutDirectoryPermission() {
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatusWithOutDirectoryPermission);
+        new MockUp<FileStatus>() {
+            @Mock
+            public boolean isDirectory() {
+                return false;
+            }
+
+        };
+
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+
+        new MockUp<FileStatus>() {
+            @Mock
+            public Path getPath() {
+                return new Path(fileName);
+            }
+
+        };
+        assertEquals(hdfsCarbonFile.listFiles(), null);
+    }
+
+    @Test
+    public void testConstructorWithFilePath() {
+        hdfsCarbonFile = new HDFSCarbonFile(fileName);
+        assertTrue(hdfsCarbonFile instanceof HDFSCarbonFile);
+    }
+
+    @Test
+    public void testListFilesForNullListStatus() {
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus[] listStatus(Path var1) throws IOException {
+
+                return null;
+            }
+
+        };
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+        assertEquals(hdfsCarbonFile.listFiles().length, 0);
+    }
+
+    @Test
+    public void testListDirectory() {
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus[] listStatus(Path var1) throws IOException {
+
+                FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))};
+                return fileStatus;
+            }
+
+        };
+
+        assertEquals(hdfsCarbonFile.listFiles().length, 1);
+    }
+
+    @Test
+    public void testListFilesForException() throws IOException {
+        new HDFSCarbonFile(fileStatusWithOutDirectoryPermission);
+
+        new MockUp<FileStatus>() {
+            @Mock
+            public Path getPath() {
+                return new Path(fileName);
+            }
+
+        };
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                throw new IOException();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus[] listStatus(Path var1) throws IOException {
+
+                throw new IOException();
+            }
+
+        };
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+        hdfsCarbonFile.listFiles();
+    }
+
+    @Test
+    public void testListFilesWithCarbonFilter() {
+        CarbonFileFilter carbonFileFilter = new CarbonFileFilter() {
+
+            @Override
+            public boolean accept(CarbonFile file) {
+                return true;
+            }
+        };
+        new MockUp<FileStatus>() {
+            @Mock
+            public boolean isDirectory() {
+                return true;
+            }
+
+        };
+
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+
+        new MockUp<FileStatus>() {
+            @Mock
+            public Path getPath() {
+                return new Path(fileName);
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus[] listStatus(Path var1) throws IOException {
+
+                FileStatus fileStatus[] = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))};
+                return fileStatus;
+            }
+
+        };
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+        assertEquals(hdfsCarbonFile.listFiles(carbonFileFilter).length, 1);
+    }
+
+    @Test
+    public void testlistFilesWithoutFilter() {
+        CarbonFileFilter carbonFileFilter = new CarbonFileFilter() {
+
+            @Override
+            public boolean accept(CarbonFile file) {
+                return false;
+            }
+        };
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus[] listStatus(Path var1) throws IOException {
+
+                FileStatus[] fileStatus = new FileStatus[]{new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName))};
+                return fileStatus;
+            }
+
+        };
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+        assertEquals(hdfsCarbonFile.listFiles(carbonFileFilter).length, 0);
+    }
+
+    @Test
+    public void testGetParentFileForNull() {
+
+        new MockUp<Path>() {
+            @Mock
+            public Path getParent() {
+                return null;
+            }
+
+        };
+        new MockUp<FileStatus>() {
+            @Mock
+            public Path getPath() {
+                return new Path(fileName);
+            }
+
+        };
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+
+        new MockUp<FileStatus>() {
+            @Mock
+            public Path getPath() {
+                return new Path(fileName);
+            }
+
+        };
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+        assertEquals(hdfsCarbonFile.getParentFile(), null);
+    }
+
+    @Test
+    public void testGetParentFile() {
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<Path>() {
+            @Mock
+            public Path getParent() {
+                return new Path(fileName);
+            }
+
+        };
+        new MockUp<FileStatus>() {
+            @Mock
+            public Path getPath() {
+                return new Path(fileName);
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public FileStatus getFileStatus(Path file) throws IOException {
+
+                return new FileStatus(12L, true, 60, 120l, 180L, new Path(fileName));
+            }
+
+        };
+
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+        assertTrue(hdfsCarbonFile.getParentFile() instanceof CarbonFile);
+    }
+
+    @Test
+    public void testForNonDisributedSystem() {
+        new HDFSCarbonFile(fileStatus);
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new WebHdfsFileSystem();
+            }
+
+        };
+        assertEquals(hdfsCarbonFile.renameForce(fileName), false);
+    }
+
+    @Test
+    public void testrenameForceForDisributedSystem() {
+        new MockUp<Path>() {
+            @Mock
+            public FileSystem getFileSystem(Configuration conf) throws IOException {
+                return new DistributedFileSystem();
+            }
+
+        };
+        new MockUp<DistributedFileSystem>() {
+            @Mock
+            public void rename(Path src, Path dst, final Options.Rename... options) throws IOException {
+
+            }
+
+        };
+        hdfsCarbonFile = new HDFSCarbonFile(fileStatus);
+        assertEquals(hdfsCarbonFile.renameForce(fileName), true);
+
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/952cf517/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/LocalCarbonFileTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/LocalCarbonFileTest.java b/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/LocalCarbonFileTest.java
new file mode 100644
index 0000000..9d1ab42
--- /dev/null
+++ b/core/src/test/java/org/apache/carbondata/core/datastorage/filesystem/LocalCarbonFileTest.java
@@ -0,0 +1,471 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.core.datastorage.filesystem;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+import org.apache.carbondata.core.datastorage.impl.FileFactory;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import sun.nio.ch.FileChannelImpl;
+
+import java.io.*;
+import java.nio.channels.ReadableByteChannel;
+import java.util.Objects;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+
+public class LocalCarbonFileTest {
+
+    private static LocalCarbonFile localCarbonFile;
+    private static File file;
+    private static File dir;
+    private static FileOutputStream oFile;
+
+    @BeforeClass
+    static public void setUp() {
+        file = new File("Test.carbondata");
+        dir = new File("Testdir.carbondata");
+        if (!file.exists())
+            try {
+                file.createNewFile();
+                dir.mkdir();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        try {
+            oFile = new FileOutputStream(file, true);
+
+
+            byte[] bytes = "core java api".getBytes();
+
+            oFile.write(bytes);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+            localCarbonFile = new LocalCarbonFile(file);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @AfterClass
+    static public void cleanUp() {
+        file.delete();
+        dir.delete();
+
+    }
+
+    @Test
+    public void testListFilesWithCarbonFileFilterAndWithOutOutDirectoryPermission() {
+        CarbonFileFilter carbonFileFilter = new CarbonFileFilter() {
+            @Override
+            public boolean accept(CarbonFile file) {
+                return false;
+            }
+        };
+        new MockUp<File>() {
+            @Mock
+            public boolean isDirectory() {
+                return false;
+            }
+
+
+        };
+        assertTrue(localCarbonFile.listFiles(carbonFileFilter) == null);
+    }
+
+    @Test
+    public void testListFilesWithOutDirPermission() {
+        localCarbonFile = new LocalCarbonFile(file);
+        new MockUp<File>() {
+            @Mock
+            public boolean isDirectory() {
+                return false;
+            }
+        };
+        assertTrue(localCarbonFile.listFiles() == null);
+    }
+
+    @Test
+    public void testCreateNewFileForException() throws IOException {
+        localCarbonFile = new LocalCarbonFile(new File(""));
+        assertTrue(!localCarbonFile.createNewFile());
+    }
+
+    @Test
+    public void testCheckIfFileExists() throws IOException {
+        localCarbonFile = new LocalCarbonFile(new File(""));
+        assertTrue(!localCarbonFile.exists());
+    }
+
+    @Test
+    public void testRenameForce() {
+        localCarbonFile = new LocalCarbonFile(file);
+        assertTrue(localCarbonFile.renameForce("Testdb.carbon"));
+        File file1 = new File("Testdb.carbon");
+        if (file1.exists()) {
+            file1.delete();
+        }
+    }
+
+    @Test
+    public void testRenameTo() {
+        localCarbonFile = new LocalCarbonFile(file);
+        assertTrue(!localCarbonFile.renameTo("Testdb.carbon"));
+    }
+
+    @Test
+    public void testsetLastModifiedTime() {
+        localCarbonFile = new LocalCarbonFile(file);
+        assertTrue(!localCarbonFile.setLastModifiedTime(50L));
+    }
+
+    @Test
+    public void testtruncate() {
+        localCarbonFile = new LocalCarbonFile(file);
+        final int[] counter = {0};
+        new MockUp<FileFactory>() {
+            @Mock
+            public FileFactory.FileType getFileType(String path) {
+                {
+                    return FileFactory.FileType.LOCAL;
+                }
+            }
+        };
+        new MockUp<FileFactory>() {
+            @Mock
+            public boolean isFileExist(String filePath, FileFactory.FileType fileType) throws IOException {
+                {
+                    return true;
+                }
+            }
+        };
+        new MockUp<CarbonFile>() {
+            @Mock
+            boolean delete() {
+                return true;
+            }
+        };
+        new MockUp<FileFactory>() {
+            @Mock
+            public boolean createNewFile(String filePath, FileFactory.FileType fileType) throws IOException {
+                {
+                    return true;
+                }
+            }
+        };
+        new MockUp<FileFactory>() {
+            @Mock
+            public CarbonFile getCarbonFile(String path, FileFactory.FileType fileType) {
+                {
+                    return new LocalCarbonFile(path);
+                }
+            }
+        };
+        new MockUp<CarbonFile>() {
+            @Mock
+            boolean delete() {
+                return true;
+            }
+        };
+
+        new MockUp<FileChannelImpl>() {
+            @Mock
+            public long transferFrom(ReadableByteChannel var1, long var2, long var4) throws IOException {
+                if (counter[0] == 0) {
+                    counter[0] = counter[0] + 1;
+                    return 0L;
+                } else {
+                    return 1L;
+                }
+            }
+        };
+        new MockUp<CarbonFile>() {
+            @Mock
+            boolean renameForce(String changetoName) {
+                return true;
+            }
+        };
+        localCarbonFile = new LocalCarbonFile(file);
+        assertTrue(localCarbonFile.truncate(file.getName(), 1L));
+    }
+
+    @Test
+    public void testtruncateForException() throws IOException {
+        localCarbonFile = new LocalCarbonFile(file);
+        new MockUp<FileFactory>() {
+            @Mock
+            public FileFactory.FileType getFileType(String path) {
+                {
+                    return FileFactory.FileType.LOCAL;
+                }
+            }
+        };
+        new MockUp<FileFactory>() {
+            @Mock
+            public boolean isFileExist(String filePath, FileFactory.FileType fileType) throws IOException {
+                {
+                    return true;
+                }
+            }
+        };
+        new MockUp<FileFactory>() {
+            @Mock
+            public CarbonFile getCarbonFile(String path, FileFactory.FileType fileType) {
+                {
+                    return new LocalCarbonFile(path);
+                }
+            }
+        };
+        new MockUp<CarbonFile>() {
+            @Mock
+            boolean delete() {
+                return true;
+            }
+        };
+        new MockUp<FileFactory>() {
+            @Mock
+            public boolean createNewFile(String filePath, FileFactory.FileType fileType) throws IOException {
+                {
+                    throw new IOException();
+                }
+            }
+        };
+
+
+        localCarbonFile.truncate(file.getName(), 2L);
+    }
+
+    @Test
+    public void testListFilesWithDirPermission() {
+        localCarbonFile = new LocalCarbonFile(file);
+        new MockUp<File>() {
+            @Mock
+            public boolean isDirectory() {
+                return true;
+            }
+        };
+        new MockUp<File>() {
+            @Mock
+            public File[] listFiles() {
+                return null;
+            }
+
+
+        };
+        localCarbonFile = new LocalCarbonFile(dir);
+        assertTrue(localCarbonFile.listFiles().length == 0);
+    }
+
+    @Test
+    public void testListFilesWithCarbonFileFilterAndDirectoryPermission() {
+        CarbonFileFilter carbonFileFilter = new CarbonFileFilter() {
+            @Override
+            public boolean accept(CarbonFile file) {
+                return true;
+            }
+        };
+        new MockUp<File>() {
+            @Mock
+            public boolean isDirectory() {
+                return true;
+            }
+        };
+        new MockUp<File>() {
+            @Mock
+            public File[] listFiles(FileFilter filter) {
+
+                File[] file = new File[]{dir};
+                return file;
+            }
+
+
+        };
+
+        localCarbonFile = new LocalCarbonFile(dir);
+
+        assertTrue(localCarbonFile.listFiles(carbonFileFilter).length == 1);
+    }
+
+    @Test
+    public void testListFilesForNullWithCarbonFileFilterAndDirectoryPermission() {
+        CarbonFileFilter carbonFileFilter = new CarbonFileFilter() {
+            @Override
+            public boolean accept(CarbonFile file) {
+                return true;
+            }
+        };
+        new MockUp<File>() {
+            @Mock
+            public File[] listFiles(FileFilter filter) {
+                return null;
+            }
+
+
+        };
+        new MockUp<File>() {
+            @Mock
+            public boolean isDirectory() {
+                return false;
+            }
+
+            @Mock
+            public File[] listFiles(FileFilter filter) {
+                return null;
+            }
+
+
+        };
+        localCarbonFile = new LocalCarbonFile(dir);
+
+        assertTrue(localCarbonFile.listFiles(carbonFileFilter) == null);
+    }
+
+    @Test
+    public void testListFilesForEmptyFileArrayWithCarbonFileFilter() {
+        CarbonFileFilter carbonFileFilter = new CarbonFileFilter() {
+            @Override
+            public boolean accept(CarbonFile file) {
+                return true;
+            }
+        };
+        new MockUp<CarbonFileFilter>() {
+            @Mock
+            boolean accept(CarbonFile file) {
+                return true;
+            }
+        };
+        new MockUp<File>() {
+            @Mock
+            public File[] listFiles(FileFilter filter) {
+                return null;
+            }
+        };
+        new MockUp<File>() {
+            @Mock
+            public boolean isDirectory() {
+                return true;
+            }
+
+            @Mock
+            public File[] listFiles(FileFilter filter) {
+                return null;
+            }
+        };
+        localCarbonFile = new LocalCarbonFile(dir);
+
+        assertTrue(localCarbonFile.listFiles(carbonFileFilter).length == 0);
+    }
+
+    @Test
+    public void testFilesForConnicalPath() {
+
+        new MockUp<File>() {
+            @Mock
+            public String getCanonicalPath() throws IOException {
+                return "testFile";
+            }
+
+
+        };
+        localCarbonFile = new LocalCarbonFile(dir);
+
+        assertTrue(Objects.equals(localCarbonFile.getCanonicalPath(), "testFile"));
+    }
+
+    @Test
+    public void testFilesForConnicalPathException() throws IOException {
+
+        new MockUp<File>() {
+            @Mock
+            public String getCanonicalPath() throws IOException {
+                throw new IOException();
+            }
+
+
+        };
+        localCarbonFile = new LocalCarbonFile(dir);
+
+        localCarbonFile.getCanonicalPath();
+    }
+
+    @Test
+    public void testFilesForAbsolutePath() {
+
+        new MockUp<File>() {
+            @Mock
+            public String getAbsolutePath() {
+                return "testFile";
+            }
+
+
+        };
+        localCarbonFile = new LocalCarbonFile(dir);
+
+        assertEquals(localCarbonFile.getAbsolutePath(), "testFile");
+    }
+
+    @Test
+    public void testFilesForGetPath() {
+
+        new MockUp<File>() {
+            @Mock
+            public String getPath() {
+                return "testFile";
+            }
+
+
+        };
+        localCarbonFile = new LocalCarbonFile(dir);
+
+        assertEquals(localCarbonFile.getPath(), "testFile");
+    }
+
+    @Test
+    public void testFilesForFileExists() {
+
+        localCarbonFile = new LocalCarbonFile(new File(""));
+        assertEquals(localCarbonFile.exists(), false);
+    }
+
+    @Test
+    public void testRenameForceForFileNotExists() {
+        new MockUp<File>() {
+            @Mock
+            public boolean exists() {
+                return false;
+            }
+
+            @Mock
+            public boolean renameTo(File dest) {
+                return true;
+            }
+        };
+
+        localCarbonFile = new LocalCarbonFile("demo.txt");
+
+        assertEquals(localCarbonFile.renameForce("Test.carbondata"), true);
+    }
+}



Mime
View raw message