Search in sources :

Example 11 with ResourceChange

use of org.apache.sling.api.resource.observation.ResourceChange in project sling by apache.

the class FileVaultFileMonitorTest method testUpdateContent.

@Test
public void testUpdateContent() throws Exception {
    List<ResourceChange> changes = resourceListener.getChanges();
    assertTrue(changes.isEmpty());
    File file = new File(tempDir, "jcr_root/content/samples/en/.content.xml");
    FileUtils.touch(file);
    Thread.sleep(WAIT_INTERVAL);
    assertChange(changes, "/content/samples/en", ChangeType.REMOVED);
    assertChange(changes, "/content/samples/en", ChangeType.ADDED);
    assertChange(changes, "/content/samples/en/jcr:content", ChangeType.ADDED);
}
Also used : ResourceChange(org.apache.sling.api.resource.observation.ResourceChange) File(java.io.File) Test(org.junit.Test)

Example 12 with ResourceChange

use of org.apache.sling.api.resource.observation.ResourceChange in project sling by apache.

the class FileMonitorTest method testRemoveFile.

@Test
public void testRemoveFile() throws Exception {
    List<ResourceChange> changes = resourceListener.getChanges();
    assertTrue(changes.isEmpty());
    File file1a = new File(tempDir, "folder1/file1a.txt");
    file1a.delete();
    Thread.sleep(WAIT_INTERVAL);
    assertEquals(2, changes.size());
    assertChange(changes, "/fs-test/folder1", ChangeType.CHANGED);
    assertChange(changes, "/fs-test/folder1/file1a.txt", ChangeType.REMOVED);
}
Also used : ResourceChange(org.apache.sling.api.resource.observation.ResourceChange) File(java.io.File) Test(org.junit.Test)

Example 13 with ResourceChange

use of org.apache.sling.api.resource.observation.ResourceChange in project sling by apache.

the class FileMonitorTest method testAddFolder.

@Test
public void testAddFolder() throws Exception {
    List<ResourceChange> changes = resourceListener.getChanges();
    assertTrue(changes.isEmpty());
    File folder99 = new File(tempDir, "folder99");
    folder99.mkdir();
    Thread.sleep(WAIT_INTERVAL);
    assertEquals(2, changes.size());
    assertChange(changes, "/fs-test", ChangeType.CHANGED);
    assertChange(changes, "/fs-test/folder99", ChangeType.ADDED);
}
Also used : ResourceChange(org.apache.sling.api.resource.observation.ResourceChange) File(java.io.File) Test(org.junit.Test)

Example 14 with ResourceChange

use of org.apache.sling.api.resource.observation.ResourceChange in project sling by apache.

the class FileVaultFileMonitorTest method testRemoveContent.

@Test
public void testRemoveContent() throws Exception {
    List<ResourceChange> changes = resourceListener.getChanges();
    assertTrue(changes.isEmpty());
    File file = new File(tempDir, "jcr_root/content/samples/en");
    FileUtils.deleteDirectory(file);
    Thread.sleep(WAIT_INTERVAL);
    assertEquals(2, changes.size());
    assertChange(changes, "/content/samples", ChangeType.CHANGED);
    assertChange(changes, "/content/samples/en", ChangeType.REMOVED);
}
Also used : ResourceChange(org.apache.sling.api.resource.observation.ResourceChange) File(java.io.File) Test(org.junit.Test)

Example 15 with ResourceChange

use of org.apache.sling.api.resource.observation.ResourceChange in project sling by apache.

the class FileVaultFileMonitorTest method testRemoveFile.

@Test
public void testRemoveFile() throws Exception {
    List<ResourceChange> changes = resourceListener.getChanges();
    assertTrue(changes.isEmpty());
    File file = new File(tempDir, "jcr_root/content/dam/talk.png/_jcr_content/renditions/web.1280.1280.png");
    file.delete();
    Thread.sleep(WAIT_INTERVAL);
    assertEquals(2, changes.size());
    assertChange(changes, "/content/dam/talk.png/jcr:content/renditions", ChangeType.CHANGED);
    assertChange(changes, "/content/dam/talk.png/jcr:content/renditions/web.1280.1280.png", ChangeType.REMOVED);
}
Also used : ResourceChange(org.apache.sling.api.resource.observation.ResourceChange) File(java.io.File) Test(org.junit.Test)

Aggregations

ResourceChange (org.apache.sling.api.resource.observation.ResourceChange)38 Test (org.junit.Test)20 File (java.io.File)17 HashSet (java.util.HashSet)4 ArrayList (java.util.ArrayList)3 Event (org.osgi.service.event.Event)2 ImmutableList (com.google.common.collect.ImmutableList)1 SoftReference (java.lang.ref.SoftReference)1 Dictionary (java.util.Dictionary)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Node (javax.jcr.Node)1 RepositoryException (javax.jcr.RepositoryException)1 Session (javax.jcr.Session)1 Event (javax.jcr.observation.Event)1 JackrabbitEvent (org.apache.jackrabbit.api.observation.JackrabbitEvent)1