From 1181dd57d3800a678c1411e1c6450050f95676e6 Mon Sep 17 00:00:00 2001 From: eschleb Date: Mon, 16 Dec 2024 13:10:03 +0100 Subject: [PATCH] Make import path and behaviour configurable --- .../merkle/oss/magnolia/testing/repository/Repository.java | 4 ++++ .../oss/magnolia/testing/repository/RepositoryUtil.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/merkle/oss/magnolia/testing/repository/Repository.java b/src/main/java/com/merkle/oss/magnolia/testing/repository/Repository.java index 6bddf0f..120a027 100644 --- a/src/main/java/com/merkle/oss/magnolia/testing/repository/Repository.java +++ b/src/main/java/com/merkle/oss/magnolia/testing/repository/Repository.java @@ -6,6 +6,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.jcr.ImportUUIDBehavior; + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) @Inherited @@ -18,6 +20,8 @@ String xml(); String repositoryId() default "magnolia"; boolean create() default false; + String path() default "/"; + int importUUIDBehavior() default ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW; } @interface NodeTypesDefinition { diff --git a/src/main/java/com/merkle/oss/magnolia/testing/repository/RepositoryUtil.java b/src/main/java/com/merkle/oss/magnolia/testing/repository/RepositoryUtil.java index dd69dc6..3b8c67c 100644 --- a/src/main/java/com/merkle/oss/magnolia/testing/repository/RepositoryUtil.java +++ b/src/main/java/com/merkle/oss/magnolia/testing/repository/RepositoryUtil.java @@ -49,7 +49,7 @@ private void load(final Class testClass, final Repository repository) throws repositoryManager.loadWorkspace(workspace.repositoryId(), workspace.name()); } final Session session = repositoryManager.getSystemSession(workspace.name()); - session.importXML("/", testClass.getResourceAsStream(workspace.xml()), ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW); + session.importXML(workspace.path(), testClass.getResourceAsStream(workspace.xml()), workspace.importUUIDBehavior()); session.save(); session.logout(); }