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.base.GeneralPathImpl;
 import  org.uberfire.java.nio.file.FileStore;
 import  org.uberfire.java.nio.file.FileSystem;
 import  org.uberfire.java.nio.file.Path;
 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  org.uberfire.java.nio.file.spi.FileSystemProvider;
 
 import static org.fest.assertions.api.Assertions.*;
 import static org.mockito.Mockito.*;
 
 public class SimpleWindowsFileStoreTest {
 
     final FileSystemProvider fsProvider  = mock( FileSystemProvider.class );
     final File[]             roots       = new File[]{ new File"c:\\" ), new File"a:\\" ) };
     final FileSystem         fileSystem  = new SimpleWindowsFileSystem"c:\\" );
     final Path               nonNullPath = GeneralPathImpl.create( "c:\\something"false );
 
     @Test
     public void simpleTests() {
         final Path path = GeneralPathImpl.create( "something"false );
         final FileStore fileStore = new SimpleWindowsFileStorepath );
 
         assertThatfileStore.name() ).isNotNull().isEqualTo( "c:\\" );
         assertThatfileStore.type() ).isNull();
         assertThatfileStore.isReadOnly() ).isFalse();
         assertThatfileStore.getTotalSpace() ).isEqualTo( 0L );
         assertThatfileStore.getUsableSpace() ).isEqualTo( 0L );
 
         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 = IllegalArgumentException.class)
     public void contructorWithNullRootsAndPath() {
         new SimpleWindowsFileStore( (File[]) null, (Path) null );
     }
 
     @Test(expected = IllegalStateException.class)
     public void contructorWithEmptyRoots() {
         new SimpleWindowsFileStorenew File[]{ }, null );
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void getUnallocatedSpaceUnsupportedOp() {
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void getAttributeUnsupportedOp() {
         new SimpleWindowsFileStore ).getAttribute"someValueHere" );
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void supportsFileAttributeViewNull1() {
         new SimpleWindowsFileStore ).supportsFileAttributeView( (Class<? extends FileAttributeView>) null );
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void supportsFileAttributeViewNull2() {
         new SimpleWindowsFileStore ).supportsFileAttributeView( (Stringnull );
    }
    @Test(expected = IllegalArgumentException.class)
    public void supportsFileAttributeViewEmpty() {
    }
    @Test(expected = IllegalArgumentException.class)
    public void getFileStoreAttributeViewNull() {
    }
    @Test(expected = IllegalArgumentException.class)
    public void getAttributeNull() {
        new SimpleWindowsFileStore ).getAttributenull );
    }
    @Test(expected = IllegalArgumentException.class)
    public void getAttributeEmpty() {
        new SimpleWindowsFileStore ).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