target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void testOpenDirectory() { String fakePath = "/foo/baz"; doReturn(mockFileSystem).when(mockPath).getFileSystem(); doReturn(fsHandle).when(mockFileSystem).getVolptr(); doReturn(fakePath).when(mockPath).getString(); mockStatic(GLFS.class); when(GLFS.glfs_opendir(fsHandle, fakePath)).thenReturn(dirHandle); st... | public void open(GlusterPath path) { dir = path; if (dirHandle == 0) { dirHandle = GLFS.glfs_opendir(path.getFileSystem().getVolptr(), path.getString()); } else { throw new IllegalStateException("Already open!"); } } | GlusterDirectoryStream implements DirectoryStream<Path> { public void open(GlusterPath path) { dir = path; if (dirHandle == 0) { dirHandle = GLFS.glfs_opendir(path.getFileSystem().getVolptr(), path.getString()); } else { throw new IllegalStateException("Already open!"); } } } | GlusterDirectoryStream implements DirectoryStream<Path> { public void open(GlusterPath path) { dir = path; if (dirHandle == 0) { dirHandle = GLFS.glfs_opendir(path.getFileSystem().getVolptr(), path.getString()); } else { throw new IllegalStateException("Already open!"); } } } | GlusterDirectoryStream implements DirectoryStream<Path> { public void open(GlusterPath path) { dir = path; if (dirHandle == 0) { dirHandle = GLFS.glfs_opendir(path.getFileSystem().getVolptr(), path.getString()); } else { throw new IllegalStateException("Already open!"); } } @Override Iterator<Path> iterator(); @Overri... | GlusterDirectoryStream implements DirectoryStream<Path> { public void open(GlusterPath path) { dir = path; if (dirHandle == 0) { dirHandle = GLFS.glfs_opendir(path.getFileSystem().getVolptr(), path.getString()); } else { throw new IllegalStateException("Already open!"); } } @Override Iterator<Path> iterator(); @Overri... |
@Test(expected = IllegalStateException.class) public void testIterator_whenAlreadyIterating() { stream.setIterator(mockIterator); stream.iterator(); } | @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this.iterator = iterator; return iterator; } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... |
@Test(expected = IllegalStateException.class) public void testIterator_whenClosed() { stream.setClosed(true); stream.iterator(); } | @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this.iterator = iterator; return iterator; } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... |
@Test public void testIterator() throws Exception { stream.setClosed(false); stream.setFilter(mockFilter); whenNew(GlusterDirectoryIterator.class). withNoArguments().thenReturn(mockIterator); stream.setDirHandle(dirHandle); Iterator<Path> iterator = stream.iterator(); verifyNew(GlusterDirectoryIterator.class).withNoArg... | @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this.iterator = iterator; return iterator; } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public Iterator<Path> iterator() { if (null != iterator || closed) { throw new IllegalStateException("Already iterating!"); } GlusterDirectoryIterator iterator = new GlusterDirectoryIterator(); iterator.setStream(this); iterator.setFilter(filter); this... |
@Test public void testClose_whenAlreadyClosed() throws IOException { stream.setDirHandle(dirHandle); stream.setClosed(true); mockStatic(GLFS.class); stream.close(); verifyStatic(Mockito.never()); GLFS.glfs_close(dirHandle); } | @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } @Override Iterator<Path> iterator(); @Override void close(); void open(GlusterPath path); } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } @Override Iterator<Path> iterator(); @Override void close(); void open(GlusterPath path); } |
@Test public void testRegisterPath() { watchService.setRunning(true); GlusterPath mockPath = mock(GlusterPath.class); WatchEvent.Kind mockKind = mock(WatchEvent.Kind.class); watchService.registerPath(mockPath, mockKind); GlusterWatchKey event = watchService.getPaths().iterator().next(); assertEquals(mockPath, event.get... | public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey(path, kinds); paths.add(key); return key; } | GlusterWatchService implements WatchService { public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey... | GlusterWatchService implements WatchService { public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey... | GlusterWatchService implements WatchService { public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey... | GlusterWatchService implements WatchService { public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey... |
@Test public void testClose() throws IOException { stream.setDirHandle(dirHandle); mockStatic(GLFS.class); Mockito.when(GLFS.glfs_close(dirHandle)).thenReturn(0); stream.close(); verifyStatic(); GLFS.glfs_close(dirHandle); } | @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } @Override Iterator<Path> iterator(); @Override void close(); void open(GlusterPath path); } | GlusterDirectoryStream implements DirectoryStream<Path> { @Override public void close() throws IOException { if (!closed) { GLFS.glfs_close(dirHandle); closed = true; } } @Override Iterator<Path> iterator(); @Override void close(); void open(GlusterPath path); } |
@Test public void testParseOptions() { Set<StandardOpenOption> options = new HashSet<StandardOpenOption>(); options.add(StandardOpenOption.APPEND); options.add(StandardOpenOption.WRITE); int result = channel.parseOptions(options); assertEquals(GlusterOpenOption.O_RDWR | GlusterOpenOption.O_APPEND, result); } | int parseOptions(Set<? extends OpenOption> options) { int opt = 0; for (OpenOption o : options) { if (!optionMap.containsKey(o)) { throw new UnsupportedOperationException("Option " + o + " is not supported at this time"); } opt |= optionMap.get(o); } return opt; } | GlusterFileChannel extends FileChannel { int parseOptions(Set<? extends OpenOption> options) { int opt = 0; for (OpenOption o : options) { if (!optionMap.containsKey(o)) { throw new UnsupportedOperationException("Option " + o + " is not supported at this time"); } opt |= optionMap.get(o); } return opt; } } | GlusterFileChannel extends FileChannel { int parseOptions(Set<? extends OpenOption> options) { int opt = 0; for (OpenOption o : options) { if (!optionMap.containsKey(o)) { throw new UnsupportedOperationException("Option " + o + " is not supported at this time"); } opt |= optionMap.get(o); } return opt; } } | GlusterFileChannel extends FileChannel { int parseOptions(Set<? extends OpenOption> options) { int opt = 0; for (OpenOption o : options) { if (!optionMap.containsKey(o)) { throw new UnsupportedOperationException("Option " + o + " is not supported at this time"); } opt |= optionMap.get(o); } return opt; } @Override int... | GlusterFileChannel extends FileChannel { int parseOptions(Set<? extends OpenOption> options) { int opt = 0; for (OpenOption o : options) { if (!optionMap.containsKey(o)) { throw new UnsupportedOperationException("Option " + o + " is not supported at this time"); } opt |= optionMap.get(o); } return opt; } @Override int... |
@Test(expected = ClosedChannelException.class) public void testRead3Arg_whenClosed() throws IOException { channel.setClosed(true); ByteBuffer[] buffers = new ByteBuffer[2]; buffers[0] = mockBuffer; buffers[1] = mockBuffer; int offset = 0; int length = 2; channel.read(buffers, offset, length); } | @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position((int)read); return (int) read; } | GlusterFileChannel extends FileChannel { @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position... | GlusterFileChannel extends FileChannel { @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position... | GlusterFileChannel extends FileChannel { @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position... | GlusterFileChannel extends FileChannel { @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position... |
@Test public void testReadHelper() throws IOException { long fileptr = 1234L; channel.setFileptr(fileptr); ByteBuffer[] buffers = new ByteBuffer[2]; buffers[0] = mockBuffer; buffers[1] = mockBuffer; int offset = 0; int length = 2; byte[] bytes = new byte[]{'h', 'e', 'l', 'l', 'o'}; doReturn(bytes).when(mockBuffer).arra... | long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byteBuffers[i].remaining()) > 0) { long read... | GlusterFileChannel extends FileChannel { long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byt... | GlusterFileChannel extends FileChannel { long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byt... | GlusterFileChannel extends FileChannel { long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byt... | GlusterFileChannel extends FileChannel { long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byt... |
@Test(expected = IOException.class) public void testReadHelper_whenReadFails() throws IOException { long fileptr = 1234L; channel.setFileptr(fileptr); ByteBuffer[] buffers = new ByteBuffer[2]; buffers[0] = mockBuffer; buffers[1] = mockBuffer; int offset = 0; int length = 2; byte[] bytes = new byte[]{'h', 'e', 'l', 'l',... | long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byteBuffers[i].remaining()) > 0) { long read... | GlusterFileChannel extends FileChannel { long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byt... | GlusterFileChannel extends FileChannel { long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byt... | GlusterFileChannel extends FileChannel { long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byt... | GlusterFileChannel extends FileChannel { long readHelper(ByteBuffer[] byteBuffers, int offset, int length) throws IOException { long totalRead = 0L; boolean endOfStream = false; for (int i = offset; i < length + offset && !endOfStream; i++) { byte[] bytes = byteBuffers[i].array(); int remaining; while ((remaining = byt... |
@Test(expected = ClosedChannelException.class) public void testRead2Arg_whenClosed() throws IOException { long position = 5L; channel.setClosed(true); channel.read(mockBuffer, position); } | @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position((int)read); return (int) read; } | GlusterFileChannel extends FileChannel { @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position... | GlusterFileChannel extends FileChannel { @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position... | GlusterFileChannel extends FileChannel { @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position... | GlusterFileChannel extends FileChannel { @Override public int read(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] bytes = byteBuffer.array(); long read = GLFS.glfs_read(fileptr, bytes, bytes.length, 0); if (read < 0) { throw new IOException(UtilJNI.strerror()); } position += read; byteBuffer.position... |
@Test(expected = ClosedChannelException.class) public void testWrite3Arg_whenClosedChannel() throws IOException { channel.setClosed(true); int length = 2; int offset = 0; ByteBuffer buffer1 = Mockito.mock(ByteBuffer.class); ByteBuffer buffer2 = Mockito.mock(ByteBuffer.class); ByteBuffer[] buffers = new ByteBuffer[]{buf... | @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.position(written); return written; } | GlusterFileChannel extends FileChannel { @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.posi... | GlusterFileChannel extends FileChannel { @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.posi... | GlusterFileChannel extends FileChannel { @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.posi... | GlusterFileChannel extends FileChannel { @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.posi... |
@Test(expected = ClosedChannelException.class) public void testWrite2Arg_whenChannelClosed() throws IOException { channel.setClosed(true); ByteBuffer buffer = Mockito.mock(ByteBuffer.class); long position = 0L; channel.write(buffer, position); } | @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.position(written); return written; } | GlusterFileChannel extends FileChannel { @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.posi... | GlusterFileChannel extends FileChannel { @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.posi... | GlusterFileChannel extends FileChannel { @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.posi... | GlusterFileChannel extends FileChannel { @Override public int write(ByteBuffer byteBuffer) throws IOException { guardClosed(); byte[] buf = byteBuffer.array(); int written = GLFS.glfs_write(fileptr, buf, buf.length, 0); if (written < 0) { throw new IOException(UtilJNI.strerror()); } position += written; byteBuffer.posi... |
@Test public void testGuardClosed_whenNotClosed() throws ClosedChannelException { channel.setClosed(false); channel.guardClosed(); } | void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } | GlusterFileChannel extends FileChannel { void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } } | GlusterFileChannel extends FileChannel { void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } } | GlusterFileChannel extends FileChannel { void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, int length); @Override int write(ByteBuffer byteBuffer); @Override long ... | GlusterFileChannel extends FileChannel { void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, int length); @Override int write(ByteBuffer byteBuffer); @Override long ... |
@Test(expected = ClosedChannelException.class) public void testGuardClosed_whenClosed() throws ClosedChannelException { channel.setClosed(true); channel.guardClosed(); } | void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } | GlusterFileChannel extends FileChannel { void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } } | GlusterFileChannel extends FileChannel { void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } } | GlusterFileChannel extends FileChannel { void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, int length); @Override int write(ByteBuffer byteBuffer); @Override long ... | GlusterFileChannel extends FileChannel { void guardClosed() throws ClosedChannelException { if (closed) { throw new ClosedChannelException(); } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, int length); @Override int write(ByteBuffer byteBuffer); @Override long ... |
@Test public void testRegisterPath_whenPathExists() { watchService.setRunning(true); GlusterPath mockPath = mock(GlusterPath.class); GlusterWatchKey keyFix = new GlusterWatchKey(mockPath, new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_MODIFY}); watchService.getPaths().add(keyFix); watchService.registerPath(mockPat... | public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey(path, kinds); paths.add(key); return key; } | GlusterWatchService implements WatchService { public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey... | GlusterWatchService implements WatchService { public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey... | GlusterWatchService implements WatchService { public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey... | GlusterWatchService implements WatchService { public WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds) { if (!running) { throw new ClosedWatchServiceException(); } for (GlusterWatchKey k : paths) { if (k.getPath().equals(path)) { k.setKinds(kinds); return k; } } GlusterWatchKey key = new GlusterWatchKey... |
@Test(expected = IllegalArgumentException.class) public void testSetPosition_whenNegative() throws IOException { long position = -1l; channel.position(position); } | @Override public long position() throws IOException { guardClosed(); return position; } | GlusterFileChannel extends FileChannel { @Override public long position() throws IOException { guardClosed(); return position; } } | GlusterFileChannel extends FileChannel { @Override public long position() throws IOException { guardClosed(); return position; } } | GlusterFileChannel extends FileChannel { @Override public long position() throws IOException { guardClosed(); return position; } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, int length); @Override int write(ByteBuffer byteBuffer); @Override long write(ByteBuffer[... | GlusterFileChannel extends FileChannel { @Override public long position() throws IOException { guardClosed(); return position; } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, int length); @Override int write(ByteBuffer byteBuffer); @Override long write(ByteBuffer[... |
@Test(expected = IOException.class) public void testForce_whenFailing() throws IOException { long fileptr = 1234l; channel.setFileptr(fileptr); mockStatic(GLFS.class); when(GLFS.glfs_fsync(fileptr)).thenReturn(-1); channel.force(true); } | @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } | GlusterFileChannel extends FileChannel { @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } } | GlusterFileChannel extends FileChannel { @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } } | GlusterFileChannel extends FileChannel { @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, ... | GlusterFileChannel extends FileChannel { @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, ... |
@Test public void testForce() throws IOException { doNothing().when(channel).guardClosed(); long fileptr = 1234l; channel.setFileptr(fileptr); mockStatic(GLFS.class); when(GLFS.glfs_fsync(fileptr)).thenReturn(0); channel.force(true); verify(channel).guardClosed(); verifyStatic(); GLFS.glfs_fsync(fileptr); } | @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } | GlusterFileChannel extends FileChannel { @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } } | GlusterFileChannel extends FileChannel { @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } } | GlusterFileChannel extends FileChannel { @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, ... | GlusterFileChannel extends FileChannel { @Override public void force(boolean b) throws IOException { guardClosed(); int fsync = GLFS.glfs_fsync(fileptr); if (0 != fsync) { throw new IOException("Unable to fsync"); } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] byteBuffers, int offset, ... |
@Test(expected = IOException.class) public void testImplCloseChannel_whenFailing() throws IOException { long fileptr = 1234l; channel.setFileptr(fileptr); mockStatic(GLFS.class); when(GLFS.glfs_close(fileptr)).thenReturn(1); channel.implCloseChannel(); } | @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } } | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } } | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffe... | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffe... |
@Test public void testImplCloseChannel_whenAlreadyClosed() throws IOException { channel.setClosed(true); long fileptr = 1234l; channel.setFileptr(fileptr); mockStatic(GLFS.class); when(GLFS.glfs_close(fileptr)).thenReturn(0); channel.implCloseChannel(); assertTrue(channel.isClosed()); verifyStatic(never()); GLFS.glfs_c... | @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } } | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } } | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffe... | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffe... |
@Test public void testImplCloseChannel() throws IOException { long fileptr = 1234l; channel.setFileptr(fileptr); mockStatic(GLFS.class); when(GLFS.glfs_close(fileptr)).thenReturn(0); channel.implCloseChannel(); assertTrue(channel.isClosed()); verifyStatic(); GLFS.glfs_close(fileptr); } | @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } } | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } } | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffe... | GlusterFileChannel extends FileChannel { @Override protected void implCloseChannel() throws IOException { if (!closed) { int close = GLFS.glfs_close(fileptr); if (0 != close) { throw new IOException("Close returned nonzero"); } closed = true; } } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffe... |
@Test public void testSize() throws Exception { long fileptr = 1234l; channel.setFileptr(fileptr); long actualSize = 321l; stat stat = new stat(); stat.st_size = actualSize; PowerMockito.whenNew(stat.class).withNoArguments().thenReturn(stat); mockStatic(GLFS.class); when(GLFS.glfs_fstat(fileptr, stat)).thenReturn(0); l... | @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } | GlusterFileChannel extends FileChannel { @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } } | GlusterFileChannel extends FileChannel { @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } } | GlusterFileChannel extends FileChannel { @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] ... | GlusterFileChannel extends FileChannel { @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] ... |
@Test(expected = IOException.class) public void testSize_whenFailing() throws Exception { long fileptr = 1234l; channel.setFileptr(fileptr); long actualSize = 321l; stat stat = new stat(); stat.st_size = actualSize; PowerMockito.whenNew(stat.class).withNoArguments().thenReturn(stat); mockStatic(GLFS.class); when(GLFS.g... | @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } | GlusterFileChannel extends FileChannel { @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } } | GlusterFileChannel extends FileChannel { @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } } | GlusterFileChannel extends FileChannel { @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] ... | GlusterFileChannel extends FileChannel { @Override public long size() throws IOException { stat stat = new stat(); int retval = GLFS.glfs_fstat(fileptr, stat); if (0 != retval) { throw new IOException("fstat failed"); } return stat.st_size; } @Override int read(ByteBuffer byteBuffer); @Override long read(ByteBuffer[] ... |
@Test public void testUpdate_whenIOException() throws IOException { PowerMockito.mockStatic(Files.class); when(Files.newDirectoryStream(mockPath)).thenThrow(new IOException()); assertFalse(key.update()); PowerMockito.verifyStatic(); Files.newDirectoryStream(mockPath); } | public boolean update() { DirectoryStream<Path> paths; try { paths = Files.newDirectoryStream(path); } catch (IOException e) { return false; } List<Path> files = new LinkedList<>(); boolean newEvents = false; for (Path f : paths) { newEvents |= processExistingFile(files, f); } for (Path f : events.keySet()) { newEvents... | GlusterWatchKey implements WatchKey { public boolean update() { DirectoryStream<Path> paths; try { paths = Files.newDirectoryStream(path); } catch (IOException e) { return false; } List<Path> files = new LinkedList<>(); boolean newEvents = false; for (Path f : paths) { newEvents |= processExistingFile(files, f); } for ... | GlusterWatchKey implements WatchKey { public boolean update() { DirectoryStream<Path> paths; try { paths = Files.newDirectoryStream(path); } catch (IOException e) { return false; } List<Path> files = new LinkedList<>(); boolean newEvents = false; for (Path f : paths) { newEvents |= processExistingFile(files, f); } for ... | GlusterWatchKey implements WatchKey { public boolean update() { DirectoryStream<Path> paths; try { paths = Files.newDirectoryStream(path); } catch (IOException e) { return false; } List<Path> files = new LinkedList<>(); boolean newEvents = false; for (Path f : paths) { newEvents |= processExistingFile(files, f); } for ... | GlusterWatchKey implements WatchKey { public boolean update() { DirectoryStream<Path> paths; try { paths = Files.newDirectoryStream(path); } catch (IOException e) { return false; } List<Path> files = new LinkedList<>(); boolean newEvents = false; for (Path f : paths) { newEvents |= processExistingFile(files, f); } for ... |
@Test public void testProcessExistingFile() { } | boolean processExistingFile(List<Path> files, Path f) { if (Files.isDirectory(f)) { return false; } files.add(f); long lastModified; try { lastModified = Files.getLastModifiedTime(f).toMillis(); } catch (IOException e) { return false; } GlusterWatchEvent event = events.get(f); if (null != event) { return checkModified(... | GlusterWatchKey implements WatchKey { boolean processExistingFile(List<Path> files, Path f) { if (Files.isDirectory(f)) { return false; } files.add(f); long lastModified; try { lastModified = Files.getLastModifiedTime(f).toMillis(); } catch (IOException e) { return false; } GlusterWatchEvent event = events.get(f); if (... | GlusterWatchKey implements WatchKey { boolean processExistingFile(List<Path> files, Path f) { if (Files.isDirectory(f)) { return false; } files.add(f); long lastModified; try { lastModified = Files.getLastModifiedTime(f).toMillis(); } catch (IOException e) { return false; } GlusterWatchEvent event = events.get(f); if (... | GlusterWatchKey implements WatchKey { boolean processExistingFile(List<Path> files, Path f) { if (Files.isDirectory(f)) { return false; } files.add(f); long lastModified; try { lastModified = Files.getLastModifiedTime(f).toMillis(); } catch (IOException e) { return false; } GlusterWatchEvent event = events.get(f); if (... | GlusterWatchKey implements WatchKey { boolean processExistingFile(List<Path> files, Path f) { if (Files.isDirectory(f)) { return false; } files.add(f); long lastModified; try { lastModified = Files.getLastModifiedTime(f).toMillis(); } catch (IOException e) { return false; } GlusterWatchEvent event = events.get(f); if (... |
@Test public void testClose_whenNotRunning() throws IOException { watchService.setRunning(false); GlusterWatchKey mockKey = mock(GlusterWatchKey.class); watchService.getPaths().add(mockKey); watchService.close(); Mockito.verify(mockKey, Mockito.never()).cancel(); } | @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } | GlusterWatchService implements WatchService { @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } } | GlusterWatchService implements WatchService { @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } } | GlusterWatchService implements WatchService { @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds); @Override void close(); @Override WatchKey poll(); @Override WatchKey p... | GlusterWatchService implements WatchService { @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds); @Override void close(); @Override WatchKey poll(); @Override WatchKey p... |
@Test public void testCheckDeleted() { } | boolean checkDeleted(List<Path> files, Path f) { GlusterWatchEvent event = events.get(f); if (!files.contains(f) && !StandardWatchEventKinds.ENTRY_DELETE.name().equals(event.kind().name())) { event.setLastModified((new Date()).getTime()); event.setKind(StandardWatchEventKinds.ENTRY_DELETE); event.setCount(event.getCoun... | GlusterWatchKey implements WatchKey { boolean checkDeleted(List<Path> files, Path f) { GlusterWatchEvent event = events.get(f); if (!files.contains(f) && !StandardWatchEventKinds.ENTRY_DELETE.name().equals(event.kind().name())) { event.setLastModified((new Date()).getTime()); event.setKind(StandardWatchEventKinds.ENTRY... | GlusterWatchKey implements WatchKey { boolean checkDeleted(List<Path> files, Path f) { GlusterWatchEvent event = events.get(f); if (!files.contains(f) && !StandardWatchEventKinds.ENTRY_DELETE.name().equals(event.kind().name())) { event.setLastModified((new Date()).getTime()); event.setKind(StandardWatchEventKinds.ENTRY... | GlusterWatchKey implements WatchKey { boolean checkDeleted(List<Path> files, Path f) { GlusterWatchEvent event = events.get(f); if (!files.contains(f) && !StandardWatchEventKinds.ENTRY_DELETE.name().equals(event.kind().name())) { event.setLastModified((new Date()).getTime()); event.setKind(StandardWatchEventKinds.ENTRY... | GlusterWatchKey implements WatchKey { boolean checkDeleted(List<Path> files, Path f) { GlusterWatchEvent event = events.get(f); if (!files.contains(f) && !StandardWatchEventKinds.ENTRY_DELETE.name().equals(event.kind().name())) { event.setLastModified((new Date()).getTime()); event.setKind(StandardWatchEventKinds.ENTRY... |
@Test public void testCheckCreated() { } | boolean checkCreated(Path f, long lastModified) { GlusterWatchEvent event = new GlusterWatchEvent(f.getFileName()); event.setLastModified(lastModified); events.put(f, event); return (lastModified > lastPolled); } | GlusterWatchKey implements WatchKey { boolean checkCreated(Path f, long lastModified) { GlusterWatchEvent event = new GlusterWatchEvent(f.getFileName()); event.setLastModified(lastModified); events.put(f, event); return (lastModified > lastPolled); } } | GlusterWatchKey implements WatchKey { boolean checkCreated(Path f, long lastModified) { GlusterWatchEvent event = new GlusterWatchEvent(f.getFileName()); event.setLastModified(lastModified); events.put(f, event); return (lastModified > lastPolled); } } | GlusterWatchKey implements WatchKey { boolean checkCreated(Path f, long lastModified) { GlusterWatchEvent event = new GlusterWatchEvent(f.getFileName()); event.setLastModified(lastModified); events.put(f, event); return (lastModified > lastPolled); } @Override boolean isValid(); boolean update(); @Override synchronize... | GlusterWatchKey implements WatchKey { boolean checkCreated(Path f, long lastModified) { GlusterWatchEvent event = new GlusterWatchEvent(f.getFileName()); event.setLastModified(lastModified); events.put(f, event); return (lastModified > lastPolled); } @Override boolean isValid(); boolean update(); @Override synchronize... |
@Test public void testCheckModified() { } | boolean checkModified(GlusterWatchEvent event, long lastModified) { if (lastModified > event.getLastModified()) { event.setLastModified(lastModified); if (event.kind().name().equals(StandardWatchEventKinds.ENTRY_DELETE.name())) { event.setKind(StandardWatchEventKinds.ENTRY_CREATE); event.setCount(0); } else { event.set... | GlusterWatchKey implements WatchKey { boolean checkModified(GlusterWatchEvent event, long lastModified) { if (lastModified > event.getLastModified()) { event.setLastModified(lastModified); if (event.kind().name().equals(StandardWatchEventKinds.ENTRY_DELETE.name())) { event.setKind(StandardWatchEventKinds.ENTRY_CREATE);... | GlusterWatchKey implements WatchKey { boolean checkModified(GlusterWatchEvent event, long lastModified) { if (lastModified > event.getLastModified()) { event.setLastModified(lastModified); if (event.kind().name().equals(StandardWatchEventKinds.ENTRY_DELETE.name())) { event.setKind(StandardWatchEventKinds.ENTRY_CREATE);... | GlusterWatchKey implements WatchKey { boolean checkModified(GlusterWatchEvent event, long lastModified) { if (lastModified > event.getLastModified()) { event.setLastModified(lastModified); if (event.kind().name().equals(StandardWatchEventKinds.ENTRY_DELETE.name())) { event.setKind(StandardWatchEventKinds.ENTRY_CREATE);... | GlusterWatchKey implements WatchKey { boolean checkModified(GlusterWatchEvent event, long lastModified) { if (lastModified > event.getLastModified()) { event.setLastModified(lastModified); if (event.kind().name().equals(StandardWatchEventKinds.ENTRY_DELETE.name())) { event.setKind(StandardWatchEventKinds.ENTRY_CREATE);... |
@Test public void testKindsContains() { } | boolean kindsContains(WatchEvent.Kind kind) { for (WatchEvent.Kind k : kinds) { if (k.name().equals(kind.name())) { return true; } } return false; } | GlusterWatchKey implements WatchKey { boolean kindsContains(WatchEvent.Kind kind) { for (WatchEvent.Kind k : kinds) { if (k.name().equals(kind.name())) { return true; } } return false; } } | GlusterWatchKey implements WatchKey { boolean kindsContains(WatchEvent.Kind kind) { for (WatchEvent.Kind k : kinds) { if (k.name().equals(kind.name())) { return true; } } return false; } } | GlusterWatchKey implements WatchKey { boolean kindsContains(WatchEvent.Kind kind) { for (WatchEvent.Kind k : kinds) { if (k.name().equals(kind.name())) { return true; } } return false; } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized boole... | GlusterWatchKey implements WatchKey { boolean kindsContains(WatchEvent.Kind kind) { for (WatchEvent.Kind k : kinds) { if (k.name().equals(kind.name())) { return true; } } return false; } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized boole... |
@Test public void testPollEvents_whenNotReady() { key.setReady(false); assertTrue(key.pollEvents().isEmpty()); } | @Override synchronized public List<WatchEvent<?>> pollEvents() { if (!ready) { return new LinkedList<>(); } ready = false; return findPendingEvents(); } | GlusterWatchKey implements WatchKey { @Override synchronized public List<WatchEvent<?>> pollEvents() { if (!ready) { return new LinkedList<>(); } ready = false; return findPendingEvents(); } } | GlusterWatchKey implements WatchKey { @Override synchronized public List<WatchEvent<?>> pollEvents() { if (!ready) { return new LinkedList<>(); } ready = false; return findPendingEvents(); } } | GlusterWatchKey implements WatchKey { @Override synchronized public List<WatchEvent<?>> pollEvents() { if (!ready) { return new LinkedList<>(); } ready = false; return findPendingEvents(); } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized b... | GlusterWatchKey implements WatchKey { @Override synchronized public List<WatchEvent<?>> pollEvents() { if (!ready) { return new LinkedList<>(); } ready = false; return findPendingEvents(); } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized b... |
@Test public void testFindPendingEvents() { } | LinkedList<WatchEvent<?>> findPendingEvents() { long maxModifiedTime = lastPolled; LinkedList<WatchEvent<?>> pendingEvents = new LinkedList<>(); for (Path p : events.keySet()) { long lastModified = queueEventIfPending(pendingEvents, p); maxModifiedTime = Math.max(maxModifiedTime, lastModified); } lastPolled = maxModifi... | GlusterWatchKey implements WatchKey { LinkedList<WatchEvent<?>> findPendingEvents() { long maxModifiedTime = lastPolled; LinkedList<WatchEvent<?>> pendingEvents = new LinkedList<>(); for (Path p : events.keySet()) { long lastModified = queueEventIfPending(pendingEvents, p); maxModifiedTime = Math.max(maxModifiedTime, l... | GlusterWatchKey implements WatchKey { LinkedList<WatchEvent<?>> findPendingEvents() { long maxModifiedTime = lastPolled; LinkedList<WatchEvent<?>> pendingEvents = new LinkedList<>(); for (Path p : events.keySet()) { long lastModified = queueEventIfPending(pendingEvents, p); maxModifiedTime = Math.max(maxModifiedTime, l... | GlusterWatchKey implements WatchKey { LinkedList<WatchEvent<?>> findPendingEvents() { long maxModifiedTime = lastPolled; LinkedList<WatchEvent<?>> pendingEvents = new LinkedList<>(); for (Path p : events.keySet()) { long lastModified = queueEventIfPending(pendingEvents, p); maxModifiedTime = Math.max(maxModifiedTime, l... | GlusterWatchKey implements WatchKey { LinkedList<WatchEvent<?>> findPendingEvents() { long maxModifiedTime = lastPolled; LinkedList<WatchEvent<?>> pendingEvents = new LinkedList<>(); for (Path p : events.keySet()) { long lastModified = queueEventIfPending(pendingEvents, p); maxModifiedTime = Math.max(maxModifiedTime, l... |
@Test public void testReset_whenInvalid() { key.setValid(false); Assert.assertFalse(key.reset()); } | @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } | GlusterWatchKey implements WatchKey { @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } } | GlusterWatchKey implements WatchKey { @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } } | GlusterWatchKey implements WatchKey { @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized boolean reset(); @Override vo... | GlusterWatchKey implements WatchKey { @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized boolean reset(); @Override vo... |
@Test public void testReset_whenReady() { WatchEvent.Kind[] kinds = new WatchEvent.Kind[]{mock(WatchEvent.Kind.class)}; GlusterPath path = mock(GlusterPath.class); GlusterWatchKey key = new GlusterWatchKey(path, kinds); key.setValid(true); key.setReady(true); Assert.assertFalse(key.reset()); } | @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } | GlusterWatchKey implements WatchKey { @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } } | GlusterWatchKey implements WatchKey { @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } } | GlusterWatchKey implements WatchKey { @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized boolean reset(); @Override vo... | GlusterWatchKey implements WatchKey { @Override synchronized public boolean reset() { if (!valid || ready) { return false; } else { ready = true; return true; } } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized boolean reset(); @Override vo... |
@Test public void testCancel() { WatchEvent.Kind[] kinds = new WatchEvent.Kind[]{mock(WatchEvent.Kind.class)}; GlusterPath path = mock(GlusterPath.class); GlusterWatchKey key = new GlusterWatchKey(path, kinds); key.setValid(true); key.setReady(false); assertTrue(key.reset()); assertTrue(key.isReady()); } | @Override public void cancel() { valid = false; } | GlusterWatchKey implements WatchKey { @Override public void cancel() { valid = false; } } | GlusterWatchKey implements WatchKey { @Override public void cancel() { valid = false; } } | GlusterWatchKey implements WatchKey { @Override public void cancel() { valid = false; } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized boolean reset(); @Override void cancel(); @Override Watchable watchable(); } | GlusterWatchKey implements WatchKey { @Override public void cancel() { valid = false; } @Override boolean isValid(); boolean update(); @Override synchronized List<WatchEvent<?>> pollEvents(); @Override synchronized boolean reset(); @Override void cancel(); @Override Watchable watchable(); } |
@Test public void testGetScheme() { GlusterFileSystemProvider p = new GlusterFileSystemProvider(); assertEquals("gluster", p.getScheme()); } | @Override public String getScheme() { return GLUSTER; } | GlusterFileSystemProvider extends FileSystemProvider { @Override public String getScheme() { return GLUSTER; } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public String getScheme() { return GLUSTER; } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public String getScheme() { return GLUSTER; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem getFileSystem(URI uri); @Override Path getPath(URI uri); @Override SeekableByteChannel... | GlusterFileSystemProvider extends FileSystemProvider { @Override public String getScheme() { return GLUSTER; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem getFileSystem(URI uri); @Override Path getPath(URI uri); @Override SeekableByteChannel... |
@Test public void testClose() throws IOException { watchService.setRunning(true); GlusterWatchKey mockKey = mock(GlusterWatchKey.class); watchService.getPaths().add(mockKey); watchService.close(); Mockito.verify(mockKey).cancel(); assertFalse(watchService.isRunning()); } | @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } | GlusterWatchService implements WatchService { @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } } | GlusterWatchService implements WatchService { @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } } | GlusterWatchService implements WatchService { @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds); @Override void close(); @Override WatchKey poll(); @Override WatchKey p... | GlusterWatchService implements WatchService { @Override public void close() throws IOException { if (running) { running = false; for (GlusterWatchKey k : paths) { k.cancel(); } } } WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds); @Override void close(); @Override WatchKey poll(); @Override WatchKey p... |
@Test public void testNewFileSystem() throws IOException, URISyntaxException { String authority = SERVER + ":" + VOLNAME; doReturn(new String[]{SERVER, VOLNAME}).when(provider).parseAuthority(authority); long volptr = 1234l; doReturn(volptr).when(provider).glfsNew(VOLNAME); doNothing().when(provider).glfsSetVolfileServ... | @Override public FileSystem newFileSystem(URI uri, Map<String, ?> stringMap) throws IOException { String authorityString = uri.getAuthority(); String[] authority = parseAuthority(authorityString); String volname = authority[1]; long volptr = glfsNew(volname); glfsSetVolfileServer(authority[0], volptr); glfsInit(authori... | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem newFileSystem(URI uri, Map<String, ?> stringMap) throws IOException { String authorityString = uri.getAuthority(); String[] authority = parseAuthority(authorityString); String volname = authority[1]; long volptr = glfsNew(volname); glfsS... | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem newFileSystem(URI uri, Map<String, ?> stringMap) throws IOException { String authorityString = uri.getAuthority(); String[] authority = parseAuthority(authorityString); String volname = authority[1]; long volptr = glfsNew(volname); glfsS... | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem newFileSystem(URI uri, Map<String, ?> stringMap) throws IOException { String authorityString = uri.getAuthority(); String[] authority = parseAuthority(authorityString); String volname = authority[1]; long volptr = glfsNew(volname); glfsS... | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem newFileSystem(URI uri, Map<String, ?> stringMap) throws IOException { String authorityString = uri.getAuthority(); String[] authority = parseAuthority(authorityString); String volname = authority[1]; long volptr = glfsNew(volname); glfsS... |
@Test(expected = IllegalArgumentException.class) public void testParseAuthority_whenNoColon() { provider.parseAuthority("a"); } | String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new IllegalArgumentException("URI must be of the form 'gluster... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... |
@Test(expected = IllegalArgumentException.class) public void testParseAuthority_whenEmptyHost() { provider.parseAuthority(":b"); } | String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new IllegalArgumentException("URI must be of the form 'gluster... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... |
@Test(expected = IllegalArgumentException.class) public void testParseAuthority_whenEmptyVolume() { provider.parseAuthority("a:"); } | String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new IllegalArgumentException("URI must be of the form 'gluster... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... |
@Test(expected = IllegalArgumentException.class) public void testParseAuthority_whenBadSplit() { provider.parseAuthority("a:b:c"); } | String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new IllegalArgumentException("URI must be of the form 'gluster... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... |
@Test public void testParseAuthority() { String[] actual = provider.parseAuthority("a:b"); assertEquals("a", actual[0]); assertEquals("b", actual[1]); } | String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new IllegalArgumentException("URI must be of the form 'gluster... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... | GlusterFileSystemProvider extends FileSystemProvider { String[] parseAuthority(String authority) { if (!authority.contains(":")) { throw new IllegalArgumentException("URI must be of the form 'gluster: } String[] aarr = authority.split(":"); if (aarr.length != 2 || aarr[0].isEmpty() || aarr[1].isEmpty()) { throw new Ill... |
@Test(expected = IllegalArgumentException.class) public void testGlfsNew_whenBad() { mockStatic(GLFS.class); when(GLFS.glfs_new(VOLNAME)).thenReturn(0l); provider.glfsNew(VOLNAME); } | long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } | GlusterFileSystemProvider extends FileSystemProvider { long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } } | GlusterFileSystemProvider extends FileSystemProvider { long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } } | GlusterFileSystemProvider extends FileSystemProvider { long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri... | GlusterFileSystemProvider extends FileSystemProvider { long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri... |
@Test public void testGlfsNew() { mockStatic(GLFS.class); when(GLFS.glfs_new(VOLNAME)).thenReturn(123l); long l = provider.glfsNew(VOLNAME); verifyStatic(); GLFS.glfs_new(VOLNAME); assertEquals(l, 123l); } | long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } | GlusterFileSystemProvider extends FileSystemProvider { long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } } | GlusterFileSystemProvider extends FileSystemProvider { long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } } | GlusterFileSystemProvider extends FileSystemProvider { long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri... | GlusterFileSystemProvider extends FileSystemProvider { long glfsNew(String volname) { long volptr = glfs_new(volname); if (0 == volptr) { throw new IllegalArgumentException("Failed to create new client for volume: " + volname); } return volptr; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri... |
@Test(expected = IllegalArgumentException.class) public void testGlfsSetVolfileServer_whenBad() { mockStatic(GLFS.class); String host = "123.45.67.89"; when(GLFS.glfs_set_volfile_server(123l, "tcp", host, 24007)).thenReturn(-1); provider.glfsSetVolfileServer(host, 123l); } | void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } @Override String getScheme(); @O... | GlusterFileSystemProvider extends FileSystemProvider { void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } @Override String getScheme(); @O... |
@Test public void testGlfsSetVolfileServer() { mockStatic(GLFS.class); String host = "123.45.67.89"; when(GLFS.glfs_set_volfile_server(123l, "tcp", host, 24007)).thenReturn(0); provider.glfsSetVolfileServer(host, 123l); verifyStatic(); GLFS.glfs_set_volfile_server(123l, "tcp", host, 24007); } | void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } @Override String getScheme(); @O... | GlusterFileSystemProvider extends FileSystemProvider { void glfsSetVolfileServer(String host, long volptr) { int setServer = glfs_set_volfile_server(volptr, TCP, host, GLUSTERD_PORT); if (0 != setServer) { throw new IllegalArgumentException("Failed to set server address: " + host); } } @Override String getScheme(); @O... |
@Test public void testPopPending_whenNonePending() { WatchKey key = watchService.popPending(); assertEquals(null, key); assertEquals(0, watchService.getPendingPaths().size()); } | WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } | GlusterWatchService implements WatchService { WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } } | GlusterWatchService implements WatchService { WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } } | GlusterWatchService implements WatchService { WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } WatchKey registerPath(GlusterPath path, WatchEvent.Kind..... | GlusterWatchService implements WatchService { WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } WatchKey registerPath(GlusterPath path, WatchEvent.Kind..... |
@Test(expected = IllegalArgumentException.class) public void testGlfsInit_whenBad() { mockStatic(GLFS.class); String host = "123.45.67.89"; when(GLFS.glfs_init(123l)).thenReturn(-1); provider.glfsInit(host, 123l); } | void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } @Override String getScheme(); @Override FileSystem newFileSyste... | GlusterFileSystemProvider extends FileSystemProvider { void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } @Override String getScheme(); @Override FileSystem newFileSyste... |
@Test public void testGlfsInit() { mockStatic(GLFS.class); String host = "123.45.67.89"; when(GLFS.glfs_init(123l)).thenReturn(0); provider.glfsInit(host, 123l); verifyStatic(); GLFS.glfs_init(123l); } | void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } } | GlusterFileSystemProvider extends FileSystemProvider { void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } @Override String getScheme(); @Override FileSystem newFileSyste... | GlusterFileSystemProvider extends FileSystemProvider { void glfsInit(String authorityString, long volptr) { int init = glfs_init(volptr); if (0 != init) { throw new IllegalArgumentException("Failed to initialize glusterfs client: " + authorityString); } } @Override String getScheme(); @Override FileSystem newFileSyste... |
@Test(expected = FileSystemNotFoundException.class) public void testGetFileSystem_whenNotFound() throws URISyntaxException { provider.getFileSystem(new URI("gluster: } | @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } @Override String getScheme(); @Ov... | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } @Override String getScheme(); @Ov... |
@Test public void testGetFileSystem() throws URISyntaxException { provider.getCache().put("foo:bar", mockFileSystem); assertEquals(mockFileSystem, provider.getFileSystem(new URI("gluster: } | @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } @Override String getScheme(); @Ov... | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileSystem getFileSystem(URI uri) { if (!cache.containsKey(uri.getAuthority())) { throw new FileSystemNotFoundException("No cached filesystem for: " + uri.getAuthority()); } return cache.get(uri.getAuthority()); } @Override String getScheme(); @Ov... |
@Test public void testNewFileChannel() throws Exception { FileAttribute<?>[] attrs = new FileAttribute[0]; Set<? extends OpenOption> opts = new HashSet<OpenOption>(); doReturn(mockChannel).when(provider).newFileChannelHelper(mockPath, opts, attrs); FileChannel fileChannel = provider.newFileChannel(mockPath, opts, attrs... | @Override public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { return newFileChannelHelper(path, options, attrs); } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { return newFileChannelHelper(path, options, attrs); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { return newFileChannelHelper(path, options, attrs); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { return newFileChannelHelper(path, options, attrs); } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri,... | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException { return newFileChannelHelper(path, options, attrs); } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri,... |
@Test public void testNewByteChannel() throws Exception { FileAttribute<?>[] attrs = new FileAttribute[0]; Set<? extends OpenOption> opts = new HashSet<OpenOption>(); doReturn(mockChannel).when(provider).newFileChannelHelper(mockPath, opts, attrs); ByteChannel fileChannel = provider.newByteChannel(mockPath, opts, attrs... | @Override public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> openOptions, FileAttribute<?>... fileAttributes) throws IOException { return newFileChannelHelper(path, openOptions, fileAttributes); } | GlusterFileSystemProvider extends FileSystemProvider { @Override public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> openOptions, FileAttribute<?>... fileAttributes) throws IOException { return newFileChannelHelper(path, openOptions, fileAttributes); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> openOptions, FileAttribute<?>... fileAttributes) throws IOException { return newFileChannelHelper(path, openOptions, fileAttributes); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> openOptions, FileAttribute<?>... fileAttributes) throws IOException { return newFileChannelHelper(path, openOptions, fileAttributes); } @Override String getScheme(); @Override... | GlusterFileSystemProvider extends FileSystemProvider { @Override public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> openOptions, FileAttribute<?>... fileAttributes) throws IOException { return newFileChannelHelper(path, openOptions, fileAttributes); } @Override String getScheme(); @Override... |
@Test public void testNewFileChannelHelper() throws Exception { Set<? extends OpenOption> options = new HashSet<OpenOption>(); FileAttribute<?> attrs[] = new FileAttribute[0]; URI uri = new URI("foo: doReturn(uri).when(mockPath).toUri(); doReturn(mockFileSystem).when(provider).getFileSystem(uri); whenNew(GlusterFileCha... | FileChannel newFileChannelHelper(Path path, Set<? extends OpenOption> options, FileAttribute<?>[] attrs) throws IOException { GlusterFileChannel channel = new GlusterFileChannel(); channel.init((GlusterFileSystem) getFileSystem(path.toUri()), path, options, attrs); return channel; } | GlusterFileSystemProvider extends FileSystemProvider { FileChannel newFileChannelHelper(Path path, Set<? extends OpenOption> options, FileAttribute<?>[] attrs) throws IOException { GlusterFileChannel channel = new GlusterFileChannel(); channel.init((GlusterFileSystem) getFileSystem(path.toUri()), path, options, attrs);... | GlusterFileSystemProvider extends FileSystemProvider { FileChannel newFileChannelHelper(Path path, Set<? extends OpenOption> options, FileAttribute<?>[] attrs) throws IOException { GlusterFileChannel channel = new GlusterFileChannel(); channel.init((GlusterFileSystem) getFileSystem(path.toUri()), path, options, attrs);... | GlusterFileSystemProvider extends FileSystemProvider { FileChannel newFileChannelHelper(Path path, Set<? extends OpenOption> options, FileAttribute<?>[] attrs) throws IOException { GlusterFileChannel channel = new GlusterFileChannel(); channel.init((GlusterFileSystem) getFileSystem(path.toUri()), path, options, attrs);... | GlusterFileSystemProvider extends FileSystemProvider { FileChannel newFileChannelHelper(Path path, Set<? extends OpenOption> options, FileAttribute<?>[] attrs) throws IOException { GlusterFileChannel channel = new GlusterFileChannel(); channel.init((GlusterFileSystem) getFileSystem(path.toUri()), path, options, attrs);... |
@Test(expected = IllegalArgumentException.class) public void testGetPath_whenSchemeIsUnknown() throws URISyntaxException { URI uri = new URI("fluster: provider.getPath(uri); } | @Override public Path getPath(URI uri) { if (!uri.getScheme().equals(getScheme())) { throw new IllegalArgumentException("No support for scheme: " + uri.getScheme()); } try { FileSystem fileSystem = getFileSystem(uri); return fileSystem.getPath(uri.getPath()); } catch (FileSystemNotFoundException e) { } try { return new... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path getPath(URI uri) { if (!uri.getScheme().equals(getScheme())) { throw new IllegalArgumentException("No support for scheme: " + uri.getScheme()); } try { FileSystem fileSystem = getFileSystem(uri); return fileSystem.getPath(uri.getPath()); } cat... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path getPath(URI uri) { if (!uri.getScheme().equals(getScheme())) { throw new IllegalArgumentException("No support for scheme: " + uri.getScheme()); } try { FileSystem fileSystem = getFileSystem(uri); return fileSystem.getPath(uri.getPath()); } cat... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path getPath(URI uri) { if (!uri.getScheme().equals(getScheme())) { throw new IllegalArgumentException("No support for scheme: " + uri.getScheme()); } try { FileSystem fileSystem = getFileSystem(uri); return fileSystem.getPath(uri.getPath()); } cat... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path getPath(URI uri) { if (!uri.getScheme().equals(getScheme())) { throw new IllegalArgumentException("No support for scheme: " + uri.getScheme()); } try { FileSystem fileSystem = getFileSystem(uri); return fileSystem.getPath(uri.getPath()); } cat... |
@Test(expected = UnsupportedOperationException.class) public void testReadAttributes_whenDosAttributes() throws IOException { provider.readAttributes(mockPath, DosFileAttributes.class); } | @Override public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... linkOptions) throws IOException { if (type.equals(DosFileAttributes.class)) { throw new UnsupportedOperationException(type + " attribute type is not supported, only PosixFileAttributes & its superinterfaces"); } st... | GlusterFileSystemProvider extends FileSystemProvider { @Override public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... linkOptions) throws IOException { if (type.equals(DosFileAttributes.class)) { throw new UnsupportedOperationException(type + " attribute type is not supported,... | GlusterFileSystemProvider extends FileSystemProvider { @Override public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... linkOptions) throws IOException { if (type.equals(DosFileAttributes.class)) { throw new UnsupportedOperationException(type + " attribute type is not supported,... | GlusterFileSystemProvider extends FileSystemProvider { @Override public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... linkOptions) throws IOException { if (type.equals(DosFileAttributes.class)) { throw new UnsupportedOperationException(type + " attribute type is not supported,... | GlusterFileSystemProvider extends FileSystemProvider { @Override public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... linkOptions) throws IOException { if (type.equals(DosFileAttributes.class)) { throw new UnsupportedOperationException(type + " attribute type is not supported,... |
@Test public void testDirectoryIsEmpty() throws IOException { doReturn(mockStream).when(provider).newDirectoryStream(mockPath, null); doReturn(mockIterator).when(mockStream).iterator(); doReturn(false).when(mockIterator).hasNext(); boolean ret = provider.directoryIsEmpty(mockPath); assertEquals(ret, true); } | boolean directoryIsEmpty(Path path) throws IOException { try (DirectoryStream<Path> stream = newDirectoryStream(path, null)) { if (stream.iterator().hasNext()) { return false; } return true; } } | GlusterFileSystemProvider extends FileSystemProvider { boolean directoryIsEmpty(Path path) throws IOException { try (DirectoryStream<Path> stream = newDirectoryStream(path, null)) { if (stream.iterator().hasNext()) { return false; } return true; } } } | GlusterFileSystemProvider extends FileSystemProvider { boolean directoryIsEmpty(Path path) throws IOException { try (DirectoryStream<Path> stream = newDirectoryStream(path, null)) { if (stream.iterator().hasNext()) { return false; } return true; } } } | GlusterFileSystemProvider extends FileSystemProvider { boolean directoryIsEmpty(Path path) throws IOException { try (DirectoryStream<Path> stream = newDirectoryStream(path, null)) { if (stream.iterator().hasNext()) { return false; } return true; } } @Override String getScheme(); @Override FileSystem newFileSystem(URI ... | GlusterFileSystemProvider extends FileSystemProvider { boolean directoryIsEmpty(Path path) throws IOException { try (DirectoryStream<Path> stream = newDirectoryStream(path, null)) { if (stream.iterator().hasNext()) { return false; } return true; } } @Override String getScheme(); @Override FileSystem newFileSystem(URI ... |
@Test public void testPopPending() { GlusterPath mockPath = mock(GlusterPath.class); GlusterWatchKey keyFix = new GlusterWatchKey(mockPath, new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_CREATE}); watchService.getPendingPaths().add(keyFix); WatchKey key = watchService.popPending(); assertEquals(keyFix, key); asser... | WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } | GlusterWatchService implements WatchService { WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } } | GlusterWatchService implements WatchService { WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } } | GlusterWatchService implements WatchService { WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } WatchKey registerPath(GlusterPath path, WatchEvent.Kind..... | GlusterWatchService implements WatchService { WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } } WatchKey registerPath(GlusterPath path, WatchEvent.Kind..... |
@Test(expected = NoSuchFileException.class) public void testDelete_whenFileDoesNotExist() throws IOException { mockStatic(Files.class); when(Files.exists(mockPath)).thenReturn(false); provider.delete(mockPath); } | @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret = GLFS.glfs_rmdir(((GlusterFileSystem)path.getFileSystem... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret =... |
@Test public void testDelete() throws IOException { } | @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret = GLFS.glfs_rmdir(((GlusterFileSystem)path.getFileSystem... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void delete(Path path) throws IOException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } if (Files.isDirectory(path)) { if(!directoryIsEmpty(path)) { throw new DirectoryNotEmptyException(path.toString()); } int ret =... |
@Test public void testIsHidden_whenNotHidden() throws IOException { GlusterPath pathName = Mockito.mock(GlusterPath.class); doReturn(new String[]{"foo"}).when(pathName).getParts(); doReturn(pathName).when(mockPath).getFileName(); boolean hidden = provider.isHidden(mockPath); assertFalse(hidden); verify(pathName).getPar... | @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem g... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem g... |
@Test public void testIsHidden_whenHidden() throws IOException { GlusterPath pathName = Mockito.mock(GlusterPath.class); doReturn(new String[]{".foo"}).when(pathName).getParts(); doReturn(pathName).when(mockPath).getFileName(); boolean hidden = provider.isHidden(mockPath); assertTrue(hidden); verify(pathName).getParts(... | @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem g... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isHidden(Path path) throws IOException { return ((GlusterPath) path.getFileName()).getParts()[0].startsWith("."); } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem g... |
@Test public void testCheckAccess() throws IOException { long volptr = 1234l; doReturn(mockFileSystem).when(mockPath).getFileSystem(); doReturn(volptr).when(mockFileSystem).getVolptr(); String path = "/foo/bar"; doReturn(path).when(mockPath).getString(); int mode = 4; stat stat = new stat(); PowerMockito.mockStatic(GLF... | @Override public void checkAccess(Path path, AccessMode... accessModes) throws IOException { long volptr = ((GlusterFileSystem) path.getFileSystem()).getVolptr(); String pathString = ((GlusterPath) path).getString(); stat stat = new stat(); int ret = GLFS.glfs_lstat(volptr, pathString, stat); if (-1 == ret) { throw new... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void checkAccess(Path path, AccessMode... accessModes) throws IOException { long volptr = ((GlusterFileSystem) path.getFileSystem()).getVolptr(); String pathString = ((GlusterPath) path).getString(); stat stat = new stat(); int ret = GLFS.glfs_lsta... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void checkAccess(Path path, AccessMode... accessModes) throws IOException { long volptr = ((GlusterFileSystem) path.getFileSystem()).getVolptr(); String pathString = ((GlusterPath) path).getString(); stat stat = new stat(); int ret = GLFS.glfs_lsta... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void checkAccess(Path path, AccessMode... accessModes) throws IOException { long volptr = ((GlusterFileSystem) path.getFileSystem()).getVolptr(); String pathString = ((GlusterPath) path).getString(); stat stat = new stat(); int ret = GLFS.glfs_lsta... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void checkAccess(Path path, AccessMode... accessModes) throws IOException { long volptr = ((GlusterFileSystem) path.getFileSystem()).getVolptr(); String pathString = ((GlusterPath) path).getString(); stat stat = new stat(); int ret = GLFS.glfs_lsta... |
@Test public void testGetTotalSpace() throws Exception { mockStatic(GLFS.class); long volptr = 1234l; String path = "/"; statvfs buf = new statvfs(); buf.f_bsize = 2; buf.f_blocks = 1000000l; whenNew(statvfs.class).withNoArguments().thenReturn(buf); when(GLFS.glfs_statvfs(volptr, path, buf)).thenReturn(0); long totalSp... | long getTotalSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_blocks; } | GlusterFileSystemProvider extends FileSystemProvider { long getTotalSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_blocks; } } | GlusterFileSystemProvider extends FileSystemProvider { long getTotalSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_blocks; } } | GlusterFileSystemProvider extends FileSystemProvider { long getTotalSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_blocks; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Overri... | GlusterFileSystemProvider extends FileSystemProvider { long getTotalSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_blocks; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Overri... |
@Test public void testGetUsableSpace() throws Exception { mockStatic(GLFS.class); long volptr = 1234l; String path = "/"; statvfs buf = new statvfs(); buf.f_bsize = 2; buf.f_bavail = 1000000l; whenNew(statvfs.class).withNoArguments().thenReturn(buf); when(GLFS.glfs_statvfs(volptr, path, buf)).thenReturn(0); long usable... | long getUsableSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bavail; } | GlusterFileSystemProvider extends FileSystemProvider { long getUsableSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bavail; } } | GlusterFileSystemProvider extends FileSystemProvider { long getUsableSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bavail; } } | GlusterFileSystemProvider extends FileSystemProvider { long getUsableSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bavail; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Overr... | GlusterFileSystemProvider extends FileSystemProvider { long getUsableSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bavail; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Overr... |
@Test public void testGetUnallocatedSpace() throws Exception { mockStatic(GLFS.class); long volptr = 1234l; String path = "/"; statvfs buf = new statvfs(); buf.f_bsize = 2; buf.f_bfree = 1000000l; whenNew(statvfs.class).withNoArguments().thenReturn(buf); when(GLFS.glfs_statvfs(volptr, path, buf)).thenReturn(0); long un... | long getUnallocatedSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bfree; } | GlusterFileSystemProvider extends FileSystemProvider { long getUnallocatedSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bfree; } } | GlusterFileSystemProvider extends FileSystemProvider { long getUnallocatedSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bfree; } } | GlusterFileSystemProvider extends FileSystemProvider { long getUnallocatedSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bfree; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @O... | GlusterFileSystemProvider extends FileSystemProvider { long getUnallocatedSpace(long volptr) throws IOException { statvfs buf = new statvfs(); GLFS.glfs_statvfs(volptr, "/", buf); return buf.f_bsize * buf.f_bfree; } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @O... |
@Test public void testCopyFileContent() throws IOException { Set<StandardOpenOption> options = new HashSet<>(); options.add(StandardOpenOption.READ); byte[] bytes = new byte[8192]; doReturn(mockChannel).when(provider).newFileChannel(mockPath, options); when(mockChannel.read(any(ByteBuffer.class))).thenReturn(10, 10, 0)... | void copyFileContent(Path path, Path path2) throws IOException { Set<StandardOpenOption> options = new HashSet<>(); options.add(StandardOpenOption.READ); byte[] readBytes = new byte[8192]; FileChannel channel = newFileChannel(path, options); ByteBuffer readBuffer = ByteBuffer.wrap(readBytes); boolean writtenTo = false;... | GlusterFileSystemProvider extends FileSystemProvider { void copyFileContent(Path path, Path path2) throws IOException { Set<StandardOpenOption> options = new HashSet<>(); options.add(StandardOpenOption.READ); byte[] readBytes = new byte[8192]; FileChannel channel = newFileChannel(path, options); ByteBuffer readBuffer =... | GlusterFileSystemProvider extends FileSystemProvider { void copyFileContent(Path path, Path path2) throws IOException { Set<StandardOpenOption> options = new HashSet<>(); options.add(StandardOpenOption.READ); byte[] readBytes = new byte[8192]; FileChannel channel = newFileChannel(path, options); ByteBuffer readBuffer =... | GlusterFileSystemProvider extends FileSystemProvider { void copyFileContent(Path path, Path path2) throws IOException { Set<StandardOpenOption> options = new HashSet<>(); options.add(StandardOpenOption.READ); byte[] readBytes = new byte[8192]; FileChannel channel = newFileChannel(path, options); ByteBuffer readBuffer =... | GlusterFileSystemProvider extends FileSystemProvider { void copyFileContent(Path path, Path path2) throws IOException { Set<StandardOpenOption> options = new HashSet<>(); options.add(StandardOpenOption.READ); byte[] readBytes = new byte[8192]; FileChannel channel = newFileChannel(path, options); ByteBuffer readBuffer =... |
@Test(expected = NotDirectoryException.class) public void testNewDirectoryStream_whenNotDirectory() throws IOException { mockStatic(Files.class); when(Files.isDirectory(mockPath)).thenReturn(false); provider.newDirectoryStream(mockPath, mockFilter); } | @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath = (GlusterPath) path; GlusterDirectoryStream stream = n... | GlusterFileSystemProvider extends FileSystemProvider { @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath ... | GlusterFileSystemProvider extends FileSystemProvider { @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath ... | GlusterFileSystemProvider extends FileSystemProvider { @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath ... | GlusterFileSystemProvider extends FileSystemProvider { @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath ... |
@Test(expected = ClosedWatchServiceException.class) public void testPoll_whenNotRunning() { watchService.setRunning(false); watchService.poll(); } | @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } } return popPending(); } | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... |
@Test public void testNewDirectoryStream() throws Exception { mockStatic(Files.class); when(Files.isDirectory(mockPath)).thenReturn(true); whenNew(GlusterDirectoryStream.class).withNoArguments().thenReturn(mockStream); doReturn(mockFileSystem).when(mockPath).getFileSystem(); doNothing().when(mockStream).setFileSystem(m... | @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath = (GlusterPath) path; GlusterDirectoryStream stream = n... | GlusterFileSystemProvider extends FileSystemProvider { @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath ... | GlusterFileSystemProvider extends FileSystemProvider { @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath ... | GlusterFileSystemProvider extends FileSystemProvider { @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath ... | GlusterFileSystemProvider extends FileSystemProvider { @Override public DirectoryStream<Path> newDirectoryStream(Path path, DirectoryStream.Filter<? super Path> filter) throws IOException { if (!Files.isDirectory(path)) { throw new NotDirectoryException("Not a directory! " + path.toString()); } GlusterPath glusterPath ... |
@Test(expected = NotLinkException.class) public void testReadSymbolicLink_whenNotLink() throws IOException { mockStatic(Files.class); when(Files.isSymbolicLink(mockPath)).thenReturn(false); provider.readSymbolicLink(mockPath); } | @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.getFileSystem(); long volptr = fileSystem.getVolptr(); ... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.... |
@Test public void testReadSymbolicLink() throws Exception { Long volptr = 12333L; doReturn(mockFileSystem).when(mockPath).getFileSystem(); doReturn(volptr).when(mockFileSystem).getVolptr(); doReturn("/").when(mockFileSystem).getSeparator(); stat stat = new stat(); int length = 13; stat.st_size = length; whenNew(stat.cl... | @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.getFileSystem(); long volptr = fileSystem.getVolptr(); ... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.... | GlusterFileSystemProvider extends FileSystemProvider { @Override public Path readSymbolicLink(Path link) throws IOException { String pathString = link.toString(); if (!Files.isSymbolicLink(link)) { throw new NotLinkException(pathString); } stat stat = new stat(); GlusterFileSystem fileSystem = (GlusterFileSystem) link.... |
@Test(expected = FileAlreadyExistsException.class) public void testCreateSymlink_whenExists() throws IOException { Mockito.doReturn("mockpath").when(mockPath).toString(); mockStatic(Files.class); when(Files.exists(mockPath, LinkOption.NOFOLLOW_LINKS)).thenReturn(true); provider.createSymbolicLink(mockPath, targetPath);... | @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != attrs && attrs.length > 0) { throw new UnsupportedOperati... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != at... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != at... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != at... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != at... |
@Test(expected = UnsupportedOperationException.class) public void testCreateSymlink_whenAttrs() throws IOException { Mockito.doReturn("mockpath").when(mockPath).toString(); mockStatic(Files.class); when(Files.exists(mockPath, LinkOption.NOFOLLOW_LINKS)).thenReturn(false); FileAttribute<Object>[] attrs = new FileAttribu... | @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != attrs && attrs.length > 0) { throw new UnsupportedOperati... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != at... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != at... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != at... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException { String linkPath = link.toString(); if (Files.exists(link, LinkOption.NOFOLLOW_LINKS)) { throw new FileAlreadyExistsException(linkPath); } if (null != at... |
@Test(expected = FileAlreadyExistsException.class) public void testCreateDirectory_whenFileOrDirectoryExists() throws IOException { mockStatic(Files.class); when(Files.exists(mockPath)).thenReturn(true); provider.createDirectory(mockPath); } | @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode = 0775; if (fileAttributes.length > 0) { mode = GlusterF... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... |
@Test(expected = IOException.class) public void testCreateDirectory_whenParentDirectoryDoesNotExist() throws IOException { mockStatic(Files.class); GlusterPath parentPath = Mockito.mock(GlusterPath.class); doReturn(parentPath).when(mockPath).getParent(); when(Files.exists(parentPath)).thenReturn(false); provider.create... | @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode = 0775; if (fileAttributes.length > 0) { mode = GlusterF... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... |
@Test public void testCreateDirectory() throws IOException { helperCreateDirectory(false, false); } | @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode = 0775; if (fileAttributes.length > 0) { mode = GlusterF... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... | GlusterFileSystemProvider extends FileSystemProvider { @Override public void createDirectory(Path path, FileAttribute<?>... fileAttributes) throws IOException { if (Files.exists(path)) { throw new FileAlreadyExistsException(path.toString()); } if (!Files.exists(path.getParent())) { throw new IOException(); } int mode =... |
@Test(expected = NoSuchFileException.class) public void testGetFileStore_whenFileDoesNotExist() throws IOException { mockStatic(Files.class); when(Files.exists(mockPath)).thenReturn(false); provider.getFileStore(mockPath); } | @Override public FileStore getFileStore(Path path) throws IOException { if (Files.exists(path)) { return path.getFileSystem().getFileStores().iterator().next(); } else { throw new NoSuchFileException(path.toString()); } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileStore getFileStore(Path path) throws IOException { if (Files.exists(path)) { return path.getFileSystem().getFileStores().iterator().next(); } else { throw new NoSuchFileException(path.toString()); } } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileStore getFileStore(Path path) throws IOException { if (Files.exists(path)) { return path.getFileSystem().getFileStores().iterator().next(); } else { throw new NoSuchFileException(path.toString()); } } } | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileStore getFileStore(Path path) throws IOException { if (Files.exists(path)) { return path.getFileSystem().getFileStores().iterator().next(); } else { throw new NoSuchFileException(path.toString()); } } @Override String getScheme(); @Override Fi... | GlusterFileSystemProvider extends FileSystemProvider { @Override public FileStore getFileStore(Path path) throws IOException { if (Files.exists(path)) { return path.getFileSystem().getFileStores().iterator().next(); } else { throw new NoSuchFileException(path.toString()); } } @Override String getScheme(); @Override Fi... |
@Test public void testIsSameFile_whenSamePaths() throws IOException { doReturn("/").when(mockFileSystem).getSeparator(); GlusterPath path = new GlusterPath(mockFileSystem, "/foo/bar"); boolean ret = provider.isSameFile(path, path); assertTrue(ret); verify(mockFileSystem, times(3)).getSeparator(); } | @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(path); stat stat2 = statPath(path2); return stat1.st_in... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(... |
@Test public void testPoll_whenPending() { watchService.setRunning(true); GlusterWatchKey mockKey = mock(GlusterWatchKey.class); watchService.getPendingPaths().add(mockKey); WatchKey key = watchService.poll(); assertEquals(mockKey, key); } | @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } } return popPending(); } | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... |
@Test public void testIsSameFile_whenPathsEqual() throws IOException { doReturn("/").when(mockFileSystem).getSeparator(); GlusterPath path1 = new GlusterPath(mockFileSystem, "/foo/bar"); GlusterPath path2 = new GlusterPath(mockFileSystem, "/foo/bar"); boolean ret = provider.isSameFile(path1, path2); assertTrue(ret); ve... | @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(path); stat stat2 = statPath(path2); return stat1.st_in... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(... | GlusterFileSystemProvider extends FileSystemProvider { @Override public boolean isSameFile(Path path, Path path2) throws IOException { if (path.equals(path2)) { return true; } if (!path.getFileSystem().equals(path2.getFileSystem())) { return false; } guardFileExists(path); guardFileExists(path2); stat stat1 = statPath(... |
@Test public void testStatPath() throws Exception { long volptr = 1234L; stat stat = new stat(); whenNew(stat.class).withNoArguments().thenReturn(stat); mockStatic(GLFS.class); String pathString = "/foo"; when(GLFS.glfs_stat(volptr, pathString, stat)).thenReturn(0); doReturn(mockFileSystem).when(mockPath).getFileSystem... | stat statPath(Path path) throws IOException { stat stat = new stat(); String pathString = ((GlusterPath) path).getString(); int ret = GLFS.glfs_stat(((GlusterFileSystem) path.getFileSystem()).getVolptr(), pathString, stat); if (ret != 0) { throw new IOException("Stat failed for " + pathString); } return stat; } | GlusterFileSystemProvider extends FileSystemProvider { stat statPath(Path path) throws IOException { stat stat = new stat(); String pathString = ((GlusterPath) path).getString(); int ret = GLFS.glfs_stat(((GlusterFileSystem) path.getFileSystem()).getVolptr(), pathString, stat); if (ret != 0) { throw new IOException("St... | GlusterFileSystemProvider extends FileSystemProvider { stat statPath(Path path) throws IOException { stat stat = new stat(); String pathString = ((GlusterPath) path).getString(); int ret = GLFS.glfs_stat(((GlusterFileSystem) path.getFileSystem()).getVolptr(), pathString, stat); if (ret != 0) { throw new IOException("St... | GlusterFileSystemProvider extends FileSystemProvider { stat statPath(Path path) throws IOException { stat stat = new stat(); String pathString = ((GlusterPath) path).getString(); int ret = GLFS.glfs_stat(((GlusterFileSystem) path.getFileSystem()).getVolptr(), pathString, stat); if (ret != 0) { throw new IOException("St... | GlusterFileSystemProvider extends FileSystemProvider { stat statPath(Path path) throws IOException { stat stat = new stat(); String pathString = ((GlusterPath) path).getString(); int ret = GLFS.glfs_stat(((GlusterFileSystem) path.getFileSystem()).getVolptr(), pathString, stat); if (ret != 0) { throw new IOException("St... |
@Test(expected = NoSuchFileException.class) public void testGuardFileExists_whenDoesNotExist() throws NoSuchFileException { mockStatic(Files.class); PowerMockito.when(Files.exists(mockPath)).thenReturn(false); provider.guardFileExists(mockPath); } | void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } | GlusterFileSystemProvider extends FileSystemProvider { void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } } | GlusterFileSystemProvider extends FileSystemProvider { void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } } | GlusterFileSystemProvider extends FileSystemProvider { void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem ge... | GlusterFileSystemProvider extends FileSystemProvider { void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem ge... |
@Test public void testGuardFileExists_whenDoesExist() throws NoSuchFileException { mockStatic(Files.class); PowerMockito.when(Files.exists(mockPath)).thenReturn(true); provider.guardFileExists(mockPath); verifyStatic(); Files.exists(mockPath); } | void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } | GlusterFileSystemProvider extends FileSystemProvider { void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } } | GlusterFileSystemProvider extends FileSystemProvider { void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } } | GlusterFileSystemProvider extends FileSystemProvider { void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem ge... | GlusterFileSystemProvider extends FileSystemProvider { void guardFileExists(Path path) throws NoSuchFileException { if (!Files.exists(path)) { throw new NoSuchFileException(path.toString()); } } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem ge... |
@Test(expected = UnsupportedOperationException.class) public void testGuardAbsolutePath_whenRelative() { doReturn(false).when(mockPath).isAbsolute(); provider.guardAbsolutePath(mockPath); } | void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } | GlusterFileSystemProvider extends FileSystemProvider { void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } } | GlusterFileSystemProvider extends FileSystemProvider { void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } } | GlusterFileSystemProvider extends FileSystemProvider { void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem get... | GlusterFileSystemProvider extends FileSystemProvider { void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem get... |
@Test public void testGuardAbsolutePath_whenAbsolute() { doReturn(true).when(mockPath).isAbsolute(); provider.guardAbsolutePath(mockPath); verify(mockPath).isAbsolute(); } | void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } | GlusterFileSystemProvider extends FileSystemProvider { void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } } | GlusterFileSystemProvider extends FileSystemProvider { void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } } | GlusterFileSystemProvider extends FileSystemProvider { void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem get... | GlusterFileSystemProvider extends FileSystemProvider { void guardAbsolutePath(Path p) { if (!p.isAbsolute()) { throw new UnsupportedOperationException("Relative paths not supported: " + p); } } @Override String getScheme(); @Override FileSystem newFileSystem(URI uri, Map<String, ?> stringMap); @Override FileSystem get... |
@Test public void testProvider() { assertEquals(mockFileSystemProvider, fileSystem.provider()); } | @Override public FileSystemProvider provider() { return provider; } | GlusterFileSystem extends FileSystem { @Override public FileSystemProvider provider() { return provider; } } | GlusterFileSystem extends FileSystem { @Override public FileSystemProvider provider() { return provider; } } | GlusterFileSystem extends FileSystem { @Override public FileSystemProvider provider() { return provider; } @Override FileSystemProvider provider(); @Override void close(); @Override boolean isOpen(); @Override boolean isReadOnly(); @Override String getSeparator(); @Override Iterable<Path> getRootDirectories(); @Overri... | GlusterFileSystem extends FileSystem { @Override public FileSystemProvider provider() { return provider; } @Override FileSystemProvider provider(); @Override void close(); @Override boolean isOpen(); @Override boolean isReadOnly(); @Override String getSeparator(); @Override Iterable<Path> getRootDirectories(); @Overri... |
@Test(expected = IOException.class) public void testClose_whenFailing() throws IOException { doReturn(11).when(mockFileSystemProvider).close(VOLPTR); fileSystem.close(); } | @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } | GlusterFileSystem extends FileSystem { @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } } | GlusterFileSystem extends FileSystem { @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } } | GlusterFileSystem extends FileSystem { @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } @Override FileSystemProvider provider(); @Override void close(); @Override bo... | GlusterFileSystem extends FileSystem { @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } @Override FileSystemProvider provider(); @Override void close(); @Override bo... |
@Test public void testClose() throws IOException { doReturn(0).when(mockFileSystemProvider).close(VOLPTR); fileSystem.close(); verify(mockFileSystemProvider).close(VOLPTR); assertEquals(-1, fileSystem.getVolptr()); } | @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } | GlusterFileSystem extends FileSystem { @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } } | GlusterFileSystem extends FileSystem { @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } } | GlusterFileSystem extends FileSystem { @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } @Override FileSystemProvider provider(); @Override void close(); @Override bo... | GlusterFileSystem extends FileSystem { @Override public void close() throws IOException { if (isOpen()) { int fini = provider.close(volptr); if (0 != fini) { throw new IOException("Unable to close filesystem: " + volname); } volptr = -1; } } @Override FileSystemProvider provider(); @Override void close(); @Override bo... |
@Test public void testIsOpen_whenOpen() { assertEquals(true, fileSystem.isOpen()); } | @Override public boolean isOpen() { return volptr > 0; } | GlusterFileSystem extends FileSystem { @Override public boolean isOpen() { return volptr > 0; } } | GlusterFileSystem extends FileSystem { @Override public boolean isOpen() { return volptr > 0; } } | GlusterFileSystem extends FileSystem { @Override public boolean isOpen() { return volptr > 0; } @Override FileSystemProvider provider(); @Override void close(); @Override boolean isOpen(); @Override boolean isReadOnly(); @Override String getSeparator(); @Override Iterable<Path> getRootDirectories(); @Override Iterable... | GlusterFileSystem extends FileSystem { @Override public boolean isOpen() { return volptr > 0; } @Override FileSystemProvider provider(); @Override void close(); @Override boolean isOpen(); @Override boolean isReadOnly(); @Override String getSeparator(); @Override Iterable<Path> getRootDirectories(); @Override Iterable... |
@Test public void testPoll_whenReadyAndNoEvent() { watchService.setRunning(true); GlusterWatchKey mockKey = mock(GlusterWatchKey.class); watchService.getPaths().add(mockKey); doReturn(true).when(mockKey).isValid(); doReturn(true).when(mockKey).isReady(); doReturn(false).when(mockKey).update(); WatchKey key = watchServi... | @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } } return popPending(); } | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... | GlusterWatchService implements WatchService { @Override public WatchKey poll() { if (!running) { throw new ClosedWatchServiceException(); } WatchKey pending = popPending(); if (null != pending) { return pending; } for (GlusterWatchKey k : paths) { if (k.isValid() && k.isReady() && k.update()) { pendingPaths.add(k); } }... |
@Test public void testSignUpButton_validatesFields() { RegisterEmailActivity registerEmailActivity = createActivity(); registerEmailActivity.onNewUser(new User.Builder(TestConstants.EMAIL).build()); Button button = (Button) registerEmailActivity.findViewById(R.id.button_create); button.performClick(); TextInputLayout n... | @Override public void onNewUser(User user) { TextInputLayout emailLayout = (TextInputLayout) findViewById(R.id.email_layout); if (mActivityHelper.getFlowParams().allowNewEmailAccounts) { RegisterEmailFragment fragment = RegisterEmailFragment.newInstance( mActivityHelper.getFlowParams(), user); FragmentTransaction ft = ... | RegisterEmailActivity extends AppCompatBase implements
CheckEmailFragment.CheckEmailListener { @Override public void onNewUser(User user) { TextInputLayout emailLayout = (TextInputLayout) findViewById(R.id.email_layout); if (mActivityHelper.getFlowParams().allowNewEmailAccounts) { RegisterEmailFragment fragment... | RegisterEmailActivity extends AppCompatBase implements
CheckEmailFragment.CheckEmailListener { @Override public void onNewUser(User user) { TextInputLayout emailLayout = (TextInputLayout) findViewById(R.id.email_layout); if (mActivityHelper.getFlowParams().allowNewEmailAccounts) { RegisterEmailFragment fragment... | RegisterEmailActivity extends AppCompatBase implements
CheckEmailFragment.CheckEmailListener { @Override public void onNewUser(User user) { TextInputLayout emailLayout = (TextInputLayout) findViewById(R.id.email_layout); if (mActivityHelper.getFlowParams().allowNewEmailAccounts) { RegisterEmailFragment fragment... | RegisterEmailActivity extends AppCompatBase implements
CheckEmailFragment.CheckEmailListener { @Override public void onNewUser(User user) { TextInputLayout emailLayout = (TextInputLayout) findViewById(R.id.email_layout); if (mActivityHelper.getFlowParams().allowNewEmailAccounts) { RegisterEmailFragment fragment... |
@Test public void testIsValid_nullPhone() throws Exception { assertFalse(PhoneNumber.isValid(null)); } | public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } } | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } PhoneNumber(String ... | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } PhoneNumber(String ... | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } PhoneNumber(String ... |
@Test public void testIsValid_emptyMembers() throws Exception { PhoneNumber invalidPhoneNumber = new PhoneNumber("", PhoneTestConstants.US_ISO2, PhoneTestConstants .US_COUNTRY_CODE); assertFalse(PhoneNumber.isValid(invalidPhoneNumber)); invalidPhoneNumber = new PhoneNumber(PhoneTestConstants.PHONE, "", PhoneTestConstan... | public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } } | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } PhoneNumber(String ... | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } PhoneNumber(String ... | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } PhoneNumber(String ... |
@Test public void testIsValid() throws Exception { final PhoneNumber validPhoneNumber = new PhoneNumber(PhoneTestConstants.PHONE, PhoneTestConstants .US_ISO2, PhoneTestConstants.US_COUNTRY_CODE); assertTrue(PhoneNumber.isValid(validPhoneNumber)); } | public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } } | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } PhoneNumber(String ... | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } PhoneNumber(String ... | PhoneNumber { public static boolean isValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getPhoneNumber()) && !TextUtils.isEmpty(phoneNumber .getCountryCode()) && !TextUtils.isEmpty(phoneNumber.getCountryIso()); } PhoneNumber(String ... |
@Test public void testIsCountryValid_nullPhone() throws Exception { assertFalse(PhoneNumber.isCountryValid(null)); } | public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } | PhoneNumber { public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } } | PhoneNumber { public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } PhoneNumber(String phoneNumber, String countryIso, String countr... | PhoneNumber { public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } PhoneNumber(String phoneNumber, String countryIso, String countr... | PhoneNumber { public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } PhoneNumber(String phoneNumber, String countryIso, String countr... |
@Test public void testIsCountryValid_emptyMembers() throws Exception { PhoneNumber invalidPhoneNumber = new PhoneNumber("", "", PhoneTestConstants.US_COUNTRY_CODE); assertFalse(PhoneNumber.isCountryValid(invalidPhoneNumber)); invalidPhoneNumber = new PhoneNumber("", PhoneTestConstants.US_ISO2, ""); assertFalse(PhoneNum... | public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } | PhoneNumber { public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } } | PhoneNumber { public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } PhoneNumber(String phoneNumber, String countryIso, String countr... | PhoneNumber { public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } PhoneNumber(String phoneNumber, String countryIso, String countr... | PhoneNumber { public static boolean isCountryValid(PhoneNumber phoneNumber) { return phoneNumber != null && !EMPTY_PHONE_NUMBER.equals(phoneNumber) && !TextUtils .isEmpty(phoneNumber.getCountryCode()) && !TextUtils.isEmpty(phoneNumber .getCountryIso()); } PhoneNumber(String phoneNumber, String countryIso, String countr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.