View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional information regarding
4    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
7    * law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
8    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
9    * for the specific language governing permissions and limitations under the License.
10   */
11  
12  package org.apache.hadoop.hbase.client;
13  
14  import java.util.List;
15  import java.util.Map.Entry;
16  import java.util.NavigableMap;
17  
18  import org.apache.hadoop.hbase.Cell;
19  import org.apache.hadoop.hbase.testclassification.SmallTests;
20  import org.apache.hadoop.hbase.util.Bytes;
21  import org.junit.Assert;
22  import org.junit.Test;
23  import org.junit.experimental.categories.Category;
24  
25  @Category(SmallTests.class)
26  public class TestDeleteTimeStamp {
27    private static final byte[] ROW = Bytes.toBytes("testRow");
28    private static final byte[] FAMILY = Bytes.toBytes("testFamily");
29    private static final byte[] QUALIFIER = Bytes.toBytes("testQualifier");
30  
31    /*
32     * Test for verifying that the timestamp in delete object is being honored.
33     * @throws Exception
34     */
35    @Test
36    public void testTimeStamp() {
37      long ts = 2014L;
38      Delete delete = new Delete(ROW);
39      delete.setTimestamp(ts);
40      delete.deleteColumn(FAMILY, QUALIFIER);
41      NavigableMap<byte[], List<Cell>> familyCellmap = delete.getFamilyCellMap();
42      for (Entry<byte[], List<Cell>> entry : familyCellmap.entrySet()) {
43        for (Cell cell : entry.getValue()) {
44          Assert.assertEquals(ts, cell.getTimestamp());
45        }
46      }
47    }
48  }