|
| 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 |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 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. |
| 17 | + */ |
| 18 | +package org.apache.hadoop.fs.viewfs; |
| 19 | + |
| 20 | +import static org.junit.Assert.*; |
| 21 | + |
| 22 | +import java.io.IOException; |
| 23 | +import java.net.URI; |
| 24 | +import java.net.URISyntaxException; |
| 25 | + |
| 26 | +import org.apache.hadoop.conf.Configuration; |
| 27 | +import org.apache.hadoop.fs.FileSystem; |
| 28 | +import org.apache.hadoop.fs.FsConstants; |
| 29 | +import org.junit.Test; |
| 30 | + |
| 31 | +/** |
| 32 | + * Test ViewFileSystem's support for having delegation tokens fetched and cached |
| 33 | + * for the file system. |
| 34 | + */ |
| 35 | +public class TestViewFileSystemDelegationTokenSupport { |
| 36 | + |
| 37 | + private static final String MOUNT_TABLE_NAME = "vfs-cluster"; |
| 38 | + |
| 39 | + /** |
| 40 | + * Ensure that a canonical service name can be determined for ViewFileSystem |
| 41 | + * instances configured with a non-default mount table name. |
| 42 | + * |
| 43 | + * Regression test for HADOOP-8408. |
| 44 | + */ |
| 45 | + @Test |
| 46 | + public void testGetCanonicalServiceNameWithNonDefaultMountTable() |
| 47 | + throws URISyntaxException, IOException { |
| 48 | + |
| 49 | + Configuration conf = new Configuration(); |
| 50 | + ConfigUtil.addLink(conf, MOUNT_TABLE_NAME, "/user", new URI("file:///")); |
| 51 | + |
| 52 | + FileSystem viewFs = FileSystem.get(new URI(FsConstants.VIEWFS_SCHEME + |
| 53 | + "://" + MOUNT_TABLE_NAME), conf); |
| 54 | + |
| 55 | + String serviceName = viewFs.getCanonicalServiceName(); |
| 56 | + assertNotNull(serviceName); |
| 57 | + assertEquals(MOUNT_TABLE_NAME, serviceName); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + public void testGetCanonicalServiceNameWithDefaultMountTable() |
| 62 | + throws URISyntaxException, IOException { |
| 63 | + |
| 64 | + Configuration conf = new Configuration(); |
| 65 | + ConfigUtil.addLink(conf, "/user", new URI("file:///")); |
| 66 | + |
| 67 | + FileSystem viewFs = FileSystem.get(FsConstants.VIEWFS_URI, conf); |
| 68 | + |
| 69 | + String serviceName = viewFs.getCanonicalServiceName(); |
| 70 | + assertNull(serviceName); |
| 71 | + } |
| 72 | + |
| 73 | +} |
0 commit comments