public boolean equals(Object f) { return file.equals(f); }
if(tableModel.hasParentFolder() && folder.equals(tableModel.getParentFolder())) fileToSelect = currentFolder;
/** * Implementation notes: returns <code>true</code> only for local files that are not archive entries and that * reside on the same volume as the trash folder. */ @Override public boolean canMoveToTrash(AbstractFile file) { return TRASH_FOLDER!=null && file.getTopAncestor() instanceof LocalFile && file.getVolume().equals(TRASH_VOLUME); }
/** * Implementation notes: returns <code>true</code> only for local files that are not archive entries and that * reside on the same volume as the trash folder. */ @Override public boolean canMoveToTrash(AbstractFile file) { return TRASH_FOLDER!=null && file.getTopAncestor() instanceof LocalFile && file.getVolume().equals(TRASH_VOLUME); }
@Override public void fireActionPerformed(ActionEvent ae) { if (!folderPanel.getCurrentFolder().equals(folder)) { folderPanel.tryChangeCurrentFolder(folder); } }
/** * Asserts that the <code>ResolvedDestination</code> returned by {@link PathUtils#resolveDestination(String, com.mucommander.commons.file.AbstractFile)} * matches the expected destination file and type. This method asserts that the destination folder is not * <code>null</code> and consistent with the destination file. * * @param resolvedDestination the ResolvedDestination to test * @param expectedDestinationFile the expected destination file * @param expectedDestinationType the expected destination type */ private void assertResult(PathUtils.ResolvedDestination resolvedDestination, AbstractFile expectedDestinationFile, int expectedDestinationType) { AbstractFile file = resolvedDestination.getDestinationFile(); int type = resolvedDestination.getDestinationType(); AbstractFile folder = resolvedDestination.getDestinationFolder(); assert file != null; assert folder != null; assert expectedDestinationFile.equals(file); assert expectedDestinationType == type; if(type==PathUtils.ResolvedDestination.EXISTING_FOLDER) assert file.equals(folder); else assert file.getParent().equals(folder); }
if(!getRoot().equals(destFile.getRoot())) throw new IOException();
if(!getRoot().equals(destFile.getRoot())) throw new IOException();
if (!currentRoot.equals(model.getRoot())) { model.setRoot(currentRoot);
/** * Tests the given volume folder and assert certain properties that a volume folder should have. * * @param volume a volume folder * @throws IOException should not happen */ protected void testVolume(AbstractFile volume) throws IOException { // Test basic volume properties assert volume != null; assert volume.equals(volume.getVolume()); // Volumes may not always exist -- for instance, removable drives under Windows. if(volume.exists()) { // If the volume exists, it must be a directory assert volume.isDirectory(); // Assert that children of the volume are located on the volume (test the first children only) AbstractFile[] children = volume.ls(); if(children.length>0) assert volume.equals(children[0].getVolume()); } }
/** * Asserts that {@link com.mucommander.commons.file.protocol.local.LocalFile#getUserHome()} returns a file that is not null, * is a directory, and exists, and that '~' can be resolved as the user home folder. * * @throws IOException should not happen */ @Test public void testUserHome() throws IOException { AbstractFile homeFolder = LocalFile.getUserHome(); assert homeFolder != null; assert homeFolder.isDirectory(); assert homeFolder.exists(); assert homeFolder.equals(FileFactory.getFile("~")); assert homeFolder.getChild("blah").equals(FileFactory.getFile("~").getChild("blah")); }
/** * Tests {@link AbstractFile#getVolume()}. * * @throws IOException should not happen */ @Test public void testVolume() throws IOException { AbstractFile volume = tempFile.getVolume(); testVolume(volume); // Test the relationship between the temporary file and its volume assert volume.isParentOf(tempFile); // Another temporary file should yield the same volume assert volume.equals(getTemporaryFile().getVolume()); }
/** * Tests {@link com.mucommander.commons.file.FileFactory#getTemporaryFolder()}. * * @throws IOException should not happen */ @Test public void testTemporaryFolder() throws IOException { // Assert that the returned file is a folder that exists AbstractFile temporaryFolder = FileFactory.getTemporaryFolder(); assert temporaryFolder != null; assert temporaryFolder.isDirectory(); assert temporaryFolder.exists(); // Assert that the temporary folder is the parent folder of temporary files AbstractFile temporaryFile = FileFactory.getTemporaryFile(false); assert temporaryFile.getParent().equals(temporaryFolder); }
if(lastSelectedFolder.equals(ThemeManager.getCustomThemesFolder())) populateThemes(theme);
/** * Tests {@link AbstractFile#getParent()} and {@link AbstractFile#isParentOf(AbstractFile)} methods. * * @throws IOException should not happen */ @Test public void testParent() throws IOException { AbstractFile file = tempFile; AbstractFile parent; AbstractFile child; // Tests all parents until the root is reached while((parent=file.getParent())!=null) { assert parent.isParentOf(file); // a file that has a parent shouldn't be a root file assert !file.isRoot(); // Assert that the child file can be resolved into the same file using getDirectChild() child = parent.getDirectChild(file.getName()); assert child != null; assert child.equals(file); file = parent; } // Assert that the root file's parent URL is null: if that is not the case, the parent file should have been // resolved. assert file.getURL().getParent()==null; // A file that has no parent should be a root file assert file.isRoot(); }
assert child.equals(children[0]); assert children[0].exists();
/** * Verifies the given path is not null, that it can be resolved by {@link FileFactory#getFile(String)} into * a file, and that this file is equal to the given one. If the given file is not a directory, the contents of both * file instances are compared to make sure they are equal. * * @param file the file instance that corresponds to the given path * @param path the path that should be resolved into the specified file * @throws IOException should not happen * @throws NoSuchAlgorithmException should not happen */ protected void testPathResolution(AbstractFile file, String path) throws IOException, NoSuchAlgorithmException { assert path != null; // If the file is authenticated, test if the given path contains credentials and if it does not, add the // credentials to it. if(file.getURL().containsCredentials()) { FileURL fileURL = FileURL.getFileURL(path); if(!fileURL.containsCredentials()) { fileURL.setCredentials(file.getURL().getCredentials()); path = fileURL.toString(true); } } // Assert that the file can be resolved again using the path, and that the resolved file is shallow-equal // and deep-equal AbstractFile resolvedFile = FileFactory.getFile(path); assert resolvedFile != null; assert resolvedFile.equals(file); // Shallow equals assert resolvedFile.isDirectory()==file.isDirectory(); if(!file.isDirectory()) assertContentsEquals(file, resolvedFile); // Deep equals (compares contents) }