testng: restore compatibility with 5.10 (IDEA-69600)

This commit is contained in:
anna
2011-05-20 14:01:40 +04:00
parent d024d02fe9
commit c77a8f6053
@@ -23,8 +23,11 @@ package org.testng;
import org.testng.remote.RemoteTestNG;
import java.io.*;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Map;
import java.util.Vector;
public class RemoteTestNGStarter {
@@ -82,6 +85,25 @@ public class RemoteTestNGStarter {
reader.close();
}
try {
//testng 5.10 do not initialize xml suites before run in normal main call => No test suite found.
//revert "cleanup" to set suites manually again, this time for old versions only
final Class aClass = Class.forName("org.testng.TestNGCommandLineArgs");
final Method parseCommandLineMethod = aClass.getDeclaredMethod("parseCommandLine", new Class[] {new String[0].getClass()});
final Map commandLineArgs = (Map)parseCommandLineMethod.invoke(null, new Object[] {(String[])resultArgs.toArray(new String[resultArgs.size()])});
final RemoteTestNG testNG = new RemoteTestNG();
testNG.configure(commandLineArgs);
//set suites manually
testNG.initializeSuitesAndJarFile();
//in order to prevent suites to be initialized twice (second time in run)
//clear string suites here
testNG.setTestSuites(new ArrayList());
testNG.run();
return;
}
catch (NoSuchMethodError ignore) {}
catch (NoClassDefFoundError ignore) {}
RemoteTestNG.main((String[])resultArgs.toArray(new String[resultArgs.size()]));
}
}