ankursinglaadobe commented on code in PR #12:
URL:
https://github.com/apache/sling-org-apache-sling-installer-provider-jcr/pull/12#discussion_r4703766773
##########
src/test/java/org/apache/sling/installer/provider/jcr/impl/JcrHandleUpdateTest.java:
##########
@@ -192,31 +192,95 @@ public void
testProcessConfigurationUpdatesWithDataPayload() throws Exception {
}
/**
- * Tests URL transformation for different root path priorities.
- *
- * Validates that configuration updates in different root paths
- * (/apps, /libs) are handled consistently.
+ * Tests that configurations from a lower priority root path (/libs) are
+ * written back below the root path with the highest priority (/apps).
*/
@Test
- public void testHandleDifferentRootPathPriorities() throws Exception {
Review Comment:
This was a wrong test that was introduced in the PR:
https://github.com/apache/sling-org-apache-sling-installer-provider-jcr/pull/10
as explained in the comment above. For now, I have reverted the changes and
restored the test. Will raise a separate PR for fixing this test.
##########
src/test/java/org/apache/sling/installer/provider/jcr/impl/JcrHandleUpdateTest.java:
##########
@@ -192,31 +192,95 @@ public void
testProcessConfigurationUpdatesWithDataPayload() throws Exception {
}
/**
- * Tests URL transformation for different root path priorities.
- *
- * Validates that configuration updates in different root paths
- * (/apps, /libs) are handled consistently.
+ * Tests that configurations from a lower priority root path (/libs) are
+ * written back below the root path with the highest priority (/apps).
*/
@Test
- public void testHandleDifferentRootPathPriorities() throws Exception {
- // Given: Different root paths with varying priorities
- String[] rootPaths = {APPS_BASE_PATH, LIBS_BASE_PATH};
-
- for (String rootPath : rootPaths) {
- // When: Handling update in different root path
- String originalUrl = JCR_INSTALL_SCHEME + rootPath + "/" +
TEST_CONFIG_NAME + ".config";
+ public void testWriteBackToRootPathWithHighestPriority() throws Exception {
+ String originalUrl = JCR_INSTALL_SCHEME + LIBS_BASE_PATH + "/config/"
+ TEST_CONFIG_NAME + ".config";
+ UpdateResult updateResult = installer.handleUpdate(
+ CONFIG_RESOURCE_TYPE,
+ TEST_CONFIG_NAME,
+ originalUrl,
+ new Hashtable<>(),
+ null
+ );
+
+ assertEquals(JCR_INSTALL_SCHEME + "/apps/sling/config/" +
TEST_CONFIG_NAME + EXPECTED_JSON_EXTENSION,
+ updateResult.getURL());
+ }
+
+ /**
+ * Tests that the extension is removed from the re-rooted path, even if the
+ * original root path has a different length than the highest priority
root path.
+ */
+ @Test
+ public void testWriteBackFromRootPathWithDifferentLength() throws
Exception {
+ String originalUrl = JCR_INSTALL_SCHEME +
"/custom/myapp/config/org.example.MyService.config";
+ UpdateResult updateResult = installer.handleUpdate(
+ CONFIG_RESOURCE_TYPE,
+ "org.example.MyService",
+ originalUrl,
+ new Hashtable<>(),
+ null
+ );
+
+ assertEquals(JCR_INSTALL_SCHEME +
"/apps/myapp/config/org.example.MyService" + EXPECTED_JSON_EXTENSION,
+ updateResult.getURL());
+ }
+
+ /**
+ * Tests that a configuration node named after the PID without any
extension
+ * (e.g. a node of type sling:OsgiConfig) keeps its full PID on write back.
+ */
+ @Test
+ public void testKeepPidOfConfigurationWithoutExtension() throws Exception {
+ String[] pids = {
+ "com.adobe.granite.csrf.impl.CSRFFilter",
Review Comment:
Done. Thanks for the catch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]