/**
 *
 *  Java FTP client library.
 *  
 *  Copyright (C) 2000  Enterprise Distributed Technologies Ltd
 *  
 *  www.enterprisedt.com
 *  
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *  
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *  
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *  
 *  Bug fixes, suggestions and comments should be sent to:
 *  
 *  bruceb@cryptsoft.com
 *  
 *  or by snail mail to:
 *  
 *  Bruce P. Blackshaw
 *  53 Wakehurst Road
 *  London SW11 6DB
 *  United Kingdom
 * 
 *  Change Log:  
 *
 *	$Log$
 */

package com.enterprisedt.net.ftp;

import java.io.IOException;

/**
 *  Crude test harness. 
 * 
 *    TO DO: expand this!
 *
 *  @author		Bruce Blackshaw
 *	@version	$Revision:   1.0  $
 *
 */
public class FTPClientTest {


	/**
	 *   Test harness. We have a long way to
	 *   go here! I'll be spending most development
	 *   time hence enhancing this!
	 *
	 *   Planned: 
	 *				- drive off a config file
	 *				- do byte by byte file comparisons of transferred
	 *                files
	 *              - exercise all functionality    
	 *              - postive and negative tests
	 *
	 */
	public static void main(String args[]) {
	
		// we want remote host, user name and password
		if (args.length != 4) {
			usage();
			System.exit(1);
		}
		try {
		
			// assign args to make it clear
			String host = args[0];
			String user = args[1];
			String password = args[2];
			String filename = args[3];
			
			// connect
			FTPClient ftp = new FTPClient(host);
		
			ftp.login(user, password);

			// binary transfer
			ftp.setType(FTPTransferType.BINARY);

			// put a local file to remote host
			ftp.put(filename, filename);
			
			// get a remote file (same one)
			ftp.get(filename + ".tst", filename);

			ftp.quit();
		}
		catch (IOException ex) {
			System.out.println("Caught exception: " + ex.getMessage());
		}
		catch (FTPException ex) {
			System.out.println("Caught exception: " + ex.getMessage());
		}					
	}
	
	
	/**
	 *  Basic usage statement
	 */
	public static void usage() {
	
		System.out.println("Usage: ");
		System.out.println("com.enterprisedt.net.ftp.FTPClientTest remotehost user password filename");
	}

}
