2
* Copyright 2010 The Apache Software Foundation
4
* Licensed to the Apache Software Foundation (ASF) under one
5
* or more contributor license agreements. See the NOTICE file
6
* distributed with this work for additional information
7
* regarding copyright ownership. The ASF licenses this file
8
* to you under the Apache License, Version 2.0 (the
9
* "License"); you may not use this file except in compliance
10
* with the License. You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
21
package org.apache.hadoop.hbase.stargate.client;
23
import org.apache.hadoop.hbase.HColumnDescriptor;
24
import org.apache.hadoop.hbase.HTableDescriptor;
25
import org.apache.hadoop.hbase.client.HBaseAdmin;
26
import org.apache.hadoop.hbase.stargate.MiniClusterTestCase;
27
import org.apache.hadoop.hbase.stargate.client.Client;
28
import org.apache.hadoop.hbase.util.Bytes;
30
public class TestRemoteAdmin extends MiniClusterTestCase {
32
static final String TABLE_1 = "TestRemoteAdmin_Table_1";
33
static final String TABLE_2 = "TestRemoteAdmin_Table_2";
34
static final byte[] COLUMN_1 = Bytes.toBytes("a");
36
static final HTableDescriptor DESC_1;
38
DESC_1 = new HTableDescriptor(TABLE_1);
39
DESC_1.addFamily(new HColumnDescriptor(COLUMN_1));
41
static final HTableDescriptor DESC_2;
43
DESC_2 = new HTableDescriptor(TABLE_2);
44
DESC_2.addFamily(new HColumnDescriptor(COLUMN_1));
48
HBaseAdmin localAdmin;
49
RemoteAdmin remoteAdmin;
52
protected void setUp() throws Exception {
54
localAdmin = new HBaseAdmin(conf);
55
remoteAdmin = new RemoteAdmin(new Client(
56
new Cluster().add("localhost", testServletPort)),
58
if (localAdmin.tableExists(TABLE_1)) {
59
localAdmin.disableTable(TABLE_1);
60
localAdmin.deleteTable(TABLE_1);
62
if (!localAdmin.tableExists(TABLE_2)) {
63
localAdmin.createTable(DESC_2);
68
protected void tearDown() throws Exception {
72
public void testCreateTable() throws Exception {
73
assertFalse(remoteAdmin.isTableAvailable(TABLE_1));
74
remoteAdmin.createTable(DESC_1);
75
assertTrue(remoteAdmin.isTableAvailable(TABLE_1));
78
public void testDeleteTable() throws Exception {
79
assertTrue(remoteAdmin.isTableAvailable(TABLE_2));
80
remoteAdmin.deleteTable(TABLE_2);
81
assertFalse(remoteAdmin.isTableAvailable(TABLE_2));