private static int getFreePort() {
        try (ServerSocket socket = new ServerSocket(0)) {
            return socket.getLocalPort();
        } catch (IOException e) {
            throw new IllegalStateException("Failed to allocate free port", e);
        }
    }
Overriding with contents of this pull request, to make fragment scanning work.
<a href="https://github.com/mjeanroy/junit-servers/pull/3"></a>
integration-tests/support/src/main/java/org/apache/shiro/testing/web/AbstractContainerIT.java