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 =
049      "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ColumnSchema " +
050          "name=\"testcolumn\" BLOCKSIZE=\"16384\" BLOOMFILTER=\"NONE\" BLOCKCACHE=\"true\" " +
051          "COMPRESSION=\"GZ\" VERSIONS=\"1\" TTL=\"86400\" IN_MEMORY=\"false\"/>";
052
053    AS_JSON =
054      "{\"name\":\"testcolumn\",\"BLOCKSIZE\":\"16384\",\"BLOOMFILTER\":\"NONE\"," +
055          "\"BLOCKCACHE\":\"true\",\"COMPRESSION\":\"GZ\",\"VERSIONS\":\"1\"," +
056          "\"TTL\":\"86400\",\"IN_MEMORY\":\"false\"}";
057  }
058
059  @Override
060  protected ColumnSchemaModel buildTestModel() {
061    ColumnSchemaModel model = new ColumnSchemaModel();
062    model.setName(COLUMN_NAME);
063    model.__setBlocksize(BLOCKSIZE);
064    model.__setBloomfilter(BLOOMFILTER);
065    model.__setBlockcache(BLOCKCACHE);
066    model.__setCompression(COMPRESSION);
067    model.__setVersions(VERSIONS);
068    model.__setTTL(TTL);
069    model.__setInMemory(IN_MEMORY);
070    return model;
071  }
072
073  @Override
074  protected void checkModel(ColumnSchemaModel model) {
075    assertEquals("name", COLUMN_NAME, model.getName());
076    assertEquals("block cache", BLOCKCACHE, model.__getBlockcache());
077    assertEquals("block size", BLOCKSIZE, model.__getBlocksize());
078    assertEquals("bloomfilter", BLOOMFILTER, model.__getBloomfilter());
079    assertTrue("compression", model.__getCompression().equalsIgnoreCase(COMPRESSION));
080    assertEquals("in memory", IN_MEMORY, model.__getInMemory());
081    assertEquals("ttl", TTL, model.__getTTL());
082    assertEquals("versions", VERSIONS, model.__getVersions());
083  }
084
085  @Override
086  @Test
087  public void testFromPB() throws Exception {
088  }
089}
090