hellrid1
12 years agoOccasional Contributor
run SoapUI from a .bat file in a Java program
I am trying to run SoapUI from a .bat file in a java program.
Running the Java program creates XML files in a directory, and then I run the .bat file to create a sub-directory with the responses.
I would like to combine these two steps.
I've tried several variations, but the Main java code looks like this:
public static void main(String[] args) {
try {
System.out.println("begin test");
Process p = Runtime.getRuntime().exec("cmd /c start \"C:/Documents and Settings/Hellrid1/Desktop/runSoapUi.bat\"");
p.waitFor();
System.out.println("end test");
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
I've also tried to run it like this:
String[] commands = new String[]{"cd C:\\Program Files\\SmartBear\\soapUI-Pro-4.0.1\\bin"}; // This will test the first command
/* and add the following to the command array
"cmd.exe /C testrunner.bat" +
" -s\"RealTimeRatingServiceSoapBinding TestSuite\" " +
"-c\"RTR-Rate Revision Request TestSuite\" " +
"\"C:/Documents and Settings/Hellrid1/Desktop/SoapUICmd/RTR-Test-soapui-project.xml",
"pause"};
*/
Process p = Runtime.getRuntime().exec(commands);
but was unsuccessful.
The batch file named runSoapUi.bat contains this code to run a SoapUI project named RTR-Test-soapui-project.xml
cd C:\Program Files\SmartBear\soapUI-Pro-4.0.1\bin\
cmd.exe /C testrunner.bat -s"RealTimeRatingServiceSoapBinding TestSuite" -c"RTR-Rate Revision Request TestSuite" "C:\Documents and Settings\Hellrid1\Desktop\SoapUICmd\RTR-Test-soapui-project.xml"
pause
Running the Java program creates XML files in a directory, and then I run the .bat file to create a sub-directory with the responses.
I would like to combine these two steps.
I've tried several variations, but the Main java code looks like this:
public static void main(String[] args) {
try {
System.out.println("begin test");
Process p = Runtime.getRuntime().exec("cmd /c start \"C:/Documents and Settings/Hellrid1/Desktop/runSoapUi.bat\"");
p.waitFor();
System.out.println("end test");
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
I've also tried to run it like this:
String[] commands = new String[]{"cd C:\\Program Files\\SmartBear\\soapUI-Pro-4.0.1\\bin"}; // This will test the first command
/* and add the following to the command array
"cmd.exe /C testrunner.bat" +
" -s\"RealTimeRatingServiceSoapBinding TestSuite\" " +
"-c\"RTR-Rate Revision Request TestSuite\" " +
"\"C:/Documents and Settings/Hellrid1/Desktop/SoapUICmd/RTR-Test-soapui-project.xml",
"pause"};
*/
Process p = Runtime.getRuntime().exec(commands);
but was unsuccessful.
The batch file named runSoapUi.bat contains this code to run a SoapUI project named RTR-Test-soapui-project.xml
cd C:\Program Files\SmartBear\soapUI-Pro-4.0.1\bin\
cmd.exe /C testrunner.bat -s"RealTimeRatingServiceSoapBinding TestSuite" -c"RTR-Rate Revision Request TestSuite" "C:\Documents and Settings\Hellrid1\Desktop\SoapUICmd\RTR-Test-soapui-project.xml"
pause