This is an automated email from the ASF dual-hosted git repository.

diru pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-sitemap.git


The following commit(s) were added to refs/heads/master by this push:
     new 5f49450  SLING-10574: fix sonar issues
5f49450 is described below

commit 5f4945045d130680891c3032837cef1fb6e1f25a
Author: Dirk Rudolph <[email protected]>
AuthorDate: Tue Jun 29 17:13:12 2021 +0200

    SLING-10574: fix sonar issues
---
 .../java/org/apache/sling/sitemap/SitemapUtil.java | 44 +++++++++++-------
 .../sitemap/impl/SitemapGeneratorExecutor.java     | 17 +++----
 .../apache/sling/sitemap/impl/SitemapServlet.java  | 13 +++---
 .../apache/sling/sitemap/impl/SitemapStorage.java  |  4 +-
 .../sling/sitemap/impl/builder/StringWriter.java   |  4 +-
 .../apache/sling/sitemap/impl/builder/UrlImpl.java | 11 +++--
 .../extensions/ExtensionProviderManager.java       |  2 +-
 .../impl/console/SitemapInventoryPlugin.java       | 28 +++++++----
 .../org/apache/sling/sitemap/SitemapUtilTest.java  | 10 ++--
 .../sitemap/impl/SitemapGeneratorExecutorTest.java | 54 +++++++++++-----------
 .../impl/SitemapGeneratorManagerImplTest.java      | 12 ++---
 .../sling/sitemap/impl/SitemapSchedulerTest.java   | 14 +++---
 .../impl/SitemapServiceImplSchedulingTest.java     | 18 ++++----
 .../sling/sitemap/impl/SitemapServiceImplTest.java | 12 ++---
 .../sling/sitemap/impl/SitemapServletTest.java     | 38 +++++++--------
 .../sling/sitemap/impl/SitemapStorageTest.java     | 25 +++++-----
 .../sitemap/impl/builder/AbstractBuilderTest.java  |  2 +
 .../sitemap/impl/builder/SitemapImplTest.java      | 25 +++++-----
 .../sitemap/impl/builder/SitemapIndexImplTest.java | 13 +++---
 .../sling/sitemap/impl/builder/UrlImplTest.java    | 26 ++++++-----
 .../extensions/AlternateLanguageExtensionTest.java | 15 +++---
 .../impl/console/SitemapInventoryPluginTest.java   | 10 ++--
 .../ResourceTreeSitemapGeneratorTest.java          | 14 +++---
 23 files changed, 221 insertions(+), 190 deletions(-)

diff --git a/src/main/java/org/apache/sling/sitemap/SitemapUtil.java 
b/src/main/java/org/apache/sling/sitemap/SitemapUtil.java
index 1101fd8..250d823 100644
--- a/src/main/java/org/apache/sling/sitemap/SitemapUtil.java
+++ b/src/main/java/org/apache/sling/sitemap/SitemapUtil.java
@@ -18,6 +18,16 @@
  */
 package org.apache.sling.sitemap;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.jcr.query.Query;
+
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.sling.api.resource.Resource;
@@ -26,9 +36,6 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.osgi.annotation.versioning.ProviderType;
 
-import javax.jcr.query.Query;
-import java.util.*;
-
 /**
  * A utility class to give access to common functionality used for sitemaps.
  */
@@ -36,6 +43,8 @@ import java.util.*;
 public final class SitemapUtil {
 
     private static final String JCR_SYSTEM_PATH = "/" + 
JcrConstants.JCR_SYSTEM + "/";
+    private static final String SITEMAP_SELECTOR = "sitemap";
+    private static final String SITEMAP_SELECTOR_SUFFIX = "-" + 
SITEMAP_SELECTOR;
 
     private SitemapUtil() {
         super();
@@ -125,8 +134,8 @@ public final class SitemapUtil {
      */
     @NotNull
     public static String getSitemapSelector(@NotNull Resource sitemapRoot, 
@NotNull Resource topLevelSitemapRoot,
-            @NotNull String name) {
-        name = SitemapService.DEFAULT_SITEMAP_NAME.equals(name) ? "sitemap" : 
name + "-sitemap";
+        @NotNull String name) {
+        name = SitemapService.DEFAULT_SITEMAP_NAME.equals(name) ? 
SITEMAP_SELECTOR : name + SITEMAP_SELECTOR_SUFFIX;
 
         if (!sitemapRoot.getPath().equals(topLevelSitemapRoot.getPath())) {
             String sitemapRootSubpath = 
sitemapRoot.getPath().substring(topLevelSitemapRoot.getPath().length() + 1);
@@ -155,26 +164,26 @@ public final class SitemapUtil {
      */
     @NotNull
     public static Map<Resource, String> resolveSitemapRoots(@NotNull Resource 
topLevelSitemapRoot,
-            @NotNull String sitemapSelector) {
+        @NotNull String sitemapSelector) {
         if (!isTopLevelSitemapRoot(topLevelSitemapRoot)) {
             // selectors are always relative to a top level sitemap root
             return Collections.emptyMap();
         }
-        if (sitemapSelector.equals("sitemap")) {
+        if (sitemapSelector.equals(SITEMAP_SELECTOR)) {
             return Collections.singletonMap(topLevelSitemapRoot, 
SitemapService.DEFAULT_SITEMAP_NAME);
         }
 
         List<String> parts = Arrays.asList(sitemapSelector.split("-"));
         List<String> relevantParts;
 
-        if (parts.size() == 2 && parts.get(0).equals("sitemap") && 
isInteger(parts.get(1))) {
+        if (parts.size() == 2 && parts.get(0).equals(SITEMAP_SELECTOR) && 
isInteger(parts.get(1))) {
             // default name with file index
             return Collections.singletonMap(topLevelSitemapRoot, 
SitemapService.DEFAULT_SITEMAP_NAME);
-        } else if (parts.size() > 1 && parts.get(parts.size() - 
1).equals("sitemap")) {
+        } else if (parts.size() > 1 && parts.get(parts.size() - 
1).equals(SITEMAP_SELECTOR)) {
             // no file index part
             relevantParts = parts.subList(0, parts.size() - 1);
-        } else if (parts.size() > 2 && parts.get(parts.size() - 
2).equals("sitemap")
-                && isInteger(parts.get(parts.size() - 1))) {
+        } else if (parts.size() > 2 && parts.get(parts.size() - 
2).equals(SITEMAP_SELECTOR)
+            && isInteger(parts.get(parts.size() - 1))) {
             // with file index part
             relevantParts = parts.subList(0, parts.size() - 2);
         } else {
@@ -215,8 +224,8 @@ public final class SitemapUtil {
                     // sitemaps given the normalized sitemap root path and the 
sitemap root's jcr:content is in the
                     // result set.
                     if (nextHit == null
-                            || nextHit.getPath().equals(correctedSearchPath)
-                            || nextHit.getPath().startsWith(JCR_SYSTEM_PATH)) {
+                        || nextHit.getPath().equals(correctedSearchPath)
+                        || nextHit.getPath().startsWith(JCR_SYSTEM_PATH)) {
                         continue;
                     }
                     return nextHit;
@@ -231,6 +240,9 @@ public final class SitemapUtil {
 
             @Override
             public Resource next() {
+                if (!hasNext()) {
+                    throw new NoSuchElementException();
+                }
                 Resource ret = next;
                 next = seek();
                 return ret;
@@ -248,13 +260,13 @@ public final class SitemapUtil {
     }
 
     private static void resolveSitemapRoots(@NotNull Resource sitemapRoot, 
@NotNull List<String> parts,
-            @NotNull Map<Resource, String> result) {
+        @NotNull Map<Resource, String> result) {
         if (isSitemapRoot(sitemapRoot)) {
             result.put(sitemapRoot, String.join("-", parts));
         }
-        for (int i = 0, j; i < parts.size(); i++) {
+        for (int i = 0; i < parts.size(); i++) {
             // products product page tops
-            j = i + 1;
+            int j = i + 1;
             String childName = String.join("-", parts.subList(0, j));
             Resource namedChild = sitemapRoot.getChild(childName);
             if (namedChild != null) {
diff --git 
a/src/main/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutor.java 
b/src/main/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutor.java
index 2364c2c..f6b987e 100644
--- a/src/main/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutor.java
+++ b/src/main/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutor.java
@@ -143,9 +143,9 @@ public class SitemapGeneratorExecutor implements 
JobExecutor {
                 IOUtils.copy(existingData, buffer);
             }
             // prefill the state from storage
-            for (String key : state.keySet()) {
-                if (key.indexOf(':') < 0) {
-                    genCtxt.data.put(key, state.get(key));
+            for (Map.Entry<String, Object> entry : state.entrySet()) {
+                if (entry.getKey().indexOf(':') < 0) {
+                    genCtxt.data.put(entry.getKey(), entry.getValue());
                 }
             }
             // get the file index, if any
@@ -203,6 +203,7 @@ public class SitemapGeneratorExecutor implements 
JobExecutor {
             return buf.get() & 0xFF;
         }
 
+        @Override
         public int read(byte @NotNull [] bytes, int off, int len) {
             if (!buf.hasRemaining()) {
                 return -1;
@@ -216,13 +217,13 @@ public class SitemapGeneratorExecutor implements 
JobExecutor {
 
     private static class CopyableByteArrayOutputStream extends 
ByteArrayOutputStream {
 
-        int checkpoint = -1;
+        private int checkpoint = -1;
 
-        void checkpoint() {
+        private void createCheckpoint() {
             checkpoint = count;
         }
 
-        void rollback() {
+        private void rollback() {
             ensureCheckpoint();
             count = checkpoint;
         }
@@ -322,7 +323,7 @@ public class SitemapGeneratorExecutor implements 
JobExecutor {
 
         private boolean rotateIfNecessary() throws IOException {
             // create a checkpoint before flushing the pending url.
-            buffer.checkpoint();
+            buffer.createCheckpoint();
             // flush the sitemap to write the last url to the underlying buffer
             currentSitemap.flush();
             // if the buffer size exceeds the limit (-10 bytes for the closing 
tag)
@@ -430,7 +431,7 @@ public class SitemapGeneratorExecutor implements 
JobExecutor {
 
         @Override
         public void setProperty(@NotNull String name, @Nullable Object data) {
-            if (name.indexOf(':') > 0) {
+            if (name.indexOf(':') >= 0) {
                 // don't allow using properties from a namespace
                 return;
             }
diff --git a/src/main/java/org/apache/sling/sitemap/impl/SitemapServlet.java 
b/src/main/java/org/apache/sling/sitemap/impl/SitemapServlet.java
index 35f23ae..fb4ef6d 100644
--- a/src/main/java/org/apache/sling/sitemap/impl/SitemapServlet.java
+++ b/src/main/java/org/apache/sling/sitemap/impl/SitemapServlet.java
@@ -61,7 +61,7 @@ public class SitemapServlet extends SlingSafeMethodsServlet {
     static final String SITEMAP_EXTENSION = "xml";
 
     private static final Logger LOG = 
LoggerFactory.getLogger(SitemapServlet.class);
-    private static SitemapGenerator.Context NOOP_CONTEXT = new 
SitemapGenerator.Context() {
+    private static final SitemapGenerator.Context NOOP_CONTEXT = new 
SitemapGenerator.Context() {
         @Nullable
         @Override
         public <T> T getProperty(@NotNull String name, @NotNull Class<T> cls) {
@@ -76,6 +76,7 @@ public class SitemapServlet extends SlingSafeMethodsServlet {
 
         @Override
         public void setProperty(@NotNull String name, @Nullable Object data) {
+            // thei implementation of SitemapGenerator.Context doesn't track 
any state
         }
     };
 
@@ -110,9 +111,9 @@ public class SitemapServlet extends SlingSafeMethodsServlet 
{
                 doGetSitemapIndex(request, response, requestedResource);
             } else if (selectors.size() == 1 && 
selectors.contains(SITEMAP_SELECTOR)) {
                 // when only one selector is provided, that means the default 
sitemap got requested
-                doGetSitemap(request, response, requestedResource, 
selectors.get(0));
+                doGetSitemap(response, requestedResource, selectors.get(0));
             } else if (selectors.size() == 2 && 
selectors.get(0).equals(SITEMAP_SELECTOR)) {
-                doGetSitemap(request, response, requestedResource, 
selectors.get(1));
+                doGetSitemap(response, requestedResource, selectors.get(1));
             } else {
                 response.sendError(HttpServletResponse.SC_BAD_REQUEST);
             }
@@ -153,10 +154,10 @@ public class SitemapServlet extends 
SlingSafeMethodsServlet {
         sitemapIndex.close();
     }
 
-    protected void doGetSitemap(@NotNull SlingHttpServletRequest request, 
@NotNull SlingHttpServletResponse response,
-            Resource topLevelSitemapRoot, String sitemapSelector) throws 
SitemapException, IOException {
+    protected void doGetSitemap(@NotNull SlingHttpServletResponse response, 
Resource topLevelSitemapRoot, String sitemapSelector)
+        throws SitemapException, IOException {
         Set<String> onDemandNames = 
generatorManager.getOnDemandNames(topLevelSitemapRoot);
-        if (onDemandNames.size() > 0) {
+        if (!onDemandNames.isEmpty()) {
             // resolve the actual sitemap root from the sitemapSelector
             Map<Resource, String> candidates = 
resolveSitemapRoots(topLevelSitemapRoot, sitemapSelector);
 
diff --git a/src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java 
b/src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java
index 35ca029..5ba3273 100644
--- a/src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java
+++ b/src/main/java/org/apache/sling/sitemap/impl/SitemapStorage.java
@@ -105,7 +105,7 @@ public class SitemapStorage implements Runnable {
     @Reference(policyOption = ReferencePolicyOption.GREEDY, cardinality = 
ReferenceCardinality.OPTIONAL)
     private MetricsService metricsService;
 
-    private String rootPath = "/var/sitemaps";
+    private String rootPath;
     private int maxStateAge = Integer.MAX_VALUE;
 
     private Counter checkpointReadsExpired;
@@ -325,7 +325,7 @@ public class SitemapStorage implements Runnable {
             Resource topLevelSitemapRoot = getTopLevelSitemapRoot(sitemapRoot);
             Predicate<SitemapStorageInfo> filter;
 
-            if (!isTopLevelSitemapRoot(sitemapRoot) || names.size() > 0) {
+            if (!isTopLevelSitemapRoot(sitemapRoot) || !names.isEmpty()) {
                 // return only those that match at least on of the names 
requested
                 filter = info -> names.stream()
                         .map(name -> 
SitemapUtil.getSitemapSelector(sitemapRoot, topLevelSitemapRoot, name))
diff --git 
a/src/main/java/org/apache/sling/sitemap/impl/builder/StringWriter.java 
b/src/main/java/org/apache/sling/sitemap/impl/builder/StringWriter.java
index 753e4a9..c229421 100644
--- a/src/main/java/org/apache/sling/sitemap/impl/builder/StringWriter.java
+++ b/src/main/java/org/apache/sling/sitemap/impl/builder/StringWriter.java
@@ -79,12 +79,12 @@ class StringWriter extends Writer {
 
     @Override
     public void flush() {
-
+        // this memory data structure must not be flushed
     }
 
     @Override
     public void close() {
-
+        // this memory data structure cannot not be closed
     }
 
     public void reset() {
diff --git a/src/main/java/org/apache/sling/sitemap/impl/builder/UrlImpl.java 
b/src/main/java/org/apache/sling/sitemap/impl/builder/UrlImpl.java
index c9549e6..3ae9226 100644
--- a/src/main/java/org/apache/sling/sitemap/impl/builder/UrlImpl.java
+++ b/src/main/java/org/apache/sling/sitemap/impl/builder/UrlImpl.java
@@ -145,11 +145,12 @@ public class UrlImpl implements Url {
             // write the extensions as separate chunks to the same output
             if (extensions != null) {
                 // use a single StringWriter and reset it for each extension 
to save memory
-                StringWriter extensionChunk = new StringWriter();
-                for (ExtensionMeta extension : extensions) {
-                    writeExtension(extensionChunk, extension);
-                    urlChunk.append(extensionChunk.asCharSequence());
-                    extensionChunk.reset();
+                try (StringWriter extensionChunk = new StringWriter()) {
+                    for (ExtensionMeta extension : extensions) {
+                        writeExtension(extensionChunk, extension);
+                        urlChunk.append(extensionChunk.asCharSequence());
+                        extensionChunk.reset();
+                    }
                 }
             }
 
diff --git 
a/src/main/java/org/apache/sling/sitemap/impl/builder/extensions/ExtensionProviderManager.java
 
b/src/main/java/org/apache/sling/sitemap/impl/builder/extensions/ExtensionProviderManager.java
index 7441f51..d3a0aec 100644
--- 
a/src/main/java/org/apache/sling/sitemap/impl/builder/extensions/ExtensionProviderManager.java
+++ 
b/src/main/java/org/apache/sling/sitemap/impl/builder/extensions/ExtensionProviderManager.java
@@ -132,7 +132,7 @@ public class ExtensionProviderManager {
                 emptyTag = Boolean.parseBoolean((String) emptyTagProp);
             } else {
                 emptyTag = false;
-                LOG.debug("Unknown type for emptyTag: " + emptyTagProp);
+                LOG.debug("Unknown type for emptyTag: {}", emptyTagProp);
             }
         }
 
diff --git 
a/src/main/java/org/apache/sling/sitemap/impl/console/SitemapInventoryPlugin.java
 
b/src/main/java/org/apache/sling/sitemap/impl/console/SitemapInventoryPlugin.java
index eec4441..9770046 100644
--- 
a/src/main/java/org/apache/sling/sitemap/impl/console/SitemapInventoryPlugin.java
+++ 
b/src/main/java/org/apache/sling/sitemap/impl/console/SitemapInventoryPlugin.java
@@ -85,6 +85,13 @@ public class SitemapInventoryPlugin implements 
InventoryPrinter {
 
     private void printJson(PrintWriter pw) {
         pw.print('{');
+        printSchedulerJson(pw);
+        pw.print(',');
+        printRootsJson(pw);
+        pw.print('}');
+    }
+
+    private void printSchedulerJson(PrintWriter pw) {
         pw.print("\"schedulers\":[");
         boolean hasScheduler = false;
         for (ServiceReference<?> ref : 
bundleContext.getBundle().getRegisteredServices()) {
@@ -102,8 +109,10 @@ public class SitemapInventoryPlugin implements 
InventoryPrinter {
                 pw.print("\"}");
             }
         }
-        pw.print("],");
+        pw.print(']');
+    }
 
+    private void printRootsJson(PrintWriter pw) {
         pw.print("\"roots\":{");
         try (ResourceResolver resolver = 
resourceResolverFactory.getServiceResourceResolver(AUTH)) {
             Iterator<Resource> roots = SitemapUtil.findSitemapRoots(resolver, 
"/");
@@ -149,14 +158,20 @@ public class SitemapInventoryPlugin implements 
InventoryPrinter {
             LOG.warn("Failed to get inventory of sitemaps: {}", 
ex.getMessage(), ex);
         }
         pw.print('}');
-        pw.print('}');
     }
 
     private void printText(PrintWriter pw) {
         pw.println("# Apache Sling Sitemap Schedulers");
         pw.println("# -------------------------------");
-        pw.println("schedulers:");
+        printSchedulersText(pw);
+        pw.println();
+        pw.println("# Apache Sling Sitemap Roots");
+        pw.println("# --------------------------");
+        printRootsText(pw);
+    }
 
+    private void printSchedulersText(PrintWriter pw) {
+        pw.println("schedulers:");
         for (ServiceReference<?> ref : 
bundleContext.getBundle().getRegisteredServices()) {
             Object schedulerExp = 
ref.getProperty(Scheduler.PROPERTY_SCHEDULER_EXPRESSION);
             Object schedulerName = 
ref.getProperty(Scheduler.PROPERTY_SCHEDULER_NAME);
@@ -169,13 +184,10 @@ public class SitemapInventoryPlugin implements 
InventoryPrinter {
                 pw.println();
             }
         }
+    }
 
-        pw.println();
-        pw.println();
-        pw.println("# Apache Sling Sitemap Roots");
-        pw.println("# --------------------------");
+    private void printRootsText(PrintWriter pw) {
         pw.println("roots:");
-
         try (ResourceResolver resolver = 
resourceResolverFactory.getServiceResourceResolver(AUTH)) {
             Iterator<Resource> roots = SitemapUtil.findSitemapRoots(resolver, 
"/");
             while (roots.hasNext()) {
diff --git a/src/test/java/org/apache/sling/sitemap/SitemapUtilTest.java 
b/src/test/java/org/apache/sling/sitemap/SitemapUtilTest.java
index 678d081..67ad9ce 100644
--- a/src/test/java/org/apache/sling/sitemap/SitemapUtilTest.java
+++ b/src/test/java/org/apache/sling/sitemap/SitemapUtilTest.java
@@ -42,12 +42,12 @@ import static org.hamcrest.Matchers.aMapWithSize;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 @ExtendWith({SlingContextExtension.class})
-public class SitemapUtilTest {
+class SitemapUtilTest {
 
-    public final SlingContext context = new SlingContext();
+    final SlingContext context = new SlingContext();
 
     @Test
-    public void testSingleRootSitemapName() {
+    void testSingleRootSitemapName() {
         // given
         Resource root = context.create().resource("/content/site/de", 
Collections.singletonMap(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
@@ -63,7 +63,7 @@ public class SitemapUtilTest {
     }
 
     @Test
-    public void testMultiRootSitemapName() {
+    void testMultiRootSitemapName() {
         // given
         context.create().resource("/content/site/de", ImmutableMap.of(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
@@ -90,7 +90,7 @@ public class SitemapUtilTest {
     }
 
     @Test
-    public void testSitemapResolutionFromFileName() {
+    void testSitemapResolutionFromFileName() {
         // given
         Resource root = context.create().resource("/content/site/de", 
Collections.singletonMap(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutorTest.java 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutorTest.java
index ac147c5..ee92fb3 100644
--- 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutorTest.java
+++ 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorExecutorTest.java
@@ -26,8 +26,8 @@ import org.apache.sling.serviceusermapping.ServiceUserMapped;
 import org.apache.sling.sitemap.SitemapException;
 import org.apache.sling.sitemap.SitemapService;
 import org.apache.sling.sitemap.builder.Sitemap;
+import org.apache.sling.sitemap.impl.builder.AbstractBuilderTest;
 import org.apache.sling.sitemap.spi.generator.SitemapGenerator;
-import org.apache.sling.sitemap.impl.builder.SitemapImplTest;
 import 
org.apache.sling.sitemap.impl.builder.extensions.ExtensionProviderManager;
 import org.apache.sling.testing.mock.osgi.MockOsgi;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -53,9 +53,9 @@ import static org.junit.jupiter.api.Assertions.*;
 import static org.mockito.Mockito.*;
 
 @ExtendWith({SlingContextExtension.class, MockitoExtension.class})
-public class SitemapGeneratorExecutorTest {
+class SitemapGeneratorExecutorTest {
 
-    public final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
+    final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
 
     private final SitemapGeneratorExecutor subject = new 
SitemapGeneratorExecutor();
     private final SitemapGeneratorManagerImpl generatorManager = new 
SitemapGeneratorManagerImpl();
@@ -80,7 +80,7 @@ public class SitemapGeneratorExecutorTest {
     private Resource storageRoot;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         rootResource = context.create().resource("/content/site/de", 
Collections.singletonMap(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
         ));
@@ -102,7 +102,7 @@ public class SitemapGeneratorExecutorTest {
     }
 
     @Test
-    public void testNoStateWrittenOnLargerChunkSize() throws IOException {
+    void testNoStateWrittenOnLargerChunkSize() throws IOException {
         context.registerService(SitemapGenerator.class, new 
FailOnceGenerator(Integer.MAX_VALUE,
                 "http://example.com/page1.html";,
                 "http://example.com/page2.html";,
@@ -117,7 +117,7 @@ public class SitemapGeneratorExecutorTest {
 
         // then
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page1.html</loc></url>"
                         + "<url><loc>http://example.com/page2.html</loc></url>"
                         + "<url><loc>http://example.com/page3.html</loc></url>"
@@ -131,7 +131,7 @@ public class SitemapGeneratorExecutorTest {
     }
 
     @Test
-    public void testStateRemovedOnJobStopped() {
+    void testStateRemovedOnJobStopped() {
         context.registerService(SitemapGenerator.class, new 
FailOnceGenerator(1,
                 "http://example.com/page1.html";,
                 "http://example.com/page2.html";
@@ -159,7 +159,7 @@ public class SitemapGeneratorExecutorTest {
     }
 
     @Test
-    public void testGeneratorExceptionRethrown() {
+    void testGeneratorExceptionRethrown() {
         // given
         ThrowingGenerator generator = new ThrowingGenerator();
         context.registerService(SitemapGenerator.class, generator);
@@ -182,7 +182,7 @@ public class SitemapGeneratorExecutorTest {
     }
 
     @Test
-    public void testJobResumesAfterBeingAborted() throws IOException {
+    void testJobResumesAfterBeingAborted() throws IOException {
         // given
         context.registerService(SitemapGenerator.class, new 
FailOnceGenerator(4,
                 "http://example.com/page1.html";,
@@ -203,7 +203,7 @@ public class SitemapGeneratorExecutorTest {
 
         // then
         assertResourceDataEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page1.html</loc></url>"
                         + "<url><loc>http://example.com/page2.html</loc></url>"
                         + 
"<url><loc>http://example.com/page3.html</loc></url>",
@@ -216,7 +216,7 @@ public class SitemapGeneratorExecutorTest {
         // then
         assertNull(storageRoot.getChild("content/site/de/sitemap.part"));
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page1.html</loc></url>"
                         + "<url><loc>http://example.com/page2.html</loc></url>"
                         + "<url><loc>http://example.com/page3.html</loc></url>"
@@ -229,7 +229,7 @@ public class SitemapGeneratorExecutorTest {
     }
 
     @Test
-    public void testJobResumesAfterBeingAbortedMultiFile() throws IOException {
+    void testJobResumesAfterBeingAbortedMultiFile() throws IOException {
         // given
         MockOsgi.activate(sitemapServiceConfiguration, 
context.bundleContext(), "maxEntries", 3);
         context.registerService(SitemapGenerator.class, new 
FailOnceGenerator(5,
@@ -252,7 +252,7 @@ public class SitemapGeneratorExecutorTest {
 
         // then
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page1.html</loc></url>"
                         + "<url><loc>http://example.com/page2.html</loc></url>"
                         + "<url><loc>http://example.com/page3.html</loc></url>"
@@ -261,7 +261,7 @@ public class SitemapGeneratorExecutorTest {
                 storageRoot.getChild("content/site/de/sitemap.xml")
         );
         assertResourceDataEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page4.html</loc></url>"
                         + 
"<url><loc>http://example.com/page5.html</loc></url>",
                 storageRoot.getChild("content/site/de/sitemap.part")
@@ -273,7 +273,7 @@ public class SitemapGeneratorExecutorTest {
         // then
         assertNull(storageRoot.getChild("content/site/de/sitemap.part"));
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page1.html</loc></url>"
                         + "<url><loc>http://example.com/page2.html</loc></url>"
                         + "<url><loc>http://example.com/page3.html</loc></url>"
@@ -282,7 +282,7 @@ public class SitemapGeneratorExecutorTest {
                 storageRoot.getChild("content/site/de/sitemap.xml")
         );
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page4.html</loc></url>"
                         + "<url><loc>http://example.com/page5.html</loc></url>"
                         + "<url><loc>http://example.com/page6.html</loc></url>"
@@ -293,7 +293,7 @@ public class SitemapGeneratorExecutorTest {
     }
 
     @Test
-    public void testMultiFileConsistentWithSizeOverflow() throws IOException {
+    void testMultiFileConsistentWithSizeOverflow() throws IOException {
         // 200 = 38 (header) + 60 (urlset) + 2 * 51 (url)
         MockOsgi.activate(sitemapServiceConfiguration, 
context.bundleContext(), "maxSize", 200);
         context.registerService(SitemapGenerator.class, new 
FailOnceGenerator(Integer.MAX_VALUE,
@@ -308,21 +308,21 @@ public class SitemapGeneratorExecutorTest {
 
         // then
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page1.html</loc></url>"
                         + "</urlset>",
                 1,
                 storageRoot.getChild("content/site/de/sitemap.xml")
         );
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page2.html</loc></url>"
                         + "</urlset>",
                 1,
                 storageRoot.getChild("content/site/de/sitemap-2.xml")
         );
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page3.html</loc></url>"
                         + "</urlset>",
                 1,
@@ -331,7 +331,7 @@ public class SitemapGeneratorExecutorTest {
     }
 
     @Test
-    public void testObsoleteFilesPurgedWhenMultiFileUpdated() throws 
IOException {
+    void testObsoleteFilesPurgedWhenMultiFileUpdated() throws IOException {
         // given
         FailOnceGenerator generator = new FailOnceGenerator(Integer.MAX_VALUE,
                 "http://example.com/page1.html";,
@@ -347,21 +347,21 @@ public class SitemapGeneratorExecutorTest {
 
         // then
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page1.html</loc></url>"
                         + "</urlset>",
                 1,
                 storageRoot.getChild("content/site/de/sitemap.xml")
         );
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page2.html</loc></url>"
                         + "</urlset>",
                 1,
                 storageRoot.getChild("content/site/de/sitemap-2.xml")
         );
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page3.html</loc></url>"
                         + "</urlset>",
                 1,
@@ -374,7 +374,7 @@ public class SitemapGeneratorExecutorTest {
 
         // then
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/pageX.html</loc></url>"
                         + "</urlset>",
                 1,
@@ -385,7 +385,7 @@ public class SitemapGeneratorExecutorTest {
     }
 
     @Test
-    public void testGenerationContextDoesNotLeakRawJcrData() throws 
IOException {
+    void testGenerationContextDoesNotLeakRawJcrData() throws IOException {
         // given
         String injectedText = "foobar";
         context.registerService(SitemapGenerator.class, new 
FailOnceGenerator(1,
@@ -417,7 +417,7 @@ public class SitemapGeneratorExecutorTest {
         subject.process(job, executionContext);
 
         assertResourceDataAndEntriesEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>http://example.com/page1.html</loc></url>"
                         + "<url><loc>http://example.com/page2.html</loc></url>"
                         + "</urlset>",
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorManagerImplTest.java
 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorManagerImplTest.java
index a8f9b0c..f1b7ab1 100644
--- 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorManagerImplTest.java
+++ 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapGeneratorManagerImplTest.java
@@ -39,9 +39,9 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.when;
 
 @ExtendWith({SlingContextExtension.class, MockitoExtension.class})
-public class SitemapGeneratorManagerImplTest {
+class SitemapGeneratorManagerImplTest {
 
-    public final SlingContext context = new SlingContext();
+    final SlingContext context = new SlingContext();
 
     private final SitemapGeneratorManagerImpl subject = new 
SitemapGeneratorManagerImpl();
     private final SitemapServiceConfiguration sitemapServiceConfiguration = 
new SitemapServiceConfiguration();
@@ -54,7 +54,7 @@ public class SitemapGeneratorManagerImplTest {
     private SitemapGenerator generator3;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         context.registerService(SitemapGenerator.class, generator1, 
"service.ranking", 1);
         context.registerService(SitemapGenerator.class, generator2, 
"service.ranking", 2);
         context.registerService(SitemapGenerator.class, generator3, 
"service.ranking", 3);
@@ -64,7 +64,7 @@ public class SitemapGeneratorManagerImplTest {
     }
 
     @Test
-    public void testAllGeneratorsReturnedWhenAllGenerateDifferentNames() {
+    void testAllGeneratorsReturnedWhenAllGenerateDifferentNames() {
         // given
         
when(generator1.getNames(any())).thenReturn(Collections.singleton("sitemap1"));
         
when(generator2.getNames(any())).thenReturn(Collections.singleton("sitemap2"));
@@ -88,7 +88,7 @@ public class SitemapGeneratorManagerImplTest {
     }
 
     @Test
-    public void testAllGeneratorsOnDemand() {
+    void testAllGeneratorsOnDemand() {
         // given
         
when(generator1.getNames(any())).thenReturn(Collections.singleton("sitemap1"));
         
when(generator2.getNames(any())).thenReturn(Collections.singleton("sitemap2"));
@@ -114,7 +114,7 @@ public class SitemapGeneratorManagerImplTest {
     }
 
     @Test
-    public void 
testThatHigherRankedGeneratorsTakePrecedenceOnConflictingNames() {
+    void testThatHigherRankedGeneratorsTakePrecedenceOnConflictingNames() {
         // given
         
when(generator1.getNames(any())).thenReturn(Collections.singleton(SitemapService.DEFAULT_SITEMAP_NAME));
         
when(generator2.getNames(any())).thenReturn(Collections.singleton(SitemapService.DEFAULT_SITEMAP_NAME));
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapSchedulerTest.java 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapSchedulerTest.java
index d91c36b..b8b081b 100644
--- a/src/test/java/org/apache/sling/sitemap/impl/SitemapSchedulerTest.java
+++ b/src/test/java/org/apache/sling/sitemap/impl/SitemapSchedulerTest.java
@@ -54,9 +54,9 @@ import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.*;
 
 @ExtendWith({SlingContextExtension.class, MockitoExtension.class})
-public class SitemapSchedulerTest {
+class SitemapSchedulerTest {
 
-    public final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
+    final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
 
     private final SitemapScheduler subject = new SitemapScheduler();
     private final SitemapGeneratorManagerImpl generatorManager = new 
SitemapGeneratorManagerImpl();
@@ -75,7 +75,7 @@ public class SitemapSchedulerTest {
     private Resource rootEnContent;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         rootDe = context.create().resource("/content/site/de", 
Collections.singletonMap(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE));
         rootEn = context.create().resource("/content/site/en");
@@ -99,7 +99,7 @@ public class SitemapSchedulerTest {
     }
 
     @Test
-    public void testOneDefaultSitemapJobStartedForEachRoot() {
+    void testOneDefaultSitemapJobStartedForEachRoot() {
         // given
         context.registerInjectActivateService(subject);
         initResourceResolver(subject, resolver -> MockJcr.setQueryResult(
@@ -130,7 +130,7 @@ public class SitemapSchedulerTest {
     }
 
     @Test
-    public void testOneSitemapJobStartedForEachName() {
+    void testOneSitemapJobStartedForEachName() {
         // given
         context.registerInjectActivateService(subject);
         initResourceResolver(subject, resolver -> MockJcr.setQueryResult(
@@ -162,7 +162,7 @@ public class SitemapSchedulerTest {
     }
 
     @Test
-    public void 
testNothingScheduledWhenNameDoesNotMatchGeneratorFromConfiguration() {
+    void testNothingScheduledWhenNameDoesNotMatchGeneratorFromConfiguration() {
         // given
         context.registerInjectActivateService(subject, "includeGenerators", 
new String[]{
                 generator1.getClass().getName()
@@ -194,7 +194,7 @@ public class SitemapSchedulerTest {
     }
 
     @Test
-    public void testNothingScheduledWhenNameDoesNotNamesFromConfiguration() {
+    void testNothingScheduledWhenNameDoesNotNamesFromConfiguration() {
         // given
         context.registerInjectActivateService(subject, "names", new String[]{
                 "foobar"
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplSchedulingTest.java
 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplSchedulingTest.java
index a0ae4a6..41d17d9 100644
--- 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplSchedulingTest.java
+++ 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplSchedulingTest.java
@@ -50,9 +50,9 @@ import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.*;
 
 @ExtendWith({SlingContextExtension.class, MockitoExtension.class})
-public class SitemapServiceImplSchedulingTest {
+class SitemapServiceImplSchedulingTest {
 
-    public final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
+    final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
 
     private final SitemapServiceImpl subject = new SitemapServiceImpl();
     private final SitemapStorage storage = new SitemapStorage();
@@ -92,7 +92,7 @@ public class SitemapServiceImplSchedulingTest {
     private SitemapScheduler schedulerWithGenerator2OnMicrosite;
 
     @BeforeEach
-    public void setup() throws LoginException {
+    void setup() throws LoginException {
         siteRoot = context.create().resource("/content/site/de", 
Collections.singletonMap(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
         ));
@@ -139,7 +139,7 @@ public class SitemapServiceImplSchedulingTest {
     }
 
     @Test
-    public void testAllSchedulersCalled() {
+    void testAllSchedulersCalled() {
         // when
         subject.scheduleGeneration();
 
@@ -149,7 +149,7 @@ public class SitemapServiceImplSchedulingTest {
     }
 
     @Test
-    public void testSchedulersCalledForName() {
+    void testSchedulersCalledForName() {
         // when
         subject.scheduleGeneration("<default>");
 
@@ -159,7 +159,7 @@ public class SitemapServiceImplSchedulingTest {
     }
 
     @Test
-    public void testSchedulersCalledForPath() {
+    void testSchedulersCalledForPath() {
         // when
         subject.scheduleGeneration(siteRoot);
 
@@ -169,13 +169,13 @@ public class SitemapServiceImplSchedulingTest {
     }
 
     @Test
-    public void testSchedulersCalledForPathAndName() {
+    void testSchedulersCalledForPathAndName() {
         // when
         subject.scheduleGeneration(siteRoot, "foo");
         subject.scheduleGeneration(micrositeRoot, "foo");
 
         // then
-        verify(schedulerWithGenerator1OnSite, 
times(1)).addJob(eq(siteRoot.getPath()), eq("foo"));
-        verify(schedulerWithGenerator2OnMicrosite, 
times(1)).addJob(eq(micrositeRoot.getPath()), eq("foo"));
+        verify(schedulerWithGenerator1OnSite, 
times(1)).addJob(siteRoot.getPath(),"foo");
+        verify(schedulerWithGenerator2OnMicrosite, 
times(1)).addJob(micrositeRoot.getPath(),"foo");
     }
 }
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplTest.java 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplTest.java
index 77f6326..94a47c1 100644
--- a/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplTest.java
+++ b/src/test/java/org/apache/sling/sitemap/impl/SitemapServiceImplTest.java
@@ -53,9 +53,9 @@ import static org.hamcrest.Matchers.hasItems;
 import static org.hamcrest.Matchers.hasSize;
 
 @ExtendWith({SlingContextExtension.class, MockitoExtension.class})
-public class SitemapServiceImplTest {
+class SitemapServiceImplTest {
 
-    public final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
+    final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
 
     private final SitemapServiceImpl subject = new SitemapServiceImpl();
     private final SitemapStorage storage = new SitemapStorage();
@@ -86,7 +86,7 @@ public class SitemapServiceImplTest {
     private Resource noRoot;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         deRoot = context.create().resource("/content/site/de", 
Collections.singletonMap(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
         ));
@@ -123,7 +123,7 @@ public class SitemapServiceImplTest {
     }
 
     @Test
-    public void testSitemapIndexUrlReturned() {
+    void testSitemapIndexUrlReturned() {
         // given
         generator.setNames(SitemapService.DEFAULT_SITEMAP_NAME);
         generator.setNames(frRoot, "a", "b");
@@ -157,7 +157,7 @@ public class SitemapServiceImplTest {
     }
 
     @Test
-    public void testSitemapUrlReturnEmptyCollections() {
+    void testSitemapUrlReturnEmptyCollections() {
         // no name
         assertThat(subject.getSitemapInfo(deRoot), hasSize(0));
         // no names nested
@@ -167,7 +167,7 @@ public class SitemapServiceImplTest {
     }
 
     @Test
-    public void testSitemapUrlReturnsProperSelectors() throws IOException {
+    void testSitemapUrlReturnsProperSelectors() throws IOException {
         // given
         storage.writeSitemap(deRoot, SitemapService.DEFAULT_SITEMAP_NAME, new 
ByteArrayInputStream(new byte[0]), 1, 100,
                 1);
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapServletTest.java 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapServletTest.java
index ba5d95b..f511410 100644
--- a/src/test/java/org/apache/sling/sitemap/impl/SitemapServletTest.java
+++ b/src/test/java/org/apache/sling/sitemap/impl/SitemapServletTest.java
@@ -24,8 +24,8 @@ import org.apache.sling.event.jobs.JobManager;
 import org.apache.sling.serviceusermapping.ServiceUserMapped;
 import org.apache.sling.sitemap.SitemapService;
 import org.apache.sling.sitemap.TestResourceTreeSitemapGenerator;
+import org.apache.sling.sitemap.impl.builder.AbstractBuilderTest;
 import org.apache.sling.sitemap.spi.generator.SitemapGenerator;
-import org.apache.sling.sitemap.impl.builder.SitemapImplTest;
 import 
org.apache.sling.sitemap.impl.builder.extensions.ExtensionProviderManager;
 import org.apache.sling.testing.mock.jcr.MockJcr;
 import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -58,7 +58,7 @@ import static org.mockito.Mockito.*;
 @ExtendWith({SlingContextExtension.class, MockitoExtension.class})
 public class SitemapServletTest {
 
-    public final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
+    final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
 
     private final SitemapServlet subject = new SitemapServlet();
     private final SitemapStorage storage = spy(new SitemapStorage());
@@ -87,14 +87,14 @@ public class SitemapServletTest {
     private final String pointInTimeAtUtc;
     private Resource root;
 
-    public SitemapServletTest() {
+    {
         pointInTime = Calendar.getInstance();
         pointInTime.setTimeInMillis(123456789L);
         pointInTimeAtUtc = 
DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(pointInTime.toInstant().atOffset(ZoneOffset.UTC));
     }
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         root = context.create().resource("/content/site/de");
         context.create().resource("/content/site/de/jcr:content", 
Collections.singletonMap(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE));
@@ -126,7 +126,7 @@ public class SitemapServletTest {
     }
 
     @Test
-    public void testBadRequestForResourcesThatAreNotSitemapRoot() throws 
ServletException, IOException {
+    void testBadRequestForResourcesThatAreNotSitemapRoot() throws 
ServletException, IOException {
         // given
         Resource notATopLevelRoot = 
context.create().resource("/content/site/en");
 
@@ -141,7 +141,7 @@ public class SitemapServletTest {
     }
 
     @Test
-    public void testBadRequestForInvalidSelectors() throws ServletException, 
IOException {
+    void testBadRequestForInvalidSelectors() throws ServletException, 
IOException {
         // given
         MockSlingHttpServletResponse response = context.response();
 
@@ -157,7 +157,7 @@ public class SitemapServletTest {
     }
 
     @Test
-    public void testSitemapIndexContainsOnlySitemapsFromStorage() throws 
IOException, ServletException {
+    void testSitemapIndexContainsOnlySitemapsFromStorage() throws IOException, 
ServletException {
         // given
         storage.writeSitemap(root, SitemapService.DEFAULT_SITEMAP_NAME, new 
ByteArrayInputStream(new byte[0]), 1, 0, 0);
         storage.writeSitemap(root, "news", new ByteArrayInputStream(new 
byte[0]), 1, 0, 0);
@@ -173,7 +173,7 @@ public class SitemapServletTest {
         assertEquals("application/xml;charset=utf-8", 
response.getContentType());
         assertEquals("utf-8", response.getCharacterEncoding());
         assertEquals(
-                SitemapImplTest.XML_HEADER + "<sitemapindex 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<sitemapindex 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<sitemap><loc>/site/de.sitemap.xml</loc><lastmod>" 
+ pointInTimeAtUtc + "</lastmod></sitemap>"
                         + 
"<sitemap><loc>/site/de.sitemap.news-sitemap.xml</loc><lastmod>" + 
pointInTimeAtUtc + "</lastmod></sitemap>"
                         + "</sitemapindex>",
@@ -182,7 +182,7 @@ public class SitemapServletTest {
     }
 
     @Test
-    public void testSitemapIndexContainsMultiFileSitemaps() throws 
IOException, ServletException {
+    void testSitemapIndexContainsMultiFileSitemaps() throws IOException, 
ServletException {
         // given
         storage.writeSitemap(root, SitemapService.DEFAULT_SITEMAP_NAME, new 
ByteArrayInputStream(new byte[0]), 1, 0, 0);
         storage.writeSitemap(root, SitemapService.DEFAULT_SITEMAP_NAME, new 
ByteArrayInputStream(new byte[0]), 2, 0, 0);
@@ -199,7 +199,7 @@ public class SitemapServletTest {
         assertEquals("application/xml;charset=utf-8", 
response.getContentType());
         assertEquals("utf-8", response.getCharacterEncoding());
         assertEquals(
-                SitemapImplTest.XML_HEADER + "<sitemapindex 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<sitemapindex 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<sitemap><loc>/site/de.sitemap.xml</loc><lastmod>" 
+ pointInTimeAtUtc + "</lastmod></sitemap>"
                         + 
"<sitemap><loc>/site/de.sitemap.sitemap-2.xml</loc><lastmod>" + 
pointInTimeAtUtc + "</lastmod></sitemap>"
                         + 
"<sitemap><loc>/site/de.sitemap.sitemap-3.xml</loc><lastmod>" + 
pointInTimeAtUtc + "</lastmod></sitemap>"
@@ -209,7 +209,7 @@ public class SitemapServletTest {
     }
 
     @Test
-    public void 
testSitemapIndexContainsOnDemandSitemapsAndSitemapsFromStorage() throws 
ServletException, IOException {
+    void testSitemapIndexContainsOnDemandSitemapsAndSitemapsFromStorage() 
throws ServletException, IOException {
         // given
         storage.writeSitemap(root, SitemapService.DEFAULT_SITEMAP_NAME, new 
ByteArrayInputStream(new byte[0]), 1, 0, 0);
 
@@ -225,7 +225,7 @@ public class SitemapServletTest {
         assertEquals("application/xml;charset=utf-8", 
response.getContentType());
         assertEquals("utf-8", response.getCharacterEncoding());
         assertEquals(
-                SitemapImplTest.XML_HEADER + "<sitemapindex 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<sitemapindex 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + 
"<sitemap><loc>/site/de.sitemap.news-sitemap.xml</loc></sitemap>"
                         + "<sitemap><loc>/site/de.sitemap.xml</loc><lastmod>" 
+ pointInTimeAtUtc + "</lastmod></sitemap>"
                         + "</sitemapindex>",
@@ -234,7 +234,7 @@ public class SitemapServletTest {
     }
 
     @Test
-    public void testSitemapServedOnDemand() throws ServletException, 
IOException {
+    void testSitemapServedOnDemand() throws ServletException, IOException {
         // given
         MockSlingHttpServletRequest request = newSitemapReq("news-sitemap", 
root);
         MockSlingHttpServletResponse response = context.response();
@@ -248,7 +248,7 @@ public class SitemapServletTest {
         assertEquals("application/xml;charset=utf-8", 
response.getContentType());
         assertEquals("utf-8", response.getCharacterEncoding());
         assertEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                         + "<url><loc>/content/site/de</loc></url>"
                         + "</urlset>",
                 response.getOutputAsString()
@@ -256,9 +256,9 @@ public class SitemapServletTest {
     }
 
     @Test
-    public void testSitemapServedFromStorage() throws ServletException, 
IOException {
+    void testSitemapServedFromStorage() throws ServletException, IOException {
         // given
-        String expectedOutcome = SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+        String expectedOutcome = AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                 + "<url><loc>/content/site/en</loc></url>"
                 + "</urlset>";
         byte[] expectedOutcomeBytes = 
expectedOutcome.getBytes(StandardCharsets.UTF_8);
@@ -283,9 +283,9 @@ public class SitemapServletTest {
     }
 
     @Test
-    public void testMultiFileSitemapServedFromStorage() throws 
ServletException, IOException {
+    void testMultiFileSitemapServedFromStorage() throws ServletException, 
IOException {
         // given
-        String expectedOutcome = SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
+        String expectedOutcome = AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\";>"
                 + "<url><loc>/content/site/en</loc></url>"
                 + "</urlset>";
         byte[] expectedOutcomeBytes = 
expectedOutcome.getBytes(StandardCharsets.UTF_8);
@@ -310,7 +310,7 @@ public class SitemapServletTest {
     }
 
     @Test
-    public void testSitemapNotServed() throws ServletException, IOException {
+    void testSitemapNotServed() throws ServletException, IOException {
         // given
         MockSlingHttpServletRequest request = newSitemapReq("sitemap", root);
         MockSlingHttpServletResponse response = context.response();
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java 
b/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java
index c327d66..129b922 100644
--- a/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java
+++ b/src/test/java/org/apache/sling/sitemap/impl/SitemapStorageTest.java
@@ -60,7 +60,7 @@ import static org.mockito.Mockito.when;
 @ExtendWith({SlingContextExtension.class, MockitoExtension.class})
 public class SitemapStorageTest {
 
-    public final SlingContext context = new SlingContext();
+    final SlingContext context = new SlingContext();
 
     private final SitemapStorage subject = new SitemapStorage();
     private final SitemapGeneratorManagerImpl generatorManager = new 
SitemapGeneratorManagerImpl();
@@ -72,7 +72,7 @@ public class SitemapStorageTest {
     private ServiceUserMapped serviceUser;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         context.registerService(SitemapGenerator.class, generator);
         context.registerService(ServiceUserMapped.class, serviceUser, 
"subServiceName", "sitemap-writer");
         context.registerInjectActivateService(configuration);
@@ -87,7 +87,7 @@ public class SitemapStorageTest {
     // Read/Write
 
     @Test
-    public void testConsecutiveWriteOfStateUpdatesContent() throws IOException 
{
+    void testConsecutiveWriteOfStateUpdatesContent() throws IOException {
         // given
         Resource root = context.create().resource("/content/site/de", 
ImmutableMap.of(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
@@ -103,7 +103,7 @@ public class SitemapStorageTest {
     }
 
     @Test
-    public void testConsecutiveWriteOfSitemapUpdatesContent() throws 
IOException {
+    void testConsecutiveWriteOfSitemapUpdatesContent() throws IOException {
         // given
         Resource root = context.create().resource("/content/site/de", 
ImmutableMap.of(
                 "sitemapRoot", Boolean.TRUE
@@ -121,7 +121,7 @@ public class SitemapStorageTest {
     }
 
     @Test
-    public void testListSitemapsReturnsOnlySitemaps() throws IOException {
+    void testListSitemapsReturnsOnlySitemaps() throws IOException {
         // given
         Resource root = context.create().resource("/content/site/de", 
ImmutableMap.of(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
@@ -142,7 +142,7 @@ public class SitemapStorageTest {
     // Cleanup
 
     @Test
-    public void testStateExpires() throws InterruptedException, IOException {
+    void testStateExpires() throws InterruptedException, IOException {
         // given
         Resource root = context.create().resource("/content/site/de", 
ImmutableMap.of(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
@@ -159,7 +159,7 @@ public class SitemapStorageTest {
 
 
     @Test
-    public void testCleanupExpiredStates() throws Exception {
+    void testCleanupExpiredStates() throws Exception {
         // given
         Resource root = context.create().resource("/content/site/de", 
ImmutableMap.of(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
@@ -180,7 +180,7 @@ public class SitemapStorageTest {
     }
 
     @Test
-    public void testCleanupObsoleteSitemapsAfterTopLevelChanged() throws 
Exception {
+    void testCleanupObsoleteSitemapsAfterTopLevelChanged() throws Exception {
         // given
         Resource newRoot = context.create().resource("/content/site/ch");
         Resource initialRoot = 
context.create().resource("/content/site/ch/de-ch", ImmutableMap.of(
@@ -208,7 +208,7 @@ public class SitemapStorageTest {
     }
 
     @Test
-    public void testCleanupObsoleteSitemapsAfterNestedSitemapRootChanged() 
throws Exception {
+    void testCleanupObsoleteSitemapsAfterNestedSitemapRootChanged() throws 
Exception {
         // given
         Resource root = context.create().resource("/content/site/de", 
ImmutableMap.of(
                 SitemapService.PROPERTY_SITEMAP_ROOT, Boolean.TRUE
@@ -238,7 +238,7 @@ public class SitemapStorageTest {
     // Eventing
 
     @Test
-    public void testNoPurgeEventSentOnStateCleanup() throws IOException, 
InterruptedException {
+    void testNoPurgeEventSentOnStateCleanup() throws IOException, 
InterruptedException {
         // given
         List<Event> capturedEvents = new ArrayList<>();
         Resource root = context.create().resource("/content/site/de", 
ImmutableMap.of(
@@ -259,7 +259,7 @@ public class SitemapStorageTest {
     }
 
     @Test
-    public void testUpdatedAndPurgeEventSentOnSitemapWriteCleanup() throws 
IOException, InterruptedException {
+    void testUpdatedAndPurgeEventSentOnSitemapWriteCleanup() throws 
IOException, InterruptedException {
         // given
         List<Event> capturedEvents = new ArrayList<>();
         Resource root = context.create().resource("/content/site/de", 
ImmutableMap.of(
@@ -287,7 +287,7 @@ public class SitemapStorageTest {
     }
 
     @Test
-    public void testUpdatedAndPurgeEventSentOnSitemapWriteDelete() throws 
IOException, InterruptedException {
+    void testUpdatedAndPurgeEventSentOnSitemapWriteDelete() throws 
IOException, InterruptedException {
         // given
         List<Event> capturedEvents = new ArrayList<>();
         Resource root = context.create().resource("/content/site/de", 
ImmutableMap.of(
@@ -333,6 +333,7 @@ public class SitemapStorageTest {
             @Override
             public boolean matches(Object o) {
                 return o instanceof Event
+                        && topic.equals(((Event) o).getTopic())
                         && storagePath.equals(
                         ((Event) 
o).getProperty(SitemapGenerator.EVENT_PROPERTY_SITEMAP_STORAGE_PATH));
             }
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/builder/AbstractBuilderTest.java 
b/src/test/java/org/apache/sling/sitemap/impl/builder/AbstractBuilderTest.java
index c57c4e2..559c29d 100644
--- 
a/src/test/java/org/apache/sling/sitemap/impl/builder/AbstractBuilderTest.java
+++ 
b/src/test/java/org/apache/sling/sitemap/impl/builder/AbstractBuilderTest.java
@@ -36,6 +36,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class AbstractBuilderTest {
 
+    public static final String XML_HEADER = "<?xml version=\"1.0\" 
encoding=\"UTF-8\"?>";
+
     private static final URL XML_XSD = 
AbstractBuilderTest.class.getClassLoader().getResource("xml.xsd");
     private static final URL XHTML_XSD = 
AbstractBuilderTest.class.getClassLoader().getResource("xhtml1-strict.xsd");
     private static final URL SITEMAP_XSD = 
AbstractBuilderTest.class.getClassLoader().getResource("sitemap-0.9.xsd");
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/builder/SitemapImplTest.java 
b/src/test/java/org/apache/sling/sitemap/impl/builder/SitemapImplTest.java
index 443ba9e..95c8a77 100644
--- a/src/test/java/org/apache/sling/sitemap/impl/builder/SitemapImplTest.java
+++ b/src/test/java/org/apache/sling/sitemap/impl/builder/SitemapImplTest.java
@@ -37,21 +37,19 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
 @ExtendWith({SlingContextExtension.class})
-public class SitemapImplTest extends AbstractBuilderTest {
+class SitemapImplTest extends AbstractBuilderTest {
 
-    public static final String XML_HEADER = "<?xml version=\"1.0\" 
encoding=\"UTF-8\"?>";
-
-    public final SlingContext context = new SlingContext();
+    final SlingContext context = new SlingContext();
 
     private ExtensionProviderManager extensionManager;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         extensionManager = context.registerInjectActivateService(new 
ExtensionProviderManager());
     }
 
     @Test
-    public void testEmptySitemap() throws IOException {
+    void testEmptySitemap() throws IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl subject = new SitemapImpl(writer, extensionManager);
@@ -68,7 +66,7 @@ public class SitemapImplTest extends AbstractBuilderTest {
     }
 
     @Test
-    public void testSitemapWithSingleLocation() throws SitemapException, 
IOException {
+    void testSitemapWithSingleLocation() throws SitemapException, IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl subject = new SitemapImpl(writer, extensionManager);
@@ -88,7 +86,7 @@ public class SitemapImplTest extends AbstractBuilderTest {
     }
 
     @Test
-    public void testWriteAfterRead() throws SitemapException, IOException {
+    void testWriteAfterRead() throws SitemapException, IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl subject = new SitemapImpl(writer, extensionManager);
@@ -117,7 +115,7 @@ public class SitemapImplTest extends AbstractBuilderTest {
     }
 
     @Test
-    public void testIOExceptionWrappedInSitemapException() throws IOException {
+    void testIOExceptionWrappedInSitemapException() throws IOException, 
SitemapException {
         // given
         Writer throwingWriter = new Writer() {
             @Override
@@ -137,10 +135,11 @@ public class SitemapImplTest extends AbstractBuilderTest {
         };
         SitemapImpl sitemap = new SitemapImpl(throwingWriter, 
extensionManager, false);
 
-        SitemapException ex = assertThrows(SitemapException.class, () -> {
-            sitemap.addUrl("http://localhost:4502";);
-            sitemap.addUrl("http://localhost:4503";); // throws
-        });
+        // when
+        sitemap.addUrl("http://localhost:4502";);
+
+        // then
+        SitemapException ex = assertThrows(SitemapException.class, () -> 
sitemap.addUrl("http://localhost:4503";));
         assertThat(ex.getCause(), instanceOf(IOException.class));
     }
 }
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/builder/SitemapIndexImplTest.java 
b/src/test/java/org/apache/sling/sitemap/impl/builder/SitemapIndexImplTest.java
index 633ae2e..5b5d73f 100644
--- 
a/src/test/java/org/apache/sling/sitemap/impl/builder/SitemapIndexImplTest.java
+++ 
b/src/test/java/org/apache/sling/sitemap/impl/builder/SitemapIndexImplTest.java
@@ -27,16 +27,15 @@ import java.time.Instant;
 import org.apache.sling.sitemap.SitemapException;
 import org.junit.jupiter.api.Test;
 
-import static org.apache.sling.sitemap.impl.builder.SitemapImplTest.XML_HEADER;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
-public class SitemapIndexImplTest extends AbstractBuilderTest {
+class SitemapIndexImplTest extends AbstractBuilderTest {
 
     private static final Instant DATETIME = 
Instant.ofEpochMilli(1622122594000L);
 
     @Test
-    public void testAfterCloseFails() throws IOException {
+    void testAfterCloseFails() throws IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapIndexImpl subject = new SitemapIndexImpl(writer);
@@ -51,7 +50,7 @@ public class SitemapIndexImplTest extends AbstractBuilderTest 
{
     }
 
     @Test
-    public void testIOExceptionWrapped() throws IOException {
+    void testIOExceptionWrapped() throws IOException {
         // given
         Writer writer = new FilterWriter(new StringWriter()) {
             @Override public void flush() throws IOException {
@@ -70,7 +69,7 @@ public class SitemapIndexImplTest extends AbstractBuilderTest 
{
     }
 
     @Test
-    public void testEmptyIndex() throws IOException {
+    void testEmptyIndex() throws IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapIndexImpl subject = new SitemapIndexImpl(writer);
@@ -86,7 +85,7 @@ public class SitemapIndexImplTest extends AbstractBuilderTest 
{
     }
 
     @Test
-    public void testAddSitemapNoLastmod() throws IOException, SitemapException 
{
+    void testAddSitemapNoLastmod() throws IOException, SitemapException {
         // given
         StringWriter writer = new StringWriter();
         SitemapIndexImpl subject = new SitemapIndexImpl(writer);
@@ -107,7 +106,7 @@ public class SitemapIndexImplTest extends 
AbstractBuilderTest {
     }
 
     @Test
-    public void testAddSitemapWithLastmod() throws IOException, 
SitemapException {
+    void testAddSitemapWithLastmod() throws IOException, SitemapException {
         // given
         StringWriter writer = new StringWriter();
         SitemapIndexImpl subject = new SitemapIndexImpl(writer);
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/builder/UrlImplTest.java 
b/src/test/java/org/apache/sling/sitemap/impl/builder/UrlImplTest.java
index bd0a330..d2496b5 100644
--- a/src/test/java/org/apache/sling/sitemap/impl/builder/UrlImplTest.java
+++ b/src/test/java/org/apache/sling/sitemap/impl/builder/UrlImplTest.java
@@ -25,9 +25,11 @@ import 
org.apache.sling.sitemap.spi.builder.AbstractExtension;
 import org.apache.sling.sitemap.spi.builder.SitemapExtensionProvider;
 import 
org.apache.sling.sitemap.impl.builder.extensions.ExtensionProviderManager;
 import org.apache.sling.testing.mock.sling.junit5.SlingContext;
+import org.apache.sling.testing.mock.sling.junit5.SlingContextExtension;
 import org.jetbrains.annotations.NotNull;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
@@ -37,16 +39,17 @@ import java.time.Instant;
 
 import static org.junit.jupiter.api.Assertions.*;
 
-public class UrlImplTest extends AbstractBuilderTest {
+@ExtendWith({ SlingContextExtension.class })
+class UrlImplTest extends AbstractBuilderTest {
 
     private static final Instant DATETIME = 
Instant.ofEpochMilli(1622122594000L);
 
-    public final SlingContext context = new SlingContext();
+    final SlingContext context = new SlingContext();
 
     private ExtensionProviderManager extensionManager;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         context.registerService(
                 SitemapExtensionProvider.class, new TestExtensionProvider(),
                 "extension.interface", TestExtension.class.getName(),
@@ -58,7 +61,7 @@ public class UrlImplTest extends AbstractBuilderTest {
     }
 
     @Test
-    public void testAddFullUrl() throws SitemapException, IOException {
+    void testAddFullUrl() throws SitemapException, IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl subject = new SitemapImpl(writer, extensionManager);
@@ -74,7 +77,7 @@ public class UrlImplTest extends AbstractBuilderTest {
 
         // then
         assertSitemap(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
                         "xmlns:tst=\"http://localhost/schema/test/1.0\";>"
                         + "<url>"
                         + "<loc>http://example.com</loc>"
@@ -88,7 +91,7 @@ public class UrlImplTest extends AbstractBuilderTest {
     }
 
     @Test
-    public void testPriorityNormalization() throws SitemapException, 
IOException {
+    void testPriorityNormalization() throws SitemapException, IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl subject = new SitemapImpl(writer, extensionManager);
@@ -100,7 +103,7 @@ public class UrlImplTest extends AbstractBuilderTest {
 
         // then
         assertSitemap(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
                         "xmlns:tst=\"http://localhost/schema/test/1.0\";>"
                         + "<url>"
                         + "<loc>http://example.com/page1.html</loc>"
@@ -116,7 +119,7 @@ public class UrlImplTest extends AbstractBuilderTest {
     }
 
     @Test
-    public void testWithExtensions() throws SitemapException, IOException {
+    void testWithExtensions() throws SitemapException, IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl subject = new SitemapImpl(writer, extensionManager);
@@ -131,7 +134,7 @@ public class UrlImplTest extends AbstractBuilderTest {
 
         // then
         assertEquals(
-                SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
+                AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
                         "xmlns:tst=\"http://localhost/schema/test/1.0\";>"
                         + "<url>"
                         + "<loc>http://example.com/page1.html</loc>"
@@ -145,10 +148,11 @@ public class UrlImplTest extends AbstractBuilderTest {
     }
 
     @Test
-    public void testWritingUrlOrExtensionTwiceFails() throws SitemapException, 
IOException {
+    void testWritingUrlOrExtensionTwiceFails() throws SitemapException, 
IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl subject = new SitemapImpl(writer, extensionManager);
+        Instant now = Instant.now();
 
         // when
         Url url = subject.addUrl("http://example.com/page1.html";);
@@ -158,7 +162,7 @@ public class UrlImplTest extends AbstractBuilderTest {
 
         assertThrows(IllegalStateException.class, () -> url.setPriority(0.0));
         assertThrows(IllegalStateException.class, () -> 
url.setChangeFrequency(Url.ChangeFrequency.ALWAYS));
-        assertThrows(IllegalStateException.class, () -> 
url.setLastModified(Instant.now()));
+        assertThrows(IllegalStateException.class, () -> 
url.setLastModified(now));
         assertThrows(IllegalStateException.class, () -> 
url.addExtension(TestExtension.class));
         assertThrows(IllegalStateException.class, () -> 
subject.addUrl("http://foo.bar";));
         assertThrows(IllegalStateException.class, subject::close);
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/builder/extensions/AlternateLanguageExtensionTest.java
 
b/src/test/java/org/apache/sling/sitemap/impl/builder/extensions/AlternateLanguageExtensionTest.java
index 447609d..f4d1dc9 100644
--- 
a/src/test/java/org/apache/sling/sitemap/impl/builder/extensions/AlternateLanguageExtensionTest.java
+++ 
b/src/test/java/org/apache/sling/sitemap/impl/builder/extensions/AlternateLanguageExtensionTest.java
@@ -27,7 +27,6 @@ import org.apache.sling.sitemap.builder.Url;
 import org.apache.sling.sitemap.builder.extensions.AlternateLanguageExtension;
 import org.apache.sling.sitemap.impl.builder.AbstractBuilderTest;
 import org.apache.sling.sitemap.impl.builder.SitemapImpl;
-import org.apache.sling.sitemap.impl.builder.SitemapImplTest;
 import org.apache.sling.testing.mock.sling.junit5.SlingContext;
 import org.apache.sling.testing.mock.sling.junit5.SlingContextExtension;
 import org.junit.jupiter.api.BeforeEach;
@@ -35,20 +34,20 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 
 @ExtendWith({ SlingContextExtension.class })
-public class AlternateLanguageExtensionTest extends AbstractBuilderTest {
+class AlternateLanguageExtensionTest extends AbstractBuilderTest {
 
-    public final SlingContext context = new SlingContext();
+    final SlingContext context = new SlingContext();
 
     private ExtensionProviderManager extensionProviderManager;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         context.registerInjectActivateService(new 
AlternateLanguageExtensionProvider());
         extensionProviderManager = context.registerInjectActivateService(new 
ExtensionProviderManager());
     }
 
     @Test
-    public void testAlternateLanguageCombinations() throws SitemapException, 
IOException {
+    void testAlternateLanguageCombinations() throws SitemapException, 
IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl sitemap = new SitemapImpl(writer, 
extensionProviderManager);
@@ -68,7 +67,7 @@ public class AlternateLanguageExtensionTest extends 
AbstractBuilderTest {
 
         // then
         assertSitemap(
-            SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
+            AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
                 "xmlns:xhtml=\"http://www.w3.org/1999/xhtml\";>"
                 + "<url>"
                 + "<loc>http://example.ch/de.html</loc>"
@@ -82,7 +81,7 @@ public class AlternateLanguageExtensionTest extends 
AbstractBuilderTest {
     }
 
     @Test
-    public void testNothingWrittenWhenExtensionMissesMandatoryProperties() 
throws SitemapException, IOException {
+    void testNothingWrittenWhenExtensionMissesMandatoryProperties() throws 
SitemapException, IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl sitemap = new SitemapImpl(writer, 
extensionProviderManager);
@@ -97,7 +96,7 @@ public class AlternateLanguageExtensionTest extends 
AbstractBuilderTest {
 
         // then
         assertSitemap(
-            SitemapImplTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
+            AbstractBuilderTest.XML_HEADER + "<urlset 
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"; " +
                 "xmlns:xhtml=\"http://www.w3.org/1999/xhtml\";>"
                 + "<url>"
                 + "<loc>http://example.ch/de.html</loc>"
diff --git 
a/src/test/java/org/apache/sling/sitemap/impl/console/SitemapInventoryPluginTest.java
 
b/src/test/java/org/apache/sling/sitemap/impl/console/SitemapInventoryPluginTest.java
index 2503fc3..73b5ea7 100644
--- 
a/src/test/java/org/apache/sling/sitemap/impl/console/SitemapInventoryPluginTest.java
+++ 
b/src/test/java/org/apache/sling/sitemap/impl/console/SitemapInventoryPluginTest.java
@@ -64,9 +64,9 @@ import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.Mockito.*;
 
 @ExtendWith({SlingContextExtension.class, MockitoExtension.class})
-public class SitemapInventoryPluginTest {
+class SitemapInventoryPluginTest {
 
-    public final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
+    final SlingContext context = new 
SlingContext(ResourceResolverType.JCR_MOCK);
     private final SitemapInventoryPlugin subject = new 
SitemapInventoryPlugin();
     private final SitemapServiceConfiguration configuration = new 
SitemapServiceConfiguration();
 
@@ -100,7 +100,7 @@ public class SitemapInventoryPluginTest {
     private ResourceResolverFactory resourceResolverFactory;
 
     @BeforeEach
-    public void setup() throws LoginException {
+    void setup() throws LoginException {
         ResourceResolver resourceResolver = spy(context.resourceResolver());
 
         context.registerService(SitemapService.class, sitemapService);
@@ -155,7 +155,7 @@ public class SitemapInventoryPluginTest {
     }
 
     @Test
-    public void testJson() {
+    void testJson() {
         // given
         StringWriter writer = new StringWriter();
 
@@ -167,7 +167,7 @@ public class SitemapInventoryPluginTest {
     }
 
     @Test
-    public void testText() {
+    void testText() {
         // given
         StringWriter writer = new StringWriter();
 
diff --git 
a/src/test/java/org/apache/sling/sitemap/spi/generator/ResourceTreeSitemapGeneratorTest.java
 
b/src/test/java/org/apache/sling/sitemap/spi/generator/ResourceTreeSitemapGeneratorTest.java
index f6be78e..c496b5f 100644
--- 
a/src/test/java/org/apache/sling/sitemap/spi/generator/ResourceTreeSitemapGeneratorTest.java
+++ 
b/src/test/java/org/apache/sling/sitemap/spi/generator/ResourceTreeSitemapGeneratorTest.java
@@ -35,14 +35,14 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import java.io.IOException;
 import java.io.StringWriter;
 
-import static org.apache.sling.sitemap.impl.builder.SitemapImplTest.XML_HEADER;
+import static 
org.apache.sling.sitemap.impl.builder.AbstractBuilderTest.XML_HEADER;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.when;
 
 @ExtendWith({SlingContextExtension.class, MockitoExtension.class})
-public class ResourceTreeSitemapGeneratorTest {
+class ResourceTreeSitemapGeneratorTest {
 
-    public final SlingContext context = new SlingContext();
+    final SlingContext context = new SlingContext();
 
     private final SitemapGenerator subject = new 
TestResourceTreeSitemapGenerator();
     private final ExtensionProviderManager extensionProviderManager = new 
ExtensionProviderManager();
@@ -52,7 +52,7 @@ public class ResourceTreeSitemapGeneratorTest {
     private Resource sitemapRoot;
 
     @BeforeEach
-    public void setup() {
+    void setup() {
         sitemapRoot = context.load()
                 .json("/ResourceTreeSitemapGeneratorTest/sitetree.json", 
"/content/site/de");
 
@@ -60,7 +60,7 @@ public class ResourceTreeSitemapGeneratorTest {
     }
 
     @Test
-    public void testSitemapContainsAllResourcesButJcrContent() throws 
SitemapException, IOException {
+    void testSitemapContainsAllResourcesButJcrContent() throws 
SitemapException, IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl sitemap = new SitemapImpl(writer, 
extensionProviderManager);
@@ -82,7 +82,7 @@ public class ResourceTreeSitemapGeneratorTest {
     }
 
     @Test
-    public void testSitemapDoesNotContainsResourcesWithoutJcrContent() throws 
SitemapException, IOException {
+    void testSitemapDoesNotContainsResourcesWithoutJcrContent() throws 
SitemapException, IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl sitemap = new SitemapImpl(writer, 
extensionProviderManager);
@@ -105,7 +105,7 @@ public class ResourceTreeSitemapGeneratorTest {
     }
 
     @Test
-    public void testSkipTo() throws SitemapException, IOException {
+    void testSkipTo() throws SitemapException, IOException {
         // given
         StringWriter writer = new StringWriter();
         SitemapImpl sitemap = new SitemapImpl(writer, 
extensionProviderManager);

Reply via email to