How to use Openfire as Maven Dependency ? Starting the server in my code?

Hi there, I have a project that use XMPP (Smack).
And I need to do some unit tests in my code.

Currently, I created a sidecar container with docker running Prosody XMPP Server when running unit tests for my project. I mainly use MUC with Anouymous SASL login of XMPP.

Is that possible to start openfire in my unit tests code?
It may like below :

OpenfireServer server = new OpenfireServer("localhost",5280);
server.start();

Any ideas on how to archive this ?

Thanks in advance.

I’m not aware of a way to run Openfire embedded in another process. I suspect that this might be difficult, given the complexity of the system. Even Openfire’s own unit tests don’t do this, and instead use various mocks for subsystems.

It is, however, possible to start an Openfire instance in an integration test phase. The ‘demoboot’ argument is particularly useful here. We do this as part of our own continuous integration. See https://github.com/igniterealtime/Openfire/blob/main/runIntegrationTests for inspiration.

Quite recently, we’ve started experiments with creating Github Actions to run integration tests. For that work, we started splitting off the starting and stopping of Openfire from the test script itself. You can look at that work in progress here.