1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.migration;
19  
20  
21  import java.io.IOException;
22  
23  import junit.framework.Assert;
24  
25  import org.apache.hadoop.hbase.*;
26  import org.apache.hadoop.hbase.catalog.MetaMigrationRemovingHTD;
27  import org.apache.hadoop.hbase.util.Writables;
28  import org.junit.Test;
29  import org.junit.experimental.categories.Category;
30  
31  /**
32   * Migration tests that do not need spin up of a cluster.
33   * @deprecated Remove after we release 0.92
34   */
35  @Category(SmallTests.class)
36  public class TestMigrationFrom090To092 {
37    @Test
38    public void testMigrateHRegionInfoFromVersion0toVersion1()
39    throws IOException {
40      HTableDescriptor htd =
41        getHTableDescriptor("testMigrateHRegionInfoFromVersion0toVersion1");
42      HRegionInfo090x ninety =
43        new HRegionInfo090x(htd, HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW);
44      byte [] bytes = Writables.getBytes(ninety);
45      // Now deserialize into an HRegionInfo
46      HRegionInfo hri = Writables.getHRegionInfo(bytes);
47      Assert.assertEquals(hri.getTableNameAsString(),
48        ninety.getTableDesc().getNameAsString());
49      Assert.assertEquals(HRegionInfo.VERSION, hri.getVersion());
50    }
51  
52    private HTableDescriptor getHTableDescriptor(final String name) {
53      HTableDescriptor htd = new HTableDescriptor(name);
54      htd.addFamily(new HColumnDescriptor("family"));
55      return htd;
56    }
57  
58    @org.junit.Rule
59    public org.apache.hadoop.hbase.ResourceCheckerJUnitRule cu =
60      new org.apache.hadoop.hbase.ResourceCheckerJUnitRule();
61  }
62