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 java.io.StringReader;
23  import java.io.StringWriter;
24  
25  import javax.xml.bind.JAXBContext;
26  import javax.xml.bind.JAXBException;
27  
28  import junit.framework.TestCase;
29  import org.apache.hadoop.hbase.SmallTests;
30  import org.junit.Ignore;
31  import org.junit.Test;
32  import org.junit.experimental.categories.Category;
33  
34  @Category(SmallTests.class)
35  public class TestColumnSchemaModel extends TestModelBase<ColumnSchemaModel> {
36  
37    protected static final String COLUMN_NAME = "testcolumn";
38    protected static final boolean BLOCKCACHE = true;
39    protected static final int BLOCKSIZE = 16384;
40    protected static final String BLOOMFILTER = "NONE";
41    protected static final String COMPRESSION = "GZ";
42    protected static final boolean IN_MEMORY = false;
43    protected static final int TTL = 86400;
44    protected static final int VERSIONS = 1;
45  
46    public TestColumnSchemaModel() throws Exception {
47      super(ColumnSchemaModel.class);
48      AS_XML =
49        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ColumnSchema " +
50            "name=\"testcolumn\" BLOCKSIZE=\"16384\" BLOOMFILTER=\"NONE\" BLOCKCACHE=\"true\" " +
51            "COMPRESSION=\"GZ\" VERSIONS=\"1\" TTL=\"86400\" IN_MEMORY=\"false\"/>";
52  
53      AS_JSON =
54        "{\"name\":\"testcolumn\",\"BLOCKSIZE\":\"16384\",\"BLOOMFILTER\":\"NONE\"," +
55            "\"BLOCKCACHE\":\"true\",\"COMPRESSION\":\"GZ\",\"VERSIONS\":\"1\"," +
56            "\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}";
57    }
58  
59    protected ColumnSchemaModel buildTestModel() {
60      ColumnSchemaModel model = new ColumnSchemaModel();
61      model.setName(COLUMN_NAME);
62      model.__setBlocksize(BLOCKSIZE);
63      model.__setBloomfilter(BLOOMFILTER);
64      model.__setBlockcache(BLOCKCACHE);
65      model.__setCompression(COMPRESSION);
66      model.__setVersions(VERSIONS);
67      model.__setTTL(TTL);
68      model.__setInMemory(IN_MEMORY);
69      return model;
70    }
71  
72    protected void checkModel(ColumnSchemaModel model) {
73      assertEquals(model.getName(), COLUMN_NAME);
74      assertEquals(model.__getBlockcache(), BLOCKCACHE);
75      assertEquals(model.__getBlocksize(), BLOCKSIZE);
76      assertEquals(model.__getBloomfilter(), BLOOMFILTER);
77      assertTrue(model.__getCompression().equalsIgnoreCase(COMPRESSION));
78      assertEquals(model.__getInMemory(), IN_MEMORY);
79      assertEquals(model.__getTTL(), TTL);
80      assertEquals(model.__getVersions(), VERSIONS);
81    }
82  
83    public void testFromPB() throws Exception {
84    }
85  }
86