1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.util;
21
22 import org.apache.hadoop.hbase.HBaseClusterTestCase;
23 import org.apache.hadoop.hbase.HColumnDescriptor;
24 import org.apache.hadoop.hbase.HTableDescriptor;
25 import org.apache.hadoop.hbase.MiniHBaseCluster;
26 import org.apache.hadoop.hbase.client.HBaseAdmin;
27 import org.apache.hadoop.hbase.client.HTable;
28 import org.apache.hadoop.hbase.client.HConnectionManager;
29
30
31
32
33 public class DisabledTestMetaUtils extends HBaseClusterTestCase {
34 public void testColumnEdits() throws Exception {
35 HBaseAdmin admin = new HBaseAdmin(this.conf);
36 final String oldColumn = "oldcolumn:";
37
38 for (int i = 0; i < 5; i++) {
39 HTableDescriptor htd = new HTableDescriptor(getName() + i);
40 htd.addFamily(new HColumnDescriptor(oldColumn));
41 admin.createTable(htd);
42 }
43 this.cluster.shutdown();
44 this.cluster = null;
45 MetaUtils utils = new MetaUtils(this.conf);
46
47 final byte [] editTable = Bytes.toBytes(getName() + 2);
48 final byte [] newColumn = Bytes.toBytes("newcolumn:");
49 utils.addColumn(editTable, new HColumnDescriptor(newColumn));
50 utils.deleteColumn(editTable, Bytes.toBytes(oldColumn));
51 utils.shutdown();
52
53 HConnectionManager.deleteConnection(conf, false);
54
55 this.cluster = new MiniHBaseCluster(this.conf, 1);
56
57 HTable t = new HTable(conf, editTable);
58 HTableDescriptor htd = t.getTableDescriptor();
59 HColumnDescriptor hcd = htd.getFamily(newColumn);
60 assertTrue(hcd != null);
61 assertNull(htd.getFamily(Bytes.toBytes(oldColumn)));
62 }
63 }