/***********************************************************************\
//                                                                      *
//      TestHarness.java	                                 	*
//                                                                      *
//      Purpose: A command-line test harness for MultipartHandler	*
//                                                                      *
//      Author:    Simon Brooke                                         *
//      Created:   4th January 2001                                   	*
//	$Revision: 1.3 $; $Date: 2001/01/23 19:12:17 $		*
//                                                                      *
//***********************************************************************/

package uk.co.weft.maybeupload;

import java.lang.*;
import java.io.*;
import java.util.*;

/** A test-harness for the multipart-form-data handler. To be run from
 *  the command line taking input from a file formatted to RFC 1867
 *  with a single command-line argument being the boundary used in the
 *  file
 *
 *  @author Simon Brooke (simon@jasmine.org.uk)
 *  @version $Revision: 1.3 $
 *  This revision: $Author: simon $
 *  <pre>
 *  $Log: TestHarness.java,v $
 *  Revision 1.3  2001/01/23 19:12:17  simon
 *  A number of bugfixes, plus an important new feature: you can decide
 *  whether to allow name collisions in the upload directory to result
 *  in overwriting, renaming of the new file, or an exception.
 *
 *  Revision 1.2  2001/01/09 12:14:12  simon
 *  Now tested with:
 *  	Netscape Communicator 4.76/Linux 2.2
 *  	Konqueror 1.9.8/Linux 2.2
 *  	Microsoft Internet Explorer 5.00.2014.0216IC
 *  File upload (including binary file upload) works. Remaining known bug:
 *  all fields must have data...
 *
 *  Revision 1.1.1.1  2001/01/05 14:58:09  simon
 *  First cut - not yet tested
 *
 *
 *  </pre> */


public class TestHarness
{
    private static MultipartHandler test;

    public static void main( String argv[])
    {
	Hashtable values = new Hashtable();

	try
	    {
		test = new MultipartHandler( values, System.in, 1000000, 
					     argv[ 0], new File( "/tmp"));

		Enumeration e = values.keys();

		while ( e.hasMoreElements())
		    {
			String key = ( String) e.nextElement();

			System.out.println( ":: " + key + " ::-> " +
					    test.values.get( key).toString());
		    }
	    }
	catch ( Exception ioioe)
	    {
		System.err.println( "###########################");
		System.err.println( ioioe.getClass().getName());
		System.err.println( ioioe.getMessage());
	    }
    }
}
