Index: src/test/org/apache/hadoop/hbase/client/TestPutAfterDelete.java =================================================================== --- src/test/org/apache/hadoop/hbase/client/TestPutAfterDelete.java (revision 0) +++ src/test/org/apache/hadoop/hbase/client/TestPutAfterDelete.java (revision 0) @@ -0,0 +1,102 @@ +/** + * Copyright 2009 The Apache Software Foundation + * + * 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.hadoop.hbase.client; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; + +import junit.framework.Assert; + +import org.apache.hadoop.hbase.HBaseClusterTestCase; +import org.apache.hadoop.hbase.HColumnDescriptor; +import org.apache.hadoop.hbase.HTableDescriptor; +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.util.Bytes; + +/** + * Test puts + */ +public class TestPutAfterDelete extends HBaseClusterTestCase { + private static final byte[] CONTENTS_FAMILY = Bytes.toBytes("contents"); + private static final byte[] SMALL_FAMILY = Bytes.toBytes("smallfam"); + + private static final byte[] row1 = Bytes.toBytes("row1"); + private static final byte[] row2 = Bytes.toBytes("row2"); + + private static final int SMALL_LENGTH = 1; + private static final int NB_BATCH_ROWS = 10; + private byte[] value; + private byte[] smallValue; + + private HTableDescriptor desc = null; + private HTable table = null; + + /** + * @throws UnsupportedEncodingException + */ + public TestPutAfterDelete() throws UnsupportedEncodingException { + super(); + value = Bytes.toBytes("abcd"); + smallValue = Bytes.toBytes("a"); + } + + @Override + public void setUp() throws Exception { + super.setUp(); + this.desc = new HTableDescriptor("test"); + desc.addFamily(new HColumnDescriptor(CONTENTS_FAMILY)); + desc.addFamily(new HColumnDescriptor(SMALL_FAMILY, + HColumnDescriptor.DEFAULT_VERSIONS, + HColumnDescriptor.DEFAULT_COMPRESSION, + HColumnDescriptor.DEFAULT_IN_MEMORY, + HColumnDescriptor.DEFAULT_BLOCKCACHE, SMALL_LENGTH, + HColumnDescriptor.DEFAULT_TTL, HColumnDescriptor.DEFAULT_BLOOMFILTER)); + HBaseAdmin admin = new HBaseAdmin(conf); + admin.createTable(desc); + table = new HTable(conf, desc.getName()); + } + + /** + * + */ + public void testPutAfterDelete() throws Exception { + byte[] qual = Bytes.toBytes("qual"); + + for (int i = 0; i < 1000; i++) { + Put put = new Put(row1); + put.add(CONTENTS_FAMILY, qual, value); + put.add(SMALL_FAMILY, qual, smallValue); + table.delete(new Delete(row1)); + table.put(put); + + + Result result = table.get(new Get(row1)); + System.out.println("On try "+(i+1)+" got "+result.size()); + + Assert.assertNotNull(result.getValue(Bytes.add(CONTENTS_FAMILY, Bytes + .toBytes(":"), qual))); + Assert.assertNotNull(result.getValue(Bytes.add(SMALL_FAMILY, Bytes + .toBytes(":"), qual))); + } + + } + +}