This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
The following commit(s) were added to refs/heads/master by this push:
new 18dbdf1c SLING-12998: ResourceResolver: implement toString() on
VanityPathConfig (#204)
18dbdf1c is described below
commit 18dbdf1ce3e9b3b35477b439b6a735d65b4d0f15
Author: Julian Reschke <[email protected]>
AuthorDate: Tue Nov 11 12:27:44 2025 +0100
SLING-12998: ResourceResolver: implement toString() on VanityPathConfig
(#204)
* SLING-12998: ResourceResolver: implement toString() on VanityPathConfig
* SLING-12998: ResourceResolver: implement toString() on VanityPathConfig
---
.../impl/mapping/MapConfigurationProvider.java | 11 ++++++++---
.../impl/mapping/VanityPathMapEntriesTest.java | 6 ++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git
a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java
b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java
index aab6e86b..8dee1658 100644
---
a/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java
+++
b/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapConfigurationProvider.java
@@ -29,7 +29,7 @@ import org.apache.sling.api.resource.path.Path;
/**
* Internal interface representing the additional methods
* MapEntries needs from the ResourceResolverFactory.
- *
+ * <p>
* Exists primarily to facilitate mocking of the ResourceResolverFactory
* when testing MapEntries.
*/
@@ -65,7 +65,7 @@ public interface MapConfigurationProvider extends
ResourceResolverFactory {
Map<String, Object> getServiceUserAuthenticationInfo(final String
subServiceName) throws LoginException;
- public class VanityPathConfig implements Comparable<VanityPathConfig> {
+ class VanityPathConfig implements Comparable<VanityPathConfig> {
public final boolean isExclude;
public final String prefix;
@@ -76,7 +76,12 @@ public interface MapConfigurationProvider extends
ResourceResolverFactory {
@Override
public int compareTo(VanityPathConfig o2) {
- return
Integer.valueOf(o2.prefix.length()).compareTo(this.prefix.length());
+ return Integer.compare(o2.prefix.length(), this.prefix.length());
+ }
+
+ @Override
+ public String toString() {
+ return (this.isExclude ? "deny " : "allow ") + "'" + this.prefix +
"'";
}
}
diff --git
a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
index 0c82c54a..05706e03 100644
---
a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
+++
b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/VanityPathMapEntriesTest.java
@@ -243,6 +243,12 @@ public class VanityPathMapEntriesTest extends
AbstractMappingMapEntriesTest {
mockCloser.close();
}
+ @Test
+ public void test_vanity_pathconfig_to_string() {
+ assertEquals("deny '/libs/'", new VanityPathConfig("/libs/",
true).toString());
+ assertEquals("allow '/2025/12/19'", new
VanityPathConfig("/2025/12/19", false).toString());
+ }
+
@Test
public void test_simple_vanity_path() {
String vanityPath = "/xyz";