NFS4Client { public synchronized NFSv41Session createSession(int sequence, int cacheSize, int cbCacheSize, int maxOps, int maxCbOps) throws ChimeraNFSException { _log.debug("session for sequience: {}", sequence); if (sequence > _sessionSequence && _isConfirmed) { throw new SeqMisorderedException("bad sequence id: " + _sessionSequence + " / " + sequence); } if (sequence == _sessionSequence - 1 && !_isConfirmed) { throw new SeqMisorderedException("bad sequence id: " + _sessionSequence + " / " + sequence); } if (sequence == _sessionSequence - 1) { _log.debug("Retransmit on create session detected"); sessionid4 sessionid = _stateHandler.createSessionId(this, sequence); return _sessions.get(sessionid); } if (sequence != _sessionSequence ) { throw new SeqMisorderedException("bad sequence id: " + _sessionSequence + " / " + sequence); } sessionid4 sessionid = _stateHandler.createSessionId(this, _sessionSequence); NFSv41Session session = new NFSv41Session(this, sessionid, cacheSize, cbCacheSize, maxOps, maxCbOps); _sessions.put(sessionid, session); _sessionSequence++; if(!_isConfirmed){ _isConfirmed = true; _log.debug("set client confirmed"); } return session; } NFS4Client(NFSv4StateHandler stateHandler, clientid4 clientId, int minorVersion, InetSocketAddress clientAddress, InetSocketAddress localAddress,
            byte[] ownerID, verifier4 verifier, Principal principal, long leaseTime, boolean calbackNeeded); void setCB(ClientCB cb); ClientCB getCB(); int getMinorVersion(); byte[] getOwnerId(); verifier4 verifier(); clientid4 getId(); boolean verifierEquals(verifier4 verifier); synchronized boolean isConfirmed(); synchronized void setConfirmed(); boolean isLeaseValid(); void updateLeaseTime(); void refreshLeaseTime(); synchronized void reset(); InetSocketAddress getRemoteAddress(); InetSocketAddress getLocalAddress(); int currentSeqID(); NFS4State createState(StateOwner stateOwner, NFS4State openState); NFS4State createState(StateOwner stateOwner); void releaseState(stateid4 stateid); void tryReleaseState(stateid4 stateid); NFS4State state(stateid4 stateid); @Override String toString(); Collection<NFSv41Session> sessions(); synchronized NFSv41Session createSession(int sequence, int cacheSize, int cbCacheSize, int maxOps, int maxCbOps); synchronized void removeSession(sessionid4 id); synchronized NFSv41Session getSession(sessionid4 id); boolean hasSessions(); Principal principal(); boolean hasState(); void attachState(NFS4State state); void detachState(NFS4State state); final void tryDispose(); synchronized void reclaimComplete(); synchronized void wantReclaim(); synchronized boolean needReclaim(); boolean isCallbackNeede(); synchronized StateOwner getOrCreateOwner(byte[] owner, seqid4 seq); synchronized void releaseOwner(byte[] owner);  }
@Test public void testCreateSessionReply() throws ChimeraNFSException { NFSv41Session session1 = nfsClient.createSession(1, 0, 0, 0, 1); NFSv41Session session2 = nfsClient.createSession(1, 0, 0, 0, 1); assertEquals(session1.id(), session2.id()); }
@Test(expected = SeqMisorderedException.class) public void testCreateSessionWrongSequence() throws ChimeraNFSException { nfsClient.createSession(2, 0, 0, 0, 1); }