SLING-9620 - ResourceMapperImpl.getAllMappings does not respect multi-valued sling:alias
Add failing tests
rombert: ignoring tests until they pass, small tweaks to InMemoryResourceProvider and test data
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/InMemoryResourceProvider.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/InMemoryResourceProvider.java
index 52f1fad..718ed55 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/InMemoryResourceProvider.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/InMemoryResourceProvider.java
@@ -70,6 +70,10 @@
putResource(path, Collections.singletonMap(key, value));
}
+ public void putResource(String path, String key, Object... values) {
+ putResource(path, Collections.singletonMap(key, values));
+ }
+
public void putResource(String path, String key, Object value, String key2, Object value2) {
Map<String, Object> props = new HashMap<>();
props.put(key, value);
diff --git a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
index 67a00f6..56001aa 100644
--- a/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
+++ b/src/test/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImplTest.java
@@ -49,6 +49,7 @@
import org.jetbrains.annotations.NotNull;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -104,6 +105,7 @@
resourceProvider.putResource("/"); // root
resourceProvider.putResource("/here"); // regular page
resourceProvider.putResource("/there", PROP_ALIAS, "alias-value"); // with alias
+ resourceProvider.putResource("/there-multiple", PROP_ALIAS, "alias-value-3", "alias-value-4"); // with multivalued alias
resourceProvider.putResource("/somewhere", PROP_ALIAS, "alias-value-2"); // with alias and also /etc/map
resourceProvider.putResource("/there/that"); // parent has alias
resourceProvider.putResource("/content");
@@ -194,6 +196,23 @@
}
/**
+ * Validates that mappings for a existing resource with multiple alias contain the alias and the resource's path
+ *
+ * @throws LoginException
+ */
+ @Test
+ @Ignore("SLING-9620")
+ public void mapResourceWithMultivaluedAlias() {
+
+ ExpectedMappings.existingResource("/there-multiple")
+ .singleMapping("/alias-value-3")
+ .singleMappingWithRequest("/app/alias-value-3")
+ .allMappings("/alias-value-3", "/alias-value-4", "/there-multiple")
+ .allMappingsWithRequest("/app/alias-value-3", "/app/alias-value-4", "/app/there-multiple")
+ .verify(resolver, req);
+ }
+
+ /**
* Validates that mappings for a existing resource with an alias and /etc/map entry
* contain the /etc/map entry, the alias and the resource's path
*