Stop service/SoapUI/Jetty programmatically in a java class
Hi everyone,
I am using SoapUI programatically in a java test. With the UI I have created mock services.
With my code I am retrieving my project and my service without any problem and am running a service without any problem, but even though i am using the methods for stopping it my method won't return ([EDIT] might be because of Jetty) .
[EDIT 2] I haven't worked on this issue for a few weeks now, nut it seems that what I want to achieve is to set the option "No block" which you can set in Maven programmatically without Maven. Jetty is not willing to shut down. Any idea? Maybe I need to go deeper in the setup to have more options.
This is the code:
private static MockRunListenerAdapter mockRunListenerAdapter;
static WsdlProject wsdlProject;
static WsdlMockService wsdlMockService;
static WsdlMockRunner wsdlMockRunner;
public static void main(String args[]){
mockRunListenerAdapter = new MockRunListenerAdapter();
try {
wsdlProject = new WsdlProject("D:\\SoapUIProjects\\myProject.xml");
} catch (IOException | SoapUIException ex) {
System.out.println("Reading wsdl failed");
} catch (Exception exception) {
System.out.println("Reading wsdl failed");
}
wsdlMockService = wsdlProject.getMockServiceByName("myService");
wsdlMockService.addMockRunListener(mockRunListenerAdapter);
System.out.println("trying to start wsdlMockService");
try {
wsdlMockRunner = wsdlMockService.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("wsdlMockService started and wsdlMockRunner initialized");
try {
wsdlMockRunner.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("wsdlMockRunner started");
System.out.println("trying to stop wsdlMockRunner");
wsdlMockRunner.stop();
System.out.println("wsdlMockRunner stopped");
System.out.println("trying to release wsdlMockService");
wsdlMockService.release();
System.out.println("wsdlMockService released");
}Output when running:
15:01:41,943 INFO [JettyMockEngine] Started mockService [myMockService] on port [8088] at path [/myMockService] wsdlMockService started and wsdlMockRunner initialized wsdlMockRunner started trying to stop wsdlMockRunner 15:01:41,959 INFO [JettyMockEngine] Stopped MockService [myMockService] on port [8088] wsdlMockRunner stopped trying to release wsdlMockService wsdlMockService released ^CTerminate batch job (Y/N)? y
I have to stop manually using CTRL+C.
What is or are the method I should use to avoir beeing blocked somewhere?
Due to my environment development I cannot debug properly
I am running the main class with a simple batch script on windows. The SoapUI GUI is of course not running.
[EDIT] It seems that Jetty is blocking, I am currently investigating in this direction. Hope this will help us to get forward. :)
Thank you in advance,
Harald