use of org.dcache.namespace.ListHandler in project dcache by dCache.
the class MonitoringNameSpaceProviderTest method shouldNotifyOnListWithSingleEntry.
@Test
public void shouldNotifyOnListWithSingleEntry() throws Exception {
ListHandler handler = mock(ListHandler.class);
PnfsId parent = new PnfsId("000000000000000000000000000000000001");
PnfsId target = new PnfsId("000000000000000000000000000000000002");
given(inner.pathToPnfsid(any(), eq("/foo"), anyBoolean())).willReturn(target);
willAnswer(i -> {
ListHandler h = i.getArgument(5, ListHandler.class);
h.addEntry("bar", new FileAttributes());
return null;
}).given(inner).list(any(), eq("/foo"), any(), any(), any(), any());
given(inner.find(any(), eq(target))).willReturn(singleLink(parent, "foo"));
monitor.list(TEST_USER, "/foo", null, Range.all(), EnumSet.noneOf(FileAttribute.class), handler);
verify(inner).list(eq(TEST_USER), eq("/foo"), eq(null), eq(Range.all()), any(), any());
verify(handler).addEntry(eq("bar"), any());
InOrder childEvents = inOrder(receiver);
childEvents.verify(receiver).notifyChildEvent(EventType.IN_OPEN, parent, "foo", FileType.DIR);
childEvents.verify(receiver).notifyChildEvent(EventType.IN_CLOSE_NOWRITE, parent, "foo", FileType.DIR);
InOrder dirEvents = inOrder(receiver);
dirEvents.verify(receiver).notifySelfEvent(EventType.IN_OPEN, target, FileType.DIR);
dirEvents.verify(receiver).notifySelfEvent(EventType.IN_CLOSE_NOWRITE, target, FileType.DIR);
verify(receiver, never()).notifyMovedEvent(any(), any(), any(), any(), any());
}
use of org.dcache.namespace.ListHandler in project dcache by dCache.
the class MonitoringNameSpaceProviderTest method shouldNotNotifyOnUnsuccessfulList.
@Test
public void shouldNotNotifyOnUnsuccessfulList() throws Exception {
ListHandler handler = mock(ListHandler.class);
PnfsId parent = new PnfsId("000000000000000000000000000000000001");
PnfsId target = new PnfsId("000000000000000000000000000000000002");
given(inner.pathToPnfsid(any(), eq("/foo"), anyBoolean())).willReturn(target);
willThrow(CacheException.class).given(inner).list(any(), eq("/foo"), any(), any(), any(), any());
given(inner.find(any(), eq(target))).willReturn(singleLink(parent, "foo"));
try {
monitor.list(TEST_USER, "/foo", null, Range.all(), EnumSet.noneOf(FileAttribute.class), handler);
fail("list unexpectedly succeeded");
} catch (CacheException e) {
}
verify(receiver, never()).notifyChildEvent(any(), any(), any(), any());
verify(receiver, never()).notifySelfEvent(any(), any(), any());
verify(receiver, never()).notifyMovedEvent(any(), any(), any(), any(), any());
}
use of org.dcache.namespace.ListHandler in project dcache by dCache.
the class MonitoringNameSpaceProviderTest method shouldNotifyOnListWithNoEntries.
@Test
public void shouldNotifyOnListWithNoEntries() throws Exception {
ListHandler handler = mock(ListHandler.class);
PnfsId parent = new PnfsId("000000000000000000000000000000000001");
PnfsId target = new PnfsId("000000000000000000000000000000000002");
given(inner.pathToPnfsid(any(), eq("/foo"), anyBoolean())).willReturn(target);
given(inner.find(any(), eq(target))).willReturn(singleLink(parent, "foo"));
monitor.list(TEST_USER, "/foo", null, Range.all(), EnumSet.noneOf(FileAttribute.class), handler);
verify(inner).list(eq(TEST_USER), eq("/foo"), eq(null), eq(Range.all()), any(), any());
verify(handler, never()).addEntry(any(), any());
InOrder childEvents = inOrder(receiver);
childEvents.verify(receiver).notifyChildEvent(EventType.IN_OPEN, parent, "foo", FileType.DIR);
childEvents.verify(receiver).notifyChildEvent(EventType.IN_CLOSE_NOWRITE, parent, "foo", FileType.DIR);
InOrder dirEvents = inOrder(receiver);
dirEvents.verify(receiver).notifySelfEvent(EventType.IN_OPEN, target, FileType.DIR);
dirEvents.verify(receiver).notifySelfEvent(EventType.IN_CLOSE_NOWRITE, target, FileType.DIR);
verify(receiver, never()).notifyMovedEvent(any(), any(), any(), any(), any());
}
use of org.dcache.namespace.ListHandler in project dcache by dCache.
the class MonitoringNameSpaceProviderTest method shouldNotifyOnListWithTwoEntries.
@Test
public void shouldNotifyOnListWithTwoEntries() throws Exception {
ListHandler handler = mock(ListHandler.class);
PnfsId parent = new PnfsId("000000000000000000000000000000000001");
PnfsId target = new PnfsId("000000000000000000000000000000000002");
given(inner.pathToPnfsid(any(), eq("/foo"), anyBoolean())).willReturn(target);
willAnswer(i -> {
ListHandler h = i.getArgument(5, ListHandler.class);
h.addEntry("bar-1", new FileAttributes());
h.addEntry("bar-2", new FileAttributes());
return null;
}).given(inner).list(any(), eq("/foo"), any(), any(), any(), any());
given(inner.find(any(), eq(target))).willReturn(singleLink(parent, "foo"));
monitor.list(TEST_USER, "/foo", null, Range.all(), EnumSet.noneOf(FileAttribute.class), handler);
verify(inner).list(eq(TEST_USER), eq("/foo"), eq(null), eq(Range.all()), any(), any());
verify(handler).addEntry(eq("bar-1"), any());
verify(handler).addEntry(eq("bar-2"), any());
InOrder childEvents = inOrder(receiver);
childEvents.verify(receiver).notifyChildEvent(EventType.IN_OPEN, parent, "foo", FileType.DIR);
childEvents.verify(receiver).notifyChildEvent(EventType.IN_CLOSE_NOWRITE, parent, "foo", FileType.DIR);
InOrder dirEvents = inOrder(receiver);
dirEvents.verify(receiver).notifySelfEvent(EventType.IN_OPEN, target, FileType.DIR);
dirEvents.verify(receiver).notifySelfEvent(EventType.IN_CLOSE_NOWRITE, target, FileType.DIR);
verify(receiver, never()).notifyMovedEvent(any(), any(), any(), any(), any());
}
Aggregations