01 /*
02 * Copyright (C) 2000 by ETHZ/INF/CS
03 * All rights reserved
04 *
05 * @version $Id$
06 * @author Christoph von Praun
07 */
08
09 import java.util.*;
10 import java.io.*;
11 import ethz.util.SystemProperties;
12
13 public class Tester implements Runnable {
14
15 private static RandomDate randomDate_ = null;
16 private static MetaSearchImpl msi_ = null;
17 private final static int TES_THREADS_;
18 private final static int TES_PAUSE_;
19 private final static int TES_ITERATIONS_;
20 private final static String TES_START_;
21 private final static String TES_END_;
22 private final static String TES_SOHO_SYNOPTIC_;
23 private final static String TES_RAG_;
24 private final static String TES_MESOLA_;
25 private final static String TES_SACREAMENTAL_;
26 private final static String TES_WAIT_TIME_;
27
28 static {
29 SystemProperties.setSource("properties.txt");
30 SystemProperties sp = SystemProperties.getUniqueInstance();
31 TES_THREADS_ = sp.getInteger("Tester.THREADS", 0);
32 TES_PAUSE_ = sp.getInteger("Tester.PAUSE", 0);
33 TES_ITERATIONS_ = sp.getInteger("Tester.ITERATIONS", 0);
34 TES_START_ = sp.getString("Tester.START", null);
35 TES_END_ = sp.getString("Tester.END", null);
36 TES_SOHO_SYNOPTIC_ = sp.getString("Tester.SOHO_SYNOPTIC", "0");
37 TES_RAG_ = sp.getString("Tester.RAG", "0");
38 TES_MESOLA_ = sp.getString("Tester.MESOLA", "0");
39 TES_SACREAMENTAL_ = sp.getString("Tester.SACREAMENTAL", "0");
40 TES_WAIT_TIME_ = sp.getString("Tester.WAIT_TIME", "3");
41 }
42
43 public static void main(String[] args) throws Exception {
44 msi_ = MetaSearchImpl.getUniqueInstance();
45 randomDate_ = new RandomDate(TES_START_, TES_END_);
46 for (int i=0; i < TES_THREADS_; ++i) {
47 try {
48 new Thread(new Tester("thread"+i+".log", TES_PAUSE_, TES_ITERATIONS_)).start();
49 } catch (Exception e) {
50 Messages.Assert(false);
51 }
52 }
53 Messages.debug(1, "Tester::main end");
54 }
55
56 private int pause_ = 0;
57 private int iterations_ = 0;
58 private FileWriter fw_ = null;
59 private String name_;
60 public Tester(String name, int pause, int iterations) throws IOException {
61 Messages.debug(1, "Tester::<init> name=%1 pause=%2 it=%3", name,
62 String.valueOf(pause), String.valueOf(iterations));
63 fw_ = new FileWriter(name);
64 pause_ = pause;
65 name_ = name;
66 iterations_ = iterations;
67 }
68
69 public void run() {
70 Messages.debug(1, "Tester::run start name=%1", name_);
71 while (iterations_ > 0) {
72 try {
73 Thread.sleep((long) (pause_ * Math.random()));
74 Hashtable parameters = new Hashtable();
75 parameters.put("MESOLA", TES_MESOLA_);
76 parameters.put("SACREAMENTAL", TES_SACREAMENTAL_);
77 parameters.put("SOHO_SYNOPTIC", TES_SOHO_SYNOPTIC_);
78 parameters.put("RAG", TES_RAG_);
79 parameters.put("WAIT_TIME", TES_WAIT_TIME_);
80 parameters.put("DATETIME", randomDate_.nextString());
81 MetaSearchRequest m = new MetaSearchRequest(null, msi_, parameters);
82 m.go();
83 fw_.write("OK: " + m.printResults() + "\n");
84 } catch (Exception e) {
85 try {
86 fw_.write("BROKEN: - exception=" + e + "\n");
87 } catch (Exception _) {}
88 } finally {
89 iterations_--;
90 }
91 }
92 try {
93 fw_.close();
94 } catch (Exception e) {
95 Messages.Assert(false);
96 }
97 Messages.debug(1, "Tester::run end");
98 }
99 }
|