001: /*
002: * This file is part of DrFTPD, Distributed FTP Daemon.
003: *
004: * DrFTPD is free software; you can redistribute it and/or modify
005: * it under the terms of the GNU General Public License as published by
006: * the Free Software Foundation; either version 2 of the License, or
007: * (at your option) any later version.
008: *
009: * DrFTPD is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with DrFTPD; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018: package org.drftpd.tests;
019:
020: import org.drftpd.master.ConnectionManager;
021: import org.drftpd.remotefile.FileUtils;
022: import org.drftpd.remotefile.LinkedRemoteFileInterface;
023:
024: import org.drftpd.sections.SectionInterface;
025: import org.drftpd.sections.SectionManagerInterface;
026:
027: import java.io.FileNotFoundException;
028:
029: import java.util.Collection;
030:
031: public class DummySectionManager implements SectionManagerInterface {
032: private LinkedRemoteFileInterface _sectionDir;
033: private SectionInterface _section = new SectionInterface() {
034: public LinkedRemoteFileInterface getFile() {
035: return _sectionDir;
036: }
037:
038: public Collection getFiles() {
039: throw new UnsupportedOperationException();
040: }
041:
042: public String getName() {
043: throw new UnsupportedOperationException();
044: }
045:
046: public String getPath() {
047: return getFile().getPath();
048: }
049:
050: public LinkedRemoteFileInterface getFirstDirInSection(
051: LinkedRemoteFileInterface dir) {
052: // LinkedRemoteFileInterface dir1 = dir, dir2 = dir;
053: // while(dir1 != getFile()) {
054: // dir2 = dir1;
055: // try {
056: // dir1 = dir1.getParentFile();
057: // } catch (FileNotFoundException e) {
058: // return getFile();
059: // }
060: // }
061: // return dir2;
062: try {
063: return FileUtils.getSubdirOfDirectory(getFile(), dir);
064: } catch (FileNotFoundException e) {
065: return dir;
066: }
067: }
068:
069: public LinkedRemoteFileInterface getBaseFile() {
070: return getFile();
071: }
072:
073: public String getBasePath() {
074: return getPath();
075: }
076: };
077:
078: public DummySectionManager(LinkedRemoteFileInterface sectionDir) {
079: _sectionDir = sectionDir;
080: }
081:
082: public SectionInterface getSection(String string) {
083: return _section;
084: }
085:
086: public void reload() {
087: }
088:
089: public ConnectionManager getConnectionManager() {
090: throw new UnsupportedOperationException();
091: }
092:
093: public Collection getSections() {
094: throw new UnsupportedOperationException();
095: }
096:
097: public SectionInterface lookup(String string) {
098: return _section;
099: }
100:
101: public SectionInterface lookup(LinkedRemoteFileInterface file) {
102: return _section;
103: }
104: }
|