public static XMPPServer mockXMPPServer() {
        final XMPPServer xmppServer = mock(XMPPServer.class, withSettings().lenient());
        doAnswer(invocationOnMock -> {
            final JID jid = invocationOnMock.getArgument(0);
            return jid.getDomain().equals(XMPP_DOMAIN);
        }).when(xmppServer).isLocal(any(JID.class));

        doAnswer(invocationOnMock -> new JID(invocationOnMock.getArgument(0), XMPP_DOMAIN, invocationOnMock.getArgument(1)))
            .when(xmppServer).createJID(any(String.class), nullable(String.class));
        doAnswer(invocationOnMock -> new JID(invocationOnMock.getArgument(0), XMPP_DOMAIN, invocationOnMock.getArgument(1), invocationOnMock.getArgument(2)))
            .when(xmppServer).createJID(any(String.class), nullable(String.class), any(Boolean.class));
        doReturn(mockXMPPServerInfo()).when(xmppServer).getServerInfo();
        doReturn(mockIQRouter()).when(xmppServer).getIQRouter();
        doReturn(mockConnectionManager()).when(xmppServer).getConnectionManager();
        doReturn(mockSessionManager()).when(xmppServer).getSessionManager();

        return xmppServer;
    }
As {@link #reconfigureOpenfireHome()} allows properties to persist, this method clears all existing properties
(both XML and 'database') to ensure clean test output. Ideally should be called in a {@link org.junit.Before} method.

@param except properties that are not cleared if they are set.
xmppserver/src/test/java/org/jivesoftware/Fixtures.java