http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentPropertiesTestUtil.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentPropertiesTestUtil.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentPropertiesTestUtil.java
new file mode 100644
index 0000000..72b9c01
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentPropertiesTestUtil.java
@@ -0,0 +1,232 @@
+/*
+ * 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.datastore.block;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.carbondata.core.metadata.datatype.DataType;
+import org.apache.carbondata.core.metadata.encoder.Encoding;
+import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema;
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+
+public class SegmentPropertiesTestUtil {
+
+  public static SegmentProperties getSegmentProperties() {
+    List<ColumnSchema> columnSchema = new ArrayList<ColumnSchema>();
+    columnSchema.add(getDimensionColumn1());
+    columnSchema.add(getDimensionColumn2());
+    columnSchema.add(getDimensionColumn3());
+    columnSchema.add(getDimensionColumn4());
+    columnSchema.add(getDimensionColumn5());
+    columnSchema.add(getDimensionColumn9());
+    columnSchema.add(getDimensionColumn10());
+    columnSchema.add(getDimensionColumn11());
+    columnSchema.add(getDimensionColumn6());
+    columnSchema.add(getDimensionColumn7());
+    columnSchema.add(getMeasureColumn());
+    columnSchema.add(getMeasureColumn1());
+    int[] cardinality = new int[columnSchema.size()];
+    int x = 100;
+    for (int i = 0; i < columnSchema.size(); i++) {
+      cardinality[i] = x;
+      x++;
+    }
+    SegmentProperties segmentProperties = new SegmentProperties(columnSchema, 
cardinality);
+    return segmentProperties;
+  }
+
+  public static ColumnSchema getDimensionColumn1() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(true);
+    dimColumn.setColumnName("IMEI");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DICTIONARY);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setNumberOfChild(0);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getDimensionColumn2() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(true);
+    dimColumn.setColumnName("IMEI1");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setNumberOfChild(0);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getDimensionColumn3() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(false);
+    dimColumn.setColumnName("IMEI2");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DICTIONARY);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setColumnGroup(0);
+    dimColumn.setNumberOfChild(0);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getDimensionColumn4() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(false);
+    dimColumn.setColumnName("IMEI3");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DICTIONARY);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setNumberOfChild(0);
+    dimColumn.setColumnGroup(0);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getDimensionColumn5() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(true);
+    dimColumn.setColumnName("IMEI4");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setNumberOfChild(0);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getDimensionColumn9() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(false);
+    dimColumn.setColumnName("IMEI9");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DICTIONARY);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setColumnGroup(1);
+    dimColumn.setNumberOfChild(0);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getDimensionColumn10() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(false);
+    dimColumn.setColumnName("IMEI10");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DICTIONARY);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setNumberOfChild(0);
+    dimColumn.setColumnGroup(1);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getDimensionColumn11() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(false);
+    dimColumn.setColumnName("IMEI11");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DICTIONARY);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setNumberOfChild(0);
+    dimColumn.setColumnGroup(1);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getDimensionColumn6() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(true);
+    dimColumn.setColumnName("IMEI5");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.ARRAY);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DICTIONARY);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setNumberOfChild(1);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getDimensionColumn7() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnar(true);
+    dimColumn.setColumnName("IMEI6");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    dimColumn.setDimensionColumn(true);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DICTIONARY);
+    dimColumn.setEncodingList(encodeList);
+    dimColumn.setNumberOfChild(0);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getMeasureColumn() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnName("IMEI_COUNT");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DELTA);
+    dimColumn.setEncodingList(encodeList);
+    return dimColumn;
+  }
+
+  public static ColumnSchema getMeasureColumn1() {
+    ColumnSchema dimColumn = new ColumnSchema();
+    dimColumn.setColumnName("IMEI_COUNT1");
+    dimColumn.setColumnUniqueId(UUID.randomUUID().toString());
+    dimColumn.setDataType(DataType.STRING);
+    List<Encoding> encodeList =
+        new ArrayList<Encoding>(CarbonCommonConstants.DEFAULT_COLLECTION_SIZE);
+    encodeList.add(Encoding.DELTA);
+    dimColumn.setEncodingList(encodeList);
+    return dimColumn;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentTaskIndexTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentTaskIndexTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentTaskIndexTest.java
new file mode 100644
index 0000000..aeced20
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/block/SegmentTaskIndexTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.datastore.block;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.carbondata.core.datastore.BTreeBuilderInfo;
+import org.apache.carbondata.core.datastore.impl.btree.BlockBTreeBuilder;
+import org.apache.carbondata.core.metadata.blocklet.BlockletInfo;
+import org.apache.carbondata.core.metadata.blocklet.DataFileFooter;
+import org.apache.carbondata.core.metadata.blocklet.SegmentInfo;
+import org.apache.carbondata.core.metadata.blocklet.index.BlockletIndex;
+import org.apache.carbondata.core.metadata.schema.table.column.ColumnSchema;
+
+import mockit.Mock;
+import mockit.MockUp;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class SegmentTaskIndexTest {
+
+  private static SegmentInfo segmentInfo;
+  private static DataFileFooter footer;
+  private static ColumnSchema columnSchema;
+  private static BlockletInfo blockletInfo;
+  private static BlockletIndex blockletIndex;
+  private static List<DataFileFooter> footerList = new 
ArrayList<DataFileFooter>();
+  private static List<ColumnSchema> columnSchemaList = new 
ArrayList<ColumnSchema>();
+
+  @BeforeClass public static void setUp() {
+    segmentInfo = new SegmentInfo();
+    footer = new DataFileFooter();
+    columnSchema = new ColumnSchema();
+    blockletInfo = new BlockletInfo();
+    blockletIndex = new BlockletIndex();
+  }
+
+  @Test public void testBuild() {
+    new MockUp<BlockBTreeBuilder>() {
+      @Mock public void build(BTreeBuilderInfo segmentBuilderInfos) {}
+    };
+    long numberOfRows = 100;
+    SegmentTaskIndex segmentTaskIndex = new SegmentTaskIndex();
+    columnSchema.setColumnName("employeeName");
+    columnSchemaList.add(new ColumnSchema());
+
+    footer.setSegmentInfo(segmentInfo);
+    footer.setColumnInTable(columnSchemaList);
+    footer.setBlockletList(Arrays.asList(blockletInfo));
+    footer.setNumberOfRows(numberOfRows);
+    footerList.add(footer);
+
+    segmentTaskIndex.buildIndex(footerList);
+    assertEquals(footerList.get(0).getNumberOfRows(), numberOfRows);
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/block/TableBlockInfoTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/block/TableBlockInfoTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/block/TableBlockInfoTest.java
new file mode 100644
index 0000000..7ad1770
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/block/TableBlockInfoTest.java
@@ -0,0 +1,176 @@
+/*
+ * 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.datastore.block;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+import org.apache.carbondata.core.metadata.ColumnarFormatVersion;
+import org.apache.carbondata.core.util.path.CarbonTablePath;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class TableBlockInfoTest {
+
+  static TableBlockInfo tableBlockInfo;
+  static TableBlockInfo tableBlockInfos;
+
+  @BeforeClass public static void setup() {
+    tableBlockInfo = new TableBlockInfo("filePath", 4, "segmentId", null, 6, 
ColumnarFormatVersion.V1);
+    tableBlockInfos = new TableBlockInfo("filepath", 6, "5", null, 6, new 
BlockletInfos(6, 2, 2), ColumnarFormatVersion.V1);
+  }
+
+  @Test public void equalTestWithSameObject() {
+    Boolean res = tableBlockInfo.equals(tableBlockInfo);
+    assert (res);
+  }
+
+  @Test public void equalTestWithSimilarObject() {
+    TableBlockInfo tableBlockInfoTest = new TableBlockInfo("filePath", 4, 
"segmentId", null, 6, ColumnarFormatVersion.V1);
+    Boolean res = tableBlockInfo.equals(tableBlockInfoTest);
+    assert (res);
+  }
+
+  @Test public void equalTestWithNullObject() {
+    Boolean res = tableBlockInfo.equals(null);
+    assert (!res);
+  }
+
+  @Test public void equalTestWithStringObject() {
+    Boolean res = tableBlockInfo.equals("dummyObject");
+    assert (!res);
+  }
+
+  @Test public void equlsTestWithDiffSegmentId() {
+    TableBlockInfo tableBlockInfoTest = new TableBlockInfo("filePath", 4, 
"diffsegmentId", null, 6, ColumnarFormatVersion.V1);
+    Boolean res = tableBlockInfo.equals(tableBlockInfoTest);
+    assert (!res);
+  }
+
+  @Test public void equlsTestWithDiffBlockOffset() {
+    TableBlockInfo tableBlockInfoTest = new TableBlockInfo("filePath", 6, 
"segmentId", null, 6, ColumnarFormatVersion.V1);
+    Boolean res = tableBlockInfo.equals(tableBlockInfoTest);
+    assert (!res);
+  }
+
+  @Test public void equalsTestWithDiffBlockLength() {
+    TableBlockInfo tableBlockInfoTest = new TableBlockInfo("filePath", 4, 
"segmentId", null, 4, ColumnarFormatVersion.V1);
+    Boolean res = tableBlockInfo.equals(tableBlockInfoTest);
+    assert (!res);
+  }
+
+  @Test public void equalsTestWithDiffBlockletNumber() {
+    TableBlockInfo tableBlockInfoTest =
+        new TableBlockInfo("filepath", 6, "segmentId", null, 6, new 
BlockletInfos(6, 3, 2), ColumnarFormatVersion.V1);
+    Boolean res = tableBlockInfos.equals(tableBlockInfoTest);
+    assert (!res);
+  }
+
+  @Test public void equalsTestWithDiffFilePath() {
+    TableBlockInfo tableBlockInfoTest =
+        new TableBlockInfo("difffilepath", 6, "segmentId", null, 6, new 
BlockletInfos(6, 3, 2), ColumnarFormatVersion.V1);
+    Boolean res = tableBlockInfos.equals(tableBlockInfoTest);
+    assert (!res);
+  }
+
+  @Test public void compareToTestForSegmentId() {
+    TableBlockInfo tableBlockInfo =
+        new TableBlockInfo("difffilepath", 6, "5", null, 6, new 
BlockletInfos(6, 3, 2), ColumnarFormatVersion.V1);
+    int res = tableBlockInfos.compareTo(tableBlockInfo);
+    int expectedResult = 2;
+    assertEquals(res, expectedResult);
+
+    TableBlockInfo tableBlockInfo1 =
+        new TableBlockInfo("difffilepath", 6, "6", null, 6, new 
BlockletInfos(6, 3, 2), ColumnarFormatVersion.V1);
+    int res1 = tableBlockInfos.compareTo(tableBlockInfo1);
+    int expectedResult1 = -1;
+    assertEquals(res1, expectedResult1);
+
+    TableBlockInfo tableBlockInfo2 =
+        new TableBlockInfo("difffilepath", 6, "4", null, 6, new 
BlockletInfos(6, 3, 2), ColumnarFormatVersion.V1);
+    int res2 = tableBlockInfos.compareTo(tableBlockInfo2);
+    int expectedresult2 = 1;
+    assertEquals(res2, expectedresult2);
+  }
+
+  @Test public void compareToTestForOffsetAndLength() {
+    new MockUp<CarbonTablePath>() {
+      @Mock boolean isCarbonDataFile(String fileNameWithPath) {
+        return true;
+      }
+
+    };
+
+    new MockUp<CarbonTablePath.DataFileUtil>() {
+      @Mock String getTaskNo(String carbonDataFileName) {
+        return carbonDataFileName.length() + "";
+      }
+
+      @Mock String getPartNo(String carbonDataFileName) {
+        return "5";
+      }
+
+    };
+
+    TableBlockInfo tableBlockInfo = new TableBlockInfo("difffilepaths", 6, 
"5", null, 3, ColumnarFormatVersion.V1);
+    int res = tableBlockInfos.compareTo(tableBlockInfo);
+    int expectedResult = -5;
+    assertEquals(res, expectedResult);
+
+    TableBlockInfo tableBlockInfo1 = new TableBlockInfo("filepath", 6, "5", 
null, 3, ColumnarFormatVersion.V1);
+    int res1 = tableBlockInfos.compareTo(tableBlockInfo1);
+    int expectedResult1 = 1;
+    assertEquals(res1, expectedResult1);
+
+    TableBlockInfo tableBlockInfoTest =
+        new TableBlockInfo("filePath", 6, "5", null, 7, new BlockletInfos(6, 
2, 2), ColumnarFormatVersion.V1);
+    int res2 = tableBlockInfos.compareTo(tableBlockInfoTest);
+    int expectedResult2 = -1;
+    assertEquals(res2, expectedResult2);
+  }
+
+  @Test public void compareToTestWithStartBlockletNo() {
+    TableBlockInfo tableBlockInfo =
+        new TableBlockInfo("filepath", 6, "5", null, 6, new BlockletInfos(6, 
3, 2), ColumnarFormatVersion.V1);
+    int res = tableBlockInfos.compareTo(tableBlockInfo);
+    int expectedresult =-1;
+    assertEquals(res, expectedresult);
+
+    TableBlockInfo tableBlockInfo1 =
+        new TableBlockInfo("filepath", 6, "5", null, 6, new BlockletInfos(6, 
1, 2), ColumnarFormatVersion.V1);
+    int res1 = tableBlockInfos.compareTo(tableBlockInfo1);
+    int expectedresult1 = 1;
+    assertEquals(res1, expectedresult1);
+  }
+
+  @Test public void compareToTest() {
+    int res = tableBlockInfos.compareTo(tableBlockInfos);
+    int expectedResult = 0;
+    assertEquals(res, expectedResult);
+  }
+
+  @Test public void hashCodeTest() {
+    int res = tableBlockInfo.hashCode();
+    int expectedResult = 1041505621;
+    assertEquals(res, expectedResult);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/block/TableTaskInfoTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/block/TableTaskInfoTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/block/TableTaskInfoTest.java
new file mode 100644
index 0000000..c2229cf
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/block/TableTaskInfoTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.datastore.block;
+
+import org.apache.carbondata.core.metadata.ColumnarFormatVersion;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class TableTaskInfoTest {
+
+  static TableTaskInfo tableTaskInfo;
+  static List<TableBlockInfo> tableBlockInfoList;
+
+  @BeforeClass public static void setup() {
+    tableBlockInfoList = new ArrayList<>(5);
+
+    String[] locations = { "loc1", "loc2", "loc3" };
+    tableBlockInfoList.add(0, new TableBlockInfo("filePath", 2, "segmentID", 
locations, 6, ColumnarFormatVersion.V1));
+
+    String[] locs = { "loc4", "loc5" };
+    tableBlockInfoList.add(1, new TableBlockInfo("filepath", 2, "segmentId", 
locs, 6, ColumnarFormatVersion.V1));
+
+    tableTaskInfo = new TableTaskInfo("taskId", tableBlockInfoList);
+  }
+
+  @Test public void getLocationsTest() {
+    String locations[] = { "loc1", "loc2", "loc3", "loc4", "loc5" };
+    String res[] = tableTaskInfo.getLocations();
+    assert (Arrays.equals(locations, res));
+  }
+
+  @Test public void maxNoNodesTest() {
+    List<String> locs = new ArrayList<String>();
+    locs.add("loc1");
+    locs.add("loc2");
+    locs.add("loc3");
+    locs.add("loc4");
+    locs.add("loc5");
+
+    List<String> res = TableTaskInfo.maxNoNodes(tableBlockInfoList);
+    assert (res.equals(locs));
+  }
+
+  @Test public void maxNoNodesTestForElse() {
+    List<String> locs = new ArrayList<String>();
+    locs.add("loc1");
+    locs.add("loc2");
+    locs.add("loc3");
+    List<TableBlockInfo> tableBlockInfoListTest = new ArrayList<>();
+
+    String[] locations = { "loc1", "loc2", "loc3" };
+    tableBlockInfoListTest.add(0, new TableBlockInfo("filePath", 2, 
"segmentID", locations, 6, ColumnarFormatVersion.V1));
+
+    String[] locations1 = { "loc1", "loc2", "loc3" };
+    tableBlockInfoListTest.add(1, new TableBlockInfo("filePath", 2, 
"segmentID", locations1, 6, ColumnarFormatVersion.V1));
+
+    List<String> res = TableTaskInfo.maxNoNodes(tableBlockInfoListTest);
+    assert (res.equals(locs));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
new file mode 100644
index 0000000..7d7c7d0
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/chunk/impl/ColumnGroupDimensionDataChunkTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.datastore.chunk.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.carbondata.core.keygenerator.KeyGenException;
+import org.apache.carbondata.core.keygenerator.KeyGenerator;
+import 
org.apache.carbondata.core.keygenerator.mdkey.MultiDimKeyVarLengthGenerator;
+import org.apache.carbondata.core.util.CarbonUtil;
+import org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo;
+import org.apache.carbondata.core.scan.executor.util.QueryUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class ColumnGroupDimensionDataChunkTest {
+
+  static ColumnGroupDimensionDataChunk columnGroupDimensionDataChunk;
+  static KeyGenerator keyGenerator;
+
+  @BeforeClass public static void setup() {
+    int[] bitLength = CarbonUtil.getDimensionBitLength(new int[] { 10, 10, 10 
}, new int[] { 3 });
+    // create a key generator
+    keyGenerator = new MultiDimKeyVarLengthGenerator(bitLength);
+    byte[] data = new byte[keyGenerator.getKeySizeInBytes() * 3];
+    int position = 0;
+    for (int i = 1; i <= 3; i++) {
+      try {
+        System.arraycopy(keyGenerator.generateKey(new int[] { i, i, i }), 0, 
data, position,
+            keyGenerator.getKeySizeInBytes());
+      } catch (KeyGenException e) {
+        assertTrue(false);
+      }
+      position += keyGenerator.getKeySizeInBytes();
+    }
+    columnGroupDimensionDataChunk =
+        new ColumnGroupDimensionDataChunk(data, 
keyGenerator.getKeySizeInBytes(), 3);
+  }
+
+  @Test public void fillChunkDataTest() {
+    List<Integer> ordinals = new ArrayList<Integer>();
+    ordinals.add(1);
+    KeyStructureInfo keyStructureInfo = getKeyStructureInfo(ordinals, 
keyGenerator);
+    byte[] buffer = new byte[1];
+    columnGroupDimensionDataChunk.fillChunkData(buffer, 0, 1, 
keyStructureInfo);
+    assertEquals(buffer[0], 2);
+  }
+
+  @Test public void getChunkDataTest() {
+    byte[] b = { 34, 2 };
+    byte res[] = columnGroupDimensionDataChunk.getChunkData(1);
+    assert (Arrays.equals(res, b));
+  }
+
+  @Test public void fillConvertedChunkDataTest() {
+    int[] row = new int[3];
+    int[] expected = { 0, 0, 3 };
+    List<Integer> ordinals = new ArrayList<Integer>();
+    ordinals.add(2);
+    KeyStructureInfo keyStructureInfo = getKeyStructureInfo(ordinals, 
keyGenerator);
+    keyStructureInfo.setMdkeyQueryDimensionOrdinal(new int[] { 2 });
+    int res = columnGroupDimensionDataChunk.fillConvertedChunkData(2, 2, row, 
keyStructureInfo);
+    assert (Arrays.equals(row, expected));
+  }
+
+  /**
+   * Below method will be used to get the key structure info for the query
+   *
+   * @param queryModel   query model
+   * @param keyGenerator
+   * @return key structure info
+   */
+  private KeyStructureInfo getKeyStructureInfo(List<Integer> ordinals, 
KeyGenerator keyGenerator) {
+    // getting the masked byte range for dictionary column
+    int[] maskByteRanges = QueryUtil.getMaskedByteRangeBasedOrdinal(ordinals, 
keyGenerator);
+
+    // getting the masked bytes for query dimension dictionary column
+    int[] maskedBytes = 
QueryUtil.getMaskedByte(keyGenerator.getKeySizeInBytes(), maskByteRanges);
+
+    // max key for the dictionary dimension present in the query
+    byte[] maxKey = null;
+    try {
+      // getting the max key which will be used to masked and get the
+      // masked key
+      maxKey = QueryUtil.getMaxKeyBasedOnOrinal(ordinals, keyGenerator);
+    } catch (KeyGenException e) {
+    }
+
+    KeyStructureInfo restructureInfos = new KeyStructureInfo();
+    restructureInfos.setKeyGenerator(keyGenerator);
+    restructureInfos.setMaskByteRanges(maskByteRanges);
+    restructureInfos.setMaxKey(maxKey);
+    return restructureInfos;
+  }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
new file mode 100644
index 0000000..bd5ba96
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/chunk/impl/FixedLengthDimensionDataChunkTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.datastore.chunk.impl;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+
+import org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+public class FixedLengthDimensionDataChunkTest {
+
+  static FixedLengthDimensionDataChunk fixedLengthDimensionDataChunk;
+  static byte[] data;
+
+  @BeforeClass public static void setup() {
+    data = "dummy string".getBytes();
+
+    int invertedIndex[] = { 1, 3, 5, 7, 8 };
+
+    int invertedIndexReverse[] = { 1, 0, 5, 7, 8 };
+    fixedLengthDimensionDataChunk =
+        new FixedLengthDimensionDataChunk(data, invertedIndex, 
invertedIndexReverse, 5, 4);
+  }
+
+  @Test public void fillChunkDataTest() {
+    KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
+    int[] maskByteRanges = { 1, 2, 4, 6, 5 };
+    keyStructureInfo.setMaskByteRanges(maskByteRanges);
+    keyStructureInfo.setMaxKey("1234567".getBytes());
+    int res = fixedLengthDimensionDataChunk.fillChunkData(data, 0, 0, 
keyStructureInfo);
+    int expectedResult = 4 ;
+    assertEquals(res, expectedResult);
+  }
+
+  @Test public void getChunkDataTest() {
+    byte expected[] = { 121, 32, 115, 116 };
+    byte res[] = fixedLengthDimensionDataChunk.getChunkData(0);
+    assert (Arrays.equals(res, expected));
+  }
+
+  @Test public void fillConvertedChunkDataTest() {
+    int[] row = { 1, 2, 4, 6 };
+    KeyStructureInfo keyStructureInfo = new KeyStructureInfo();
+    int res = fixedLengthDimensionDataChunk.fillConvertedChunkData(1, 0, row, 
keyStructureInfo);
+    int expectedResult = 1;
+    assertEquals(res, expectedResult);
+  }
+}
+
+

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
new file mode 100644
index 0000000..0362ad6
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/chunk/reader/dimension/CompressedDimensionChunkFileBasedReaderTest.java
@@ -0,0 +1,134 @@
+/*
+ * 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.datastore.chunk.reader.dimension;
+
+
+public class CompressedDimensionChunkFileBasedReaderTest {
+
+//  static CompressedDimensionChunkFileBasedReaderV1 
compressedDimensionChunkFileBasedReader;
+//  static List<DataChunk> dataChunkList;
+//
+//  @BeforeClass public static void setup() {
+//    int eachColumnBlockSize[] = { 1, 2, 4, 5 };
+//    dataChunkList = new ArrayList<>();
+//
+//    DataChunk dataChunk = new DataChunk();
+//    dataChunkList.add(dataChunk);
+//    BlockletInfo info = new BlockletInfo();
+//    info.setDimensionColumnChunk(dataChunkList);
+//    compressedDimensionChunkFileBasedReader =
+//        new CompressedDimensionChunkFileBasedReaderV1(info, 
eachColumnBlockSize, "filePath");
+//  }
+//
+//  @Test public void readDimensionChunksTest() {
+//    FileHolder fileHolder = new MockUp<FileHolder>() {
+//      @Mock public byte[] readByteArray(String filePath, long offset, int 
length) {
+//        byte mockedValue[] = { 1, 5, 4, 8, 7 };
+//        return mockedValue;
+//      }
+//    }.getMockInstance();
+//
+//    new MockUp<CarbonUtil>() {
+//      @Mock public boolean hasEncoding(List<Encoding> encodings, Encoding 
encoding) {
+//        return true;
+//      }
+//
+//      @Mock public int[] getUnCompressColumnIndex(int totalLength, byte[] 
columnIndexData,
+//          NumberCompressor numberCompressor,int offset) {
+//        int mockedValue[] = { 1, 1 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<SnappyCompressor>() {
+//      @Mock public byte[] unCompressByte(byte[] compInput) {
+//        byte mockedValue[] = { 1 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<UnBlockIndexer>() {
+//      @Mock public byte[] uncompressData(byte[] data, int[] index, int 
keyLen) {
+//        byte mockedValue[] = { 1, 5, 4, 8, 7 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    int[][] blockIndexes = {{0,0}};
+//    DimensionColumnDataChunk dimensionColumnDataChunk[] =
+//        
compressedDimensionChunkFileBasedReader.readDimensionChunks(fileHolder, 
blockIndexes);
+//    byte expectedResult[] = { 1 };
+//    assertEquals(dimensionColumnDataChunk[0].getColumnValueSize(), 1);
+//    for (int i = 0; i < dimensionColumnDataChunk[0].getChunkData(0).length; 
i++) {
+//      assertEquals(dimensionColumnDataChunk[0].getChunkData(0)[i], 
expectedResult[i]);
+//    }
+//  }
+//
+//  @Test public void readDimensionChunksTestForIfStatement() {
+//    FileHolder fileHolder = new MockUp<FileHolder>() {
+//      @Mock public byte[] readByteArray(String filePath, long offset, int 
length) {
+//        byte mockedValue[] = { 1, 5, 4, 8, 7 };
+//        return mockedValue;
+//      }
+//    }.getMockInstance();
+//
+//    new MockUp<CarbonUtil>() {
+//      @Mock public boolean hasEncoding(List<Encoding> encodings, Encoding 
encoding) {
+//        return true;
+//      }
+//
+//      @Mock public int[] getUnCompressColumnIndex(int totalLength, byte[] 
columnIndexData,
+//          NumberCompressor numberCompressor, int offset) {
+//        int mockedValue[] = { 1, 1 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<SnappyCompressor>() {
+//      @Mock public byte[] unCompressByte(byte[] compInput) {
+//        byte mockedValue[] = { 1 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<UnBlockIndexer>() {
+//      @Mock public byte[] uncompressData(byte[] data, int[] index, int 
keyLen) {
+//        byte mockedValue[] = { 1, 5, 4, 8, 7 };
+//        return mockedValue;
+//      }
+//    };
+//
+//    new MockUp<DataChunk>() {
+//      @Mock public boolean isRowMajor() {
+//        return true;
+//      }
+//    };
+//    int[][] blockIndexes = {{0,0}};
+//    DimensionColumnDataChunk dimensionColumnDataChunk[] =
+//        
compressedDimensionChunkFileBasedReader.readDimensionChunks(fileHolder, 
blockIndexes);
+//
+//    byte expectedResult[] = { 1 };
+//    assertEquals(dimensionColumnDataChunk[0].getColumnValueSize(), 1);
+//
+//    for (int i = 0; i < dimensionColumnDataChunk[0].getChunkData(0).length; 
i++) {
+//      assertEquals(dimensionColumnDataChunk[0].getChunkData(0)[i], 
expectedResult[i]);
+//    }
+//  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
new file mode 100644
index 0000000..7d7bab3
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/chunk/reader/measure/CompressedMeasureChunkFileBasedReaderTest.java
@@ -0,0 +1,109 @@
+package org.apache.carbondata.core.datastore.chunk.reader.measure;
+
+import static junit.framework.TestCase.assertEquals;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+import org.apache.carbondata.core.datastore.chunk.MeasureColumnDataChunk;
+import 
org.apache.carbondata.core.datastore.chunk.reader.measure.v1.CompressedMeasureChunkFileBasedReaderV1;
+
+import org.apache.carbondata.core.datastore.impl.data.compressed
+    .HeavyCompressedDoubleArrayDataInMemoryStore;
+import org.apache.carbondata.core.metadata.blocklet.BlockletInfo;
+import org.apache.carbondata.core.metadata.blocklet.datachunk.DataChunk;
+import org.apache.carbondata.core.datastore.FileHolder;
+import org.apache.carbondata.core.datastore.compression.MeasureMetaDataModel;
+import org.apache.carbondata.core.datastore.compression.WriterCompressModel;
+import org.apache.carbondata.core.datastore.dataholder.CarbonWriteDataHolder;
+import org.apache.carbondata.core.metadata.ValueEncoderMeta;
+import org.apache.carbondata.core.util.ValueCompressionUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CompressedMeasureChunkFileBasedReaderTest {
+
+  static CompressedMeasureChunkFileBasedReaderV1 
compressedMeasureChunkFileBasedReader;
+  static CarbonWriteDataHolder[] dataHolder = new CarbonWriteDataHolder[1];
+
+  static WriterCompressModel writerCompressModel;
+  @BeforeClass public static void setup() {
+    List<DataChunk> dataChunkList = new ArrayList<>();
+    DataChunk dataChunk = new DataChunk();
+    dataChunkList.add(dataChunk);
+    dataChunk.setDataPageLength(10);
+    writerCompressModel = new WriterCompressModel();
+    Object maxValue[] = new Object[]{new Long[]{8L, 0L}};
+    Object minValue[] = new Object[]{new Long[]{1L,0L}};
+    byte[] dataTypeSelected = new byte[1];
+    char[] aggType = new char[]{'b'};
+    MeasureMetaDataModel measureMDMdl =
+                new MeasureMetaDataModel(minValue, maxValue, new int[]{1}, 
maxValue.length, null,
+                    aggType, dataTypeSelected);
+    writerCompressModel = 
ValueCompressionUtil.getWriterCompressModel(measureMDMdl);
+    
+
+    ValueEncoderMeta meta = new ValueEncoderMeta();
+    meta.setMaxValue(new Long[]{8L,0L});
+    meta.setMinValue(new Long[]{1L,0L});
+    meta.setMantissa(1);
+    meta.setType('b');
+    List<ValueEncoderMeta> valueEncoderMetaList = new ArrayList<>();
+    valueEncoderMetaList.add(meta);
+    dataChunkList.get(0).setValueEncoderMeta(valueEncoderMetaList);
+    BlockletInfo info = new BlockletInfo();
+    info.setMeasureColumnChunk(dataChunkList);
+    compressedMeasureChunkFileBasedReader =
+        new CompressedMeasureChunkFileBasedReaderV1(info, "filePath");
+  }
+
+  @Test public void readMeasureChunkTest() throws IOException {
+    FileHolder fileHolder = new MockUp<FileHolder>() {
+      @Mock public byte[] readByteArray(String filePath, long offset, int 
length) {
+        dataHolder[0] = new CarbonWriteDataHolder();
+        dataHolder[0].initialiseBigDecimalValues(1);
+        dataHolder[0].setWritableBigDecimalValueByIndex(0, new long[]{2L,1L});
+        byte[][] writableMeasureDataArray =
+            new 
HeavyCompressedDoubleArrayDataInMemoryStore(writerCompressModel)
+                .getWritableMeasureDataArray(dataHolder).clone();
+        return writableMeasureDataArray[0];
+      }
+    }.getMockInstance();
+
+    MeasureColumnDataChunk measureColumnDataChunks =
+        compressedMeasureChunkFileBasedReader.readMeasureChunk(fileHolder, 0);
+
+    BigDecimal bigD = new BigDecimal("2.1");
+    assertEquals(bigD,
+        
measureColumnDataChunks.getMeasureDataHolder().getReadableBigDecimalValueByIndex(0));
+      
+  }
+
+  @Test public void readMeasureChunksTest() throws IOException {
+    FileHolder fileHolder = new MockUp<FileHolder>() {
+      @Mock public byte[] readByteArray(String filePath, long offset, int 
length) {
+        dataHolder[0] = new CarbonWriteDataHolder();
+        dataHolder[0].initialiseBigDecimalValues(1);
+        dataHolder[0].setWritableBigDecimalValueByIndex(0, new long[]{2L,1L});
+        byte[][] writableMeasureDataArray =
+            new 
HeavyCompressedDoubleArrayDataInMemoryStore(writerCompressModel)
+                .getWritableMeasureDataArray(dataHolder).clone();
+        return writableMeasureDataArray[0];
+      }
+    }.getMockInstance();
+
+    int[][] blockIndexes = {{0,0}};
+    MeasureColumnDataChunk measureColumnDataChunks[] =
+        compressedMeasureChunkFileBasedReader.readMeasureChunks(fileHolder, 
blockIndexes);
+
+    BigDecimal bigD = new BigDecimal("2.1");
+    assertEquals(bigD,
+        
measureColumnDataChunks[0].getMeasureDataHolder().getReadableBigDecimalValueByIndex(0));
+
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/columnar/ColumnarKeyStoreDataHolderUnitTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/columnar/ColumnarKeyStoreDataHolderUnitTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/columnar/ColumnarKeyStoreDataHolderUnitTest.java
new file mode 100644
index 0000000..132b3a9
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/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.datastore.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/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/AlluxioCarbonFileTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/AlluxioCarbonFileTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/AlluxioCarbonFileTest.java
new file mode 100644
index 0000000..aada6f8
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/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.datastore.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/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/HDFSCarbonFileTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/HDFSCarbonFileTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/HDFSCarbonFileTest.java
new file mode 100644
index 0000000..a85280a
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/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.datastore.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/ce09aaaf/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/LocalCarbonFileTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/LocalCarbonFileTest.java
 
b/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/LocalCarbonFileTest.java
new file mode 100644
index 0000000..fe54cab
--- /dev/null
+++ 
b/core/src/test/java/org/apache/carbondata/core/datastore/filesystem/LocalCarbonFileTest.java
@@ -0,0 +1,470 @@
+/*
+ * 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.datastore.filesystem;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+import org.apache.carbondata.core.datastore.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);
+    }
+}

Reply via email to