001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.rest.model;
019
020import static org.junit.Assert.assertEquals;
021import static org.junit.Assert.assertTrue;
022
023import org.apache.hadoop.hbase.HBaseClassTestRule;
024import org.apache.hadoop.hbase.testclassification.RestTests;
025import org.apache.hadoop.hbase.testclassification.SmallTests;
026import org.junit.ClassRule;
027import org.junit.Test;
028import org.junit.experimental.categories.Category;
029
030@Category({ RestTests.class, SmallTests.class })
031public class TestColumnSchemaModel extends TestModelBase<ColumnSchemaModel> {
032
033  @ClassRule
034  public static final HBaseClassTestRule CLASS_RULE =
035    HBaseClassTestRule.forClass(TestColumnSchemaModel.class);
036
037  protected static final String COLUMN_NAME = "testcolumn";
038  protected static final boolean BLOCKCACHE = true;
039  protected static final int BLOCKSIZE = 16384;
040  protected static final String BLOOMFILTER = "NONE";
041  protected static final String COMPRESSION = "GZ";
042  protected static final boolean IN_MEMORY = false;
043  protected static final int TTL = 86400;
044  protected static final int VERSIONS = 1;
045
046  public TestColumnSchemaModel() throws Exception {
047    super(ColumnSchemaModel.class);
048    AS_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ColumnSchema "
049      + "name=\"testcolumn\" BLOCKSIZE=\"16384\" BLOOMFILTER=\"NONE\" BLOCKCACHE=\"true\" "
050      + "COMPRESSION=\"GZ\" VERSIONS=\"1\" TTL=\"86400\" IN_MEMORY=\"false\"/>";
051
052    AS_JSON = "{\"name\":\"testcolumn\",\"BLOCKSIZE\":\"16384\",\"BLOOMFILTER\":\"NONE\","
053      + "\"BLOCKCACHE\":\"true\",\"COMPRESSION\":\"GZ\",\"VERSIONS\":\"1\","
054      + "\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}";
055  }
056
057  @Override
058  protected ColumnSchemaModel buildTestModel() {
059    ColumnSchemaModel model = new ColumnSchemaModel();
060    model.setName(COLUMN_NAME);
061    model.__setBlocksize(BLOCKSIZE);
062    model.__setBloomfilter(BLOOMFILTER);
063    model.__setBlockcache(BLOCKCACHE);
064    model.__setCompression(COMPRESSION);
065    model.__setVersions(VERSIONS);
066    model.__setTTL(TTL);
067    model.__setInMemory(IN_MEMORY);
068    return model;
069  }
070
071  @Override
072  protected void checkModel(ColumnSchemaModel model) {
073    assertEquals("name", COLUMN_NAME, model.getName());
074    assertEquals("block cache", BLOCKCACHE, model.__getBlockcache());
075    assertEquals("block size", BLOCKSIZE, model.__getBlocksize());
076    assertEquals("bloomfilter", BLOOMFILTER, model.__getBloomfilter());
077    assertTrue("compression", model.__getCompression().equalsIgnoreCase(COMPRESSION));
078    assertEquals("in memory", IN_MEMORY, model.__getInMemory());
079    assertEquals("ttl", TTL, model.__getTTL());
080    assertEquals("versions", VERSIONS, model.__getVersions());
081  }
082
083  @Override
084  @Test
085  public void testFromPB() throws Exception {
086  }
087}