001: /**
002: *
003: * Java FTP client library.
004: *
005: * Copyright (C) 2000 Enterprise Distributed Technologies Ltd
006: *
007: * www.enterprisedt.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022: *
023: * Bug fixes, suggestions and comments should be should posted on
024: * http://www.enterprisedt.com/forums/index.php
025: *
026: * Change Log:
027: *
028: * $Log: TestTimeout.java,v $
029: * Revision 1.9 2007-08-09 00:10:52 hans
030: * Removed unused imports.
031: *
032: * Revision 1.8 2005/07/15 17:30:06 bruceb
033: * rework of unit testing structure
034: *
035: * Revision 1.7 2005/06/03 11:27:05 bruceb
036: * comment update
037: *
038: * Revision 1.6 2004/08/31 10:44:49 bruceb
039: * minor tweaks re compile warnings
040: *
041: * Revision 1.5 2004/05/01 17:05:43 bruceb
042: * Logger stuff added
043: *
044: * Revision 1.4 2004/04/17 18:38:38 bruceb
045: * tweaks for ssl and new parsing functionality
046: *
047: * Revision 1.3 2004/04/05 20:58:42 bruceb
048: * latest hans tweaks to tests
049: *
050: * Revision 1.2 2003/05/31 14:54:05 bruceb
051: * cleaned up unused imports
052: *
053: * Revision 1.1 2003/01/29 22:45:35 bruceb
054: * ??
055: *
056: * Revision 1.1 2002/11/19 22:00:15 bruceb
057: * New JUnit test cases
058: *
059: *
060: */package com.enterprisedt.net.ftp.test;
061:
062: import junit.framework.Test;
063: import junit.framework.TestSuite;
064:
065: import com.enterprisedt.net.ftp.FTPTransferType;
066:
067: /**
068: * Test timeout functionality. On a local network there is
069: * virtually no blocking, so ordinarily timeouts will not
070: * occur on network reads. We do this test in isolation and
071: * pull out a network cable to test the timeout
072: *
073: * @author Bruce Blackshaw
074: * @version $Revision: 1.9 $
075: */
076: public class TestTimeout extends FTPTestCase {
077:
078: /**
079: * Revision control id
080: */
081: public static String cvsId = "@(#)$Id: TestTimeout.java,v 1.9 2007-08-09 00:10:52 hans Exp $";
082:
083: /**
084: * Get name of log file
085: *
086: * @return name of file to log to
087: */
088: protected String getLogName() {
089: return "TestTimeout.log";
090: }
091:
092: /**
093: * Test some general methods
094: */
095: public void testTimeout() throws Exception {
096:
097: connect();
098:
099: // move to test directory
100: ftp.chdir(testdir);
101: ftp.setType(FTPTransferType.BINARY);
102:
103: // put to a random filename
104: String filename = generateRandomFilename();
105: ftp.put(localDataDir + localBinaryFile, filename);
106:
107: // sleep - here we pull out the network!
108: System.out.println("Disconnect network cable now!");
109: Thread.sleep(30000);
110: System.out
111: .println("Trying to read - network should be disconnected");
112:
113: // get it back & delete remotely
114: ftp.get(localDataDir + filename, filename);
115: ftp.delete(filename);
116:
117: fail("Login should have failed with timeout!");
118: }
119:
120: /**
121: * Automatic test suite construction
122: *
123: * @return suite of tests for this class
124: */
125: public static Test suite() {
126: return new TestSuite(TestTimeout.class);
127: }
128:
129: /**
130: * Enable our class to be run, doing the
131: * tests
132: */
133: public static void main(String[] args) {
134: junit.textui.TestRunner.run(suite());
135: }
136:
137: }
|