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 net.sf.drftpd.event.Event;
021: import net.sf.drftpd.master.BaseFtpConnection;
022: import net.sf.drftpd.master.FtpRequest;
023: import net.sf.drftpd.master.command.CommandManager;
024: import net.sf.drftpd.master.command.plugins.DataConnectionHandler;
025:
026: import org.drftpd.Bytes;
027: import org.drftpd.remotefile.LinkedRemoteFile;
028: import org.drftpd.remotefile.StaticRemoteFile;
029: import org.drftpd.usermanager.NoSuchUserException;
030: import org.drftpd.usermanager.User;
031:
032: import java.io.IOException;
033: import java.io.PrintWriter;
034: import java.io.StringWriter;
035:
036: import java.net.InetAddress;
037: import java.net.Socket;
038:
039: import java.util.Collections;
040:
041: import javax.net.ServerSocketFactory;
042: import javax.net.SocketFactory;
043:
044: /**
045: * @author mog
046: * @version $Id: DummyBaseFtpConnection.java 1243 2005-09-04 02:21:12Z zubov $
047: */
048: public class DummyBaseFtpConnection extends BaseFtpConnection {
049: private InetAddress _clientAddress;
050: private DataConnectionHandler _dch;
051: private StringWriter _out2;
052: private DummyServerSocketFactory _serverSocketFactory;
053: private DummySocketFactory _socketFactory;
054:
055: public DummyBaseFtpConnection(DataConnectionHandler dch) {
056: _dch = dch;
057: _socketFactory = new DummySocketFactory();
058: _serverSocketFactory = new DummyServerSocketFactory(
059: _socketFactory);
060:
061: _currentDirectory = new LinkedRemoteFile(null);
062: _currentDirectory.addFile(new StaticRemoteFile(
063: Collections.EMPTY_LIST, "testfile", "drftpd", "drftpd",
064: Bytes.parseBytes("10M"), System.currentTimeMillis()));
065: _out2 = new StringWriter();
066: _out = new PrintWriter(_out2);
067: }
068:
069: protected Object clone() throws CloneNotSupportedException {
070: throw new UnsupportedOperationException();
071: }
072:
073: /**
074: * @deprecated
075: */
076: protected void dispatchFtpEvent(Event event) {
077: throw new UnsupportedOperationException();
078: }
079:
080: /* (non-Javadoc)
081: * @see java.lang.Object#equals(java.lang.Object)
082: */
083: public boolean equals(Object obj) {
084: throw new UnsupportedOperationException();
085: }
086:
087: public InetAddress getClientAddress() {
088: if (_clientAddress == null) {
089: throw new NullPointerException();
090: }
091:
092: return _clientAddress;
093: }
094:
095: public CommandManager getCommandManager() {
096: throw new UnsupportedOperationException();
097: }
098:
099: public Socket getControlSocket() {
100: return new DummySocket();
101: }
102:
103: public DataConnectionHandler getDataConnectionHandler() {
104: if (_dch == null) {
105: throw new NullPointerException(
106: "No DataConnectionHandler set");
107: }
108:
109: return _dch;
110: }
111:
112: public char getDirection() {
113: throw new UnsupportedOperationException();
114: }
115:
116: public StringWriter getDummyOut() {
117: return _out2;
118: }
119:
120: public DummyServerSocketFactory getDummySSF() {
121: return _serverSocketFactory;
122: }
123:
124: public long getLastActive() {
125: throw new UnsupportedOperationException();
126: }
127:
128: public ServerSocketFactory getServerSocketFactory() {
129: return _serverSocketFactory;
130: }
131:
132: public SocketFactory getSocketFactory() {
133: return _socketFactory;
134: }
135:
136: public char getTransferDirection() {
137: throw new UnsupportedOperationException();
138: }
139:
140: public User getUser() throws NoSuchUserException {
141: throw new UnsupportedOperationException();
142: }
143:
144: /* (non-Javadoc)
145: * @see net.sf.drftpd.master.BaseFtpConnection#getUserNull()
146: */
147: public User getUserNull() {
148: return super .getUserNull();
149: }
150:
151: /* (non-Javadoc)
152: * @see java.lang.Object#hashCode()
153: */
154: public int hashCode() {
155: throw new UnsupportedOperationException();
156: }
157:
158: protected boolean hasPermission(FtpRequest request) {
159: throw new UnsupportedOperationException();
160: }
161:
162: public boolean isExecuting() {
163: throw new UnsupportedOperationException();
164: }
165:
166: /**
167: * @deprecated
168: */
169: public void reset() {
170: throw new UnsupportedOperationException();
171: }
172:
173: public void resetState() {
174: }
175:
176: /* (non-Javadoc)
177: * @see java.lang.Runnable#run()
178: */
179: public void run() {
180: throw new UnsupportedOperationException();
181: }
182:
183: /* (non-Javadoc)
184: * @see net.sf.drftpd.master.BaseFtpConnection#service(net.sf.drftpd.master.FtpRequest, java.io.PrintWriter)
185: */
186: public void service(FtpRequest request, PrintWriter out)
187: throws IOException {
188: throw new UnsupportedOperationException();
189: }
190:
191: public void setClientAddress(InetAddress clientAddress) {
192: _clientAddress = clientAddress;
193: }
194:
195: /* (non-Javadoc)
196: * @see net.sf.drftpd.master.BaseFtpConnection#setControlSocket(java.net.Socket)
197: */
198: public void setControlSocket(Socket socket) {
199: throw new UnsupportedOperationException();
200: }
201:
202: public void setRequest(FtpRequest request) {
203: _request = request;
204: }
205:
206: public void setUser(String user) {
207: super .setUser(user);
208: }
209:
210: /* (non-Javadoc)
211: * @see net.sf.drftpd.master.BaseFtpConnection#start()
212: */
213: public void start() {
214: throw new UnsupportedOperationException();
215: }
216:
217: /* (non-Javadoc)
218: * @see net.sf.drftpd.master.BaseFtpConnection#status()
219: */
220: public String status() {
221: return "dummy status string";
222: }
223:
224: /* (non-Javadoc)
225: * @see net.sf.drftpd.master.BaseFtpConnection#stop()
226: */
227: public void stop() {
228: throw new UnsupportedOperationException();
229: }
230:
231: /* (non-Javadoc)
232: * @see net.sf.drftpd.master.BaseFtpConnection#stop(java.lang.String)
233: */
234: public void stop(String message) {
235: throw new UnsupportedOperationException();
236: }
237:
238: /* (non-Javadoc)
239: * @see java.lang.Object#toString()
240: */
241: public String toString() {
242: throw new UnsupportedOperationException();
243: }
244:
245: public void setGlobalConext(DummyGlobalContext gctx) {
246: _gctx = gctx;
247: }
248: }
|