Issue #5086 Improve ScannerTest
Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
parent
4883332593
commit
4304c7861c
|
@ -24,6 +24,8 @@ import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.PathMatcher;
|
import java.nio.file.PathMatcher;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
@ -121,6 +123,20 @@ public class ScannerTest
|
||||||
_filename = filename;
|
_filename = filename;
|
||||||
_notification = notification;
|
_notification = notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj)
|
||||||
|
{
|
||||||
|
return ((Event)obj)._filename.equals(_filename) && ((Event)obj)._notification == _notification;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return ("File: " + _filename + ":" + _notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -274,7 +290,6 @@ public class ScannerTest
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisabledOnOs(WINDOWS) // TODO: needs review
|
@DisabledOnOs(WINDOWS) // TODO: needs review
|
||||||
@DisabledIfSystemProperty(named = "env", matches = "ci") // TODO: SLOW, needs review
|
|
||||||
public void testAddedChangeRemove() throws Exception
|
public void testAddedChangeRemove() throws Exception
|
||||||
{
|
{
|
||||||
touch("a0");
|
touch("a0");
|
||||||
|
@ -304,19 +319,14 @@ public class ScannerTest
|
||||||
touch("a2");
|
touch("a2");
|
||||||
delete("a3");
|
delete("a3");
|
||||||
|
|
||||||
// only a1 is stable so it should be seen.
|
// only a1 is stable so it should be seen, a3 is deleted
|
||||||
_scanner.scan();
|
_scanner.scan();
|
||||||
event = _queue.poll();
|
List<Event> actualEvents = new ArrayList<>();
|
||||||
assertNotNull(event);
|
_queue.drainTo(actualEvents);
|
||||||
assertEquals(_directory + "/a1", event._filename);
|
assertEquals(2, actualEvents.size());
|
||||||
assertEquals(Notification.ADDED, event._notification);
|
Event a1 = new Event(_directory + "/a1", Notification.ADDED);
|
||||||
|
Event a3 = new Event(_directory + "/a3", Notification.REMOVED);
|
||||||
//TODO: behaviour change, we should see an immediate
|
assertThat(actualEvents, Matchers.containsInAnyOrder(a1, a3));
|
||||||
//delete for a3
|
|
||||||
event = _queue.poll();
|
|
||||||
assertNotNull(event);
|
|
||||||
assertEquals(_directory + "/a3", event._filename);
|
|
||||||
assertEquals(Notification.REMOVED, event._notification);
|
|
||||||
assertTrue(_queue.isEmpty());
|
assertTrue(_queue.isEmpty());
|
||||||
|
|
||||||
// Now a2 is stable
|
// Now a2 is stable
|
||||||
|
@ -360,18 +370,14 @@ public class ScannerTest
|
||||||
delete("a1");
|
delete("a1");
|
||||||
delete("a2");
|
delete("a2");
|
||||||
|
|
||||||
//TODO: behaviour change, now we get immediate notification of
|
//Immediate notification of deletes.
|
||||||
//deletes.
|
|
||||||
_scanner.scan();
|
_scanner.scan();
|
||||||
|
a1 = new Event(_directory + "/a1", Notification.REMOVED);
|
||||||
event = _queue.poll();
|
Event a2 = new Event(_directory + "/a2", Notification.REMOVED);
|
||||||
assertNotNull(event);
|
actualEvents = new ArrayList<>();
|
||||||
assertEquals(_directory + "/a1", event._filename);
|
_queue.drainTo(actualEvents);
|
||||||
assertEquals(Notification.REMOVED, event._notification);
|
assertEquals(2, actualEvents.size());
|
||||||
event = _queue.poll();
|
assertThat(actualEvents, Matchers.containsInAnyOrder(a1, a2));
|
||||||
assertNotNull(event);
|
|
||||||
assertEquals(_directory + "/a2", event._filename);
|
|
||||||
assertEquals(Notification.REMOVED, event._notification);
|
|
||||||
assertTrue(_queue.isEmpty());
|
assertTrue(_queue.isEmpty());
|
||||||
|
|
||||||
// recreate a2
|
// recreate a2
|
||||||
|
@ -383,8 +389,7 @@ public class ScannerTest
|
||||||
assertNull(event);
|
assertNull(event);
|
||||||
assertTrue(_queue.isEmpty());
|
assertTrue(_queue.isEmpty());
|
||||||
|
|
||||||
//TODO: behaviour change, now a2 is reported as ADDED. Previously, a2
|
//Now a2 is reported as ADDED.
|
||||||
//delete was not reported, but was reported as CHANGED when re-added.
|
|
||||||
_scanner.scan();
|
_scanner.scan();
|
||||||
event = _queue.poll();
|
event = _queue.poll();
|
||||||
assertTrue(event != null);
|
assertTrue(event != null);
|
||||||
|
|
Loading…
Reference in New Issue