From common-commits-return-16820-apmail-hadoop-common-commits-archive=hadoop.apache.org@hadoop.apache.org Fri Feb 3 23:02:57 2012 Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DFF609111 for ; Fri, 3 Feb 2012 23:02:57 +0000 (UTC) Received: (qmail 48070 invoked by uid 500); 3 Feb 2012 23:02:57 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 47933 invoked by uid 500); 3 Feb 2012 23:02:56 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 47926 invoked by uid 99); 3 Feb 2012 23:02:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Feb 2012 23:02:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Feb 2012 23:02:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6362A23888E4; Fri, 3 Feb 2012 23:02:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1240385 - /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java Date: Fri, 03 Feb 2012 23:02:35 -0000 To: common-commits@hadoop.apache.org From: bobby@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120203230235.6362A23888E4@eris.apache.org> Author: bobby Date: Fri Feb 3 23:02:34 2012 New Revision: 1240385 URL: http://svn.apache.org/viewvc?rev=1240385&view=rev Log: HADOOP-8013 ViewFileSystem does not honor setVerifyChecksum (Missed a file) (Daryn Sharp via bobby) Added: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java Added: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java?rev=1240385&view=auto ============================================================================== --- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java (added) +++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java Fri Feb 3 23:02:34 2012 @@ -0,0 +1,102 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.fs.viewfs; + +import java.io.IOException; +import java.net.URI; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.FileSystemTestHelper; +import org.apache.hadoop.fs.FsConstants; +import org.apache.hadoop.fs.LocalFileSystem; +import org.apache.hadoop.fs.Path; +import org.junit.*; +import static org.junit.Assert.*; + +/** + * Verify that viewfs propagates certain methods to the underlying fs + */ +public class TestViewFileSystemDelegation { //extends ViewFileSystemTestSetup { + static Configuration conf; + static FileSystem viewFs; + static FakeFileSystem fs1; + static FakeFileSystem fs2; + + @BeforeClass + public static void setup() throws Exception { + conf = ViewFileSystemTestSetup.configWithViewfsScheme(); + fs1 = setupFileSystem(new URI("fs1:/"), FakeFileSystem.class); + fs2 = setupFileSystem(new URI("fs2:/"), FakeFileSystem.class); + viewFs = FileSystem.get(FsConstants.VIEWFS_URI, conf); + } + + static FakeFileSystem setupFileSystem(URI uri, Class clazz) + throws Exception { + String scheme = uri.getScheme(); + conf.set("fs."+scheme+".impl", clazz.getName()); + FakeFileSystem fs = (FakeFileSystem)FileSystem.get(uri, conf); + assertEquals(uri, fs.getUri()); + Path targetPath = FileSystemTestHelper.getAbsoluteTestRootPath(fs); + ConfigUtil.addLink(conf, "/mounts/"+scheme, targetPath.toUri()); + return fs; + } + + @Test + public void testSanity() { + assertEquals("fs1:/", fs1.getUri().toString()); + assertEquals("fs2:/", fs2.getUri().toString()); + } + + @Test + public void testVerifyChecksum() throws Exception { + checkVerifyChecksum(false); + checkVerifyChecksum(true); + } + + void checkVerifyChecksum(boolean flag) { + viewFs.setVerifyChecksum(flag); + assertEquals(flag, fs1.getVerifyChecksum()); + assertEquals(flag, fs2.getVerifyChecksum()); + } + + static class FakeFileSystem extends LocalFileSystem { + boolean verifyChecksum = true; + URI uri; + + @Override + public void initialize(URI uri, Configuration conf) throws IOException { + super.initialize(uri, conf); + this.uri = uri; + } + + @Override + public URI getUri() { + return uri; + } + + @Override + public void setVerifyChecksum(boolean verifyChecksum) { + this.verifyChecksum = verifyChecksum; + } + + public boolean getVerifyChecksum(){ + return verifyChecksum; + } + } +}