in tester/src/main/java/org/apache/james/jspf/tester/DNSTestingServerLauncher.java [78:162]
public static void main(String[] args) {
String ip = null;
String port = null;
String file = null;
String test = null;
Options options = generateOptions();
CommandLineParser parser = new PosixParser();
try {
CommandLine line = parser.parse(options, args);
ip = line.getOptionValue(CHAR_IP);
port = line.getOptionValue(CHAR_PORT);
file = line.getOptionValue(CHAR_FILE);
test = line.getOptionValue(CHAR_TESTNAME);
if (ip == null) ip = "0.0.0.0";
if (port == null) port = "53";
if (file != null && test != null) {
InputStream is = new FileInputStream(file);
if (is != null) {
Reader br = new BufferedReader(new InputStreamReader(is));
YAMLFactory fact = new DefaultYAMLFactory();
Constructor ctor = fact.createConstructor(fact.createComposer(fact.createParser(fact.createScanner(br)),fact.createResolver()));
boolean found = false;
HashMap zonedata = new HashMap();
HashMap testMap = null;
while(ctor.checkData() && !found) {
Object o = ctor.getData();
if (o instanceof HashMap) {
testMap = (HashMap) o;
if (test.equals(testMap.get("description")) || "ALL".equalsIgnoreCase(test)) {
found = true;
loadZoneData(testMap, zonedata);
}
}
}
if (found) {
DNSTestingServer testingServer = new DNSTestingServer(ip, port);
testingServer.setData(zonedata);
System.out.println("Listening on "+ip+":"+port);
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
}
}
} else {
throw new RuntimeException("Unable to find a <"+test+"> section in the passed file.");
}
} else {
throw new RuntimeException("Unable to load the file: "+file);
}
} else {
System.out.println("Missing required parameter.");
usage();
}
} catch (ParseException e) {
usage();
} catch (RuntimeException e) {
System.out.println("Error: "+e.getMessage());
e.printStackTrace();
usage();
} catch (TextParseException e) {
System.out.println("Parsing Error: "+e.getMessage());
e.printStackTrace();
usage();
} catch (IOException e) {
System.out.println("IO Error: "+e.getMessage());
e.printStackTrace();
usage();
}
}