Skip to content

Commit

Permalink
feat: incorporate with the deprecated api cleanup per upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
missedone committed Jan 15, 2024
1 parent 7152198 commit 35d7b9b
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions remote/src/main/java/org/testng/remote/RemoteTestNG.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,17 @@ public static void main(String[] args) throws ParameterException {
remoteTestNg.dontExit(ra.dontExit);

boolean debug = ra.debug;
try {
Field debugField = CommandLineArgs.class.getDeclaredField("debug");
if (debugField.getBoolean(cla)) {
debug = true;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
if (isDebug()) {
e.printStackTrace();
if (!debug) {
// use reflection below for backward compatibility of testng version < 7.10.0
try {
Field debugField = CommandLineArgs.class.getDeclaredField("debug");
if (debugField.getBoolean(cla)) {
debug = true;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
if (isDebug()) {
e.printStackTrace();
}
}
}
m_debug = debug;
Expand Down Expand Up @@ -240,7 +243,22 @@ private static void initAndRun(IRemoteTestNG remoteTestNg, String[] args, Comman
});
}
remoteTestNg.configure(cla);
remoteTestNg.setHost(ra.host);
String host = ra.host;
if (host == null || host.isBlank()) {
// use reflection below for backward compatibility of testng version < 7.10.0
try {
Field hostField = CommandLineArgs.class.getDeclaredField("host");
Object h = hostField.get(cla);
if (h != null) {
host = (String) h;
}
} catch (NoSuchFieldException | IllegalAccessException e) {
if (isDebug()) {
e.printStackTrace();
}
}
}
remoteTestNg.setHost(host);
remoteTestNg.setSerPort(ra.serPort);
remoteTestNg.setProtocol(ra.protocol);
if (isVerbose()) {
Expand Down

0 comments on commit 35d7b9b

Please sign in to comment.