hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ss...@apache.org
Subject svn commit: r1398581 [12/14] - in /hadoop/common/branches/MR-3902/hadoop-common-project: hadoop-annotations/src/main/java/org/apache/hadoop/classification/tools/ hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/client/ hadoop-auth/sr...
Date Tue, 16 Oct 2012 00:03:31 GMT
Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextMainOperations.java Tue Oct 16 00:02:55 2012
@@ -27,6 +27,7 @@ import org.junit.Test;
 
 public class TestLocalFSFileContextMainOperations extends FileContextMainOperationsBaseTest {
 
+  @Override
   @Before
   public void setUp() throws Exception {
     fc = FileContext.getLocalFSFileContext();
@@ -34,6 +35,7 @@ public class TestLocalFSFileContextMainO
   }
   
   static Path wd = null;
+  @Override
   protected Path getDefaultWorkingDirectory() throws IOException {
     if (wd == null)
       wd = FileSystem.getLocal(new Configuration()).getWorkingDirectory();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextSymlink.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextSymlink.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextSymlink.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFSFileContextSymlink.java Tue Oct 16 00:02:55 2012
@@ -35,18 +35,22 @@ import org.junit.Before;
  */
 public class TestLocalFSFileContextSymlink extends FileContextSymlinkBaseTest {
   
+  @Override
   protected String getScheme() {
     return "file";
   }
 
+  @Override
   protected String testBaseDir1() throws IOException {
     return getAbsoluteTestRootDir(fc)+"/test1";
   }
   
+  @Override
   protected String testBaseDir2() throws IOException {
     return getAbsoluteTestRootDir(fc)+"/test2";
   }
 
+  @Override
   protected URI testURI() {
     try {
       return new URI("file:///");
@@ -55,6 +59,7 @@ public class TestLocalFSFileContextSymli
     }
   }
   
+  @Override
   @Before
   public void setUp() throws Exception {
     fc = FileContext.getLocalFSFileContext();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFsFCStatistics.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFsFCStatistics.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFsFCStatistics.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFsFCStatistics.java Tue Oct 16 00:02:55 2012
@@ -47,15 +47,18 @@ public class TestLocalFsFCStatistics ext
     fc.delete(getTestRootPath(fc, "test"), true);
   }
 
+  @Override
   protected void verifyReadBytes(Statistics stats) {
     Assert.assertEquals(blockSize, stats.getBytesRead());
   }
 
+  @Override
   protected void verifyWrittenBytes(Statistics stats) {
     //Extra 12 bytes are written apart from the block.
     Assert.assertEquals(blockSize + 12, stats.getBytesWritten());
   }
   
+  @Override
   protected URI getFsUri() {
     return URI.create(LOCAL_FS_ROOT_URI);
   }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocal_S3FileContextURI.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocal_S3FileContextURI.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocal_S3FileContextURI.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocal_S3FileContextURI.java Tue Oct 16 00:02:55 2012
@@ -24,6 +24,7 @@ import org.junit.Before;
 
 public class TestLocal_S3FileContextURI extends FileContextURIBase {
 
+  @Override
   @Before
   public void setUp() throws Exception {
     Configuration S3Conf = new Configuration();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestS3_LocalFileContextURI.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestS3_LocalFileContextURI.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestS3_LocalFileContextURI.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestS3_LocalFileContextURI.java Tue Oct 16 00:02:55 2012
@@ -24,6 +24,7 @@ import org.junit.Before;
 
 public class TestS3_LocalFileContextURI extends FileContextURIBase {
 
+  @Override
   @Before
   public void setUp() throws Exception {
 

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java Tue Oct 16 00:02:55 2012
@@ -26,6 +26,8 @@ import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -67,6 +69,7 @@ public class TestTrash extends TestCase 
 
     // filter that matches all the files that start with fileName*
     PathFilter pf = new PathFilter() {
+      @Override
       public boolean accept(Path file) {
         return file.getName().startsWith(prefix);
       }
@@ -98,7 +101,6 @@ public class TestTrash extends TestCase 
   }
 
   /**
-   * 
    * Test trash for the shell's delete command for the default file system
    * specified in the paramter conf
    * @param conf 
@@ -428,8 +430,40 @@ public class TestTrash extends TestCase 
       String output = byteStream.toString();
       System.setOut(stdout);
       System.setErr(stderr);
-      assertTrue("skipTrash wasn't suggested as remedy to failed rm command",
-        output.indexOf(("Consider using -skipTrash option")) != -1 );
+      assertTrue("skipTrash wasn't suggested as remedy to failed rm command" +
+          " or we deleted / even though we could not get server defaults",
+          output.indexOf("Consider using -skipTrash option") != -1 ||
+          output.indexOf("Failed to determine server trash configuration") != -1);
+    }
+
+    // Verify old checkpoint format is recognized
+    {
+      // emulate two old trash checkpoint directories, one that is old enough
+      // to be deleted on the next expunge and one that isn't.
+      long trashInterval = conf.getLong(FS_TRASH_INTERVAL_KEY,
+          FS_TRASH_INTERVAL_DEFAULT);
+      long now = Time.now();
+      DateFormat oldCheckpointFormat = new SimpleDateFormat("yyMMddHHmm");
+      Path dirToDelete = new Path(trashRoot.getParent(),
+          oldCheckpointFormat.format(now - (trashInterval * 60 * 1000) - 1));
+      Path dirToKeep = new Path(trashRoot.getParent(),
+          oldCheckpointFormat.format(now));
+      mkdir(trashRootFs, dirToDelete);
+      mkdir(trashRootFs, dirToKeep);
+
+      // Clear out trash
+      int rc = -1;
+      try {
+        rc = shell.run(new String [] { "-expunge" } );
+      } catch (Exception e) {
+        System.err.println("Exception raised from fs expunge " +
+            e.getLocalizedMessage());
+      }
+      assertEquals(0, rc);
+      assertFalse("old checkpoint format not recognized",
+          trashRootFs.exists(dirToDelete));
+      assertTrue("old checkpoint format directory should not be removed",
+          trashRootFs.exists(dirToKeep));
     }
 
   }
@@ -563,6 +597,7 @@ public class TestTrash extends TestCase 
       super();
       this.home = home;
     }
+    @Override
     public Path getHomeDirectory() {
       return home;
     }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/DataGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/DataGenerator.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/DataGenerator.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/DataGenerator.java Tue Oct 16 00:02:55 2012
@@ -67,6 +67,7 @@ public class DataGenerator extends Confi
    * namespace. Afterwards it reads the file attributes and creates files 
    * in the file. All file content is filled with 'a'.
    */
+  @Override
   public int run(String[] args) throws Exception {
     int exitCode = 0;
     exitCode = init(args);

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java Tue Oct 16 00:02:55 2012
@@ -186,6 +186,7 @@ public class LoadGenerator extends Confi
     /** Main loop
      * Each iteration decides what's the next operation and then pauses.
      */
+    @Override
     public void run() {
       try {
         while (shouldRun) {
@@ -281,6 +282,7 @@ public class LoadGenerator extends Confi
    * Before exiting, it prints the average execution for 
    * each operation and operation throughput.
    */
+  @Override
   public int run(String[] args) throws Exception {
     int exitCode = init(args);
     if (exitCode != 0) {

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/StructureGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/StructureGenerator.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/StructureGenerator.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/StructureGenerator.java Tue Oct 16 00:02:55 2012
@@ -214,6 +214,7 @@ public class StructureGenerator {
     }
     
     /** Output a file attribute */
+    @Override
     protected void outputFiles(PrintStream out, String prefix) {
       prefix = (prefix == null)?super.name: prefix + "/"+super.name;
       out.println(prefix + " " + numOfBlocks);

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/s3/InMemoryFileSystemStore.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/s3/InMemoryFileSystemStore.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/s3/InMemoryFileSystemStore.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/s3/InMemoryFileSystemStore.java Tue Oct 16 00:02:55 2012
@@ -47,34 +47,42 @@ class InMemoryFileSystemStore implements
   private SortedMap<Path, INode> inodes = new TreeMap<Path, INode>();
   private Map<Long, byte[]> blocks = new HashMap<Long, byte[]>();
   
+  @Override
   public void initialize(URI uri, Configuration conf) {
     this.conf = conf;
   }
   
+  @Override
   public String getVersion() throws IOException {
     return "0";
   }
 
+  @Override
   public void deleteINode(Path path) throws IOException {
     inodes.remove(normalize(path));
   }
 
+  @Override
   public void deleteBlock(Block block) throws IOException {
     blocks.remove(block.getId());
   }
 
+  @Override
   public boolean inodeExists(Path path) throws IOException {
     return inodes.containsKey(normalize(path));
   }
 
+  @Override
   public boolean blockExists(long blockId) throws IOException {
     return blocks.containsKey(blockId);
   }
 
+  @Override
   public INode retrieveINode(Path path) throws IOException {
     return inodes.get(normalize(path));
   }
 
+  @Override
   public File retrieveBlock(Block block, long byteRangeStart) throws IOException {
     byte[] data = blocks.get(block.getId());
     File file = createTempFile();
@@ -100,6 +108,7 @@ class InMemoryFileSystemStore implements
     return result;
   }
 
+  @Override
   public Set<Path> listSubPaths(Path path) throws IOException {
     Path normalizedPath = normalize(path);
     // This is inefficient but more than adequate for testing purposes.
@@ -112,6 +121,7 @@ class InMemoryFileSystemStore implements
     return subPaths;
   }
 
+  @Override
   public Set<Path> listDeepSubPaths(Path path) throws IOException {
     Path normalizedPath = normalize(path);    
     String pathString = normalizedPath.toUri().getPath();
@@ -128,10 +138,12 @@ class InMemoryFileSystemStore implements
     return subPaths;
   }
 
+  @Override
   public void storeINode(Path path, INode inode) throws IOException {
     inodes.put(normalize(path), inode);
   }
 
+  @Override
   public void storeBlock(Block block, File file) throws IOException {
     ByteArrayOutputStream out = new ByteArrayOutputStream();
     byte[] buf = new byte[8192];
@@ -157,11 +169,13 @@ class InMemoryFileSystemStore implements
     return new Path(path.toUri().getPath());
   }
 
+  @Override
   public void purge() throws IOException {
     inodes.clear();
     blocks.clear();
   }
 
+  @Override
   public void dump() throws IOException {
     StringBuilder sb = new StringBuilder(getClass().getSimpleName());
     sb.append(", \n");

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/s3native/InMemoryNativeFileSystemStore.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/s3native/InMemoryNativeFileSystemStore.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/s3native/InMemoryNativeFileSystemStore.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/s3native/InMemoryNativeFileSystemStore.java Tue Oct 16 00:02:55 2012
@@ -55,15 +55,18 @@ class InMemoryNativeFileSystemStore impl
     new TreeMap<String, FileMetadata>();
   private SortedMap<String, byte[]> dataMap = new TreeMap<String, byte[]>();
 
+  @Override
   public void initialize(URI uri, Configuration conf) throws IOException {
     this.conf = conf;
   }
 
+  @Override
   public void storeEmptyFile(String key) throws IOException {
     metadataMap.put(key, new FileMetadata(key, 0, Time.now()));
     dataMap.put(key, new byte[0]);
   }
 
+  @Override
   public void storeFile(String key, File file, byte[] md5Hash)
     throws IOException {
     
@@ -86,10 +89,12 @@ class InMemoryNativeFileSystemStore impl
     dataMap.put(key, out.toByteArray());
   }
 
+  @Override
   public InputStream retrieve(String key) throws IOException {
     return retrieve(key, 0);
   }
   
+  @Override
   public InputStream retrieve(String key, long byteRangeStart)
     throws IOException {
     
@@ -118,15 +123,18 @@ class InMemoryNativeFileSystemStore impl
     return result;
   }
 
+  @Override
   public FileMetadata retrieveMetadata(String key) throws IOException {
     return metadataMap.get(key);
   }
 
+  @Override
   public PartialListing list(String prefix, int maxListingLength)
       throws IOException {
     return list(prefix, maxListingLength, null, false);
   }
 
+  @Override
   public PartialListing list(String prefix, int maxListingLength,
       String priorLastKey, boolean recursive) throws IOException {
 
@@ -165,16 +173,19 @@ class InMemoryNativeFileSystemStore impl
         commonPrefixes.toArray(new String[0]));
   }
 
+  @Override
   public void delete(String key) throws IOException {
     metadataMap.remove(key);
     dataMap.remove(key);
   }
 
+  @Override
   public void copy(String srcKey, String dstKey) throws IOException {
     metadataMap.put(dstKey, metadataMap.get(srcKey));
     dataMap.put(dstKey, dataMap.get(srcKey));
   }
   
+  @Override
   public void purge(String prefix) throws IOException {
     Iterator<Entry<String, FileMetadata>> i =
       metadataMap.entrySet().iterator();
@@ -187,6 +198,7 @@ class InMemoryNativeFileSystemStore impl
     }
   }
 
+  @Override
   public void dump() throws IOException {
     System.out.println(metadataMap.values());
     System.out.println(dataMap.keySet());

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCommandFactory.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCommandFactory.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCommandFactory.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCommandFactory.java Tue Oct 16 00:02:55 2012
@@ -48,6 +48,10 @@ public class TestCommandFactory {
     factory.addClass(TestCommand3.class, "tc3");
     names = factory.getNames();
     assertArrayEquals(new String []{"tc1", "tc2", "tc2.1", "tc3"}, names);
+    
+    factory.addClass(TestCommand4.class, (new TestCommand4()).getName());
+    names = factory.getNames();
+    assertArrayEquals(new String[]{"tc1", "tc2", "tc2.1", "tc3", "tc4"}, names);
   }
   
   @Test
@@ -72,8 +76,17 @@ public class TestCommandFactory {
     assertNotNull(instance);
     assertEquals(TestCommand2.class, instance.getClass());    
     assertEquals("tc2.1", instance.getCommandName());
+    
+    factory.addClass(TestCommand4.class, "tc4");
+    instance = factory.getInstance("tc4");
+    assertNotNull(instance);
+    assertEquals(TestCommand4.class, instance.getClass());    
+    assertEquals("tc4", instance.getCommandName());
+    String usage = instance.getUsage();
+    assertEquals("-tc4 tc4_usage", usage);
+    assertEquals("tc4_description", instance.getDescription());
   }
-  
+
   static class TestRegistrar {
     public static void registerCommands(CommandFactory factory) {
       factory.addClass(TestCommand1.class, "tc1");
@@ -84,4 +97,10 @@ public class TestCommandFactory {
   static class TestCommand1 extends FsCommand {}
   static class TestCommand2 extends FsCommand {}
   static class TestCommand3 extends FsCommand {}
+  
+  static class TestCommand4 extends FsCommand {
+    static final String NAME = "tc4";
+    static final String USAGE = "tc4_usage";
+    static final String DESCRIPTION = "tc4_description";
+  }
 }
\ No newline at end of file

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFileSystem.java Tue Oct 16 00:02:55 2012
@@ -342,11 +342,21 @@ public class TestChRootedFileSystem {
     chrootFs.close();
     verify(mockFs).delete(eq(rawPath), eq(true));
   }
+  
+  @Test
+  public void testURIEmptyPath() throws IOException {
+    Configuration conf = new Configuration();
+    conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
+
+    URI chrootUri = URI.create("mockfs://foo");
+    new ChRootedFileSystem(chrootUri, conf);
+  }
 
   static class MockFileSystem extends FilterFileSystem {
     MockFileSystem() {
       super(mock(FileSystem.class));
     }
+    @Override
     public void initialize(URI name, Configuration conf) throws IOException {}
   }
 }
\ No newline at end of file

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFSMainOperationsLocalFileSystem.java Tue Oct 16 00:02:55 2012
@@ -33,6 +33,7 @@ import org.junit.Test;
 
 public class TestFSMainOperationsLocalFileSystem extends FSMainOperationsBaseTest {
    static FileSystem fcTarget;
+  @Override
   @Before
   public void setUp() throws Exception {
     Configuration conf = new Configuration();
@@ -42,6 +43,7 @@ public class TestFSMainOperationsLocalFi
     super.setUp();
   }
   
+  @Override
   @After
   public void tearDown() throws Exception {
     super.tearDown();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcCreateMkdirLocalFs.java Tue Oct 16 00:02:55 2012
@@ -28,12 +28,14 @@ public class TestFcCreateMkdirLocalFs  e
   FileContextCreateMkdirBaseTest {
 
 
+  @Override
   @Before
   public void setUp() throws Exception {
     fc = ViewFsTestSetup.setupForViewFsLocalFs();
     super.setUp();
   }
   
+  @Override
   @After
   public void tearDown() throws Exception {
     super.tearDown();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcMainOperationsLocalFs.java Tue Oct 16 00:02:55 2012
@@ -36,6 +36,7 @@ public class TestFcMainOperationsLocalFs
   FileContext fclocal;
   Path targetOfTests;
 
+  @Override
   @Before
   public void setUp() throws Exception {
     /**
@@ -79,6 +80,7 @@ public class TestFcMainOperationsLocalFs
     super.setUp();
   }
   
+  @Override
   @After
   public void tearDown() throws Exception {
     super.tearDown();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestFcPermissionsLocalFs.java Tue Oct 16 00:02:55 2012
@@ -27,12 +27,14 @@ import org.junit.Before;
 public class TestFcPermissionsLocalFs  extends FileContextPermissionBase {
 
 
+  @Override
   @Before
   public void setUp() throws Exception {
     fc = ViewFsTestSetup.setupForViewFsLocalFs();
     super.setUp();
   }
   
+  @Override
   @After
   public void tearDown() throws Exception {
     super.tearDown();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegationTokenSupport.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegationTokenSupport.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegationTokenSupport.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegationTokenSupport.java Tue Oct 16 00:02:55 2012
@@ -160,6 +160,7 @@ public class TestViewFileSystemDelegatio
   static class FakeFileSystem extends RawLocalFileSystem {
     URI uri;
 
+    @Override
     public void initialize(URI name, Configuration conf) throws IOException {
       this.uri = name;
     }
@@ -169,6 +170,7 @@ public class TestViewFileSystemDelegatio
       return new Path("/"); // ctor calls getUri before the uri is inited...
     }
     
+    @Override
     public URI getUri() {
       return uri;
     }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLocalFileSystem.java Tue Oct 16 00:02:55 2012
@@ -39,6 +39,7 @@ import org.junit.Before;
 public class TestViewFileSystemLocalFileSystem extends ViewFileSystemBaseTest {
 
 
+  @Override
   @Before
   public void setUp() throws Exception {
     // create the test root on local_fs
@@ -47,6 +48,7 @@ public class TestViewFileSystemLocalFile
     
   }
 
+  @Override
   @After
   public void tearDown() throws Exception {
     fsTarget.delete(FileSystemTestHelper.getTestRootPath(fsTarget), true);

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemWithAuthorityLocalFileSystem.java Tue Oct 16 00:02:55 2012
@@ -42,6 +42,7 @@ import org.junit.Test;
 public class TestViewFileSystemWithAuthorityLocalFileSystem extends ViewFileSystemBaseTest {
   URI schemeWithAuthority;
 
+  @Override
   @Before
   public void setUp() throws Exception {
     // create the test root on local_fs
@@ -55,12 +56,14 @@ public class TestViewFileSystemWithAutho
     fsView = FileSystem.get(schemeWithAuthority, conf);
   }
 
+  @Override
   @After
   public void tearDown() throws Exception {
     fsTarget.delete(FileSystemTestHelper.getTestRootPath(fsTarget), true);
     super.tearDown();
   }
  
+  @Override
   @Test
   public void testBasicPaths() {
     Assert.assertEquals(schemeWithAuthority,

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLocalFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLocalFs.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLocalFs.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLocalFs.java Tue Oct 16 00:02:55 2012
@@ -26,6 +26,7 @@ import org.junit.Before;
 
 public class TestViewFsLocalFs extends ViewFsBaseTest {
 
+  @Override
   @Before
   public void setUp() throws Exception {
     // create the test root on local_fs
@@ -34,6 +35,7 @@ public class TestViewFsLocalFs extends V
     
   }
 
+  @Override
   @After
   public void tearDown() throws Exception {
     super.tearDown();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java Tue Oct 16 00:02:55 2012
@@ -30,7 +30,6 @@ import org.apache.hadoop.fs.TestTrash;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.mortbay.log.Log;
 
 public class TestViewFsTrash {
   FileSystem fsTarget;  // the target file system - the mount will point here
@@ -46,6 +45,7 @@ public class TestViewFsTrash {
       super();
       this.home = home;
     }
+    @Override
     public Path getHomeDirectory() {
       return home;
     }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAuthorityLocalFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAuthorityLocalFs.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAuthorityLocalFs.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsWithAuthorityLocalFs.java Tue Oct 16 00:02:55 2012
@@ -41,6 +41,7 @@ import org.junit.Test;
 public class TestViewFsWithAuthorityLocalFs extends ViewFsBaseTest {
   URI schemeWithAuthority;
 
+  @Override
   @Before
   public void setUp() throws Exception {
     // create the test root on local_fs
@@ -54,11 +55,13 @@ public class TestViewFsWithAuthorityLoca
     fcView = FileContext.getFileContext(schemeWithAuthority, conf);  
   }
 
+  @Override
   @After
   public void tearDown() throws Exception {
     super.tearDown();
   }
   
+  @Override
   @Test
   public void testBasicPaths() {
       Assert.assertEquals(schemeWithAuthority,

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java Tue Oct 16 00:02:55 2012
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.net.URISyntaxException;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileChecksum;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileUtil;

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java Tue Oct 16 00:02:55 2012
@@ -25,7 +25,6 @@ import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -82,6 +81,7 @@ public abstract class ClientBaseWithFixe
      *
      */
     protected class NullWatcher implements Watcher {
+        @Override
         public void process(WatchedEvent event) { /* nada */ }
     }
 
@@ -97,6 +97,7 @@ public abstract class ClientBaseWithFixe
             clientConnected = new CountDownLatch(1);
             connected = false;
         }
+        @Override
         synchronized public void process(WatchedEvent event) {
             if (event.getState() == KeeperState.SyncConnected ||
                 event.getState() == KeeperState.ConnectedReadOnly) {

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/DummyHAService.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/DummyHAService.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/DummyHAService.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/DummyHAService.java Tue Oct 16 00:02:55 2012
@@ -184,6 +184,7 @@ class DummyHAService extends HAServiceTa
   }
   
   public static class DummyFencer implements FenceMethod {
+    @Override
     public void checkArgs(String args) throws BadFencingConfigurationException {
     }
 

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestGlobalFilter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestGlobalFilter.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestGlobalFilter.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestGlobalFilter.java Tue Oct 16 00:02:55 2012
@@ -46,14 +46,17 @@ public class TestGlobalFilter extends Ht
   static public class RecordingFilter implements Filter {
     private FilterConfig filterConfig = null;
 
+    @Override
     public void init(FilterConfig filterConfig) {
       this.filterConfig = filterConfig;
     }
 
+    @Override
     public void destroy() {
       this.filterConfig = null;
     }
 
+    @Override
     public void doFilter(ServletRequest request, ServletResponse response,
         FilterChain chain) throws IOException, ServletException {
       if (filterConfig == null)
@@ -69,6 +72,7 @@ public class TestGlobalFilter extends Ht
     static public class Initializer extends FilterInitializer {
       public Initializer() {}
 
+      @Override
       public void initFilter(FilterContainer container, Configuration conf) {
         container.addGlobalFilter("recording", RecordingFilter.class.getName(), null);
       }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestPathFilter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestPathFilter.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestPathFilter.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestPathFilter.java Tue Oct 16 00:02:55 2012
@@ -46,14 +46,17 @@ public class TestPathFilter extends Http
   static public class RecordingFilter implements Filter {
     private FilterConfig filterConfig = null;
 
+    @Override
     public void init(FilterConfig filterConfig) {
       this.filterConfig = filterConfig;
     }
 
+    @Override
     public void destroy() {
       this.filterConfig = null;
     }
 
+    @Override
     public void doFilter(ServletRequest request, ServletResponse response,
         FilterChain chain) throws IOException, ServletException {
       if (filterConfig == null)
@@ -69,6 +72,7 @@ public class TestPathFilter extends Http
     static public class Initializer extends FilterInitializer {
       public Initializer() {}
 
+      @Override
       public void initFilter(FilterContainer container, Configuration conf) {
         container.addFilter("recording", RecordingFilter.class.getName(), null);
       }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestServletFilter.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestServletFilter.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestServletFilter.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestServletFilter.java Tue Oct 16 00:02:55 2012
@@ -35,6 +35,7 @@ import javax.servlet.http.HttpServletReq
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.test.GenericTestUtils;
 import org.junit.Test;
 
 public class TestServletFilter extends HttpServerFunctionalTest {
@@ -45,14 +46,17 @@ public class TestServletFilter extends H
   static public class SimpleFilter implements Filter {
     private FilterConfig filterConfig = null;
 
+    @Override
     public void init(FilterConfig filterConfig) throws ServletException {
       this.filterConfig = filterConfig;
     }
 
+    @Override
     public void destroy() {
       this.filterConfig = null;
     }
 
+    @Override
     public void doFilter(ServletRequest request, ServletResponse response,
         FilterChain chain) throws IOException, ServletException {
       if (filterConfig == null)
@@ -67,6 +71,7 @@ public class TestServletFilter extends H
     static public class Initializer extends FilterInitializer {
       public Initializer() {}
 
+      @Override
       public void initFilter(FilterContainer container, Configuration conf) {
         container.addFilter("simple", SimpleFilter.class.getName(), null);
       }
@@ -149,6 +154,7 @@ public class TestServletFilter extends H
       public Initializer() {
       }
 
+      @Override
       public void initFilter(FilterContainer container, Configuration conf) {
         container.addFilter("simple", ErrorFilter.class.getName(), null);
       }
@@ -158,7 +164,7 @@ public class TestServletFilter extends H
   @Test
   public void testServletFilterWhenInitThrowsException() throws Exception {
     Configuration conf = new Configuration();
-    // start a http server with CountingFilter
+    // start a http server with ErrorFilter
     conf.set(HttpServer.FILTER_INITIALIZER_PROPERTY,
         ErrorFilter.Initializer.class.getName());
     HttpServer http = createTestServer(conf);
@@ -169,4 +175,25 @@ public class TestServletFilter extends H
       assertTrue( e.getMessage().contains("Problem in starting http server. Server handlers failed"));
     }
   }
+  
+  /**
+   * Similar to the above test case, except that it uses a different API to add the
+   * filter. Regression test for HADOOP-8786.
+   */
+  @Test
+  public void testContextSpecificServletFilterWhenInitThrowsException()
+      throws Exception {
+    Configuration conf = new Configuration();
+    HttpServer http = createTestServer(conf);
+    http.defineFilter(http.webAppContext,
+        "ErrorFilter", ErrorFilter.class.getName(),
+        null, null);
+    try {
+      http.start();
+      fail("expecting exception");
+    } catch (IOException e) {
+      GenericTestUtils.assertExceptionContains("Unable to initialize WebAppContext", e);
+    }
+  }
+
 }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/AvroTestUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/AvroTestUtil.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/AvroTestUtil.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/AvroTestUtil.java Tue Oct 16 00:02:55 2012
@@ -18,12 +18,10 @@
 
 package org.apache.hadoop.io;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.lang.reflect.Type;
 
 import org.apache.avro.Schema;
-import org.apache.avro.io.BinaryEncoder;
 import org.apache.avro.io.EncoderFactory;
 import org.apache.avro.reflect.ReflectData;
 import org.apache.avro.reflect.ReflectDatumWriter;

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/RandomDatum.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/RandomDatum.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/RandomDatum.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/RandomDatum.java Tue Oct 16 00:02:55 2012
@@ -21,6 +21,7 @@ package org.apache.hadoop.io;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Random;
 
 
@@ -40,11 +41,13 @@ public class RandomDatum implements Writ
     return length;
   }
   
+  @Override
   public void write(DataOutput out) throws IOException {
     out.writeInt(length);
     out.write(data);
   }
 
+  @Override
   public void readFields(DataInput in) throws IOException {
     length = in.readInt();
     if (data == null || length > data.length)
@@ -63,6 +66,11 @@ public class RandomDatum implements Writ
     return compareTo((RandomDatum)o) == 0;
   }
 
+  @Override
+  public int hashCode() {
+    return Arrays.hashCode(this.data);
+  }
+  
   private static final char[] HEX_DIGITS =
   {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
 
@@ -102,6 +110,7 @@ public class RandomDatum implements Writ
       super(RandomDatum.class);
     }
 
+    @Override
     public int compare(byte[] b1, int s1, int l1,
                        byte[] b2, int s2, int l2) {
       int n1 = readInt(b1, s1);

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestEnumSetWritable.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestEnumSetWritable.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestEnumSetWritable.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestEnumSetWritable.java Tue Oct 16 00:02:55 2012
@@ -19,17 +19,9 @@
 package org.apache.hadoop.io;
 
 import java.io.IOException;
-import java.io.ByteArrayOutputStream;
 import java.util.EnumSet;
 import java.lang.reflect.Type;
 
-import org.apache.avro.Schema;
-import org.apache.avro.reflect.ReflectData;
-import org.apache.avro.reflect.ReflectDatumWriter;
-import org.apache.avro.reflect.ReflectDatumReader;
-import org.apache.avro.io.BinaryEncoder;
-import org.apache.avro.io.DecoderFactory;
-
 import junit.framework.TestCase;
 
 /** Unit test for EnumSetWritable */

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestGenericWritable.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestGenericWritable.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestGenericWritable.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestGenericWritable.java Tue Oct 16 00:02:55 2012
@@ -48,9 +48,11 @@ public class TestGenericWritable extends
   /** Dummy class for testing {@link GenericWritable} */
   public static class Foo implements Writable {
     private String foo = "foo";
+    @Override
     public void readFields(DataInput in) throws IOException {
       foo = Text.readString(in);
     }
+    @Override
     public void write(DataOutput out) throws IOException {
       Text.writeString(out, foo);
     }
@@ -65,15 +67,19 @@ public class TestGenericWritable extends
   public static class Bar implements Writable, Configurable {
     private int bar = 42; //The Answer to The Ultimate Question Of Life, the Universe and Everything
     private Configuration conf = null;
+    @Override
     public void readFields(DataInput in) throws IOException {
       bar = in.readInt();
     }
+    @Override
     public void write(DataOutput out) throws IOException {
       out.writeInt(bar);
     }
+    @Override
     public Configuration getConf() {
       return conf;
     }
+    @Override
     public void setConf(Configuration conf) {
       this.conf = conf;
     }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtils.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtils.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestIOUtils.java Tue Oct 16 00:02:55 2012
@@ -67,6 +67,36 @@ public class TestIOUtils {
   }
 
   @Test
+  public void testCopyBytesShouldCloseInputSteamWhenOutputStreamCloseThrowsRunTimeException()
+      throws Exception {
+    InputStream inputStream = Mockito.mock(InputStream.class);
+    OutputStream outputStream = Mockito.mock(OutputStream.class);
+    Mockito.doReturn(-1).when(inputStream).read(new byte[1]);
+    Mockito.doThrow(new RuntimeException()).when(outputStream).close();
+    try {
+      IOUtils.copyBytes(inputStream, outputStream, 1, true);
+      fail("Didn't throw exception");
+    } catch (RuntimeException e) {
+    }
+    Mockito.verify(outputStream, Mockito.atLeastOnce()).close();
+  }
+
+  @Test
+  public void testCopyBytesShouldCloseInputSteamWhenInputStreamCloseThrowsRunTimeException()
+      throws Exception {
+    InputStream inputStream = Mockito.mock(InputStream.class);
+    OutputStream outputStream = Mockito.mock(OutputStream.class);
+    Mockito.doReturn(-1).when(inputStream).read(new byte[1]);
+    Mockito.doThrow(new RuntimeException()).when(inputStream).close();
+    try {
+      IOUtils.copyBytes(inputStream, outputStream, 1, true);
+      fail("Didn't throw exception");
+    } catch (RuntimeException e) {
+    }
+    Mockito.verify(inputStream, Mockito.atLeastOnce()).close();
+  }
+
+  @Test
   public void testCopyBytesShouldNotCloseStreamsWhenCloseIsFalse()
       throws Exception {
     InputStream inputStream = Mockito.mock(InputStream.class);
@@ -76,7 +106,7 @@ public class TestIOUtils {
     Mockito.verify(inputStream, Mockito.atMost(0)).close();
     Mockito.verify(outputStream, Mockito.atMost(0)).close();
   }
-  
+
   @Test
   public void testCopyBytesWithCountShouldCloseStreamsWhenCloseIsTrue()
       throws Exception {
@@ -117,7 +147,7 @@ public class TestIOUtils {
     Mockito.verify(inputStream, Mockito.atLeastOnce()).close();
     Mockito.verify(outputStream, Mockito.atLeastOnce()).close();
   }
-  
+
   @Test
   public void testWriteFully() throws IOException {
     final int INPUT_BUFFER_LEN = 10000;
@@ -148,6 +178,7 @@ public class TestIOUtils {
       for (int i = HALFWAY; i < input.length; i++) {
         assertEquals(input[i - HALFWAY], output[i]);
       }
+      raf.close();
     } finally {
       File f = new File(TEST_FILE_NAME);
       if (f.exists()) {
@@ -177,7 +208,7 @@ public class TestIOUtils {
           "Error while reading compressed data", ioe);
     }
   }
-  
+
   @Test
   public void testSkipFully() throws IOException {
     byte inArray[] = new byte[] {0, 1, 2, 3, 4};

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMD5Hash.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMD5Hash.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMD5Hash.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMD5Hash.java Tue Oct 16 00:02:55 2012
@@ -91,6 +91,7 @@ public class TestMD5Hash extends TestCas
                closeHash1.hashCode() != closeHash2.hashCode());
      
     Thread t1 = new Thread() {      
+      @Override
       public void run() {
         for (int i = 0; i < 100; i++) {
           MD5Hash hash = new MD5Hash(DFF);
@@ -100,6 +101,7 @@ public class TestMD5Hash extends TestCas
     };
     
     Thread t2 = new Thread() {
+      @Override
       public void run() {
         for (int i = 0; i < 100; i++) {
           MD5Hash hash = new MD5Hash(D00);

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSecureIOUtils.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSecureIOUtils.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSecureIOUtils.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSecureIOUtils.java Tue Oct 16 00:02:55 2012
@@ -21,17 +21,14 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.io.nativeio.NativeIO;
 
 import org.junit.BeforeClass;
-import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assume.*;
 import static org.junit.Assert.*;
 import java.io.IOException;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileOutputStream;
 
 public class TestSecureIOUtils {

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java Tue Oct 16 00:02:55 2012
@@ -481,6 +481,7 @@ public class TestSequenceFile extends Te
       super(in);
     }
 
+    @Override
     public void close() throws IOException {
       closed = true;
       super.close();
@@ -505,6 +506,7 @@ public class TestSequenceFile extends Te
     try {
       new SequenceFile.Reader(fs, path, conf) {
         // this method is called by the SequenceFile.Reader constructor, overwritten, so we can access the opened file
+        @Override
         protected FSDataInputStream openFile(FileSystem fs, Path file, int bufferSize, long length) throws IOException {
           final InputStream in = super.openFile(fs, file, bufferSize, length);
           openedFile[0] = new TestFSDataInputStream(in);

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestText.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestText.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestText.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestText.java Tue Oct 16 00:02:55 2012
@@ -284,6 +284,7 @@ public class TestText extends TestCase {
       super(name);
     }
 
+    @Override
     public void run() {
       String name = this.getName();
       DataOutputBuffer out = new DataOutputBuffer();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestVersionedWritable.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestVersionedWritable.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestVersionedWritable.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestVersionedWritable.java Tue Oct 16 00:02:55 2012
@@ -37,16 +37,19 @@ public class TestVersionedWritable exten
 
 		
     private static byte VERSION = 1;
+    @Override
     public byte getVersion() { 
       return VERSION; 
     }		
 		
 
+    @Override
     public void write(DataOutput out) throws IOException {
       super.write(out); // version.
       out.writeInt(state);
     }
 		
+    @Override
     public void readFields(DataInput in) throws IOException {
       super.readFields(in); // version
       this.state = in.readInt();
@@ -61,6 +64,7 @@ public class TestVersionedWritable exten
 		
 
     /** Required by test code, below. */
+    @Override
     public boolean equals(Object o) {
       if (!(o instanceof SimpleVersionedWritable))
         return false;
@@ -85,6 +89,7 @@ public class TestVersionedWritable exten
     SimpleVersionedWritable containedObject = new SimpleVersionedWritable();
     String[] testStringArray = {"The", "Quick", "Brown", "Fox", "Jumped", "Over", "The", "Lazy", "Dog"};
 
+    @Override
     public void write(DataOutput out) throws IOException {
       super.write(out);
       out.writeUTF(shortTestString); 
@@ -97,6 +102,7 @@ public class TestVersionedWritable exten
     }
 		
 		
+    @Override
     public void readFields(DataInput in) throws IOException {
       super.readFields(in);
       shortTestString = in.readUTF();
@@ -108,6 +114,7 @@ public class TestVersionedWritable exten
 			
 
 
+    @Override
     public boolean equals(Object o) {
       super.equals(o);
 
@@ -134,6 +141,7 @@ public class TestVersionedWritable exten
   /* This one checks that version mismatch is thrown... */
   public static class SimpleVersionedWritableV2 extends SimpleVersionedWritable {
     static byte VERSION = 2;
+    @Override
     public byte getVersion() { 
       return VERSION; 
     }		

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWritable.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWritable.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWritable.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWritable.java Tue Oct 16 00:02:55 2012
@@ -38,10 +38,12 @@ public class TestWritable extends TestCa
 
     int state = RANDOM.nextInt();
 
+    @Override
     public void write(DataOutput out) throws IOException {
       out.writeInt(state);
     }
 
+    @Override
     public void readFields(DataInput in) throws IOException {
       this.state = in.readInt();
     }
@@ -53,6 +55,7 @@ public class TestWritable extends TestCa
     }
 
     /** Required by test code, below. */
+    @Override
     public boolean equals(Object o) {
       if (!(o instanceof SimpleWritable))
         return false;

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWritableName.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWritableName.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWritableName.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWritableName.java Tue Oct 16 00:02:55 2012
@@ -39,10 +39,12 @@ public class TestWritableName extends Te
 
     int state = RANDOM.nextInt();
 
+    @Override
     public void write(DataOutput out) throws IOException {
       out.writeInt(state);
     }
 
+    @Override
     public void readFields(DataInput in) throws IOException {
       this.state = in.readInt();
     }
@@ -54,6 +56,7 @@ public class TestWritableName extends Te
     }
 
     /** Required by test code, below. */
+    @Override
     public boolean equals(Object o) {
       if (!(o instanceof SimpleWritable))
         return false;

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodec.java Tue Oct 16 00:02:55 2012
@@ -34,6 +34,8 @@ import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Random;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.GZIPOutputStream;
@@ -52,7 +54,6 @@ import org.apache.hadoop.io.SequenceFile
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.SequenceFile.CompressionType;
-import org.apache.hadoop.io.compress.snappy.LoadSnappy;
 import org.apache.hadoop.io.compress.zlib.BuiltInGzipDecompressor;
 import org.apache.hadoop.io.compress.zlib.BuiltInZlibDeflater;
 import org.apache.hadoop.io.compress.zlib.BuiltInZlibInflater;
@@ -101,14 +102,9 @@ public class TestCodec {
   
   @Test
   public void testSnappyCodec() throws IOException {
-    if (LoadSnappy.isAvailable()) {
-      if (LoadSnappy.isLoaded()) {
-        codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.SnappyCodec");
-        codecTest(conf, seed, count, "org.apache.hadoop.io.compress.SnappyCodec");
-      }
-      else {
-        Assert.fail("Snappy native available but Hadoop native not");
-      }
+    if (SnappyCodec.isNativeCodeLoaded()) {
+      codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.SnappyCodec");
+      codecTest(conf, seed, count, "org.apache.hadoop.io.compress.SnappyCodec");
     }
   }
   
@@ -202,6 +198,15 @@ public class TestCodec {
       v2.readFields(inflateIn);
       assertTrue("original and compressed-then-decompressed-output not equal",
                  k1.equals(k2) && v1.equals(v2));
+      
+      // original and compressed-then-decompressed-output have the same hashCode
+      Map<RandomDatum, String> m = new HashMap<RandomDatum, String>();
+      m.put(k1, k1.toString());
+      m.put(v1, v1.toString());
+      String result = m.get(k2);
+      assertEquals("k1 and k2 hashcode not equal", result, k1.toString());
+      result = m.get(v2);
+      assertEquals("v1 and v2 hashcode not equal", result, v1.toString());
     }
 
     // De-compress data byte-at-a-time

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodecFactory.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodecFactory.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodecFactory.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodecFactory.java Tue Oct 16 00:02:55 2012
@@ -40,68 +40,81 @@ public class TestCodecFactory extends Te
       return conf;
     }
     
+    @Override
     public CompressionOutputStream createOutputStream(OutputStream out) 
     throws IOException {
       return null;
     }
     
+    @Override
     public Class<? extends Compressor> getCompressorType() {
       return null;
     }
 
+    @Override
     public Compressor createCompressor() {
       return null;
     }
 
+    @Override
     public CompressionInputStream createInputStream(InputStream in, 
                                                     Decompressor decompressor) 
     throws IOException {
       return null;
     }
 
+    @Override
     public CompressionInputStream createInputStream(InputStream in) 
     throws IOException {
       return null;
     }
 
+    @Override
     public CompressionOutputStream createOutputStream(OutputStream out, 
                                                       Compressor compressor) 
     throws IOException {
       return null;
     }
 
+    @Override
     public Class<? extends Decompressor> getDecompressorType() {
       return null;
     }
 
+    @Override
     public Decompressor createDecompressor() {
       return null;
     }
 
+    @Override
     public String getDefaultExtension() {
       return ".base";
     }
   }
   
   private static class BarCodec extends BaseCodec {
+    @Override
     public String getDefaultExtension() {
       return "bar";
     }
   }
   
   private static class FooBarCodec extends BaseCodec {
+    @Override
     public String getDefaultExtension() {
       return ".foo.bar";
     }
   }
   
   private static class FooCodec extends BaseCodec {
+    @Override
     public String getDefaultExtension() {
       return ".foo";
     }
   }
   
   private static class NewGzipCodec extends BaseCodec {
+    @Override
     public String getDefaultExtension() {
       return ".gz";
     }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/NanoTimer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/NanoTimer.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/NanoTimer.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/NanoTimer.java Tue Oct 16 00:02:55 2012
@@ -93,6 +93,7 @@ public class NanoTimer {
    * 
    * Note: If timer is never started, "ERR" will be returned.
    */
+  @Override
   public String toString() {
     if (!readable()) {
       return "ERR";

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileByteArrays.java Tue Oct 16 00:02:55 2012
@@ -35,7 +35,6 @@ import org.apache.hadoop.io.file.tfile.T
 import org.apache.hadoop.io.file.tfile.TFile.Writer;
 import org.apache.hadoop.io.file.tfile.TFile.Reader.Location;
 import org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner;
-import org.apache.hadoop.util.NativeCodeLoader;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsJClassComparatorByteArrays.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsJClassComparatorByteArrays.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsJClassComparatorByteArrays.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileNoneCodecsJClassComparatorByteArrays.java Tue Oct 16 00:02:55 2012
@@ -19,9 +19,6 @@ package org.apache.hadoop.io.file.tfile;
 
 import java.io.IOException;
 
-import org.apache.hadoop.io.RawComparator;
-import org.apache.hadoop.io.WritableComparator;
-
 /**
  * 
  * Byte arrays test case class using GZ compression codec, base class of none

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/file/tfile/TestTFileSeqFileComparison.java Tue Oct 16 00:02:55 2012
@@ -148,12 +148,14 @@ public class TestTFileSeqFileComparison 
       this.writer = new TFile.Writer(fsdos, minBlkSize, compress, null, conf);
     }
 
+    @Override
     public void append(BytesWritable key, BytesWritable value)
         throws IOException {
       writer.append(key.get(), 0, key.getSize(), value.get(), 0, value
           .getSize());
     }
 
+    @Override
     public void close() throws IOException {
       writer.close();
       fsdos.close();
@@ -196,22 +198,27 @@ public class TestTFileSeqFileComparison 
               - valueBuffer.length)];
     }
 
+    @Override
     public byte[] getKey() {
       return keyBuffer;
     }
 
+    @Override
     public int getKeyLength() {
       return keyLength;
     }
 
+    @Override
     public byte[] getValue() {
       return valueBuffer;
     }
 
+    @Override
     public int getValueLength() {
       return valueLength;
     }
 
+    @Override
     public boolean next() throws IOException {
       if (scanner.atEnd()) return false;
       Entry entry = scanner.entry();
@@ -225,6 +232,7 @@ public class TestTFileSeqFileComparison 
       return true;
     }
 
+    @Override
     public void close() throws IOException {
       scanner.close();
       reader.close();
@@ -266,11 +274,13 @@ public class TestTFileSeqFileComparison 
       }
     }
 
+    @Override
     public void append(BytesWritable key, BytesWritable value)
         throws IOException {
       writer.append(key, value);
     }
 
+    @Override
     public void close() throws IOException {
       writer.close();
       fsdos.close();
@@ -291,26 +301,32 @@ public class TestTFileSeqFileComparison 
       value = new BytesWritable();
     }
 
+    @Override
     public byte[] getKey() {
       return key.get();
     }
 
+    @Override
     public int getKeyLength() {
       return key.getSize();
     }
 
+    @Override
     public byte[] getValue() {
       return value.get();
     }
 
+    @Override
     public int getValueLength() {
       return value.getSize();
     }
 
+    @Override
     public boolean next() throws IOException {
       return reader.next(key, value);
     }
 
+    @Override
     public void close() throws IOException {
       reader.close();
     }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/nativeio/TestNativeIO.java Tue Oct 16 00:02:55 2012
@@ -67,7 +67,7 @@ public class TestNativeIO {
 
     assertEquals(System.getProperty("user.name"), stat.getOwner());
     assertNotNull(stat.getGroup());
-    assertTrue(!"".equals(stat.getGroup()));
+    assertTrue(!stat.getGroup().isEmpty());
     assertEquals("Stat mode field should indicate a regular file",
       NativeIO.Stat.S_IFREG, stat.getMode() & NativeIO.Stat.S_IFMT);
   }
@@ -88,6 +88,7 @@ public class TestNativeIO {
     List<Thread> statters = new ArrayList<Thread>();
     for (int i = 0; i < 10; i++) {
       Thread statter = new Thread() {
+        @Override
         public void run() {
           long et = Time.now() + 5000;
           while (Time.now() < et) {
@@ -95,7 +96,7 @@ public class TestNativeIO {
               NativeIO.Stat stat = NativeIO.fstat(fos.getFD());
               assertEquals(System.getProperty("user.name"), stat.getOwner());
               assertNotNull(stat.getGroup());
-              assertTrue(!"".equals(stat.getGroup()));
+              assertTrue(!stat.getGroup().isEmpty());
               assertEquals("Stat mode field should indicate a regular file",
                 NativeIO.Stat.S_IFREG, stat.getMode() & NativeIO.Stat.S_IFMT);
             } catch (Throwable t) {

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java Tue Oct 16 00:02:55 2012
@@ -252,6 +252,7 @@ public class TestFailoverProxy {
       this.unreliable = unreliable;
     }
     
+    @Override
     public void run() {
       try {
         result = unreliable.failsIfIdentifierDoesntMatch("impl2");

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/UnreliableImplementation.java Tue Oct 16 00:02:55 2012
@@ -19,7 +19,6 @@ package org.apache.hadoop.io.retry;
 
 import java.io.IOException;
 
-import org.apache.hadoop.io.retry.UnreliableInterface.UnreliableException;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.ipc.StandbyException;
 
@@ -60,24 +59,29 @@ public class UnreliableImplementation im
     this.exceptionToFailWith = exceptionToFailWith;
   }
   
+  @Override
   public void alwaysSucceeds() {
     // do nothing
   }
   
+  @Override
   public void alwaysFailsWithFatalException() throws FatalException {
     throw new FatalException();
   }
   
+  @Override
   public void alwaysFailsWithRemoteFatalException() throws RemoteException {
     throw new RemoteException(FatalException.class.getName(), "Oops");
   }
 
+  @Override
   public void failsOnceThenSucceeds() throws UnreliableException {
     if (failsOnceInvocationCount++ == 0) {
       throw new UnreliableException();
     }
   }
 
+  @Override
   public boolean failsOnceThenSucceedsWithReturnValue() throws UnreliableException {
     if (failsOnceWithValueInvocationCount++ == 0) {
       throw new UnreliableException();
@@ -85,6 +89,7 @@ public class UnreliableImplementation im
     return true;
   }
 
+  @Override
   public void failsTenTimesThenSucceeds() throws UnreliableException {
     if (failsTenTimesInvocationCount++ < 10) {
       throw new UnreliableException();

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestSerializationFactory.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestSerializationFactory.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestSerializationFactory.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestSerializationFactory.java Tue Oct 16 00:02:55 2012
@@ -17,27 +17,62 @@
  */
 package org.apache.hadoop.io.serializer;
 
+import org.junit.BeforeClass;
 import org.junit.Test;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertNotNull;
 
+import org.apache.commons.logging.impl.Log4JLogger;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.CommonConfigurationKeys;
 import org.apache.hadoop.io.Writable;
+import org.apache.log4j.Level;
 
 public class TestSerializationFactory {
 
+  static {
+    ((Log4JLogger) SerializationFactory.LOG).getLogger().setLevel(Level.ALL);
+  }
+
+  static Configuration conf;
+  static SerializationFactory factory;
+
+  @BeforeClass
+  public static void setup() throws Exception {
+    conf = new Configuration();
+    factory = new SerializationFactory(conf);
+  }
+
+  @Test
+  public void testSerializationKeyIsEmpty() {
+    Configuration conf = new Configuration();
+    conf.set(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY, "");
+    SerializationFactory factory = new SerializationFactory(conf);
+  }
+
   @Test
-  public void testSerializerAvailability() {
+  public void testSerializationKeyIsInvalid() {
     Configuration conf = new Configuration();
+    conf.set(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY, "INVALID_KEY_XXX");
     SerializationFactory factory = new SerializationFactory(conf);
+  }
+
+  @Test
+  public void testGetSerializer() {
     // Test that a valid serializer class is returned when its present
-    assertNotNull("A valid class must be returned for default Writable Serde",
+    assertNotNull("A valid class must be returned for default Writable SerDe",
         factory.getSerializer(Writable.class));
-    assertNotNull("A valid class must be returned for default Writable serDe",
-        factory.getDeserializer(Writable.class));
     // Test that a null is returned when none can be found.
     assertNull("A null should be returned if there are no serializers found.",
         factory.getSerializer(TestSerializationFactory.class));
+  }
+
+  @Test
+  public void testGetDeserializer() {
+    // Test that a valid serializer class is returned when its present
+    assertNotNull("A valid class must be returned for default Writable SerDe",
+        factory.getDeserializer(Writable.class));
+    // Test that a null is returned when none can be found.
     assertNull("A null should be returned if there are no deserializers found",
         factory.getDeserializer(TestSerializationFactory.class));
   }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestWritableSerialization.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestWritableSerialization.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestWritableSerialization.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestWritableSerialization.java Tue Oct 16 00:02:55 2012
@@ -18,25 +18,34 @@
 
 package org.apache.hadoop.io.serializer;
 
+import java.io.Serializable;
+
+import org.apache.hadoop.io.DataInputBuffer;
+import org.apache.hadoop.io.DataOutputBuffer;
 import static org.apache.hadoop.io.TestGenericWritable.CONF_TEST_KEY;
 import static org.apache.hadoop.io.TestGenericWritable.CONF_TEST_VALUE;
-import junit.framework.TestCase;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.TestGenericWritable.Baz;
 import org.apache.hadoop.io.TestGenericWritable.FooGenericWritable;
+import org.apache.hadoop.io.WritableComparator;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
 
-public class TestWritableSerialization extends TestCase {
+public class TestWritableSerialization {
 
   private static final Configuration conf = new Configuration();
 
+  @Test
   public void testWritableSerialization() throws Exception {
     Text before = new Text("test writable"); 
     Text after = SerializationTestUtil.testSerialization(conf, before);
     assertEquals(before, after);
   }
   
+  @Test
   public void testWritableConfigurable() throws Exception {
     
     //set the configuration parameter
@@ -52,4 +61,42 @@ public class TestWritableSerialization e
     assertEquals(baz, result);
     assertNotNull(result.getConf());
   }
+
+  @Test
+  @SuppressWarnings({"rawtypes", "unchecked"})
+  public void testWritableComparatorJavaSerialization() throws Exception {
+    Serialization ser = new JavaSerialization();
+
+    Serializer<TestWC> serializer = ser.getSerializer(TestWC.class);
+    DataOutputBuffer dob = new DataOutputBuffer();
+    serializer.open(dob);
+    TestWC orig = new TestWC(0);
+    serializer.serialize(orig);
+    serializer.close();
+
+    Deserializer<TestWC> deserializer = ser.getDeserializer(TestWC.class);
+    DataInputBuffer dib = new DataInputBuffer();
+    dib.reset(dob.getData(), 0, dob.getLength());
+    deserializer.open(dib);
+    TestWC deser = deserializer.deserialize(null);
+    deserializer.close();
+    assertEquals(orig, deser);
+  }
+
+  static class TestWC extends WritableComparator implements Serializable {
+    static final long serialVersionUID = 0x4344;
+    final int val;
+    TestWC() { this(7); }
+    TestWC(int val) { this.val = val; }
+    @Override
+    public boolean equals(Object o) {
+      if (o instanceof TestWC) {
+        return ((TestWC)o).val == val;
+      }
+      return false;
+    }
+    @Override
+    public int hashCode() { return val; }
+  }
+
 }

Modified: hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/avro/Record.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/avro/Record.java?rev=1398581&r1=1398580&r2=1398581&view=diff
==============================================================================
--- hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/avro/Record.java (original)
+++ hadoop/common/branches/MR-3902/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/avro/Record.java Tue Oct 16 00:02:55 2012
@@ -21,10 +21,12 @@ package org.apache.hadoop.io.serializer.
 public class Record {
   public int x = 7;
 
+  @Override
   public int hashCode() {
     return x;
   }
 
+  @Override
   public boolean equals(Object obj) {
     if (this == obj)
       return true;



Mime
View raw message