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.io.compress.xerial;
019
020import static org.junit.jupiter.api.Assumptions.assumeTrue;
021
022import org.apache.hadoop.conf.Configuration;
023import org.apache.hadoop.fs.Path;
024import org.apache.hadoop.hbase.HBaseTestingUtil;
025import org.apache.hadoop.hbase.io.compress.Compression;
026import org.apache.hadoop.hbase.io.compress.HFileTestBase;
027import org.apache.hadoop.hbase.testclassification.IOTests;
028import org.apache.hadoop.hbase.testclassification.SmallTests;
029import org.junit.jupiter.api.BeforeAll;
030import org.junit.jupiter.api.Tag;
031import org.junit.jupiter.api.Test;
032
033@Tag(IOTests.TAG)
034@Tag(SmallTests.TAG)
035public class TestHFileCompressionSnappy extends HFileTestBase {
036
037  private static Configuration conf;
038
039  @BeforeAll
040  public static void setUpBeforeClass() throws Exception {
041    assumeTrue(SnappyCodec.isLoaded());
042    conf = TEST_UTIL.getConfiguration();
043    conf.set(Compression.SNAPPY_CODEC_CLASS_KEY, SnappyCodec.class.getCanonicalName());
044    Compression.Algorithm.SNAPPY.reload(conf);
045    HFileTestBase.setUpBeforeClass();
046  }
047
048  @Test
049  public void test() throws Exception {
050    Path path =
051      new Path(TEST_UTIL.getDataTestDir(), HBaseTestingUtil.getRandomUUID().toString() + ".hfile");
052    doTest(conf, path, Compression.Algorithm.SNAPPY);
053  }
054}