Skip to content

Commit

Permalink
SLING-5371 - avoid path conflicts with other tests
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1728088 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
bdelacretaz committed Feb 2, 2016
1 parent 54886fc commit e717340
Showing 1 changed file with 14 additions and 5 deletions.
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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());
Expand Down

0 comments on commit e717340

Please sign in to comment.