HDFSFileSystem extends AbstractFileSystem implements FileSystem { @Override @SuppressWarnings( { "unchecked", "rawtypes" } ) protected void addCapabilities( Collection caps ) { caps.addAll( HDFSFileProvider.capabilities ); try { if ( getHDFSFileSystem() != null && Boolean.parseBoolean( getHDFSFileSystem().getProperty( "dfs.support.append", "true" ) ) ) { caps.add( Capability.APPEND_CONTENT ); } } catch ( FileSystemException e ) { throw new RuntimeException( e ); } } HDFSFileSystem( final FileName rootName, final FileSystemOptions fileSystemOptions,
                            HadoopFileSystem hdfs ); HadoopFileSystem getHDFSFileSystem();  }
@Test public void testAddCapabilities() { Collection caps = mock( Collection.class ); hdfsFileSystem.addCapabilities( caps ); verify( caps ).addAll( HDFSFileProvider.capabilities ); }
@Test public void testAddAppendCapabilities() { Collection caps = new ArrayList( ); when( hadoopFileSystem.getProperty( eq( "dfs.support.append" ), anyString() ) ).thenReturn( "false" ); hdfsFileSystem.addCapabilities( caps ); Collection res = new ArrayList( HDFSFileProvider.capabilities ); assertArrayEquals( caps.toArray(), Collections.unmodifiableCollection( res ).toArray() ); caps = new ArrayList( ); when( hadoopFileSystem.getProperty( eq( "dfs.support.append" ), anyString() ) ).thenReturn( "true" ); hdfsFileSystem.addCapabilities( caps ); res.add( Capability.APPEND_CONTENT ); assertArrayEquals( caps.toArray(), Collections.unmodifiableCollection( res ).toArray() ); }