@Override
    public final MetadataResolver resolve(final boolean force) {
        if (force) {
            this.metadataResolver = prepareServiceProviderMetadata();
        }
        return this.metadataResolver;
    }
@Test
    public void resolveServiceProviderMetadataViaUrl() throws Exception {
        val restBody = IOUtils.toString(
            new ClassPathResource("sample-sp-metadata.xml").getInputStream(), StandardCharsets.UTF_8);
        val wireMockServer = new WireMockServer(8181);
        wireMockServer.stubFor(
            get(urlPathEqualTo("/saml"))
                .willReturn(aResponse()
                    .withStatus(200)
                    .withHeader("Content-Type", ContentType.APPLICATION_XML.getMimeType())
                    .withBody(restBody)));
        wireMockServer.stubFor(
            post(urlPathEqualTo("/saml"))
                .willReturn(aResponse().withStatus(200)));

        val keystore = IOUtils.toString(
            new ClassPathResource("dummy-keystore.txt").getInputStream(), StandardCharsets.UTF_8);
        wireMockServer.stubFor(
            get(urlPathEqualTo("/keystore"))
                .willReturn(aResponse().withStatus(200).withBody(keystore)));
        wireMockServer.stubFor(
            post(urlPathEqualTo("/keystore"))
                .willReturn(aResponse().withStatus(200)));

        try {
            wireMockServer.start();
            val configuration =
                initializeConfiguration(new FileUrlResource(new URL("http://localhost:8181/saml")),
                    "http://localhost:8181/keystore");
            final SAML2MetadataResolver metadataResolver = new SAML2ServiceProviderMetadataResolver(configuration);
            assertNotNull(metadataResolver.resolve());
        } finally {
            wireMockServer.stop();
        }
    }