View Javadoc

1   /*
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  package org.apache.hadoop.hbase.rest.model;
21  
22  import org.apache.hadoop.hbase.testclassification.SmallTests;
23  import org.junit.experimental.categories.Category;
24  
25  @Category(SmallTests.class)
26  public class TestColumnSchemaModel extends TestModelBase<ColumnSchemaModel> {
27  
28    protected static final String COLUMN_NAME = "testcolumn";
29    protected static final boolean BLOCKCACHE = true;
30    protected static final int BLOCKSIZE = 16384;
31    protected static final String BLOOMFILTER = "NONE";
32    protected static final String COMPRESSION = "GZ";
33    protected static final boolean IN_MEMORY = false;
34    protected static final int TTL = 86400;
35    protected static final int VERSIONS = 1;
36  
37    public TestColumnSchemaModel() throws Exception {
38      super(ColumnSchemaModel.class);
39      AS_XML =
40        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ColumnSchema " +
41            "name=\"testcolumn\" BLOCKSIZE=\"16384\" BLOOMFILTER=\"NONE\" BLOCKCACHE=\"true\" " +
42            "COMPRESSION=\"GZ\" VERSIONS=\"1\" TTL=\"86400\" IN_MEMORY=\"false\"/>";
43  
44      AS_JSON =
45        "{\"name\":\"testcolumn\",\"BLOCKSIZE\":\"16384\",\"BLOOMFILTER\":\"NONE\"," +
46            "\"BLOCKCACHE\":\"true\",\"COMPRESSION\":\"GZ\",\"VERSIONS\":\"1\"," +
47            "\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}";
48    }
49  
50    protected ColumnSchemaModel buildTestModel() {
51      ColumnSchemaModel model = new ColumnSchemaModel();
52      model.setName(COLUMN_NAME);
53      model.__setBlocksize(BLOCKSIZE);
54      model.__setBloomfilter(BLOOMFILTER);
55      model.__setBlockcache(BLOCKCACHE);
56      model.__setCompression(COMPRESSION);
57      model.__setVersions(VERSIONS);
58      model.__setTTL(TTL);
59      model.__setInMemory(IN_MEMORY);
60      return model;
61    }
62  
63    protected void checkModel(ColumnSchemaModel model) {
64      assertEquals(model.getName(), COLUMN_NAME);
65      assertEquals(model.__getBlockcache(), BLOCKCACHE);
66      assertEquals(model.__getBlocksize(), BLOCKSIZE);
67      assertEquals(model.__getBloomfilter(), BLOOMFILTER);
68      assertTrue(model.__getCompression().equalsIgnoreCase(COMPRESSION));
69      assertEquals(model.__getInMemory(), IN_MEMORY);
70      assertEquals(model.__getTTL(), TTL);
71      assertEquals(model.__getVersions(), VERSIONS);
72    }
73  
74    public void testFromPB() throws Exception {
75    }
76  }
77