private static SimpleFileAttributes getDefaultAttributes() { SimpleFileAttributes attributes = new SimpleFileAttributes(); attributes.setDate(System.currentTimeMillis()); attributes.setSize(-1); // Unknown attributes.setPermissions(PERMISSIONS); // exist = false // isDirectory = false // path = null (unused) return attributes; }
/** * Creates a SimpleFileAttributes instance from an AbstractFile and ensures that the values returned by * SimpleFileAttributes' getters match those of AbstractFile. * * @throws IOException should not happen */ @Test public void testAccessors() throws IOException { LocalFileTest lft = new LocalFileTest(); // File doesn't exist AbstractFile tempFile = lft.getTemporaryFile(); assertAttributesMatch(tempFile, new SimpleFileAttributes(tempFile)); // File exists as a regular file tempFile.mkfile(); assertAttributesMatch(tempFile, new SimpleFileAttributes(tempFile)); // File exists as a directory tempFile.delete(); tempFile.mkdir(); assertAttributesMatch(tempFile, new SimpleFileAttributes(tempFile)); }
protected S3Root(FileURL url, S3Service service) { super(url, service); atts = new SimpleFileAttributes(); atts.setPath("/"); atts.setExists(true); atts.setDate(0); atts.setSize(0); atts.setDirectory(true); atts.setPermissions(DEFAULT_PERMISSIONS); atts.setOwner(null); atts.setGroup(null); }
/** * Creates a SimpleFileAttributes instance with the no-arg constructor and ensures that the default values returned * by SimpleFileAttributes' getters are as specified by {@link FileAttributes}. */ @Test public void testDefaultValues() { SimpleFileAttributes attrs = new SimpleFileAttributes(); assert attrs.getPath() == null; assert !attrs.exists(); assert 0 == attrs.getDate(); assert 0 == attrs.getSize(); assert !attrs.isDirectory(); assert attrs.getPermissions() == null; assert attrs.getOwner() == null; assert attrs.getGroup() == null; } }