Class UniqueRoot
- java.lang.Object
-
- org.apache.sling.testing.mock.sling.context.UniqueRoot
-
@ConsumerType public class UniqueRoot extends Object
Manages unique root paths in JCR repository. This is important for resource resolver types like JCR_JACKRABBIT where the repository is not cleaned for each test run. This class provides unique root paths for each run, and cleans them up when done.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringuniquePathPart
-
Constructor Summary
Constructors Modifier Constructor Description protectedUniqueRoot(@NotNull SlingContextImpl context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull Stringapps()Gets (and creates if required) a unique path at/apps/xxx.protected voidcleanUp()Cleanup is called when the unit test rule completes a unit test run.@NotNull Stringcontent()Gets (and creates if required) a unique path at/content/xxx.protected voiddeleteResources(@Nullable org.apache.sling.api.resource.Resource @NotNull ... resources)Deletes the given set of resources and commits afterwards.protected org.apache.sling.api.resource.ResourcegetOrCreateResource(@NotNull String path, @NotNull String primaryType)Get or create resource with given JCR primary type@NotNull Stringlibs()Gets (and creates if required) a unique path at/libs/xxx.
-
-
-
Field Detail
-
uniquePathPart
protected final String uniquePathPart
-
-
Constructor Detail
-
UniqueRoot
protected UniqueRoot(@NotNull @NotNull SlingContextImpl context)
-
-
Method Detail
-
getOrCreateResource
protected final org.apache.sling.api.resource.Resource getOrCreateResource(@NotNull @NotNull String path, @NotNull @NotNull String primaryType)Get or create resource with given JCR primary type- Parameters:
path- PathprimaryType- JCR primary type- Returns:
- Resource (never null)
-
content
@NotNull public final @NotNull String content()
Gets (and creates if required) a unique path at/content/xxx. The path (incl. all children) is automatically removed when the unit test completes.- Returns:
- Unique content path
-
apps
@NotNull public final @NotNull String apps()
Gets (and creates if required) a unique path at/apps/xxx. The path (incl. all children) is automatically removed when the unit test completes.- Returns:
- Unique content path
-
libs
@NotNull public final @NotNull String libs()
Gets (and creates if required) a unique path at/libs/xxx. The path (incl. all children) is automatically removed when the unit test completes.- Returns:
- Unique content path
-
cleanUp
protected void cleanUp()
Cleanup is called when the unit test rule completes a unit test run. All resources created have to be removed.
-
deleteResources
protected final void deleteResources(@Nullable @Nullable org.apache.sling.api.resource.Resource @NotNull ... resources)Deletes the given set of resources and commits afterwards.- Parameters:
resources- Resources to be deleted
-
-