package com.speed;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.net.URL;
public class TestServer {
static int loopTimes = 500;
public Parameter readFromArgFile(String str) {
FileInputStream fileInput;
BufferedReader br;
Parameter param =
new Parameter();
try {
fileInput =
new FileInputStream(
new File(str));
br =
new BufferedReader(
new InputStreamReader(fileInput));
String line;
while ((line = br.readLine()) !=
null) {
if (line.startsWith(
"URL") ==
true && line.indexOf(
"=") >= 3) {
int f = line.indexOf(
"=");
String urlstring = line.substring(f + 1);
urlstring.trim();
param.url =
new URL(urlstring);
}
else if (line.startsWith(
"METHOD") ==
true && line.indexOf(
"=") >= 3) {
int f = line.indexOf(
"=");
String method = line.substring(f + 1);
method.trim();
param.method = method;
}
else if (line.indexOf(
"=") != -1) {
int f = line.indexOf(
"=");
String key = line.substring(0, f - 1);
String value = line.substring(f + 1);
param.addPair(key.trim(), value.trim());
}
}
fileInput.close();
br.close();
}
catch (FileNotFoundException e) {
System.out.println(
"File" + str +
"not found.");
}
catch (NullPointerException e) {
}
catch (IOException e) {
System.out.println(e);
}
return param;
}
public static void main(String[] args) {
int i;
int j;
Parameter param;
TestServer tester =
new TestServer();
for (i = 0; i < Array.getLength(args); i++) {
param = tester.readFromArgFile(args[i]);
for (j = 0; j < loopTimes; j++) {
Thread th =
new Thread(
new TestThread(param));
th.start();
}
}
}
}