Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 JBoss Inc
   *
   * Licensed 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.uberfire.java.nio.fs.file;
 
 import java.io.File;
 
 import org.junit.Test;
 import  org.uberfire.java.nio.IOException;
 import  org.uberfire.java.nio.file.FileStore;
 import  org.uberfire.java.nio.file.attribute.BasicFileAttributeView;
 import  org.uberfire.java.nio.file.attribute.BasicFileAttributes;
 import  org.uberfire.java.nio.file.attribute.FileAttributeView;
 import  org.uberfire.java.nio.file.attribute.FileStoreAttributeView;
 import  org.uberfire.java.nio.file.attribute.FileTime;
 
 import static org.fest.assertions.api.Assertions.*;
 
 public class SimpleUnixFileStoreTest {
 
     @Test
     public void simpleTests() {
         final FileStore fileStore = new SimpleUnixFileStorenull );
 
         assertThatfileStore.name() ).isNotNull().isEqualTo( "/" );
         assertThatfileStore.type() ).isNull();
         assertThatfileStore.isReadOnly() ).isFalse();
         assertThatfileStore.getTotalSpace() ).isEqualTo( File.listRoots()[ 0 ].getTotalSpace() );
         assertThatfileStore.getUsableSpace() ).isEqualTo( File.listRoots()[ 0 ].getUsableSpace() );
 
         assertThatfileStore.supportsFileAttributeView( BasicFileAttributeView.class ) ).isTrue();
         assertThatfileStore.supportsFileAttributeView( MyFileAttributeView.class ) ).isFalse();
         assertThatfileStore.supportsFileAttributeView( MyAlsoInvalidFileAttributeView.class ) ).isFalse();
         assertThatfileStore.supportsFileAttributeView( "basic" ) ).isTrue();
         assertThatfileStore.supportsFileAttributeView( "any" ) ).isFalse();
         assertThatfileStore.supportsFileAttributeView( BasicFileAttributeView.class.getName() ) ).isFalse();
         assertThatfileStore.supportsFileAttributeView( MyAlsoInvalidFileAttributeView.class.getName() ) ).isFalse();
         assertThatfileStore.getFileStoreAttributeView( FileStoreAttributeView.class ) ).isNull();
 
         assertThatfileStore.getAttribute( "name" ) ).isNotNull().isEqualTo( fileStore.name() );
         assertThatfileStore.getAttribute( "totalSpace" ) ).isNotNull().isEqualTo( fileStore.getTotalSpace() );
         assertThatfileStore.getAttribute( "usableSpace" ) ).isNotNull().isEqualTo( fileStore.getUsableSpace() );
         assertThatfileStore.getAttribute( "readOnly" ) ).isNotNull().isEqualTo( fileStore.isReadOnly() );
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void getUnallocatedSpaceUnsupportedOp() {
         new SimpleUnixFileStorenull ).getUnallocatedSpace();
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void getAttributeUnsupportedOp() {
         new SimpleUnixFileStorenull ).getAttribute"someValueHere" );
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void supportsFileAttributeViewNull1() {
         new SimpleUnixFileStorenull ).supportsFileAttributeView( (Class<? extends FileAttributeView>) null );
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void supportsFileAttributeViewNull2() {
         new SimpleUnixFileStorenull ).supportsFileAttributeView( (Stringnull );
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void supportsFileAttributeViewEmpty() {
         new SimpleUnixFileStorenull ).supportsFileAttributeView"" );
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void getFileStoreAttributeViewNull() {
         new SimpleUnixFileStorenull ).getFileStoreAttributeViewnull );
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void getAttributeNull() {
         new SimpleUnixFileStorenull ).getAttributenull );
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void getAttributeEmpty() {
         new SimpleUnixFileStorenull ).getAttribute"" );
     }
 
    private static class MyFileAttributeView implements FileAttributeView {
        @Override
        public String name() {
            return null;
        }
    }
    private static class MyAlsoInvalidFileAttributeView implements BasicFileAttributeView {
        @Override
        public BasicFileAttributes readAttributes() throws IOException {
            return null;
        }
        @Override
        public void setTimes( FileTime lastModifiedTime,
                              FileTime lastAccessTime,
                              FileTime createTime ) throws IOException {
        }
        @Override
        public String name() {
            return null;
        }
    }
New to GrepCode? Check out our FAQ X