I want to write functional tests for my Codename One app. 

To do this, I need to be able to mock some server responses, so that they return exactly what I need for the specific test. 

One thing that I tried to make the functions that send the HTTP requests take ConnectionRequest as a parameter, this way I can inject something to simulate network latency and then call the callback with the mocked response. 

However, when I try to inject the mocks of ConnectionRequest in the prepare method of a unit test, they are still injected after the app is started, which does not work for my case, since I sent HTTP request on the start of the app.

Is it possible to mock ConnectionRequest or do something equivalent before starting the app?