package testclient; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.RandomAccessFile; import java.net.HttpURLConnection; import java.net.URL; import java.util.Date; /** * @author Sven * * To change this generated comment edit the template variable "typecomment": * Window>Preferences>Java>Templates. * To enable and disable the creation of type comments go to * Window>Preferences>Java>Code Generation. */ public class LasttestClient { public int max_thread_count = 300; public int thread_counter = 0; public int error_count = 0; public int turns = 0; public long max = 0; public long min = Long.MAX_VALUE; public PrintStream Log = null; public boolean stop = false; private String readFile(String filename) throws Exception { RandomAccessFile raf = new RandomAccessFile(filename, "r"); if (raf.length() > Integer.MAX_VALUE) throw new IOException("file too big to fit in byte array."); byte[] result = new byte[(int) raf.length()]; raf.read(result); return new String(result); } public String buildRequest(String filename) throws Exception { String data = readFile(filename); int index = data.indexOf(">"); String xml_head = data.substring(0,index+1); data = data.substring(index+1); //Log.println("Data2:\n"+data); data = xml_head + "\" "+ "soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\"> "+ " "+ data + ""+ ""; if(data.indexOf("10.16.46.109")!=-1) data = replaceString(data,"10.16.46.109","127.0.0.1"); System.out.println("Request:"+data); return data; } public String buildEndpoint(String request,String server) { String ep = null; if(request.indexOf(""); if(pos==-1) { return true; } else { return false; } } } private String replaceString( String input, String oldPart, String newPart) throws Exception { String erg = null; //First Part erg = input.substring(0, input.indexOf(oldPart)); //Insert new Part erg += newPart; //insert REST erg += input.substring( input.indexOf(oldPart) + oldPart.length(), input.length()); return erg; } public static void main(String[] args) throws Exception { int sek = 0; int turns = 0; if(args.length!=4) { System.out.println("Parameteranzahl falsch. Bitte verwenden Sie die Syntax "); return; } try { sek = Integer.parseInt(args[2]); if(args[3].equals("INF")) { turns = 0; } else turns = Integer.parseInt(args[3]); } catch(NumberFormatException e) { System.out.println("Einer der Parameter (Requestanzahl oder Testanzahl) ist keine Zahl !"); return; } System.out.println("Starte Lastest mit folgenden Parametern ..."); System.out.println("Requestdatei: "+args[0]); System.out.println("ServerURL: "+args[1]); System.out.println("Requests pro Sekunde: "+sek); System.out.println("Durchläufe: "+(turns==0?"INF":turns+"")); LasttestClient lc = new LasttestClient(); //lc.startTest("data/CX0/TestGeneratorCX0.001.Req.xml","http://161.106.2.255:8080/",10,1000); lc.startTest(args[0],args[1],sek,turns); } } class Dispatcher extends Thread { private String request = null; private String endpoint = null; private LasttestClient parent = null; private int max; private int turns; public Dispatcher(LasttestClient parent,String request,String endpoint,int max,int turns) { this.request = request; this.endpoint = endpoint; this.parent = parent; this.max = max; this.turns = turns; } public void run() { this.setPriority(Thread.NORM_PRIORITY+1); System.out.println("Dispatcher wird gestartet..."); TestThread[] old_reqs = buildRequests(); for(int turn_counter=0;turns==0?true:(turn_counter"); if(pos==-1) { long diff = end-start; if(parent.maxdiff) { parent.min=diff; } return true; } else { return false; } } } }