HBASE-23868 : Replace usages of HColumnDescriptor(byte [] familyName)… (#1222)
[hbase.git] / hbase-backup / src / test / java / org / apache / hadoop / hbase / backup / TestBackupSmallTests.java
blob1aa267b67bbd52d129e99f82edb0dceb8df641a5
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.backup;
20 import java.io.IOException;
21 import org.apache.hadoop.fs.FileSystem;
22 import org.apache.hadoop.fs.Path;
23 import org.apache.hadoop.fs.permission.FsPermission;
24 import org.apache.hadoop.hbase.HBaseClassTestRule;
25 import org.apache.hadoop.hbase.testclassification.SmallTests;
26 import org.apache.hadoop.hdfs.DFSTestUtil;
27 import org.apache.hadoop.security.UserGroupInformation;
28 import org.junit.ClassRule;
29 import org.junit.Test;
30 import org.junit.experimental.categories.Category;
32 @Category(SmallTests.class)
33 public class TestBackupSmallTests extends TestBackupBase {
35 @ClassRule
36 public static final HBaseClassTestRule CLASS_RULE =
37 HBaseClassTestRule.forClass(TestBackupSmallTests.class);
39 private static final UserGroupInformation DIANA =
40 UserGroupInformation.createUserForTesting("diana", new String[] {});
41 private static final String PERMISSION_TEST_PATH = Path.SEPARATOR + "permissionUT";
43 @Test public void testBackupPathIsAccessible() throws Exception {
44 Path path = new Path(PERMISSION_TEST_PATH);
45 FileSystem fs = FileSystem.get(TEST_UTIL.getConnection().getConfiguration());
46 fs.mkdirs(path);
49 @Test(expected = IOException.class) public void testBackupPathIsNotAccessible() throws Exception {
50 Path path = new Path(PERMISSION_TEST_PATH);
51 FileSystem rootFs = FileSystem.get(TEST_UTIL.getConnection().getConfiguration());
52 rootFs.mkdirs(path.getParent());
53 rootFs.setPermission(path.getParent(), FsPermission.createImmutable((short) 000));
54 FileSystem fs =
55 DFSTestUtil.getFileSystemAs(DIANA, TEST_UTIL.getConnection().getConfiguration());
56 fs.mkdirs(path);