public void testAddIndexForTableWhenStringAndValLengthIsZero() throws Exception {
    IndexManager im = IndexManager.getInstance();
    assertNotNull("Index Manager should not be null.", im);

    List<IndexSpecification> indexList = new ArrayList<IndexSpecification>(1);
    IndexSpecification iSpec = new IndexSpecification("index_name");

    iSpec.addIndexColumn(new HColumnDescriptor("cf"), "cq", null, 0);
    indexList.add(iSpec);
    im.addIndexForTable("index_name", indexList);
    indexList = im.getIndicesForTable("index_name");
    assertEquals("the total value length should be 2", 2, indexList.get(0).getTotalValueLength());
  }
  public void testRemoveIndicesForTable() throws Exception {

    IndexManager im = IndexManager.getInstance();
    assertNotNull("Index Manager should not be null.", im);

    List<IndexSpecification> indexList = new ArrayList<IndexSpecification>(1);
    IndexSpecification iSpec = new IndexSpecification("index_name");

    iSpec.addIndexColumn(new HColumnDescriptor("cf"), "cq", null, 10);
    indexList.add(iSpec);
    im.removeIndices("index_name");
    indexList = im.getIndicesForTable("index_name");
    assertNull("Index specification List should be null.", indexList);
  }
  public void testShouldNotThrowNPEIfValueTypeIsNull() throws Exception {
    IndexManager im = IndexManager.getInstance();
    assertNotNull("Index Manager should not be null.", im);

    List<IndexSpecification> indexList = new ArrayList<IndexSpecification>(1);
    IndexSpecification iSpec = new IndexSpecification("index_name");

    iSpec.addIndexColumn(new HColumnDescriptor("cf"), "cq", null, 5);
    indexList.add(iSpec);
    im.addIndexForTable("index_name", indexList);
    indexList = im.getIndicesForTable("index_name");

    Set<ColumnQualifier> indexColumns = indexList.get(0).getIndexColumns();
    for (ColumnQualifier columnQualifier : indexColumns) {
      assertNotNull(columnQualifier.getType());
    }
  }
  public void testAddIndexForTable() throws Exception {

    IndexManager im = IndexManager.getInstance();
    assertNotNull("Index Manager should not be null.", im);

    List<IndexSpecification> indexList = new ArrayList<IndexSpecification>(1);
    IndexSpecification iSpec = new IndexSpecification("index_name");

    iSpec.addIndexColumn(new HColumnDescriptor("cf"), "cq", null, 10);
    indexList.add(iSpec);
    im.addIndexForTable("index_name", indexList);
    indexList = im.getIndicesForTable("index_name");
    assertEquals(
        "Index name should be equal with actual value.", "index_name", indexList.get(0).getName());
    assertTrue(
        "Column qualifier state mismatch.",
        indexList.get(0).getIndexColumns().contains(new ColumnQualifier("cf", "cq", null, 10)));
  }