Commit 7b3f4d13 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

unit: fix NPE in SETXATTR test

mocked vfs should return a valid stat for a file

Acked-by: Olufemi Adeyemi
Target: master
parent a1f08100
......@@ -8,14 +8,17 @@ import org.dcache.nfs.v4.xdr.COMPOUND4args;
import org.dcache.nfs.v4.xdr.nfs_fh4;
import org.dcache.nfs.v4.xdr.setxattr_option4;
import org.dcache.nfs.vfs.Inode;
import org.dcache.nfs.vfs.Stat;
import org.dcache.nfs.vfs.VirtualFileSystem;
import org.junit.Before;
import org.junit.Test;
import static org.dcache.nfs.v4.NfsTestUtils.execute;
import static org.dcache.nfs.v4.NfsTestUtils.generateRpcCall;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class OperationSETXATTRTest {
......@@ -24,8 +27,23 @@ public class OperationSETXATTRTest {
private final nfs_fh4 fh = new nfs_fh4(inode.toNfsHandle());
@Before
public void setUp() {
public void setUp() throws IOException {
vfs = mock(VirtualFileSystem.class);
Stat fileStat = new Stat();
fileStat.setMode(Stat.S_IFREG | 0755);
fileStat.setMTime(System.currentTimeMillis());
fileStat.setATime(System.currentTimeMillis());
fileStat.setCTime(System.currentTimeMillis());
fileStat.setGeneration(1);
fileStat.setNlink(2);
fileStat.setUid(1);
fileStat.setGid(2);
fileStat.setDev(1);
fileStat.setFileid(1);
fileStat.setSize(512);
when(vfs.getattr(any())).thenReturn(fileStat);
}
@Test
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment