From e717340053023b0326df5878958e5f4206b14c05 Mon Sep 17 00:00:00 2001 From: Bertrand Delacretaz Date: Tue, 2 Feb 2016 11:27:24 +0000 Subject: [PATCH] SLING-5371 - avoid path conflicts with other tests git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1728088 13f79535-47bb-0310-9956-ffa450edef68 --- .../jcr/impl/RootFolderMoveListenerTest.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/installer/providers/jcr/src/test/java/org/apache/sling/installer/provider/jcr/impl/RootFolderMoveListenerTest.java b/installer/providers/jcr/src/test/java/org/apache/sling/installer/provider/jcr/impl/RootFolderMoveListenerTest.java index 14ff9997aa..7e7605b299 100644 --- a/installer/providers/jcr/src/test/java/org/apache/sling/installer/provider/jcr/impl/RootFolderMoveListenerTest.java +++ b/installer/providers/jcr/src/test/java/org/apache/sling/installer/provider/jcr/impl/RootFolderMoveListenerTest.java @@ -22,6 +22,8 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.util.UUID; + import javax.jcr.Session; import org.apache.sling.commons.testing.jcr.RepositoryProvider; @@ -39,8 +41,15 @@ public class RootFolderMoveListenerTest { private Session contentModificationSession; private Session moveListenerSession; - public static final String [] ROOTS = { "/foo", "/bar" }; + public static final String ROOT_1 = "/" + uniqueName(); + public static final String ROOT_2 = "/" + uniqueName(); + + public static final String [] ROOTS = { ROOT_1, ROOT_2 }; + private static String uniqueName() { + return RootFolderMoveListener.class.getSimpleName() + "_" + UUID.randomUUID().toString(); + } + @Before public void setup() throws Exception { // Need 2 sessions for this test, as the RootFolderMoveListener is registered with noLocal property set to true. @@ -67,7 +76,7 @@ private void waitForScanDelay() { @Test public void testToString() { final String str = rmlt.toString(); - assertTrue("Expecting " + str + " to contain our list of paths", str.contains("/foo, /bar")); + assertTrue("Expecting " + str + " to contain our list of paths", str.contains(ROOT_1 + ", " + ROOT_2)); } @Test @@ -80,14 +89,14 @@ public void testTimer() { @Test public void testMove() throws Exception { - contentModificationSession.getRootNode().addNode("foo"); - contentModificationSession.getNode("/foo").addNode("one"); + contentModificationSession.getRootNode().addNode(ROOT_1.substring(1)); + contentModificationSession.getNode(ROOT_1).addNode("one"); contentModificationSession.save(); waitForScanDelay(); assertFalse("Expecting no scheduled scan before move", timer.expired()); - contentModificationSession.move("/foo/one", "/foo/two"); + contentModificationSession.move(ROOT_1 + "/one", ROOT_1 + "/two"); contentModificationSession.save(); waitForScanDelay(); assertTrue("Expecting scan to be triggered after move", timer.expired());