Skip to content

Commit

Permalink
alias processing happens asynchronously, so it may take a bit until t…
Browse files Browse the repository at this point in the history
…he alias resolution works
  • Loading branch information
stefanseifert committed Dec 7, 2023
1 parent 94c666b commit e35881e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@

import static com.day.cq.commons.jcr.JcrConstants.JCR_PRIMARYTYPE;
import static com.day.cq.commons.jcr.JcrConstants.NT_UNSTRUCTURED;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
Expand Down Expand Up @@ -52,7 +55,10 @@ public void testSlingAlias() throws PersistenceException {
context.resourceResolver().commit();

assertEquals(contentRoot + "/myresource", resource.getPath());
assertEquals(contentRoot + "/myalias", context.resourceResolver().map(resource.getPath()));

// alias processing happens asynchronously, so it may take a bit until the alias resolution works
await().atMost(2, SECONDS).until(() -> StringUtils.equals(contentRoot + "/myalias",
context.resourceResolver().map(resource.getPath())));
}

}

0 comments on commit e35881e

Please sign in to comment.