1 16 package org.apache.coyote.http11; 17 18 import java.io.File ; 19 import java.io.FileInputStream ; 20 import java.io.FileOutputStream ; 21 import java.io.InputStream ; 22 import java.io.IOException ; 23 import java.io.OutputStream ; 24 import java.net.Socket ; 25 import java.util.Locale ; 26 27 import org.apache.coyote.Adapter; 28 import org.apache.coyote.ActionCode; 29 import org.apache.coyote.Processor; 30 31 41 public class FileTester { 42 43 44 46 47 49 50 59 public FileTester(Adapter adapter, Processor processor, 60 File inputFile, File outputFile) { 61 62 processor.setAdapter(adapter); 63 64 this.adapter = adapter; 65 this.processor = processor; 66 this.inputFile = inputFile; 67 this.outputFile = outputFile; 68 69 } 70 71 72 74 75 81 public static void main(String args[]) 82 throws Exception { 83 84 if (args.length < 2) { 85 System.out.println("Incorrect number of arguments"); 86 return; 87 } 88 89 File inputFile = new File (args[0]); 91 92 File outputFile = new File (args[1]); 94 95 Adapter testAdapter = new RandomAdapter(); 96 Http11Processor http11Processor = new Http11Processor(); 97 http11Processor.setSocket(new Socket ("127.0.0.1", 8080)); 98 http11Processor.action(ActionCode.ACTION_START, null); 99 100 FileTester tester = new FileTester(testAdapter, http11Processor, 101 inputFile, outputFile); 102 tester.test(); 103 104 } 105 106 107 109 110 113 protected File inputFile; 114 115 116 119 protected File outputFile; 120 121 122 125 protected Adapter adapter; 126 127 128 131 protected Processor processor; 132 133 134 136 137 140 public void test() 141 throws Exception { 142 143 InputStream is = new FileInputStream (inputFile); 144 OutputStream os = new FileOutputStream (outputFile); 145 146 processor.process(is, os); 147 148 } 149 150 151 } 152 | Popular Tags |