Browse Source

Update ShellCommandExecutorTest.java

add unit test
pull/3/MERGE
小清 3 years ago committed by GitHub
parent
commit
658016731f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 42
      dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/shell/ShellCommandExecutorTest.java

42
dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/shell/ShellCommandExecutorTest.java

@ -123,7 +123,47 @@ public class ShellCommandExecutorTest {
Method method = shellCommandExecutorClass.getDeclaredMethod("parseProcessOutput", new Class[]{Process.class});
method.setAccessible(true);
Object[] arg1s = {PowerMockito.mock(Process.class)};
Object[] arg1s = {new Process() {
@Override
public OutputStream getOutputStream() {
return new OutputStream() {
@Override
public void write(int b) throws IOException {
}
};
}
@Override
public InputStream getInputStream() {
return new InputStream() {
@Override
public int read() throws IOException {
return 0;
}
};
}
@Override
public InputStream getErrorStream() {
return null;
}
@Override
public int waitFor() throws InterruptedException {
return 0;
}
@Override
public int exitValue() {
return 0;
}
@Override
public void destroy() {
}
}};
ShellCommandExecutor result = (ShellCommandExecutor) method.invoke(instance, arg1s);
} catch (Exception e) {
logger.error(e.getMessage());

Loading…
Cancel
Save