@Test
        void verifyResolverFromBackup() throws Throwable {
            val service = new SamlRegisteredService();
            service.setName(RandomUtils.randomAlphabetic(12));
            service.setId(RandomUtils.nextInt());

            val resolver = getMetadataResolver();
            try (val webServer = new MockWebServer(new ClassPathResource("sample-metadata.xml"))) {
                webServer.start();
                service.setMetadataLocation("http://localhost:%s".formatted(webServer.getPort()));
                val results = resolver.resolve(service);
                assertFalse(results.isEmpty());
            }

            val backupFile = resolver.getMetadataBackupFile(new UrlResource(service.getMetadataLocation()), service);
            FileUtils.writeByteArrayToFile(backupFile, UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8));
            try (val webServer = new MockWebServer(new ClassPathResource("sample-metadata.xml"))) {
                webServer.start();
                service.setMetadataLocation("http://localhost:%s".formatted(webServer.getPort()));
                val finalResults = resolver.resolve(service);
                assertFalse(finalResults.isEmpty());
            }

            FileUtils.writeByteArrayToFile(backupFile, new ClassPathResource("metadata-invalid.xml").getInputStream().readAllBytes());
            try (val webServer = new MockWebServer(new ClassPathResource("sample-metadata.xml"))) {
                webServer.start();
                service.setMetadataLocation("http://localhost:%s".formatted(webServer.getPort()));
                val finalResults = resolver.resolve(service);
                assertFalse(finalResults.isEmpty());
            }
        }
This is {@link UrlResourceMetadataResolverTests}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-saml-idp-metadata/src/test/java/org/apereo/cas/support/saml/services/idp/metadata/cache/resolver/UrlResourceMetadataResolverTests.java