Commit 9489f907 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

junit: more state handling tests

parent d6b3cc45
......@@ -4,10 +4,12 @@ import org.dcache.chimera.nfs.v4.xdr.stateid4;
import org.dcache.chimera.nfs.v4.xdr.verifier4;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import org.dcache.chimera.nfs.ChimeraNFSException;
public class NFSv4StateHandlerTest {
......@@ -27,6 +29,59 @@ public class NFSv4StateHandlerTest {
_stateHandler.getClientIdByStateId(state);
}
@Test
public void testGetByVerifier() throws Exception {
NFS4Client client = createClient();
stateid4 state = client.createState().stateid();
_stateHandler.addClient(client);
assertEquals(client, _stateHandler.getClientByVerifier(client.verifier()));
}
@Test
public void testGetByVerifierNotExists() throws Exception {
assertNull("get not exisintg", _stateHandler.getClientByVerifier( new verifier4()));
}
@Test(expected=ChimeraNFSException.class)
public void testGetClientNotExists() throws Exception {
_stateHandler.getClientByID(1L);
}
@Test
public void testGetClientExists() throws Exception {
NFS4Client client = createClient();
_stateHandler.addClient(client);
assertEquals(client, _stateHandler.getClientByID(client.getId()));
}
@Test
public void testUpdateLeaseTime() throws Exception {
NFS4Client client = createClient();
NFS4State state = client.createState();
stateid4 stateid = state.stateid();
state.confirm();
_stateHandler.addClient(client);
_stateHandler.updateClientLeaseTime(stateid);
}
@Test(expected=ChimeraNFSException.class)
public void testUpdateLeaseTimeNotConfirmed() throws Exception {
NFS4Client client = createClient();
NFS4State state = client.createState();
stateid4 stateid = state.stateid();
_stateHandler.addClient(client);
_stateHandler.updateClientLeaseTime(stateid);
}
@Test(expected=ChimeraNFSException.class)
public void testUpdateLeaseTimeNotExists() throws Exception {
NFS4Client client = createClient();
stateid4 state = client.createState().stateid();
_stateHandler.updateClientLeaseTime(state);
}
static NFS4Client createClient() throws UnknownHostException {
InetSocketAddress address = new InetSocketAddress(InetAddress.getByName("www.google.com"), 123);
NFS4Client client = new NFS4Client(address, address, "123".getBytes(),
......
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