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    @Override
51    protected ColumnSchemaModel buildTestModel() {
52      ColumnSchemaModel model = new ColumnSchemaModel();
53      model.setName(COLUMN_NAME);
54      model.__setBlocksize(BLOCKSIZE);
55      model.__setBloomfilter(BLOOMFILTER);
56      model.__setBlockcache(BLOCKCACHE);
57      model.__setCompression(COMPRESSION);
58      model.__setVersions(VERSIONS);
59      model.__setTTL(TTL);
60      model.__setInMemory(IN_MEMORY);
61      return model;
62    }
63  
64    @Override
65    protected void checkModel(ColumnSchemaModel model) {
66      assertEquals(COLUMN_NAME, model.getName());
67      assertEquals(BLOCKCACHE, model.__getBlockcache());
68      assertEquals(BLOCKSIZE, model.__getBlocksize());
69      assertEquals(BLOOMFILTER, model.__getBloomfilter());
70      assertTrue(model.__getCompression().equalsIgnoreCase(COMPRESSION));
71      assertEquals(IN_MEMORY, model.__getInMemory());
72      assertEquals(TTL, model.__getTTL());
73      assertEquals(VERSIONS, model.__getVersions());
74    }
75  
76    @Override
77    public void testFromPB() throws Exception {
78    }
79  }